r53664 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r53663‎ | r53664 | r53665 >
Date:00:31, 23 July 2009
Author:demon
Status:ok (Comments)
Tags:
Comment:
* (bug 14201) Set $wgDBadminuser/$wgDBadminpassword during setup
* (bug 18768) Remove AdminSettings requirements. Maintenance environment will still load it if it exists, but it's not required for anything
Modified paths:
  • /trunk/phase3/AdminSettings.sample (deleted) (history)
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/UPGRADE (modified) (history)
  • /trunk/phase3/config/index.php (modified) (history)
  • /trunk/phase3/docs/scripts.txt (modified) (history)
  • /trunk/phase3/maintenance/README (modified) (history)
  • /trunk/phase3/maintenance/commandLine.inc (modified) (history)
  • /trunk/phase3/maintenance/fuzz-tester.php (modified) (history)
  • /trunk/phase3/profileinfo.php (modified) (history)
  • /trunk/phase3/t/Search.inc (modified) (history)

Diff [purge]

Index: trunk/phase3/AdminSettings.sample
@@ -1,32 +0,0 @@
2 -<?php
3 -/**
4 - * This file should be copied to AdminSettings.php, and modified
5 - * to reflect local settings. It is required for the maintenance
6 - * scripts which run on the command line, as an extra security
7 - * measure to allow using a separate user account with higher
8 - * privileges to do maintenance work.
9 - *
10 - * Developers: Do not check AdminSettings.php into Subversion
11 - */
12 -
13 -/*
14 - * This data is used by all database maintenance scripts
15 - * (see directory maintenance/). The SQL user MUST BE
16 - * MANUALLY CREATED or set to an existing user with
17 - * necessary permissions.
18 - *
19 - * This is not to be confused with sysop accounts for the
20 - * wiki.
21 - *
22 - * NOTE: for PostgreSQL this should be set to the same user and
23 - * password as the web user, that is, the same as $wgDBuser and
24 - * $wgDBpassword in LocalSettings.php. This is necessary to
25 - * ensure that the owner for new tables is set correctly.
26 - */
27 -$wgDBadminuser = 'wikiadmin';
28 -$wgDBadminpassword = 'adminpass';
29 -
30 -/*
31 - * Whether to enable the profileinfo.php script.
32 - */
33 -$wgEnableProfileInfo = false;
Index: trunk/phase3/maintenance/fuzz-tester.php
@@ -138,7 +138,7 @@
139139 }
140140 // --------- End ---------
141141
142 - Also add/change this in AdminSettings.php:
 142+ Also add/change this in LocalSettings.php:
143143 // --------- Start ---------
144144 $wgEnableProfileInfo = true;
145145 $wgDBserver = "localhost"; // replace with DB server hostname
Index: trunk/phase3/maintenance/README
@@ -10,8 +10,8 @@
1111
1212 Certain scripts will require elevated access to the database. In order to
1313 provide this, first create a MySQL user with "all" permissions on the wiki
14 -database, and then place their username and password in an AdminSettings.php
15 -file in the directory above. See AdminSettings.sample for specifics on this.
 14+database, and then set $wgDBadminuser and $wgDBadminpassword in your
 15+LocalSettings.php
1616
1717 === Brief explanation of files ===
1818
@@ -94,7 +94,7 @@
9595 Immediately complete all jobs in the job queue
9696
9797 stats.php
98 - Show all statistics stored in memcached
 98+ Show all statistics stored in the cache
9999
100100 undelete.php
101101 Undelete all revisions of a page
Index: trunk/phase3/maintenance/commandLine.inc
@@ -171,8 +171,8 @@
172172 #require_once( $IP.'/includes/ProfilerStub.php' );
173173 require( $IP.'/includes/Defines.php' );
174174 require( $IP.'/CommonSettings.php' );
175 - if ( !$wgUseNormalUser ) {
176 - require( $IP.'/AdminSettings.php' );
 175+ if ( !$wgUseNormalUser && is_readable( "$IP/AdminSettings.php" ) ) {
 176+ require( "$IP/AdminSettings.php" );
177177 }
178178 } else {
179179 $wgWikiFarm = false;
Index: trunk/phase3/UPGRADE
@@ -42,8 +42,7 @@
4343 repository, via a checkout or export operation.
4444
4545 Replace the existing MediaWiki files with the new. You should preserve the
46 -LocalSettings.php file, AdminSettings.php file (if present), and the
47 -"extensions" and "images" directories.
 46+LocalSettings.php file and the "extensions" and "images" directories.
4847
4948 Depending upon your configuration, you may also need to preserve additional
5049 directories, including a custom upload directory ($wgUploadDirectory),
@@ -51,8 +50,8 @@
5251
5352 === Perform the database upgrade ===
5453
55 -You will need an AdminSettings.php file set up in the correct format; see
56 -AdminSettings.sample in the wiki root for more information and examples.
 54+You will need to have $wgDBadminuser and $wgDBadminpass set in your
 55+LocalSettings.php, see there for more info.
5756
5857 From the command line, browse to the "maintenance" directory and run the
5958 update.php script to check and update the schema. This will insert missing
@@ -172,10 +171,10 @@
173172 === Web installer ===
174173
175174 You can use the web-based installer wizard if you first remove the
176 -LocalSettings.php (and AdminSettings.php, if any) files; be sure to
177 -give the installer the same information as you did on the original
178 -install (language/encoding, database name, password, etc). This will
179 -also generate a fresh LocalSettings.php, which you may need to customize.
 175+LocalSettings.php file; be sure to give the installer the same
 176+information as you did on the original install (language/encoding,
 177+database name, password, etc). This will also generate a fresh
 178+LocalSettings.php, which you may need to customize.
180179
181180 You may change some settings during the install, but be very careful!
182181 Changing the encoding in particular will generally leave you with a
@@ -185,8 +184,8 @@
186185
187186 Additionally, as of 1.4.0 you can run an in-place upgrade script from
188187 the command line, keeping your existing LocalSettings.php. This requires
189 -that you create an AdminSettings.php giving an appropriate database user
190 -and password with privileges to modify the database structure.
 188+that you set $wgDBadminuser and $wgDBadminpassword with an appropriate
 189+database user and password with privileges to modify the database structure.
191190
192191 Once the new files are in place, go into the maintenance subdirectory and
193192 run the script:
Index: trunk/phase3/docs/scripts.txt
@@ -35,10 +35,9 @@
3636 to force the profiler to save the informations in the database and apply the
3737 maintenance/archives/patch-profiling.sql patch to the database.
3838
39 - To enable the profileinfo.php itself, you'll need to create the
40 - AdminSettings.php file (see AdminSettings.sample for more information) and
41 - set $wgEnableProfileInfo to true in that file. See also
42 - http://www.mediawiki.org/wiki/How_to_debug#Profiling.
 39+ To enable the profileinfo.php itself, you'll need to set $wgDBadminuser
 40+ and $wgDBadminpassword in your LocalSettings.php, as well as $wgEnableProfileInfo
 41+ See also http://www.mediawiki.org/wiki/How_to_debug#Profiling.
4342
4443 redirect.php
4544 Script that only redirect to the article passed in the wpDropdown parameter
Index: trunk/phase3/profileinfo.php
@@ -4,7 +4,6 @@
55 $wgEnableProfileInfo = $wgProfileToDatabase = false;
66
77 require_once( './includes/WebStart.php' );
8 -@include_once( './AdminSettings.php' );
98
109 ?>
1110 <!--
Index: trunk/phase3/t/Search.inc
@@ -7,11 +7,10 @@
88 require 'includes/Defines.php';
99 require 'includes/ProfilerStub.php';
1010 require 'LocalSettings.php';
11 -require 'AdminSettings.php';
1211 require 'includes/Setup.php';
1312
1413 function buildTestDatabase( $tables ) {
15 - global $wgDBprefix, $wgDBserver, $wgDBadminuser, $wgDBadminpassword, $wgDBname, $wgDBtype;
 14+ global $wgDBprefix, $wgDBserver, $wgDBname, $wgDBtype;
1615 $oldPrefix = $wgDBprefix;
1716 $wgDBprefix = 'parsertest';
1817
Index: trunk/phase3/config/index.php
@@ -633,6 +633,7 @@
634634 $conf->RootUser = importPost( "RootUser", "root" );
635635 $conf->RootPW = importPost( "RootPW", "" );
636636 $useRoot = importCheck( 'useroot', false );
 637+ $conf->populateadmin = importCheck( 'populateadmin', false );
637638 $conf->LanguageCode = importPost( "LanguageCode", "en" );
638639 ## MySQL specific:
639640 $conf->DBprefix = importPost( "DBprefix" );
@@ -1000,7 +1001,7 @@
10011002 if ($wgDatabase->isOpen()) {
10021003 $wgDBOracleDefTS = $conf->DBdefTS_ora;
10031004 $wgDBOracleTempTS = $conf->DBtempTS_ora;
1004 - dbsource( "../maintenance/ora/user.sql", $wgDatabase );
 1005+ $wgDatabase->sourceFile( "../maintenance/ora/user.sql" );
10051006 } else {
10061007 echo "<li>Invalid database superuser, please supply a valid superuser account.</li>";
10071008 echo "<li>ERR: ".print_r(oci_error(), true)."</li>";
@@ -1173,7 +1174,7 @@
11741175 print " <b class='error'>If the next step fails, see <a href='http://dev.mysql.com/doc/mysql/en/old-client.html'>http://dev.mysql.com/doc/mysql/en/old-client.html</a> for help.</b>";
11751176 }
11761177 print "</li>\n";
1177 - dbsource( "../maintenance/users.sql", $wgDatabase );
 1178+ $wgDatabase->sourceFile( "../maintenance/users.sql" );
11781179 }
11791180 }
11801181 }
@@ -1207,8 +1208,8 @@
12081209 # FIXME: Check for errors
12091210 print "<li>Creating tables...";
12101211 if ($conf->DBtype == 'mysql') {
1211 - dbsource( "../maintenance/tables.sql", $wgDatabase );
1212 - dbsource( "../maintenance/interwiki.sql", $wgDatabase );
 1212+ $wgDatabase->sourceFile( "../maintenance/tables.sql" );
 1213+ $wgDatabase->sourceFile( "../maintenance/interwiki.sql" );
12131214 } elseif (is_callable(array($wgDatabase, 'setup_database'))) {
12141215 $wgDatabase->setup_database();
12151216 }
@@ -1241,7 +1242,7 @@
12421243 } else {
12431244 # Yes, so run the grants
12441245 echo( "<li>" . htmlspecialchars( "Granting user permissions to $wgDBuser on $wgDBname..." ) );
1245 - dbsource( "../maintenance/users.sql", $wgDatabase );
 1246+ $wgDatabase->sourceFile( "../maintenance/users.sql" );
12461247 echo( "success.</li>\n" );
12471248 }
12481249 }
@@ -1547,6 +1548,8 @@
15481549 <label class="column">Superuser account:</label>
15491550 <input type="checkbox" name="useroot" id="useroot" <?php if( $useRoot ) { ?>checked="checked" <?php } ?> />
15501551 &nbsp;<label for="useroot">Use superuser account</label>
 1552+ <input type="checkbox" name="populateadmin" id="populateadmin" <?php if( $conf->populateadmin ) { ?>checked="checked" <?php } ?> />
 1553+ &nbsp;<label for="populateadmin">Set as admin user for maintenance</label>
15511554 </div>
15521555 <div class="config-input"><?php aField( $conf, "RootUser", "Superuser name:", "text" ); ?></div>
15531556 <div class="config-input"><?php aField( $conf, "RootPW", "Superuser password:", "password" ); ?></div>
@@ -1812,6 +1815,11 @@
18131816 # Needs literal string interpolation for the current style path
18141817 $slconf['RightsIcon'] = $conf->RightsIcon;
18151818 }
 1819+
 1820+ if( $conf->populateadmin ) {
 1821+ $slconf['DBadminuser'] = $conf->RootUser;
 1822+ $slconf['DBadminpassword'] = $conf->RootPW;
 1823+ }
18161824
18171825 if( $conf->DBtype == 'mysql' ) {
18181826 $dbsettings =
@@ -1919,6 +1927,10 @@
19201928
19211929 {$dbsettings}
19221930
 1931+## Database admin settings, used for maintenance scripts
 1932+\$wgDBadminuser = \"{$slconf['DBadminuser']}\";
 1933+\$wgDBadminpassword = \"{$slconf['DBadminpassword']}\";
 1934+
19231935 ## Shared memory settings
19241936 \$wgMainCacheType = $cacheType;
19251937 \$wgMemCachedServers = $mcservers;
Index: trunk/phase3/RELEASE-NOTES
@@ -37,7 +37,6 @@
3838 this. Was used when mwEmbed was going to be an extension.
3939 * $wgDebugJavaScript if we want to enable fresh debug javascript
4040 * $wgPhpCliPath Path to php-cli for spinning up background php processes
41 -
4241 * (bug 18222) $wgMinimalPasswordLength default is now 1
4342 * $wgSessionHandler can be used to configure session.save_handler
4443 * $wgLocalFileRepo/$wgForeignFileRepos now have a 'fileMode' parameter to
@@ -151,7 +150,10 @@
152151 thumbnails to be stored in a separate location to the source images.
153152 * If config/ directory is not executable, the command to make it executable
154153 now asks the user to cd to the correct directory
155 -* Add experimental new external authentication framework, ExternalAuth.
 154+* Add experimental new external authentication framework, ExternalAuth
 155+* (bug 14201) Set $wgDBadminuser/$wgDBadminpassword during setup
 156+* (bug 18768) Remove AdminSettings requirements. Maintenance environment
 157+ will still load it if it exists, but it's not required for anything
156158
157159 === Bug fixes in 1.16 ===
158160

Follow-up revisions

RevisionCommit summaryAuthorDate
r55612Partial revert of r53664 (bug 14201 Set $wgDBadminuser/$wgDBadminpassword dur...demon18:56, 26 August 2009

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r51676Basic implementation of abstract Maintenance class + docs. TODO: Handle confi...demon02:41, 10 June 2009
r52336Merge maintenance-work branch:...demon02:02, 24 June 2009

Comments

#Comment by Brion VIBBER (talk | contribs)   22:28, 21 August 2009

Root user/pass should under NO circumstances be saved into LocalSettings.php -- this is patently unsafe.

#Comment by 😂 (talk | contribs)   19:01, 26 August 2009

Resolved with r55612? On thinking about this more, I'm not sure how very useful this will be anyway. Inclined to WONTFIX the bug actually.

#Comment by Werdna (talk | contribs)   17:06, 27 August 2009

Marking as OK now. Seems not to block deployment.

Status & tagging log