MediaWiki REL1_33
CommandFactory.php
Go to the documentation of this file.
1<?php
21namespace MediaWiki\Shell;
22
26
33 use LoggerAwareTrait;
34
36 private $limits;
37
39 private $cgroup;
40
42 private $doLogStderr = false;
43
48
52 private $firejail;
53
62 $this->limits = $limits;
63 $this->cgroup = $cgroup;
64 if ( $restrictionMethod === 'autodetect' ) {
65 // On Linux systems check for firejail
66 if ( PHP_OS === 'Linux' && $this->findFirejail() !== false ) {
67 $this->restrictionMethod = 'firejail';
68 } else {
69 $this->restrictionMethod = false;
70 }
71 } else {
72 $this->restrictionMethod = $restrictionMethod;
73 }
74 $this->setLogger( new NullLogger() );
75 }
76
77 private function findFirejail() {
78 if ( $this->firejail === null ) {
79 $this->firejail = ExecutableFinder::findInDefaultPaths( 'firejail' );
80 }
81
82 return $this->firejail;
83 }
84
91 public function logStderr( $yesno = true ) {
92 $this->doLogStderr = $yesno;
93 }
94
100 public function create() {
101 if ( $this->restrictionMethod === 'firejail' ) {
102 $command = new FirejailCommand( $this->findFirejail() );
104 } else {
105 $command = new Command();
106 }
107 $command->setLogger( $this->logger );
108
109 return $command
110 ->limits( $this->limits )
111 ->cgroup( $this->cgroup )
112 ->logStderr( $this->doLogStderr );
113 }
114}
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
$command
Definition cdb.php:65
Utility class to find executables in likely places.
static findInDefaultPaths( $names, $versionInfo=false)
Same as locateExecutable(), but checks in getPossibleBinPaths() by default.
Factory facilitating dependency injection for Command.
__construct(array $limits, $cgroup, $restrictionMethod)
Constructor.
logStderr( $yesno=true)
When enabled, text sent to stderr will be logged with a level of 'error'.
create()
Instantiates a new Command.
Class used for executing shell commands.
Definition Command.php:35
Restricts execution of shell commands using firejail.
const RESTRICT_DEFAULT
Apply a default set of restrictions for improved security out of the box.
Definition Shell.php:100
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))
Copyright (C) 2017 Kunal Mehta legoktm@member.fsf.org
Definition Command.php:21