From 1ac75d9951ed6bb213751e73ec1cf1d7c095ecc9 Mon Sep 17 00:00:00 2001 From: Ilia Rostovtsev Date: Thu, 4 Feb 2021 14:25:31 +0300 Subject: [PATCH] Fix to use absolute paths for commands https://www.virtualmin.com/node/70617#comment-832718 --- virtualmin-nginx-lib.pl | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/virtualmin-nginx-lib.pl b/virtualmin-nginx-lib.pl index 77600de..ed681fc 100644 --- a/virtualmin-nginx-lib.pl +++ b/virtualmin-nginx-lib.pl @@ -1700,12 +1700,19 @@ sub setup_php_fcgi_server } my $name = &init_script_name($d); my $envs = join(" ", map { $_."=".$envs_to_set->{$_} } keys %$envs_to_set); +my %cmds_abs = ( + 'echo', &has_command('echo'), + 'cat', &has_command('cat'), + 'chmod', &has_command('chmod'), + 'kill', &has_command('kill'), + 'sleep', &has_command('sleep'), +); &init::enable_at_boot($name, "Starts Nginx PHP FastCGI server for $d->{'dom'} (Virtualmin)", &command_as_user($d->{'user'}, 0, - "$envs $cmd >>$log 2>&1 $pidfile && chmod +r $pidfile", + "$envs $cmd >>$log 2>&1 $pidfile && $cmds_abs{'chmod'} +r $pidfile", &command_as_user($d->{'user'}, 0, - "kill `cat $pidfile`")." ; sleep 1", + "$cmds_abs{'kill'} `$cmds_abs{'cat'} $pidfile`")." ; $cmds_abs{'sleep'} 1", undef, { 'fork' => 1, 'pidfile' => $pidfile },