r93834 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r93833‎ | r93834 | r93835 >
Date:15:46, 3 August 2011
Author:mah
Status:ok
Tags:
Comment:
* Make envCheckPath() specific to each installer, web vs cli
* Add warning during the CLI install that the uploads directory isn't
being checked for arbitrary script execution
Modified paths:
  • /trunk/phase3/includes/installer/CliInstaller.php (modified) (history)
  • /trunk/phase3/includes/installer/Installer.i18n.php (modified) (history)
  • /trunk/phase3/includes/installer/Installer.php (modified) (history)
  • /trunk/phase3/includes/installer/WebInstaller.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/installer/WebInstaller.php
@@ -1007,20 +1007,6 @@
10081008 }
10091009 }
10101010
1011 - // PHP_SELF isn't available sometimes, such as when PHP is CGI but
1012 - // cgi.fix_pathinfo is disabled. In that case, fall back to SCRIPT_NAME
1013 - // to get the path to the current script... hopefully it's reliable. SIGH
1014 - $path = false;
1015 - if ( !empty( $_SERVER['PHP_SELF'] ) ) {
1016 - $path = $_SERVER['PHP_SELF'];
1017 - } elseif ( !empty( $_SERVER['SCRIPT_NAME'] ) ) {
1018 - $path = $_SERVER['SCRIPT_NAME'];
1019 - }
1020 - if ($path !== false) {
1021 - $uri = preg_replace( '{^(.*)/(mw-)?config.*$}', '$1', $path );
1022 - $this->setVar( 'wgScriptPath', $uri );
1023 - }
1024 -
10251011 return $newValues;
10261012 }
10271013
@@ -1067,4 +1053,27 @@
10681054 $img . ' ' . wfMsgHtml( 'config-download-localsettings' ) );
10691055 return Html::rawElement( 'div', array( 'class' => 'config-download-link' ), $anchor );
10701056 }
 1057+
 1058+ public function envCheckPath( ) {
 1059+ // PHP_SELF isn't available sometimes, such as when PHP is CGI but
 1060+ // cgi.fix_pathinfo is disabled. In that case, fall back to SCRIPT_NAME
 1061+ // to get the path to the current script... hopefully it's reliable. SIGH
 1062+ $path = false;
 1063+ if ( !empty( $_SERVER['PHP_SELF'] ) ) {
 1064+ $path = $_SERVER['PHP_SELF'];
 1065+ } elseif ( !empty( $_SERVER['SCRIPT_NAME'] ) ) {
 1066+ $path = $_SERVER['SCRIPT_NAME'];
 1067+ }
 1068+ if ($path !== false) {
 1069+ $uri = preg_replace( '{^(.*)/(mw-)?config.*$}', '$1', $path );
 1070+ $this->setVar( 'wgScriptPath', $uri );
 1071+ } else {
 1072+ $this->showError( 'config-no-uri' );
 1073+ return false;
 1074+ }
 1075+
 1076+
 1077+ return parent::envCheckPath();
 1078+ }
 1079+
10711080 }
Index: trunk/phase3/includes/installer/Installer.php
@@ -859,10 +859,6 @@
860860 $IP = dirname( dirname( dirname( __FILE__ ) ) );
861861 $this->setVar( 'IP', $IP );
862862
863 - if( !$this->getVar( 'wgScriptPath' ) ) {
864 - $this->showError( 'config-no-uri' );
865 - return false;
866 - }
867863 $this->showMessage( 'config-using-uri', $this->getVar( 'wgServer' ), $this->getVar( 'wgScriptPath' ) );
868864 return true;
869865 }
Index: trunk/phase3/includes/installer/Installer.i18n.php
@@ -147,10 +147,13 @@
148148 Image thumbnailing will be disabled.',
149149 'config-no-uri' => "'''Error:''' Could not determine the current URI.
150150 Installation aborted.",
 151+ 'config-no-cli-uri' => "'''Warning''': No --scriptpath specified, using default: <code>$1</code>.",
151152 'config-using-server' => 'Using server name "<nowiki>$1</nowiki>".',
152153 'config-using-uri' => 'Using server URL "<nowiki>$1$2</nowiki>".',
153154 'config-uploads-not-safe' => "'''Warning:''' Your default directory for uploads <code>$1</code> is vulnerable to arbitrary scripts execution.
154155 Although MediaWiki checks all uploaded files for security threats, it is highly recommended to [http://www.mediawiki.org/wiki/Manual:Security#Upload_security close this security vulnerability] before enabling uploads.",
 156+ 'config-no-cli-uploads-check' => "'''Warning:''' Your default directory for uploads (<code>$1</code>) is not checked for vulnerability
 157+to arbitrary script execution during the CLI install.",
155158 'config-brokenlibxml' => 'Your system has a combination of PHP and libxml2 versions which is buggy and can cause hidden data corruption in MediaWiki and other web applications.
156159 Upgrade to PHP 5.2.9 or later and libxml2 2.7.3 or later ([http://bugs.php.net/bug.php?id=45996 bug filed with PHP]).
157160 Installation aborted.',
Index: trunk/phase3/includes/installer/CliInstaller.php
@@ -13,6 +13,7 @@
1414 * @since 1.17
1515 */
1616 class CliInstaller extends Installer {
 17+ private $specifiedScriptPath = false;
1718
1819 private $optionMap = array(
1920 'dbtype' => 'wgDBtype',
@@ -45,6 +46,10 @@
4647
4748 parent::__construct();
4849
 50+ if ( isset( $option['scriptpath'] ) ) {
 51+ $this->specifiedScriptPath = true;
 52+ }
 53+
4954 foreach ( $this->optionMap as $opt => $global ) {
5055 if ( isset( $option[$opt] ) ) {
5156 $GLOBALS[$global] = $option[$opt];
@@ -170,4 +175,16 @@
171176 exit;
172177 }
173178 }
 179+
 180+ public function envCheckPath( ) {
 181+ if ( !$this->specifiedScriptPath ) {
 182+ $this->showMessage( 'config-no-cli-uri', $this->getVar("wgScriptPath") );
 183+ }
 184+ return parent::envCheckPath();
 185+ }
 186+
 187+ public function dirIsExecutable( $dir, $url ) {
 188+ $this->showMessage( 'config-no-cli-uploads-check', $dir );
 189+ return false;
 190+ }
174191 }

Sign-offs

UserFlagDate
😂inspected15:49, 3 August 2011

Follow-up revisions

RevisionCommit summaryAuthorDate
r102514REL1_18 MFT r92846, r93065, r93834, r94171reedy14:31, 9 November 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r93635Fixes Bug #30061 - Command line installer $wgScriptPath...mah18:03, 1 August 2011
r93828re: r93635...mah14:25, 3 August 2011

Status & tagging log