Merge "Added --postime option syncFileBackend."
[lhc/web/wiklou.git] / maintenance / locking / LockServerDaemon.php
index c591665..01fbac7 100644 (file)
@@ -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 );
@@ -79,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"
                                );
                        }
                }
@@ -242,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';