Merge pull request #1889 from SimonFair/ntp-fix

killall and pgrep updates.
This commit is contained in:
tom mortensen
2024-10-10 17:02:59 -07:00
committed by GitHub
26 changed files with 41 additions and 57 deletions
+1 -1
View File
@@ -69,7 +69,7 @@ $cache_type = $cache_rate = [];
$parity = _var($var,'mdResync');
$mover = file_exists('/var/run/mover.pid');
$btrfs = exec('pgrep -cf /sbin/btrfs');
$btrfs = exec('pgrep --ns $$ -cf /sbin/btrfs');
$vdisk = exec("grep -Pom1 '^DOCKER_IMAGE_TYPE=\"\\K[^\"]+' /boot/config/docker.cfg 2>/dev/null")!='folder' ? _('Docker vdisk') : _('Docker folder');
$dot = _var($display,'number','.,')[0];
$zfs = count(array_filter(array_column($disks,'fsType'),function($fs){return str_replace('luks:','',$fs??'')=='zfs';}));
+2 -2
View File
@@ -60,8 +60,8 @@ foreach ($ports as $ethX) {
}
}
// enable interface only when VMs and Docker are stopped
$service = exec("pgrep libvirt") ? _('VM manager') : '';
$service .= exec("pgrep docker") ? ($service ? ' '._('and').' ' : '')._('Docker service') : '';
$service = exec('pgrep --ns $$ libvirt') ? _('VM manager') : '';
$service .= exec('pgrep --ns $$ docker') ? ($service ? ' '._('and').' ' : '')._('Docker service') : '';
// eth0 port status
$no_eth0 = exec("ip link show eth0|grep -Pom1 '(NO-CARRIER|state DOWN)'");
@@ -40,9 +40,9 @@ default:
$file = "/var/lib/$dir/check.status.$id";
if (file_exists($file)) {
switch ($cmd) {
case 'btrfs-check': $pgrep = "pgrep -f '/sbin/btrfs check .*$dev'"; break;
case 'rfs-check': $pgrep = "pgrep -f '/sbin/reiserfsck $dev'"; break;
case 'xfs-check': $pgrep = "pgrep -f '/sbin/xfs_repair.*$dev'"; break;
case 'btrfs-check': $pgrep = 'pgrep --ns \$\$ -f '."'/sbin/btrfs check .*$dev'"; break;
case 'rfs-check': $pgrep = 'pgrep --ns $$ -f '."'/sbin/reiserfsck $dev'"; break;
case 'xfs-check': $pgrep = 'pgrep --ns $$ -f '."'/sbin/xfs_repair.*$dev'"; break;
}
echo file_get_contents($file);
if (!exec($pgrep)) echo "\0";
+2 -2
View File
@@ -263,7 +263,7 @@ function urlencode_path($path) {
return str_replace("%2F", "/", urlencode($path));
}
function pgrep($process_name, $escape_arg=true) {
$pid = exec("pgrep ".($escape_arg?escapeshellarg($process_name):$process_name), $output, $retval);
$pid = exec('pgrep --ns $$ '.($escape_arg?escapeshellarg($process_name):$process_name), $output, $retval);
return $retval==0 ? $pid : false;
}
function is_block($path) {
@@ -372,7 +372,7 @@ function my_rmdir($dirname) {
'dataset' => $zfsdataset,
'type' => $fstype,
'cmd' => $cmdstr,
'error' => $error,
'error' =>
];
break;
case "btrfs":
@@ -44,10 +44,10 @@ switch ($_GET['tag']) {
case 'ttyd':
// check if ttyd already running
$sock = "/var/run/ttyd.sock";
exec("pgrep -f '$sock'", $ttyd_pid, $retval);
exec('pgrep --ns $$ -f '."'$sock'", $ttyd_pid, $retval);
if ($retval == 0) {
// check if there are any child processes, ie, curently open tty windows
exec("pgrep -P ".$ttyd_pid[0], $output, $retval);
exec('pgrep --ns $$ -P '.$ttyd_pid[0], $output, $retval);
// no child processes, restart ttyd to pick up possible font size change
if ($retval != 0) exec("kill ".$ttyd_pid[0]);
}
@@ -15,7 +15,7 @@ $docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
require_once "$docroot/webGui/include/Secure.php";
function pgrep($proc) {
return exec("pgrep -f $proc");
return exec('pgrep --ns $$ -f '."$proc");
}
if (isset($_POST['kill']) && $_POST['kill'] > 1) {
@@ -16,7 +16,7 @@ case "$1" in
else
echo "Not available"
fi;
pgrep -f "/sbin/reiserfsck $2" >/dev/null
pgrep --ns $$ -f "/sbin/reiserfsck $2" >/dev/null
;;
'cancel')
pkill -f "/sbin/reiserfsck $2"