array( 'name' => 'tables', 'callback' => array( $this, 'installTables' ) ),
array( 'name' => 'interwiki', 'callback' => array( $installer, 'populateInterwikiTable' ) ),
array( 'name' => 'secretkey', 'callback' => array( $this, 'generateSecretKey' ) ),
+ array( 'name' => 'upgradekey', 'callback' => array( $this, 'generateUpgradeKey' ) ),
array( 'name' => 'sysop', 'callback' => array( $this, 'createSysop' ) ),
array( 'name' => 'mainpage', 'callback' => array( $this, 'createMainpage' ) ),
);
* @return Status
*/
protected function generateSecretKey() {
+ return $this->generateSecret( 'wgSecretKey' );
+ }
+
+ /**
+ * Generate a secret value for a variable using either
+ * /dev/urandom or mt_rand() Produce a warning in the later case.
+ *
+ * @return Status
+ */
+ protected function generateSecret( $secretName ) {
if ( wfIsWindows() ) {
$file = null;
} else {
$secretKey .= dechex( mt_rand( 0, 0x7fffffff ) );
}
- $status->warning( 'config-insecure-secretkey' );
+ $status->warning( 'config-insecure-secret', '$' . $secretName );
}
- $this->setVar( 'wgSecretKey', $secretKey );
-
- // Generate a $wgUpgradeKey from our secret key
- $secretKey = md5( $secretKey );
- $randPos = mt_rand( 0, strlen( $secretKey ) - 8 );
- $this->setVar( 'wgUpgradeKey', substr( $secretKey, $randPos, $randPos + 8 ) );
+ $this->setVar( $secretName, $secretKey );
return $status;
}
+ /**
+ * Generate a default $wgUpradeKey, Will warn if we had to use
+ * mt_rand() instead of /dev/urandom
+ *
+ * @return Status
+ */
+ protected function generateUpgradeKey() {
+ return $this->generateSecret( 'wgUpgradeKey' );
+ }
+
/**
* Create the first user account, grant it sysop and bureaucrat rights
*
'config-install-interwiki-exists' => "'''Warning''': The interwiki table seems to already have entries.
Skipping default list.",
'config-install-secretkey' => 'Generating secret key',
- 'config-insecure-secretkey' => "'''Warning:''' Unable to create secure <code>\$wgSecretKey</code>.
+ 'config-insecure-secret' => "'''Warning:''' Unable to create a secure <code>$1</code>.
Consider changing it manually.",
'config-install-sysop' => 'Creating administrator user account',
'config-install-mainpage' => 'Creating main page with default content',