GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||
GeezerVison is showing www.mediawiki.org — Manual:Shell framework - MediaWiki
MediaWiki provides a robust framework for shelling out to external commands for increased performance, security, and portability. See the documentation for Shell and Command. A basic example: use MediaWiki\Shell\Shell; use MediaWiki\Logger\LoggerFactory; $result = Shell::command( '/usr/bin/command' ) ->environment( [ 'VAR' => 'VALUE' ] ) ->limits( [ 'time' => 300 ] ) ->execute(); $exitCode = $result->getExitCode(); $output = $result->getStdout(); $error = $result->getStderr(); This replaces the ParametersMost of the time you'll also want to provide some parameters to the command. MediaWiki will automatically escape all parameters to prevent shell injection attacks: $command = Shell::command( 'command', '--path' , $somePath ); In the rare case you need to pass a parameter unscaped, you can use: $command = Shell::command( 'command' )->unsafeParams( '-x -y -z' ); You can use LimitsFor both performance and security reasons, MediaWiki institutes limits on CPU time, wall clock time, file size and the memory usage a command can use. The defaults from Further restrictions can be implemented using cgroups, see Restrictions
Since 1.31, MediaWiki supports sandboxing commands with external restriction software - currently only firejail is supported, and must be enabled with
You can look at the restriction of binaries in the Score extension as an example. firejail profileMediaWiki uses a firejail profile that allows for extra customization and restrictions depending upon your platform. Create # MediaWiki local firejail additions blacklist /srv/private See Wikimedia's mediawiki.local as an example. LoggingBy default, errors and standard error output are logged to the | ||||||||
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |