47 parent::__construct();
55 $this->whitelistedPaths = array_merge( $this->whitelistedPaths, $paths );
64 if ( $this->restrictions === 0 ) {
65 $splitCommand = explode(
' ',
$command, 2 );
67 "firejail: Command {$splitCommand[0]} {params} has no restrictions",
68 [
'params' => $splitCommand[1] ??
'' ]
70 return parent::buildFinalCommand(
$command );
73 if ( $this->firejail ===
false ) {
74 throw new RuntimeException(
'firejail is enabled, but cannot be found' );
83 $cmd[] =
'--profile=' . __DIR__ .
'/firejail.profile';
89 static $useAllUsers =
null;
90 if ( $useAllUsers ===
null ) {
94 $realIP = realpath(
$IP );
95 $currentUser = posix_getpwuid( posix_geteuid() );
96 $useAllUsers = ( strpos( $realIP,
'/home/' ) === 0 )
97 && ( strpos( $realIP, $currentUser[
'dir'] ) !== 0 );
99 $this->logger->warning(
'firejail: MediaWiki is located ' .
100 'in a home directory that does not belong to the ' .
101 'current user, so allowing access to all home ' .
102 'directories (--allusers)' );
106 if ( $useAllUsers ) {
107 $cmd[] =
'--allusers';
110 if ( $this->whitelistedPaths ) {
112 $cmd[] =
'--whitelist=' . __DIR__ .
'/limit.sh';
113 foreach ( $this->whitelistedPaths as $whitelistedPath ) {
114 $cmd[] =
"--whitelist={$whitelistedPath}";
119 $cmd[] =
'--blacklist=' . realpath( MW_CONFIG_FILE );
130 $extraSeccomp[] =
'execve';
134 $cmd[] =
'--shell=none';
138 $seccomp =
'--seccomp';
139 if ( $extraSeccomp ) {
141 $seccomp .=
'=' . implode(
',', $extraSeccomp );
147 $cmd[] =
'--private-dev';
151 $cmd[] =
'--net=none';
154 $builtCmd = implode(
' ', $cmd );
157 return parent::buildFinalCommand(
"$builtCmd -- {$command}" );
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))