diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2013-08-12 09:28:15 +0200 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2013-08-12 09:28:15 +0200 |
commit | 08aa4418c30cfc18ccc69a0f0f9cb9e17be6c196 (patch) | |
tree | 577a29fb579188d16003a209ce2a2e9c5b0aa2bd /maintenance/locking | |
parent | cacc939b34e315b85e2d72997811eb6677996cc1 (diff) |
Update to MediaWiki 1.21.1
Diffstat (limited to 'maintenance/locking')
-rw-r--r-- | maintenance/locking/LockServerDaemon.php | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/maintenance/locking/LockServerDaemon.php b/maintenance/locking/LockServerDaemon.php index 689c9309..01fbac72 100644 --- a/maintenance/locking/LockServerDaemon.php +++ b/maintenance/locking/LockServerDaemon.php @@ -23,7 +23,7 @@ * @ingroup LockManager Maintenance */ -if ( php_sapi_name() !== 'cli' ) { +if ( PHP_SAPI !== 'cli' ) { die( "This is not a valid entry point.\n" ); } error_reporting( E_ALL ); @@ -39,6 +39,8 @@ LockServerDaemon::init( /** * Simple lock server daemon that accepts lock/unlock requests + * + * @ingroup LockManager Maintenance */ class LockServerDaemon { /** @var resource */ @@ -66,6 +68,8 @@ class LockServerDaemon { /** * @params $config Array + * @param array $config + * @throws Exception * @return LockServerDaemon */ public static function init( array $config ) { @@ -75,9 +79,9 @@ class LockServerDaemon { foreach ( array( 'address', 'port', 'authKey' ) as $par ) { if ( !isset( $config[$par] ) ) { die( "Usage: php LockServerDaemon.php " . - "--address <address> --port <port> --authkey <key> " . + "--address <address> --port <port> --authKey <key> " . "[--lockTimeout <seconds>] " . - "[--maxLocks <integer>] [--maxClients <integer>] [--maxBacklog <integer>]" + "[--maxLocks <integer>] [--maxClients <integer>] [--maxBacklog <integer>]\n" ); } } @@ -111,6 +115,7 @@ class LockServerDaemon { } /** + * @throws Exception * @return void */ protected function setupServerSocket() { @@ -237,7 +242,9 @@ class LockServerDaemon { $m = explode( ':', $data ); // <session, key, command, type, values> if ( count( $m ) == 5 ) { list( $session, $key, $command, $type, $values ) = $m; - if ( sha1( $session . $command . $type . $values . $this->authKey ) !== $key ) { + $goodKey = hash_hmac( 'sha1', + "{$session}\n{$command}\n{$type}\n{$values}", $this->authKey ); + if ( $goodKey !== $key ) { return 'BAD_KEY'; } elseif ( strlen( $session ) !== 32 ) { return 'BAD_SESSION'; |