http://www.mediawiki.org/wiki/Special:Code/MediaWiki/69008
Revision: 69008
Author: avar
Date: 2010-07-04 16:16:28 +0000 (Sun, 04 Jul 2010)
Log Message:
-----------
new-installer: GRANT permissions to our new non-root user by sourcing users.sql
The old installer sourced maintenance/users.sql to create a new
non-root user if requested. Do that in the new installer as well.
So far this only works on MySQL, but I'm adding a generic setupUser
function on the assumption that other databases (except SQLite) want
to do some sort of user setup.
Modified Paths:
--------------
trunk/phase3/includes/installer/Installer.i18n.php
trunk/phase3/includes/installer/Installer.php
trunk/phase3/includes/installer/InstallerDBType.php
trunk/phase3/includes/installer/MysqlInstaller.php
Modified: trunk/phase3/includes/installer/Installer.i18n.php
===================================================================
--- trunk/phase3/includes/installer/Installer.i18n.php 2010-07-04 15:56:46 UTC
(rev 69007)
+++ trunk/phase3/includes/installer/Installer.i18n.php 2010-07-04 16:16:28 UTC
(rev 69008)
@@ -419,6 +419,8 @@
'config-install-database' => 'Setting up database',
'config-install-pg-schema-failed' => 'Tables creation failed.
Make sure that the user "$1" can write to the schema "$2".',
+ 'config-install-user' => 'Creating database user',
+ 'config-install-user-failed' => 'Granting permission to user "$1"
failed: $2',
'config-install-tables' => 'Creating tables',
'config-install-interwiki' => 'Populating default interwiki
table',
'config-install-interwiki-sql' => 'Could not find file
<code>interwiki.sql</code>',
Modified: trunk/phase3/includes/installer/Installer.php
===================================================================
--- trunk/phase3/includes/installer/Installer.php 2010-07-04 15:56:46 UTC
(rev 69007)
+++ trunk/phase3/includes/installer/Installer.php 2010-07-04 16:16:28 UTC
(rev 69008)
@@ -128,6 +128,7 @@
var $installSteps = array(
'database',
+ 'user',
'tables',
'interwiki',
'secretkey',
@@ -870,6 +871,12 @@
return $status;
}
+ public function installUser() {
+ $installer = $this->getDBInstaller( $this->getVar( 'wgDBtype' )
);
+ $status = $installer->setupUser();
+ return $status;
+ }
+
public function installTables() {
$installer = $this->getDBInstaller();
$status = $installer->createTables();
Modified: trunk/phase3/includes/installer/InstallerDBType.php
===================================================================
--- trunk/phase3/includes/installer/InstallerDBType.php 2010-07-04 15:56:46 UTC
(rev 69007)
+++ trunk/phase3/includes/installer/InstallerDBType.php 2010-07-04 16:16:28 UTC
(rev 69008)
@@ -86,6 +86,18 @@
abstract function setupDatabase();
/**
+ * Create a new non-root user for the database and return a Status
+ * object indicating success or failure. A default implementation
+ * that returns a good status is supplied for those databases that
+ * don't need to set up users.
+ *
+ * @return Status
+ */
+ function setupUser() {
+ return Status::newGood();
+ }
+
+ /**
* Create database tables from scratch
* @return \type Status
*/
Modified: trunk/phase3/includes/installer/MysqlInstaller.php
===================================================================
--- trunk/phase3/includes/installer/MysqlInstaller.php 2010-07-04 15:56:46 UTC
(rev 69007)
+++ trunk/phase3/includes/installer/MysqlInstaller.php 2010-07-04 16:16:28 UTC
(rev 69008)
@@ -376,6 +376,28 @@
return $status;
}
+ function setupUser() {
+ global $IP;
+
+ if ( !$this->getVar( '_CreateDBAccount' ) ) {
+ return;
+ }
+
+ $status = $this->getConnection();
+ if ( !$status->isOK() ) {
+ return $status;
+ }
+
+ $db = $this->getVar( 'wgDBname' );
+ $this->db->selectDB( $db );
+ $error = $this->db->sourceFile( "$IP/maintenance/users.sql" );
+ if ( !$error ) {
+ $status->fatal( 'config-install-user-failed',
$this->getVar( 'wgDBuser' ), $error );
+ }
+
+ return $status;
+ }
+
function createTables() {
global $IP;
$status = $this->getConnection();
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs