]>
git.proxmox.com Git - pve-access-control.git/blob - PVE/RPCEnvironment.pm
1 package PVE
::RPCEnvironment
;
5 use POSIX
qw(:sys_wait_h EINTR);
10 use PVE
::Exception
qw(raise raise_perm_exc);
16 use PVE
::AccessControl
;
19 # we use this singleton class to pass RPC related environment values
23 # save $SIG{CHLD} handler implementation.
24 # simply set $SIG{CHLD} = $worker_reaper;
25 # and register forked processes with &$register_worker(pid)
26 # Note: using $SIG{CHLD} = 'IGNORE' or $SIG{CHLD} = sub { wait (); } or ...
27 # has serious side effects, because perls built in system() and open()
28 # functions can't get the correct exit status of a child. So we cant use
29 # that (also see perlipc)
33 my $log_task_result = sub {
34 my ($upid, $user, $status) = @_;
36 my $msg = 'successful';
39 my $ec = $status >> 8;
40 my $ic = $status & 255;
41 $msg = $ec ?
"failed ($ec)" : "interrupted ($ic)";
44 my $tlist = active_workers
($upid);
45 PVE
::Cluster
::broadcast_tasklist
($tlist);
47 foreach my $t (@$tlist) {
48 if ($t->{upid
} eq $upid) {
53 if ($task && $task->{status
}) {
54 $msg = $task->{status
};
56 PVE
::Cluster
::log_msg
($pri, $user, "end task $upid $msg");
59 my $worker_reaper = sub {
61 foreach my $pid (keys %$WORKER_PIDS) {
62 my $waitpid = waitpid ($pid, WNOHANG
);
63 if (defined($waitpid) && ($waitpid == $pid)) {
64 my $info = $WORKER_PIDS->{$pid};
65 if ($info && $info->{upid
} && $info->{user
}) {
66 &$log_task_result($info->{upid
}, $info->{user
}, $?);
68 delete ($WORKER_PIDS->{$pid});
73 my $register_worker = sub {
74 my ($pid, $user, $upid) = @_;
78 # do not register if already finished
79 my $waitpid = waitpid ($pid, WNOHANG
);
80 if (defined($waitpid) && ($waitpid == $pid)) {
81 delete ($WORKER_PIDS->{$pid});
85 $WORKER_PIDS->{$pid} = {
93 my $compile_acl_path = sub {
94 my ($self, $user, $path) = @_;
96 my $cfg = $self->{user_cfg
};
98 return undef if !$cfg->{roles
};
100 die "internal error" if $user eq 'root@pam';
102 my $cache = $self->{aclcache
};
103 $cache->{$user} = {} if !$cache->{$user};
104 my $data = $cache->{$user};
106 if (!$data->{poolroles
}) {
107 $data->{poolroles
} = {};
109 foreach my $pool (keys %{$cfg->{pools
}}) {
110 my $d = $cfg->{pools
}->{$pool};
111 my @ra = PVE
::AccessControl
::roles
($cfg, $user, "/pool/$pool"); # pool roles
112 next if !scalar(@ra);
113 foreach my $vmid (keys %{$d->{vms
}}) {
115 $data->{poolroles
}->{"/vms/$vmid"}->{$role} = 1;
118 foreach my $storeid (keys %{$d->{storage
}}) {
120 $data->{poolroles
}->{"/storage/$storeid"}->{$role} = 1;
126 my @ra = PVE
::AccessControl
::roles
($cfg, $user, $path);
128 # apply roles inherited from pools
129 # Note: assume we do not want to propagate those privs
130 if ($data->{poolroles
}->{$path}) {
131 if (!($ra[0] && $ra[0] eq 'NoAccess')) {
132 if ($data->{poolroles
}->{$path}->{NoAccess
}) {
135 foreach my $role (keys %{$data->{poolroles
}->{$path}}) {
142 $data->{roles
}->{$path} = [ @ra ];
145 foreach my $role (@ra) {
146 if (my $privset = $cfg->{roles
}->{$role}) {
147 foreach my $p (keys %$privset) {
152 $data->{privs
}->{$path} = $privs;
158 my ($self, $user, $path) = @_;
160 if ($user eq 'root@pam') { # root can do anything
161 return ('Administrator');
164 $user = PVE
::AccessControl
::verify_username
($user, 1);
167 my $cache = $self->{aclcache
};
168 $cache->{$user} = {} if !$cache->{$user};
170 my $acl = $cache->{$user};
172 my $roles = $acl->{roles
}->{$path};
173 return @$roles if $roles;
175 &$compile_acl_path($self, $user, $path);
176 $roles = $acl->{roles
}->{$path} || [];
181 my ($self, $user, $path) = @_;
183 if ($user eq 'root@pam') { # root can do anything
184 my $cfg = $self->{user_cfg
};
185 return $cfg->{roles
}->{'Administrator'};
188 $user = PVE
::AccessControl
::verify_username
($user, 1);
191 my $cache = $self->{aclcache
};
192 $cache->{$user} = {} if !$cache->{$user};
194 my $acl = $cache->{$user};
196 my $perm = $acl->{privs
}->{$path};
197 return $perm if $perm;
199 return &$compile_acl_path($self, $user, $path);
203 my ($self, $user, $path, $privs, $noerr) = @_;
205 my $perm = $self->permissions($user, $path);
207 foreach my $priv (@$privs) {
208 PVE
::AccessControl
::verify_privname
($priv);
209 if (!$perm->{$priv}) {
210 return undef if $noerr;
211 raise_perm_exc
("$path, $priv");
219 my ($self, $user, $path, $privs, $noerr) = @_;
221 my $perm = $self->permissions($user, $path);
224 foreach my $priv (@$privs) {
225 PVE
::AccessControl
::verify_privname
($priv);
226 if ($perm->{$priv}) {
234 return undef if $noerr;
236 raise_perm_exc
("$path, " . join("|", @$privs));
240 my ($self, $username, $path, $privs, $any, $noerr) = @_;
242 return $self->check_any($username, $path, $privs, $noerr);
244 return $self->check($username, $path, $privs, $noerr);
248 sub check_user_enabled
{
249 my ($self, $user, $noerr) = @_;
251 my $cfg = $self->{user_cfg
};
252 return PVE
::AccessControl
::check_user_enabled
($cfg, $user, $noerr);
255 sub check_user_exist
{
256 my ($self, $user, $noerr) = @_;
258 my $cfg = $self->{user_cfg
};
259 return PVE
::AccessControl
::check_user_exist
($cfg, $user, $noerr);
262 sub check_pool_exist
{
263 my ($self, $pool, $noerr) = @_;
265 my $cfg = $self->{user_cfg
};
267 return 1 if $cfg->{pools
}->{$pool};
269 return undef if $noerr;
271 raise_perm_exc
("pool '$pool' does not exist");
275 my ($self, $user, $vmid, $pool, $privs, $any, $noerr) = @_;
277 my $cfg = $self->{user_cfg
};
280 return if $self->check_full($user, "/pool/$pool", $privs, $any, 1);
282 return $self->check_full($user, "/vms/$vmid", $privs, $any, $noerr);
285 sub check_storage_perm
{
286 my ($self, $user, $vmid, $pool, $storeid, $privs, $any, $noerr) = @_;
288 my $cfg = $self->{user_cfg
};
290 if ($pool && $cfg->{pools
}->{$pool} &&
291 $cfg->{pools
}->{$pool}->{storage
}->{$storeid}) {
292 return if $self->check_full($user, "/pool/$pool", $privs, $any, 1);
294 return $self->check_full($user, "/storage/$storeid", $privs, $any, $noerr);
297 sub is_group_member
{
298 my ($self, $group, $user) = @_;
300 my $cfg = $self->{user_cfg
};
302 return 0 if !$cfg->{groups
}->{$group};
304 return defined($cfg->{groups
}->{$group}->{users
}->{$user});
308 my ($self, $user, $privs, $any) = @_;
310 my $cfg = $self->{user_cfg
};
313 foreach my $group (keys %{$cfg->{groups
}}) {
314 my $path = "/access/groups/$group";
315 if ($self->check_full($user, $path, $privs, $any, 1)) {
316 $groups->{$group} = $cfg->{groups
}->{$group};
323 sub group_member_join
{
324 my ($self, $grouplist) = @_;
328 my $cfg = $self->{user_cfg
};
329 foreach my $group (@$grouplist) {
330 my $data = $cfg->{groups
}->{$group};
332 foreach my $user (keys %{$data->{users
}}) {
340 sub check_perm_modify
{
341 my ($self, $username, $path, $noerr) = @_;
343 return $self->check($username, '/access', [ 'Permissions.Modify' ], $noerr) if !$path;
345 my $testperms = [ 'Permissions.Modify' ];
346 if ($path =~ m
|^/storage/.+$|) {
347 push @$testperms, 'Datastore.Allocate';
348 } elsif ($path =~ m
|^/vms/.+$|) {
349 push @$testperms, 'VM.Allocate';
350 } elsif ($path =~ m
|^/pool/.+$|) {
351 push @$testperms, 'Pool.Allocate';
354 return $self->check_any($username, $path, $testperms, $noerr);
357 sub exec_api2_perm_check
{
358 my ($self, $check, $username, $param, $noerr) = @_;
360 # syslog("info", "CHECK " . join(', ', @$check));
363 my $test = $check->[$ind++];
364 die "no permission test specified" if !$test;
366 if ($test eq 'and') {
367 while (my $subcheck = $check->[$ind++]) {
368 $self->exec_api2_perm_check($subcheck, $username, $param);
371 } elsif ($test eq 'or') {
372 while (my $subcheck = $check->[$ind++]) {
373 return 1 if $self->exec_api2_perm_check($subcheck, $username, $param, 1);
377 } elsif ($test eq 'perm') {
378 my ($t, $tmplpath, $privs, %options) = @$check;
379 my $any = $options{any
};
380 die "missing parameters" if !($tmplpath && $privs);
381 my $require_param = $options{require_param
};
382 if ($require_param && !defined($param->{$require_param})) {
386 my $path = PVE
::Tools
::template_replace
($tmplpath, $param);
387 $path = PVE
::AccessControl
::normalize_path
($path);
388 return $self->check_full($username, $path, $privs, $any, $noerr);
389 } elsif ($test eq 'userid-group') {
390 my $userid = $param->{userid
};
391 my ($t, $privs, %options) = @$check;
392 return 0 if !$options{groups_param
} && !$self->check_user_exist($userid, $noerr);
393 if (!$self->check_any($username, "/access/groups", $privs, 1)) {
394 my $groups = $self->filter_groups($username, $privs, 1);
395 if ($options{groups_param
}) {
396 my @group_param = PVE
::Tools
::split_list
($param->{groups
});
397 raise_perm_exc
("/access/groups, " . join("|", @$privs)) if !scalar(@group_param);
398 foreach my $pg (@group_param) {
399 raise_perm_exc
("/access/groups/$pg, " . join("|", @$privs))
403 my $allowed_users = $self->group_member_join([keys %$groups]);
404 if (!$allowed_users->{$userid}) {
411 } elsif ($test eq 'userid-param') {
412 my ($userid, undef, $realm) = verify_username
($param->{userid
});
413 return if !$self->check_user_exist($userid, $noerr);
414 my ($t, $subtest) = @$check;
415 die "missing parameters" if !$subtest;
416 if ($subtest eq 'self') {
417 return 1 if $username eq 'userid';
420 } elsif ($subtest eq 'Realm.AllocateUser') {
421 my $path = "/access/realm/$realm";
422 return $self->check($username, $path, ['Realm.AllocateUser'], $noerr);
424 die "unknown userid-param test";
426 } elsif ($test eq 'perm-modify') {
427 my ($t, $tmplpath) = @$check;
428 my $path = PVE
::Tools
::template_replace
($tmplpath, $param);
429 $path = PVE
::AccessControl
::normalize_path
($path);
430 return $self->check_perm_modify($username, $path, $noerr);
432 die "unknown permission test";
436 sub check_api2_permissions
{
437 my ($self, $perm, $username, $param) = @_;
439 return 1 if !$username && $perm->{user
} eq 'world';
441 raise_perm_exc
("user != null") if !$username;
443 return 1 if $username eq 'root@pam';
445 raise_perm_exc
('user != root@pam') if !$perm;
447 return 1 if $perm->{user
} && $perm->{user
} eq 'all';
449 return $self->exec_api2_perm_check($perm->{check
}, $username, $param)
455 # initialize environment - must be called once at program startup
457 my ($class, $type, %params) = @_;
459 $class = ref($class) || $class;
461 die "already initialized" if $pve_env;
463 die "unknown environment type" if !$type || $type !~ m/^(cli|pub|priv|ha)$/;
465 $SIG{CHLD
} = $worker_reaper;
468 # cli ... command started fron command line
469 # pub ... access from public server (apache)
470 # priv ... access from private server (pvedaemon)
471 # ha ... access from HA resource manager agent (rgmanager)
482 foreach my $p (keys %params) {
483 if ($p eq 'atfork') {
484 $self->{$p} = $params{$p};
486 die "unknown option '$p'";
492 my ($sysname, $nodename) = POSIX
::uname
();
494 $nodename =~ s/\..*$//; # strip domain part, if any
496 $self->{nodename
} = $nodename;
504 die "not initialized" if !$pve_env;
510 my ($self, $enable_upload) = @_;
512 if ($self->{request_rec
}) {
514 if ($enable_upload) {
515 $cgi = CGI-
>new($self->{request_rec
});
517 # disable upload using empty upload_hook
518 $cgi = CGI-
>new($self->{request_rec
}, sub {}, undef, 0);
521 my $params = $cgi->Vars();
522 return PVE
::Tools
::decode_utf8_parameters
($params);
523 } elsif ($self->{params
}) {
524 return $self->{params
};
526 die "no parameters registered";
530 sub get_upload_info
{
531 my ($self, $param) = @_;
533 my $cgi = $self->{cgi
};
534 die "CGI not initialized" if !$cgi;
536 my $pd = $cgi->param($param);
537 die "unable to get cgi parameter info\n" if !$pd;
538 my $info = $cgi->uploadInfo($pd);
539 die "unable to get cgi upload info\n" if !$info;
541 my $res = { %$info };
543 my $tmpfilename = $cgi->tmpFileName($pd);
544 die "unable to get cgi upload file name\n" if !$tmpfilename;
545 $res->{tmpfilename
} = $tmpfilename;
547 #my $hndl = $cgi->upload($param);
548 #die "unable to get cgi upload handle\n" if !$hndl;
549 #$res->{handle} = $hndl->handle;
554 # init_request - must be called before each RPC request
556 my ($self, %params) = @_;
558 PVE
::Cluster
::cfs_update
();
560 $self->{result_attributes
} = {};
562 my $userconfig; # we use this for regression tests
563 foreach my $p (keys %params) {
564 if ($p eq 'userconfig') {
565 $userconfig = $params{$p};
566 } elsif ($p eq 'request_rec') {
567 # pass Apache2::RequestRec
568 $self->{request_rec
} = $params{$p};
569 } elsif ($p eq 'params') {
570 $self->{params
} = $params{$p};
572 die "unknown parameter '$p'";
577 $self->{aclcache
} = {};
579 my $ucdata = PVE
::Tools
::file_get_contents
($userconfig);
580 my $cfg = PVE
::AccessControl
::parse_user_config
($userconfig, $ucdata);
581 $self->{user_cfg
} = $cfg;
584 my $ucvers = PVE
::Cluster
::cfs_file_version
('user.cfg');
585 if (!$self->{aclcache
} || !defined($self->{aclversion
}) ||
586 !defined($ucvers) || ($ucvers ne $self->{aclversion
})) {
587 $self->{aclversion
} = $ucvers;
588 my $cfg = PVE
::Cluster
::cfs_read_file
('user.cfg');
589 $self->{user_cfg
} = $cfg;
594 $self->{user_cfg
} = {};
595 die "Unable to load access control list: $err";
600 my ($self, $ip) = @_;
602 $self->{client_ip
} = $ip;
608 return $self->{client_ip
};
611 sub set_result_attrib
{
612 my ($self, $key, $value) = @_;
614 $self->{result_attributes
}->{$key} = $value;
617 sub get_result_attrib
{
618 my ($self, $key) = @_;
620 return $self->{result_attributes
}->{$key};
624 my ($self, $lang) = @_;
626 # fixme: initialize I18N
628 $self->{language
} = $lang;
634 return $self->{language
};
638 my ($self, $user) = @_;
642 $self->{user
} = $user;
648 die "user name not set\n" if !$self->{user
};
650 return $self->{user
};
653 # read/update list of active workers
654 # we move all finished tasks to the archive index,
655 # but keep aktive and most recent task in the active file.
656 # $nocheck ... consider $new_upid still running (avoid that
657 # we try to read the reult to early.
659 my ($new_upid, $nocheck) = @_;
661 my $lkfn = "/var/log/pve/tasks/.active.lock";
667 my $tasklist = PVE
::INotify
::read_file
('active');
671 my $thash = {}; # only list task once
673 my $check_task = sub {
674 my ($task, $running) = @_;
676 if ($running || PVE
::ProcFSTools
::check_process_running
($task->{pid
}, $task->{pstart
})) {
682 delete $task->{pstart
};
685 foreach my $task (@$tasklist) {
686 my $upid = $task->{upid
};
687 next if $thash->{$upid};
688 $thash->{$upid} = $task;
692 if ($new_upid && !(my $task = $thash->{$new_upid})) {
693 $task = PVE
::Tools
::upid_decode
($new_upid);
694 $task->{upid
} = $new_upid;
695 $thash->{$new_upid} = $task;
696 &$check_task($task, $nocheck);
700 @ta = sort { $b->{starttime
} cmp $a->{starttime
} } @ta;
702 my $save = defined($new_upid);
704 foreach my $task (@ta) {
705 next if $task->{endtime
};
706 $task->{endtime
} = time();
707 $task->{status
} = PVE
::Tools
::upid_read_status
($task->{upid
});
713 foreach my $task (@ta) {
714 if (!$task->{saved
}) {
715 $archive .= sprintf("$task->{upid} %08X $task->{status}\n", $task->{endtime
});
724 my $filename = "/var/log/pve/tasks/index";
726 my $fh = IO
::File-
>new($filename, '>>', 0644) ||
727 die "unable to open file '$filename' - $!\n";
728 PVE
::Tools
::safe_print
($filename, $fh, $archive);
731 die "unable to close file '$filename' - $!\n";
736 foreach my $task (@arlist) { # mark as not saved
740 my $maxsize = 50000; # about 1000 entries
741 if ($size > $maxsize) {
742 rename($filename, "$filename.1");
746 # we try to reduce the amount of data
747 # list all running tasks and task and a few others
748 # try to limit to 25 tasks
750 my $max = 25 - scalar(@$tlist);
751 foreach my $task (@ta) {
757 PVE
::INotify
::write_file
('active', $tlist) if $save;
762 my $res = PVE
::Tools
::lock_file
($lkfn, $timeout, $code);
768 my $kill_process_group = sub {
769 my ($pid, $pstart) = @_;
771 # send kill to process group (negative pid)
774 # always send signal to all pgrp members
775 kill(15, $kpid); # send TERM signal
777 # give max 5 seconds to shut down
778 for (my $i = 0; $i < 5; $i++) {
779 return if !PVE
::ProcFSTools
::check_process_running
($pid, $pstart);
788 my ($upid, $killit) = @_;
790 my $task = PVE
::Tools
::upid_decode
($upid);
792 my $running = PVE
::ProcFSTools
::check_process_running
($task->{pid
}, $task->{pstart
});
794 return 0 if !$running;
797 &$kill_process_group($task->{pid
});
804 # start long running workers
805 # STDIN is redirected to /dev/null
806 # STDOUT,STDERR are redirected to the filename returned by upid_decode
807 # NOTE: we simulate running in foreground if ($self->{type} eq 'cli')
809 my ($self, $dtype, $id, $user, $function) = @_;
811 $dtype = 'unknown' if !defined ($dtype);
812 $id = '' if !defined ($id);
814 $user = 'root@pve' if !defined ($user);
816 my $sync = $self->{type
} eq 'cli' ?
1 : 0;
821 local $SIG{TERM
} = 'IGNORE';
823 my $starttime = time ();
825 my @psync = POSIX
::pipe();
826 my @csync = POSIX
::pipe();
828 my $node = $self->{nodename
};
831 die "unable to fork worker - $!" if !defined($cpid);
833 my $workerpuid = $cpid ?
$cpid : $$;
835 my $pstart = PVE
::ProcFSTools
::read_proc_starttime
($workerpuid) ||
836 die "unable to read process start time";
838 my $upid = PVE
::Tools
::upid_encode
({
839 node
=> $node, pid
=> $workerpuid, pstart
=> $pstart,
840 starttime
=> $starttime, type
=> $dtype, id
=> $id, user
=> $user });
844 if (!$cpid) { # child
848 $SIG{INT
} = $SIG{QUIT
} = $SIG{TERM
} = sub { die "received interrupt\n"; };
850 $SIG{CHLD
} = $SIG{PIPE
} = 'DEFAULT';
852 # set sess/process group - we want to be able to kill the
853 # whole process group
856 POSIX
::close ($psync[0]);
857 POSIX
::close ($csync[1]);
859 $outfh = $sync ?
$psync[1] : undef;
862 PVE
::INotify
::inotify_close
();
864 if (my $atfork = $self->{atfork
}) {
868 # same algorythm as used inside SA
870 my $fd = fileno (STDIN
);
874 POSIX
::close(0) if $fd != 0;
876 die "unable to redirect STDIN - $!"
877 if !open(STDIN
, "</dev/null");
879 $outfh = PVE
::Tools
::upid_open
($upid);
884 $fd = fileno(STDOUT
);
886 POSIX
::close (1) if $fd != 1;
888 die "unable to redirect STDOUT - $!"
889 if !open(STDOUT
, ">&", $outfh);
891 STDOUT-
>autoflush (1);
893 # redirect STDERR to STDOUT
894 $fd = fileno (STDERR
);
896 POSIX
::close(2) if $fd != 2;
898 die "unable to redirect STDERR - $!"
899 if !open(STDERR
, ">&1");
901 STDERR-
>autoflush(1);
904 my $msg = "ERROR: $err";
905 POSIX
::write($psync[1], $msg, length ($msg));
906 POSIX
::close($psync[1]);
911 # sync with parent (signal that we are ready)
915 POSIX
::write($psync[1], $upid, length ($upid));
916 POSIX
::close($psync[1]);
920 # sync with parent (wait until parent is ready)
921 POSIX
::read($csync[0], $readbuf, 4096);
922 die "parent setup error\n" if $readbuf ne 'OK';
924 if ($self->{type
} eq 'ha') {
925 print "task started by HA resource agent\n";
927 eval { &$function($upid); };
933 print STDERR
"TASK ERROR: $err\n";
936 print STDERR
"TASK OK\n";
944 POSIX
::close ($psync[1]);
945 POSIX
::close ($csync[0]);
948 # sync with child (wait until child starts)
949 POSIX
::read($psync[0], $readbuf, 4096);
952 POSIX
::close($psync[0]);
953 &$register_worker($cpid, $user, $upid);
959 die "got no worker upid - start worker failed\n" if !$readbuf;
961 if ($readbuf =~ m/^ERROR:\s*(.+)$/m) {
962 die "starting worker failed: $1\n";
965 if ($readbuf ne $upid) {
966 die "got strange worker upid ('$readbuf' != '$upid') - start worker failed\n";
970 $outfh = PVE
::Tools
::upid_open
($upid);
977 POSIX
::write($csync[1], $msg, length ($msg));
978 POSIX
::close($csync[1]);
981 POSIX
::close($csync[1]);
982 kill(-9, $cpid); # make sure it gets killed
986 PVE
::Cluster
::log_msg
('info', $user, "starting task $upid");
988 my $tlist = active_workers
($upid, $sync);
989 PVE
::Cluster
::broadcast_tasklist
($tlist);
998 local $SIG{INT
} = local $SIG{QUIT
} = local $SIG{TERM
} = sub {
999 # always send signal to all pgrp members
1001 if ($int_count < 3) {
1002 kill(15, $kpid); # send TERM signal
1004 kill(9, $kpid); # send KILL signal
1008 local $SIG{PIPE
} = sub { die "broken pipe\n"; };
1010 my $select = new IO
::Select
;
1011 my $fh = IO
::Handle-
>new_from_fd($psync[0], 'r');
1014 while ($select->count) {
1015 my @handles = $select->can_read(1);
1016 if (scalar(@handles)) {
1017 my $count = sysread ($handles[0], $readbuf, 4096);
1018 if (!defined ($count)) {
1020 die "sync pipe read error: $err\n";
1022 last if $count == 0; # eof
1024 $outbuf .= $readbuf;
1025 while ($outbuf =~ s/^(([^\010\r\n]*)(\r|\n|(\010)+|\r\n))//s) {
1028 if ($data =~ m/^TASK OK$/) {
1030 } elsif ($data =~ m/^TASK ERROR: (.+)$/) {
1031 print STDERR
"$1\n";
1041 # some commands daemonize without closing stdout
1042 last if !PVE
::ProcFSTools
::check_process_running
($cpid);
1048 POSIX
::close($psync[0]);
1050 if ($outbuf) { # just to be sure
1053 print $outfh $outbuf;
1059 print STDERR
"$err\n";
1061 print $outfh "TASK ERROR: $err\n";
1065 &$kill_process_group($cpid, $pstart); # make sure it gets killed
1071 &$log_task_result($upid, $user, $res);
1074 return wantarray ?
($upid, $res) : $upid;