Index: trunk/phase3/includes/installer/CoreInstaller.php |
— | — | @@ -308,6 +308,7 @@ |
309 | 309 | array( 'name' => 'tables', 'callback' => array( $this, 'installTables' ) ), |
310 | 310 | array( 'name' => 'interwiki', 'callback' => array( $installer, 'populateInterwikiTable' ) ), |
311 | 311 | array( 'name' => 'secretkey', 'callback' => array( $this, 'generateSecretKey' ) ), |
| 312 | + array( 'name' => 'upgradekey', 'callback' => array( $this, 'generateUpgradeKey' ) ), |
312 | 313 | array( 'name' => 'sysop', 'callback' => array( $this, 'createSysop' ) ), |
313 | 314 | array( 'name' => 'mainpage', 'callback' => array( $this, 'createMainpage' ) ), |
314 | 315 | ); |
— | — | @@ -369,6 +370,16 @@ |
370 | 371 | * @return Status |
371 | 372 | */ |
372 | 373 | protected function generateSecretKey() { |
| 374 | + return $this->generateSecret( 'wgSecretKey' ); |
| 375 | + } |
| 376 | + |
| 377 | + /** |
| 378 | + * Generate a secret value for a variable using either |
| 379 | + * /dev/urandom or mt_rand() Produce a warning in the later case. |
| 380 | + * |
| 381 | + * @return Status |
| 382 | + */ |
| 383 | + protected function generateSecret( $secretName ) { |
373 | 384 | if ( wfIsWindows() ) { |
374 | 385 | $file = null; |
375 | 386 | } else { |
— | — | @@ -389,20 +400,25 @@ |
390 | 401 | $secretKey .= dechex( mt_rand( 0, 0x7fffffff ) ); |
391 | 402 | } |
392 | 403 | |
393 | | - $status->warning( 'config-insecure-secretkey' ); |
| 404 | + $status->warning( 'config-insecure-secret', '$' . $secretName ); |
394 | 405 | } |
395 | 406 | |
396 | | - $this->setVar( 'wgSecretKey', $secretKey ); |
| 407 | + $this->setVar( $secretName, $secretKey ); |
397 | 408 | |
398 | | - // Generate a $wgUpgradeKey from our secret key |
399 | | - $secretKey = md5( $secretKey ); |
400 | | - $randPos = mt_rand( 0, strlen( $secretKey ) - 8 ); |
401 | | - $this->setVar( 'wgUpgradeKey', substr( $secretKey, $randPos, $randPos + 8 ) ); |
402 | | - |
403 | 409 | return $status; |
404 | 410 | } |
405 | 411 | |
406 | 412 | /** |
| 413 | + * Generate a default $wgUpradeKey, Will warn if we had to use |
| 414 | + * mt_rand() instead of /dev/urandom |
| 415 | + * |
| 416 | + * @return Status |
| 417 | + */ |
| 418 | + protected function generateUpgradeKey() { |
| 419 | + return $this->generateSecret( 'wgUpgradeKey' ); |
| 420 | + } |
| 421 | + |
| 422 | + /** |
407 | 423 | * Create the first user account, grant it sysop and bureaucrat rights |
408 | 424 | * |
409 | 425 | * @return Status |
Index: trunk/phase3/includes/installer/Installer.i18n.php |
— | — | @@ -475,7 +475,7 @@ |
476 | 476 | 'config-install-interwiki-exists' => "'''Warning''': The interwiki table seems to already have entries. |
477 | 477 | Skipping default list.", |
478 | 478 | 'config-install-secretkey' => 'Generating secret key', |
479 | | - 'config-insecure-secretkey' => "'''Warning:''' Unable to create secure <code>\$wgSecretKey</code>. |
| 479 | + 'config-insecure-secret' => "'''Warning:''' Unable to create a secure <code>$1</code>. |
480 | 480 | Consider changing it manually.", |
481 | 481 | 'config-install-sysop' => 'Creating administrator user account', |
482 | 482 | 'config-install-mainpage' => 'Creating main page with default content', |