From 77fa1cdc99fce01495d0b8385e1a5e525fee4e1d Mon Sep 17 00:00:00 2001 From: Platonides Date: Sun, 25 Jul 2010 21:02:42 +0000 Subject: [PATCH] Kill $wgDBsuperuser --- config/Installer.php | 7 +++---- includes/db/DatabasePostgres.php | 20 ++++++++++---------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/config/Installer.php b/config/Installer.php index f32ac5ffd4..2bf20c912c 100644 --- a/config/Installer.php +++ b/config/Installer.php @@ -1033,10 +1033,9 @@ if( $conf->posted && ( 0 == count( $errs ) ) ) { ## Possible connect as a superuser // Changed !mysql to postgres check since it seems to only apply to postgres if( $useRoot && $conf->DBtype == 'postgres' ) { - $wgDBsuperuser = $conf->RootUser; echo( "
  • Attempting to connect to database \"postgres\" as superuser \"" . - htmlspecialchars( $wgDBsuperuser ) . "\"..." ); - $wgDatabase = $dbc->newFromParams($wgDBserver, $wgDBsuperuser, $conf->RootPW, "postgres", 1); + htmlspecialchars( $conf->RootUser ) . "\"..." ); + $wgDatabase = $dbc->newFromParams($wgDBserver, $conf->RootUser, $conf->RootPW, "postgres", 1); if (!$wgDatabase->isOpen()) { print " error: " . htmlspecialchars( $wgDatabase->lastError() ) . "
  • \n"; $errs["DBserver"] = "Could not connect to database as superuser"; @@ -1044,7 +1043,7 @@ if( $conf->posted && ( 0 == count( $errs ) ) ) { $errs["RootPW"] = "and password"; continue; } - $wgDatabase->initial_setup($conf->RootPW, 'postgres'); + $wgDatabase->initial_setup($conf->RootUser, $conf->RootPW, 'postgres'); } echo( "
  • Attempting to connect to database \"" . htmlspecialchars( $wgDBname ) . "\" as \"" . htmlspecialchars( $wgDBuser ) . "\"..." ); diff --git a/includes/db/DatabasePostgres.php b/includes/db/DatabasePostgres.php index 9086198b87..960b74adc7 100644 --- a/includes/db/DatabasePostgres.php +++ b/includes/db/DatabasePostgres.php @@ -227,9 +227,9 @@ class DatabasePostgres extends DatabaseBase { } - function initial_setup($password, $dbName) { + function initial_setup($superuser, $password, $dbName) { // If this is the initial connection, setup the schema stuff and possibly create the user - global $wgDBname, $wgDBuser, $wgDBpassword, $wgDBsuperuser, $wgDBmwschema, $wgDBts2schema; + global $wgDBname, $wgDBuser, $wgDBpassword, $superuser, $wgDBmwschema, $wgDBts2schema; print "
  • Checking the version of Postgres..."; $version = $this->getServerVersion(); @@ -242,17 +242,17 @@ class DatabasePostgres extends DatabaseBase { $safeuser = $this->quote_ident($wgDBuser); // Are we connecting as a superuser for the first time? - if ($wgDBsuperuser) { + if ($superuser) { // Are we really a superuser? Check out our rights $SQL = "SELECT CASE WHEN usesuper IS TRUE THEN CASE WHEN usecreatedb IS TRUE THEN 3 ELSE 1 END ELSE CASE WHEN usecreatedb IS TRUE THEN 2 ELSE 0 END END AS rights - FROM pg_catalog.pg_user WHERE usename = " . $this->addQuotes($wgDBsuperuser); + FROM pg_catalog.pg_user WHERE usename = " . $this->addQuotes($superuser); $rows = $this->numRows($res = $this->doQuery($SQL)); if (!$rows) { - print "
  • ERROR: Could not read permissions for user \"" . htmlspecialchars( $wgDBsuperuser ) . "\"
  • \n"; + print "
  • ERROR: Could not read permissions for user \"" . htmlspecialchars( $superuser ) . "\"
  • \n"; dieout(''); } $perms = pg_fetch_result($res, 0, 0); @@ -264,7 +264,7 @@ class DatabasePostgres extends DatabaseBase { } else { if ($perms != 1 and $perms != 3) { - print "
  • ERROR: the user \"" . htmlspecialchars( $wgDBsuperuser ) . "\" cannot create other users. "; + print "
  • ERROR: the user \"" . htmlspecialchars( $superuser ) . "\" cannot create other users. "; print 'Please use a different Postgres user.
  • '; dieout(''); } @@ -283,7 +283,7 @@ class DatabasePostgres extends DatabaseBase { } else { if ($perms < 1) { - print "
  • ERROR: the user \"" . htmlspecialchars( $wgDBsuperuser ) . "\" cannot create databases. "; + print "
  • ERROR: the user \"" . htmlspecialchars( $superuser ) . "\" cannot create databases. "; print 'Please use a different Postgres user.
  • '; dieout(''); } @@ -297,7 +297,7 @@ class DatabasePostgres extends DatabaseBase { // Reconnect to check out tsearch2 rights for this user print "
  • Connecting to \"" . htmlspecialchars( $wgDBname ) . "\" as superuser \"" . - htmlspecialchars( $wgDBsuperuser ) . "\" to check rights..."; + htmlspecialchars( $superuser ) . "\" to check rights..."; $connectVars = array(); if ($this->mServer!=false && $this->mServer!="") { @@ -307,7 +307,7 @@ class DatabasePostgres extends DatabaseBase { $connectVars['port'] = $this->mPort; } $connectVars['dbname'] = $wgDBname; - $connectVars['user'] = $wgDBsuperuser; + $connectVars['user'] = $superuser; $connectVars['password'] = $password; @$this->mConn = pg_connect( $this->makeConnectionString( $connectVars ) ); @@ -380,7 +380,7 @@ class DatabasePostgres extends DatabaseBase { // Install plpgsql if needed $this->setup_plpgsql(); - $wgDBsuperuser = ''; + $superuser = ''; return true; // Reconnect as regular user } // end superuser -- 2.20.1