r45495 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r45494‎ | r45495 | r45496 >
Date:12:20, 7 January 2009
Author:tstarling
Status:ok
Tags:
Comment:
Test for disable_functions as well as safe_mode before attempting passthru(). For fix of bug 16902 in new-installer branch.
Modified paths:
  • /trunk/phase3/includes/GlobalFunctions.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/GlobalFunctions.php
@@ -2101,11 +2101,26 @@
21022102 function wfShellExec( $cmd, &$retval=null ) {
21032103 global $IP, $wgMaxShellMemory, $wgMaxShellFileSize, $wgMaxShellTime;
21042104
2105 - if( wfIniGetBool( 'safe_mode' ) ) {
2106 - wfDebug( "wfShellExec can't run in safe_mode, PHP's exec functions are too broken.\n" );
 2105+ static $disabled;
 2106+ if ( is_null( $disabled ) ) {
 2107+ $disabled = false;
 2108+ if( wfIniGetBool( 'safe_mode' ) ) {
 2109+ wfDebug( "wfShellExec can't run in safe_mode, PHP's exec functions are too broken.\n" );
 2110+ $disabled = true;
 2111+ }
 2112+ $functions = explode( ',', ini_get( 'disable_functions' ) );
 2113+ $functions = array_map( 'trim', $functions );
 2114+ $functions = array_map( 'strtolower', $functions );
 2115+ if ( in_array( 'passthru', $functions ) ) {
 2116+ wfDebug( "passthru is in disabled_functions\n" );
 2117+ $disabled = true;
 2118+ }
 2119+ }
 2120+ if ( $disabled ) {
21072121 $retval = 1;
21082122 return "Unable to run external programs in safe mode.";
21092123 }
 2124+
21102125 wfInitShellLocale();
21112126
21122127 if ( php_uname( 's' ) == 'Linux' ) {

Status & tagging log