MediaWiki REL1_35
|
Class used for executing shell commands. More...
Public Member Functions | |
__construct () | |
Don't call directly, instead use Shell::command() | |
__destruct () | |
Makes sure the programmer didn't forget to execute the command after all. | |
__toString () | |
Returns the final command line before environment/limiting, etc are applied. | |
cgroup ( $cgroup) | |
Sets cgroup for this command. | |
environment (array $env) | |
Sets environment variables which should be added to the executed command environment. | |
execute () | |
Executes command. | |
includeStderr (bool $yesno=true) | |
Controls whether stderr should be included in stdout, including errors from limit.sh. | |
input (?string $inputString) | |
Sends the provided input to the command. | |
limits (array $limits) | |
Sets execution limits. | |
logStderr (bool $yesno=true) | |
When enabled, text sent to stderr will be logged with a level of 'error'. | |
params (... $args) | |
Adds parameters to the command. | |
profileMethod (string $method) | |
Sets calling function for profiler. | |
restrict (int $restrictions) | |
Set restrictions for this request, overwriting any previously set restrictions. | |
unsafeParams (... $args) | |
Adds unsafe parameters to the command. | |
whitelistPaths (array $paths) | |
If called, only the files/directories that are whitelisted will be available to the shell command. | |
Protected Member Functions | |
buildFinalCommand (string $command) | |
String together all the options and build the final command to execute. | |
hasRestriction (int $restriction) | |
Bitfield helper on whether a specific restriction is enabled. | |
Protected Attributes | |
string | $command = '' |
int | $restrictions = 0 |
Bitfield with restrictions. | |
Private Attributes | |
string false | $cgroup = false |
bool | $doIncludeStderr = false |
bool | $doLogStderr = false |
string[] | $env = [] |
bool | $everExecuted = false |
string null | $inputString |
array | $limits |
string | $method |
MediaWiki\Shell\Command::__construct | ( | ) |
Don't call directly, instead use Shell::command()
ShellDisabledError |
Definition at line 87 of file Command.php.
References MediaWiki\Shell\Shell\isDisabled().
MediaWiki\Shell\Command::__destruct | ( | ) |
Makes sure the programmer didn't forget to execute the command after all.
Definition at line 98 of file Command.php.
References MediaWiki\Shell\Command\$command, and MediaWiki\Shell\Command\$method.
MediaWiki\Shell\Command::__toString | ( | ) |
Returns the final command line before environment/limiting, etc are applied.
Use string conversion only for debugging, don't try to pass this to some other execution medium.
Definition at line 585 of file Command.php.
|
protected |
String together all the options and build the final command to execute.
string | $command | Already-escaped command to run |
Reimplemented in MediaWiki\Shell\FirejailCommand.
Definition at line 304 of file Command.php.
References wfIsWindows().
MediaWiki\Shell\Command::cgroup | ( | $cgroup | ) |
Sets cgroup for this command.
string | false | $cgroup | Absolute file path to the cgroup, or false to not use a cgroup |
Definition at line 237 of file Command.php.
MediaWiki\Shell\Command::environment | ( | array | $env | ) |
Sets environment variables which should be added to the executed command environment.
string[] | $env | array of variable name => value |
Definition at line 176 of file Command.php.
MediaWiki\Shell\Command::execute | ( | ) |
Executes command.
Afterwards, getExitCode() and getOutput() can be used to access execution results.
Exception | |
ProcOpenError | |
ShellDisabledError |
Definition at line 367 of file Command.php.
|
protected |
Bitfield helper on whether a specific restriction is enabled.
int | $restriction |
Definition at line 278 of file Command.php.
MediaWiki\Shell\Command::includeStderr | ( | bool | $yesno = true | ) |
Controls whether stderr should be included in stdout, including errors from limit.sh.
Default: don't include.
bool | $yesno |
Definition at line 213 of file Command.php.
MediaWiki\Shell\Command::input | ( | ?string | $inputString | ) |
Sends the provided input to the command.
When set to null (default), the command will use the standard input.
string | null | $inputString |
Definition at line 200 of file Command.php.
MediaWiki\Shell\Command::limits | ( | array | $limits | ) |
Sets execution limits.
array | $limits | Associative array of limits. Keys (all optional): filesize (for ulimit -f), memory, time, walltime. |
Definition at line 159 of file Command.php.
MediaWiki\Shell\Command::logStderr | ( | bool | $yesno = true | ) |
When enabled, text sent to stderr will be logged with a level of 'error'.
bool | $yesno |
Definition at line 225 of file Command.php.
MediaWiki\Shell\Command::params | ( | $args | ) |
Adds parameters to the command.
All parameters are sanitized via Shell::escape(). Null values are ignored.
string|string[] | ...$args |
Reimplemented in MediaWiki\Shell\FirejailCommand.
Definition at line 118 of file Command.php.
References $args.
MediaWiki\Shell\Command::profileMethod | ( | string | $method | ) |
Sets calling function for profiler.
By default, the caller for execute() will be used.
string | $method |
Definition at line 188 of file Command.php.
MediaWiki\Shell\Command::restrict | ( | int | $restrictions | ) |
Set restrictions for this request, overwriting any previously set restrictions.
Add the "no network" restriction:
Allow LocalSettings.php access:
Disable all restrictions:
int | $restrictions |
Definition at line 265 of file Command.php.
MediaWiki\Shell\Command::unsafeParams | ( | $args | ) |
Adds unsafe parameters to the command.
These parameters are NOT sanitized in any way. Null values are ignored.
string|string[] | ...$args |
Definition at line 136 of file Command.php.
References $args.
MediaWiki\Shell\Command::whitelistPaths | ( | array | $paths | ) |
If called, only the files/directories that are whitelisted will be available to the shell command.
limit.sh will always be whitelisted
string[] | $paths |
Reimplemented in MediaWiki\Shell\FirejailCommand.
Definition at line 292 of file Command.php.
|
private |
Definition at line 73 of file Command.php.
|
protected |
Definition at line 40 of file Command.php.
Referenced by MediaWiki\Shell\Command\__destruct().
|
private |
Definition at line 64 of file Command.php.
|
private |
Definition at line 67 of file Command.php.
|
private |
Definition at line 55 of file Command.php.
|
private |
Definition at line 70 of file Command.php.
|
private |
Definition at line 61 of file Command.php.
|
private |
Definition at line 43 of file Command.php.
|
private |
Definition at line 58 of file Command.php.
Referenced by MediaWiki\Shell\Command\__destruct().
|
protected |
Bitfield with restrictions.
Definition at line 80 of file Command.php.