"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "server/lib/classes/system.inc.php" between
ISPConfig-3.2.6.tar.gz and ISPConfig-3.2.7.tar.gz

About: ISPConfig is an ISP management and Hosting Control Panel (for different Managed Services).

system.inc.php  (ISPConfig-3.2.6):system.inc.php  (ISPConfig-3.2.7)
skipping to change at line 1280 skipping to change at line 1280
*/ */
function cat($file){ function cat($file){
global $app; global $app;
return $app->file->rf($file); return $app->file->rf($file);
} }
/** /**
* Control services to restart etc * Control services to restart etc
* *
*/ */
/*
function daemon_init($daemon, $action){ function daemon_init($daemon, $action){
//* $action = start|stop|restart|reload //* $action = start|stop|restart|reload
global $app; global $app;
$dist = $this->server_conf['dist']; $dist = $this->server_conf['dist'];
$dist_init_scripts = $this->server_conf['dist_init_scripts']; $dist_init_scripts = $this->server_conf['dist_init_scripts'];
if(!strstr($dist, 'freebsd')){ if(!strstr($dist, 'freebsd')){
$app->log->caselog("$dist_init_scripts/$daemon $action &> /dev/null", $this->FILE, __LINE__); $app->log->caselog("$dist_init_scripts/$daemon $action &> /dev/null", $this->FILE, __LINE__);
} else { } else {
if(is_file($dist_init_scripts.'/'.$daemon.'.sh') || is_li nk($dist_init_scripts.'/'.$daemon.'.sh')){ if(is_file($dist_init_scripts.'/'.$daemon.'.sh') || is_li nk($dist_init_scripts.'/'.$daemon.'.sh')){
if($action == 'start' || $action == 'stop'){ if($action == 'start' || $action == 'stop'){
skipping to change at line 1318 skipping to change at line 1319
$app->log->caselog('/etc/ rc.d/'.$daemon.' '.$action.' &> /dev/null', $this->FILE, __LINE__); $app->log->caselog('/etc/ rc.d/'.$daemon.' '.$action.' &> /dev/null', $this->FILE, __LINE__);
} else { } else {
$app->log->caselog('/etc/ rc.d/'.$daemon.' stop &> /dev/null', $this->FILE, __LINE__); $app->log->caselog('/etc/ rc.d/'.$daemon.' stop &> /dev/null', $this->FILE, __LINE__);
sleep(3); sleep(3);
$app->log->caselog('/etc/ rc.d/'.$daemon.' start &> /dev/null', $this->FILE, __LINE__); $app->log->caselog('/etc/ rc.d/'.$daemon.' start &> /dev/null', $this->FILE, __LINE__);
} }
} }
} }
} }
} }
} } */
function netmask($netmask){ function netmask($netmask){
list($f1, $f2, $f3, $f4) = explode('.', trim($netmask)); list($f1, $f2, $f3, $f4) = explode('.', trim($netmask));
$bin = str_pad(decbin($f1), 8, '0', STR_PAD_LEFT).str_pad(decbin( $f2), 8, '0', STR_PAD_LEFT).str_pad(decbin($f3), 8, '0', STR_PAD_LEFT).str_pad(d ecbin($f4), 8, '0', STR_PAD_LEFT); $bin = str_pad(decbin($f1), 8, '0', STR_PAD_LEFT).str_pad(decbin( $f2), 8, '0', STR_PAD_LEFT).str_pad(decbin($f3), 8, '0', STR_PAD_LEFT).str_pad(d ecbin($f4), 8, '0', STR_PAD_LEFT);
$parts = explode('0', $bin); $parts = explode('0', $bin);
$bin = str_pad($parts[0], 32, '0', STR_PAD_RIGHT); $bin = str_pad($parts[0], 32, '0', STR_PAD_RIGHT);
$bin = wordwrap($bin, 8, '.', 1); $bin = wordwrap($bin, 8, '.', 1);
list($f1, $f2, $f3, $f4) = explode('.', trim($bin)); list($f1, $f2, $f3, $f4) = explode('.', trim($bin));
return bindec($f1).'.'.bindec($f2).'.'.bindec($f3).'.'.bindec($f4 ); return bindec($f1).'.'.bindec($f2).'.'.bindec($f3).'.'.bindec($f4 );
} }
skipping to change at line 1956 skipping to change at line 1957
} }
} }
} }
} }
return $unmounted; return $unmounted;
} }
function _getinitcommand($servicename, $action, $init_script_directory = '', $check_service) { function _getinitcommand($servicename, $action, $init_script_directory = '', $check_service) {
global $conf; global $conf, $app;
// upstart // upstart
/* removed upstart support - deprecated
if(is_executable('/sbin/initctl')){ if(is_executable('/sbin/initctl')){
exec('/sbin/initctl version 2>/dev/null | /bin/grep -q up start', $retval['output'], $retval['retval']); exec('/sbin/initctl version 2>/dev/null | /bin/grep -q up start', $retval['output'], $retval['retval']);
if(intval($retval['retval']) == 0) return 'service '.$ser vicename.' '.$action; if(intval($retval['retval']) == 0) return 'service '.$ser vicename.' '.$action;
} }
*/
if(!in_array($action,array('restart','reload','force-reload'))) {
$app->log('Invalid init command action '.$action,LOGLEVEL
_WARN);
return false;
}
// systemd //* systemd (now default in all supported OS)
if(is_executable('/bin/systemd') || is_executable('/usr/bin/syste mctl')){ if(is_executable('/bin/systemd') || is_executable('/usr/bin/syste mctl')){
if ($check_service) { $app->log('Trying to use Systemd to restart service',LOGL
$this->exec_safe("systemctl is-enabled ? 2>&1", $ EVEL_DEBUG);
servicename);
$ret_val = $this->last_exec_retcode(); //* Test service name via regex
} if(preg_match('/[a-zA-Z0-9\.\-\_]/',$servicename)) {
if ($ret_val == 0 || !$check_service) {
return 'systemctl '.$action.' '.$servicename.'.se //* Test if systemd service is enabled
rvice'; if ($check_service) {
$this->exec_safe("systemctl is-enabled ?
2>&1", $servicename);
$ret_val = $this->last_exec_retcode();
} else {
$app->log('Systemd service '.$servicename
.' not found or not enabled.',LOGLEVEL_DEBUG);
}
//* Return service command
if ($ret_val == 0 || !$check_service) {
return 'systemctl '.$action.' '.$servicen
ame.'.service';
} else {
$app->log('Failed to use Systemd to resta
rt service '.$servicename.', we try init script instead.',LOGLEVEL_DEBUG);
}
} else {
$app->log('Systemd service name contains invalid
chars: '.$servicename,LOGLEVEL_DEBUG);
} }
} else {
$app->log('Not using Systemd to restart services',LOGLEVE
L_DEBUG);
} }
// sysvinit //* sysvinit fallback
$app->log('Using init script to restart service',LOGLEVEL_DEBUG);
//* Get init script directory
if($init_script_directory == '') $init_script_directory = $conf[' init_scripts']; if($init_script_directory == '') $init_script_directory = $conf[' init_scripts'];
if(substr($init_script_directory, -1) === '/') $init_script_direc tory = substr($init_script_directory, 0, -1); if(substr($init_script_directory, -1) === '/') $init_script_direc tory = substr($init_script_directory, 0, -1);
if($check_service && is_executable($init_script_directory.'/'.$se $init_script_directory = realpath($init_script_directory);
rvicename)) {
return $init_script_directory.'/'.$servicename.' '.$actio //* Check init script dir
n; if(!is_dir($init_script_directory)) {
$app->log('Init script directory '.$init_script_directory
.' not found',LOGLEVEL_WARN);
return false;
}
//* Forbidden init script paths
if(substr($init_script_directory,0,4) == '/var' || substr($init_s
cript_directory,0,4) == '/tmp') {
$app->log('Do not put init scripts in /var or /tmp folder
.',LOGLEVEL_WARN);
return false;
}
//* Check init script dir owner
if(fileowner($init_script_directory) !== 0) {
$app->log('Init script directory '.$init_script_directory
.' not owned by root user',LOGLEVEL_WARN);
return false;
}
$full_init_script_path = realpath($init_script_directory.'/'.$ser
vicename);
if($full_init_script_path == '') {
$app->log('No init script, we quit here.',LOGLEVEL_WARN);
return false;
}
//* Check init script
if(!is_file($full_init_script_path)) {
$app->log('Init script '.$full_init_script_path.' not fou
nd',LOGLEVEL_WARN);
return false;
}
//* Check init script owner
if(fileowner($full_init_script_path) !== 0) {
$app->log('Init script '.$full_init_script_path.' not own
ed by root user',LOGLEVEL_WARN);
return false;
}
if($check_service && is_executable($full_init_script_path)) {
return $full_init_script_path.' '.$action;
} }
if (!$check_service) { if (!$check_service) {
return $init_script_directory.'/'.$servicename.' '.$actio n; return $full_init_script_path.' '.$action;
} }
} }
function getinitcommand($servicename, $action, $init_script_directory = ' ', $check_service=false) { function getinitcommand($servicename, $action, $init_script_directory = ' ', $check_service=true) {
if (is_array($servicename)) { if (is_array($servicename)) {
foreach($servicename as $service) { foreach($servicename as $service) {
$out = $this->_getinitcommand($service, $action, $init_script_directory, true); $out = $this->_getinitcommand($service, $action, $init_script_directory, true);
if ($out != '') return $out; if ($out != '') return $out;
} }
} else { } else {
return $this->_getinitcommand($servicename, $action, $ini t_script_directory, $check_service); return $this->_getinitcommand($servicename, $action, $ini t_script_directory, $check_service);
} }
} }
 End of changes. 12 change blocks. 
18 lines changed or deleted 97 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)