in MW 1.20 (saving preferences using Special:Preferences cleared any
additional fields) and which has been disabled in 1.20.1 as a part of
a security fix (bug 42202).
+* Added the ability to limit the wall clock time used by shell processes,
+ as well as the CPU time. Configurable with $wgMaxShellWallClockTime.
=== Bug fixes in 1.21 ===
* (bug 40353) SpecialDoubleRedirect should support interwiki redirects.
$wgMaxShellFileSize = 102400;
/**
- * Maximum CPU time in seconds for shell processes under linux
+ * Maximum CPU time in seconds for shell processes under Linux
*/
$wgMaxShellTime = 180;
+/**
+ * Maximum wall clock time (i.e. real time, of the kind the clock on the wall
+ * would measure) in seconds for shell processes under Linux
+ */
+$wgMaxShellWallClockTime = 180;
+
/**
* Executable path of the PHP cli binary (php/php5). Should be set up on install.
*/
* (non-zero is usually failure)
* @param $environ Array optional environment variables which should be
* added to the executed command environment.
- * @param $limits Array optional array with limits(filesize, memory, time)
+ * @param $limits Array optional array with limits(filesize, memory, time, walltime)
* this overwrites the global wgShellMax* limits.
* @return string collected stdout as a string (trailing newlines stripped)
*/
function wfShellExec( $cmd, &$retval = null, $environ = array(), $limits = array() ) {
- global $IP, $wgMaxShellMemory, $wgMaxShellFileSize, $wgMaxShellTime;
+ global $IP, $wgMaxShellMemory, $wgMaxShellFileSize, $wgMaxShellTime,
+ $wgMaxShellWallClockTime;
static $disabled;
if ( is_null( $disabled ) ) {
if ( php_uname( 's' ) == 'Linux' ) {
$time = intval ( isset($limits['time']) ? $limits['time'] : $wgMaxShellTime );
+ if ( isset( $limits['walltime'] ) ) {
+ $wallTime = intval( $limits['walltime'] );
+ } elseif ( isset( $limits['time'] ) ) {
+ $wallTime = $time;
+ } else {
+ $wallTime = intval( $wgMaxShellWallClockTime );
+ }
$mem = intval ( isset($limits['memory']) ? $limits['memory'] : $wgMaxShellMemory );
$filesize = intval ( isset($limits['filesize']) ? $limits['filesize'] : $wgMaxShellFileSize );
- if ( $time > 0 && $mem > 0 ) {
- $script = "$IP/bin/ulimit4.sh";
- if ( is_executable( $script ) ) {
- $cmd = '/bin/bash ' . escapeshellarg( $script ) . " $time $mem $filesize " . escapeshellarg( $cmd );
- }
+ if ( $time > 0 || $mem > 0 || $filesize > 0 || $wallTime > 0 ) {
+ $cmd = '/bin/bash ' . escapeshellarg( "$IP/bin/ulimit5.sh" ) .
+ " $time $mem $filesize $wallTime " . escapeshellarg( $cmd );
}
}
wfDebug( "wfShellExec: $cmd\n" );