Skip to content

Commit b81daaf

Browse files
committed
added gentoo specific code to keep symlinks in _getinitcommand
server/lib/classes/system.inc.php added gentoo specific code to keep symlinks as init script. gentoo uses symlinks to start different php-fpm versions, but "realpath" kills these symlinks.
1 parent e55f409 commit b81daaf

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

server/lib/classes/system.inc.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2132,6 +2132,26 @@ function _getinitcommand($servicename, $action, $init_script_directory = '', $ch
21322132
}
21332133

21342134
$full_init_script_path = realpath($init_script_directory.'/'.$servicename);
2135+
2136+
//** Gentoo, keep symlink as init script, but do some checks
2137+
if(file_exists('/etc/gentoo-release')) {
2138+
//* check if init script is symlink
2139+
if(is_link($init_script_directory.'/'.$servicename)) {
2140+
//* Check init script owner (realpath, symlink is checked later)
2141+
if(fileowner($full_init_script_path) !== 0) {
2142+
$app->log('Init script '.$full_init_script_path.' not owned by root user',LOGLEVEL_WARN);
2143+
return false;
2144+
}
2145+
2146+
//* full path is symlink
2147+
$full_init_script_path_symlink = $init_script_directory.'/'.$servicename;
2148+
2149+
//* check if realpath matches symlink
2150+
if(strpos($full_init_script_path_symlink,$full_init_script_path) == 0) {
2151+
$full_init_script_path = $full_init_script_path_symlink;
2152+
}
2153+
}
2154+
}
21352155

21362156
if($full_init_script_path == '') {
21372157
$app->log('No init script, we quit here.',LOGLEVEL_WARN);

0 commit comments

Comments
 (0)