Added file size limit for all shell processes, to stop ImageMagick from writing out...
authorTim Starling <tstarling@users.mediawiki.org>
Wed, 27 Sep 2006 00:43:37 +0000 (00:43 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Wed, 27 Sep 2006 00:43:37 +0000 (00:43 +0000)
bin/ulimit-tvf.sh [new file with mode: 0755]
includes/DefaultSettings.php
includes/GlobalFunctions.php

diff --git a/bin/ulimit-tvf.sh b/bin/ulimit-tvf.sh
new file mode 100755 (executable)
index 0000000..8a1eb81
--- /dev/null
@@ -0,0 +1,6 @@
+#!/bin/bash
+
+ulimit -t $1 -v $2 -f $3
+shift 3
+"$@"
+
index 7375be9..f7be878 100644 (file)
@@ -2201,6 +2201,12 @@ $wgContentNamespaces = array( NS_MAIN );
  */
 $wgMaxShellMemory = 102400;
 
+/**
+ * Maximum file size created by shell processes under linux, in KB
+ * ImageMagick convert for example can be fairly hungry for scratch space
+ */
+$wgMaxShellFileSize = 102400;
+
 /**
  * DJVU settings
  * Path of the djvutoxml executable
index 3079fba..c1a9906 100644 (file)
@@ -1671,7 +1671,7 @@ function wfUrlProtocols() {
  * @return collected stdout as a string (trailing newlines stripped)
  */
 function wfShellExec( $cmd, &$retval=null ) {
-       global $IP, $wgMaxShellMemory;
+       global $IP, $wgMaxShellMemory, $wgMaxShellFileSize;
        
        if( ini_get( 'safe_mode' ) ) {
                wfDebug( "wfShellExec can't run in safe_mode, PHP's exec functions are too broken.\n" );
@@ -1682,11 +1682,12 @@ function wfShellExec( $cmd, &$retval=null ) {
        if ( php_uname( 's' ) == 'Linux' ) {
                $time = ini_get( 'max_execution_time' );
                $mem = intval( $wgMaxShellMemory );
+               $filesize = intval( $wgMaxShellFileSize );
 
                if ( $time > 0 && $mem > 0 ) {
-                       $script = "$IP/bin/ulimit.sh";
+                       $script = "$IP/bin/ulimit-tvf.sh";
                        if ( is_executable( $script ) ) {
-                               $cmd = escapeshellarg( $script ) . " $time $mem $cmd";
+                               $cmd = escapeshellarg( $script ) . " $time $mem $filesize $cmd";
                        }
                }
        } elseif ( php_uname( 's' ) == 'Windows NT' ) {