cgroup = $cgroup; } public function wrap( Command $command ) { $time = intval( $command->getCpuTimeLimit() ); $wallTime = intval( $command->getWallTimeLimit() ); $mem = intval( $command->getMemoryLimit() ); $filesize = intval( $command->getFileSizeLimit() ); if ( $time > 0 || $mem > 0 || $filesize > 0 || $wallTime > 0 ) { $cmd = '/bin/bash ' . Shellbox::escape( __DIR__ . '/limit.sh' ) . ' ' . Shellbox::escape( $command->getCommandString() ) . ' ' . Shellbox::escape( "SB_INCLUDE_STDERR=" . ( $command->getIncludeStderr() ? '1' : '' ) . ';' . "SB_CPU_LIMIT=$time; " . 'SB_CGROUP=' . Shellbox::escape( $this->cgroup ) . '; ' . "SB_MEM_LIMIT=$mem; " . "SB_FILE_SIZE_LIMIT=$filesize; " . "SB_WALL_CLOCK_LIMIT=$wallTime; " . "SB_USE_LOG_PIPE=yes" ); $command->unsafeCommand( $cmd ) ->useLogPipe(); if ( $command->getAllowedPaths() ) { // If specific paths have been allowed, make sure we explicitly // allow limit.sh. We don't do this unconditionally because it // doesn't work as expected in firejail, see T274474, T182486 $command->allowPath( __DIR__ . '/limit.sh' ); } } } public function getPriority() { return self::PRIORITY; } }