From: Rob Church Date: Sat, 14 Jan 2006 23:07:08 +0000 (+0000) Subject: Improve installer: X-Git-Tag: 1.6.0~541 X-Git-Url: https://git.cyclocoop.org/%28%28?a=commitdiff_plain;h=5533f8c9b616cd803c50655ecfee8876c803af97;p=lhc%2Fweb%2Fwiklou.git Improve installer: * Use a superuser account (such as root), if specifed, to create tables * Don't overwrite conservative permissions on the mySQL user with ALL permissions, if said user exists * Changes to some of the wording of explanations for fields This will pre-emptively fix an issue arising if the regular-use user doesn't have permissions to set up the schema, since the end-user must now indicate this and provide superuser account details. Follow-on from last night's fixing 921 et al. --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 7382e61a14..5dfb357146 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -114,6 +114,14 @@ Images: Installer: * (bug 3782) Throw fatal installation warning if mbstring.func_overload on. Why do people invent these crazy options that change language semantics? +* Fixed installer bugs 921 and 3914 (issues with using root and so forth) +* (bug 4258) Use ugly urls for ISAPI by default + patch by Rob Church +* Improve installer + * Use a superuser account (such as root), if specifed, to create tables + * Don't overwrite conservative permissions on the mySQL user with ALL + permissions, if said user exists + * Changes to some of the wording of explanations for fields i18n / Languages: * Partial support for Basque language (from wikipedia and meta) @@ -413,8 +421,6 @@ fully support the editing toolbar, but was found to be too confusing. * (bug 3407) Fix encoding of subject and from/to headers on notification mails; userMailer() now takes a MailAddress wrapper object instead of a raw string to abstract things a level. -* (bug 4258) Use ugly urls for ISAPI by default - patch by Rob Church * Fixed --server override on dumpTextPass.php * Added plugin interface for dumpBackup, so additional filters and output sink types can be registered at runtime from an extension @@ -480,7 +486,6 @@ fully support the editing toolbar, but was found to be too confusing. * Linker::formatComment corrupted the passed title object on PHP 5 if the comment included a section link. Use clone() to make a safe copy. * Add wfClone() wrapper since we're still using PHP 4 on some servers. -* Fixed installer bugs 921 and 3914 (issues with using root and so forth) * Remove obsolete killthread.php * Added wfDie() wrapper, and some manual die(-1), to force the return code to the shell to return nonzero when we crap out with an error. diff --git a/config/index.php b/config/index.php index b4bed7636a..449de55d85 100644 --- a/config/index.php +++ b/config/index.php @@ -395,7 +395,8 @@ print "
  • Environment check $conf->DBpassword2 = importPost( "DBpassword2" ); $conf->DBprefix = importPost( "DBprefix" ); $conf->DBmysql5 = (importPost( "DBmysql5" ) == "true") ? "true" : "false"; - $conf->RootPW = importPost( "RootPW" ); + $conf->RootUser = importPost( "RootUser", "root" ); + $conf->RootPW = importPost( "RootPW", "-" ); $conf->LanguageCode = importPost( "LanguageCode", "en" ); $conf->SysopName = importPost( "SysopName", "WikiSysop" ); $conf->SysopPass = importPost( "SysopPass" ); @@ -503,67 +504,65 @@ if( $conf->posted && ( 0 == count( $errs ) ) ) { } $dbc = new $dbclass; - # Attempt to connect with the specific credentials *first* - # This is a quick fix to bug 921 ("Install script always attempts to connect to database as root") - if( $conf->DBtype == 'mysql' ) { $ok = true; # Let's be optimistic - echo( "
  • Attempting to connect to database server..." ); - $wgDatabase = Database::newFromParams( $wgDBserver, $wgDBuser, $wgDBpassword, "", 1 ); - if( $wgDatabase->isOpen() ) { - # Whee, we're in + + # Decide if we're going to use the superuser or the regular database user + if( $conf->RootPW == '-' ) { + # Regular user $conf->Root = false; - $wgDBadminuser = $wgDBuser; + $db_user = $wgDBuser; + $db_pass = $wgDBpassword; + } else { + # Superuser + $conf->Root = true; + $db_user = $conf->RootUser; + $db_pass = $conf->RootPW; + } + + # Attempt to connect + echo( "
  • Attempting to connect to database server as $db_user..." ); + $wgDatabase = Database::newFromParams( $wgDBserver, $db_user, $db_pass, '', 1 ); + + # Check the connection and respond to errors + if( $wgDatabase->isOpen() ) { + # Seems OK + $ok = true; + $wgDBadminuser = $db_user; $wgDBadminpassword = $wgDBpassword; - echo( "success. Connected as $wgDBuser.
  • \n" ); + echo( "success.\n" ); + $wgDatabase->ignoreErrors( true ); + $myver = mysql_get_server_info( $wgDatabase->mConn ); } else { - # Right, work out what's up + # There were errors, report them and back out + $ok = false; $errno = mysql_errno(); $errtx = htmlspecialchars( mysql_error() ); switch( $errno ) { - case 2002: - case 2003: - # Connection to server failed - $ok = false; - echo( "failed with error [$errno] $errtx.\n" ); - $errs["DBserver"] = "Connection failed"; - break; case 1045: case 2000: - # Authentication error, attempt to use root - sleep( 1 ); # Rate limiting - $wgDatabase = $dbc->newFromParams( $wgDBserver, "root", $conf->RootPW, "", 1 ); - if( $wgDatabase->isOpen() ) { - # Whee, fixed - $conf->Root = true; - echo( "success. Connected as root.\n" ); + echo( "failed due to authentication errors. Check passwords." ); + if( $conf->Root ) { + # The superuser details are wrong + $errs["RootUser"] = "Check username"; + $errs["RootPW"] = "and password"; } else { - # That didn't work either - $ok = false; - echo( "failed due to authentication errors. Check passwords." ); - $errs["DBuser"] = "Check name/pass"; - $errs["DBpassword"] = "or enter root"; - $errs["DBpassword2"] = "password below"; - $errs["RootPW"] = "Got root?"; + # The regular user details are wrong + $errs["DBuser"] = "Check username"; + $errs["DBpassword"] = "and password"; } break; + case 2002: + case 2003: default: - # Something vicious and undocumented happened - # Panic and run our little installer ass off - $ok = false; + # General connection problem echo( "failed with error [$errno] $errtx.\n" ); - $errs["DBserver"] = "Couldn't connect to database"; + $errs["DBserver"] = "Connection failed"; break; } # switch - } # norm. conn. attempt - - if( $ok ) { - # Set the version info. and ignore errors - $wgDatabase->ignoreErrors( true ); - $myver = mysql_get_server_info( $wgDatabase->mConn ); - } else { - continue; - } + } #conn. att. + + if( !$ok ) { continue; } } else /* not mysql */ { print "
  • Connecting to SQL server..."; @@ -678,12 +677,23 @@ if( $conf->posted && ( 0 == count( $errs ) ) ) { 'ss_total_views' => 0, 'ss_total_edits' => 0, 'ss_good_articles' => 0 ) ); - # setting up the db user + + # Set up the "regular user" account *if we can, and if we need to* if( $conf->Root ) { - print "
  • Granting user permissions...
  • \n"; - dbsource( "../maintenance/users.sql", $wgDatabase ); + # See if we need to + $wgDatabase2 = Database::newFromParams( $wgDBserver, $wgDBuser, $wgDBpassword, '', 1 ); + if( $wgDatabase2->isOpen() ) { + # Nope, just close the test connection and continue + $wgDatabase2->close(); + echo( "
  • User $wgDBuser exists. Skipping grants.
  • " ); + } else { + # Yes, so run the grants + echo( "
  • Granting user permissions to $wgDBuser on $wgDBname..." ); + dbsource( "../maintenance/users.sql", $wgDatabase ); + echo( "success.
  • " ); + } } - + if( $conf->SysopName ) { $u = User::newFromName( $conf->getSysopName() ); if ( 0 == $u->idForName() ) { @@ -985,6 +995,10 @@ if( count( $errs ) ) { enter those here. If you have database root access (see below) you can specify new accounts/databases to be created.

    +

    + This account will not be created if it pre-exists. If this is the case, ensure that it + has SELECT, INSERT, UPDATE and DELETE permissions on the MediaWiki database. +

    +
    +
    +
    +

    - You will only need this if the database and/or user account - above don't already exist. - Do not type in your machine's root password! MySQL - has its own "root" user with a separate password. (It might - even be blank, depending on your configuration.) + If the database user specified above does not exist, or does not have access to create + the database (if needed) or tables within it, please provide details of a superuser account, + such as root, which does. Leave the password set to - if this is not needed.