r90228 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r90227‎ | r90228 | r90229 >
Date:20:58, 16 June 2011
Author:platonides
Status:ok
Tags:
Comment:
Allow to provide the db password inside a file instead of using
the command line, so that it isn't exposed in the process list.

Sadly, use of /dev/stdin or <(process) doesn't work in Linux,
since they are shown as symlinks to pipe:[12345678] and php
dereferences all of them. It has to be a real file.
However, such constructs work in Solaris, where they are
presented as character devices.
Modified paths:
  • /trunk/phase3/maintenance/install.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/install.php
@@ -55,6 +55,7 @@
5656 $this->addOption( 'installdbpass', 'The pasword for the DB user to install as.', false, true );
5757 $this->addOption( 'dbuser', 'The user to use for normal operations (wikiuser)', false, true );
5858 $this->addOption( 'dbpass', 'The pasword for the DB user for normal operations', false, true );
 59+ $this->addOption( 'dbpassfile', 'An alternative way to provide dbpass option, as the contents of this file', false, true );
5960 $this->addOption( 'confpath', "Path to write LocalSettings.php to, default $IP", false, true );
6061 /* $this->addOption( 'dbschema', 'The schema for the MediaWiki DB in pg (mediawiki)', false, true ); */
6162 /* $this->addOption( 'namespace', 'The project namespace (same as the name)', false, true ); */
@@ -67,6 +68,17 @@
6869 $adminName = isset( $this->mArgs[1] ) ? $this->mArgs[1] : null;
6970 $wgTitle = Title::newFromText( 'Installer script' );
7071
 72+ $dbpassfile = $this->getOption( 'dbpassfile', false );
 73+ if ( $dbpassfile !== false ) {
 74+ wfSuppressWarnings();
 75+ $dbpass = file_get_contents( $dbpassfile );
 76+ wfRestoreWarnings();
 77+ if ( $dbpass === false ) {
 78+ $this->error( "Couldn't open $dbpassfile", true );
 79+ }
 80+ $this->mOptions['dbpass'] = $dbpass;
 81+ }
 82+
7183 $installer =
7284 new CliInstaller( $siteName, $adminName, $this->mOptions );
7385

Follow-up revisions

RevisionCommit summaryAuthorDate
r90229Remove trailing newline from pass, which is very unlikely to be intended.platonides21:01, 16 June 2011

Status & tagging log