]> git.proxmox.com Git - pve-common.git/blobdiff - src/PVE/Daemon.pm
tools: add fchownat syscall
[pve-common.git] / src / PVE / Daemon.pm
index ee3c67c4d4895fb6bcbae008946f7228263a619f..e3e43d9b3f0561998c6318eaf16d2a856ffd360d 100644 (file)
@@ -3,7 +3,7 @@ package PVE::Daemon;
 # Abstract class to implement Daemons
 #
 # Features:
-# * lock and write PID file /var/run/$name.pid to make sure onyl
+# * lock and write PID file /var/run/$name.pid to make sure only
 #   one instance is running.
 # * keep lock open during restart
 # * correctly daemonize (redirect STDIN/STDOUT)
@@ -102,9 +102,9 @@ my $lockpidfile = sub {
 
        my ($running, $pid) = $self->running();
        if ($running) {
-           die "can't aquire lock '$lkfn' - daemon already started (pid = $pid)\n";
+           die "can't acquire lock '$lkfn' - daemon already started (pid = $pid)\n";
        } else {
-           die "can't aquire lock '$lkfn' - $err\n";
+           die "can't acquire lock '$lkfn' - $err\n";
        }
     }
 };
@@ -201,7 +201,7 @@ my $terminate_server = sub {
     return if $allow_open_children && $self->{leave_children_open_on_reload};
 
     # else send TERM to all (old and current) child workers
-    kill 15, keys %{$self->@{'workers','old_workers'}};
+    kill 15, (keys %{$self->{workers}}, keys %{$self->{old_workers}});
 
     # nicely shutdown childs (give them max 10 seconds to shut down)
     my $previous_alarm = alarm(10);
@@ -280,7 +280,12 @@ sub setup {
 
     if ($restart && $self->{max_workers}) {
        if (my $wpids = $ENV{PVE_DAEMON_WORKER_PIDS}) {
-           $self->{old_workers}->{$_} = 1 foreach (split(':', $wpids));
+           foreach my $pid (split(':', $wpids)) {
+               # check & untaint
+               if ($pid =~ m/^(\d+)$/) {
+                   $self->{old_workers}->{$1} = 1;
+               }
+           }
        }
     }