]> git.proxmox.com Git - pve-access-control.git/blobdiff - PVE/RPCEnvironment.pm
drop libdigest-hmac-perl dependency
[pve-access-control.git] / PVE / RPCEnvironment.pm
index 765008eee5c63a5ee0b3ae591c25da372f770153..3ec2c912d220498ca50303e23db5a25e0b67b0c1 100644 (file)
@@ -14,7 +14,6 @@ use PVE::INotify;
 use PVE::Cluster;
 use PVE::ProcFSTools;
 use PVE::AccessControl;
-use Cwd 'abs_path';
 
 # we use this singleton class to pass RPC related environment values
 
@@ -29,6 +28,7 @@ my $pve_env;
 # that (also see perlipc)
 
 my $WORKER_PIDS;
+my $WORKER_FLAG = 0;
 
 my $log_task_result = sub {
     my ($upid, $user, $status) = @_;
@@ -287,11 +287,9 @@ sub check_volume_access {
 
     # test if we have read access to volid
 
-    my $path;
     my ($sid, $volname) = PVE::Storage::parse_volume_id($volid, 1);
     if ($sid) {
-       my ($ownervm, $vtype);
-       ($path, $ownervm, $vtype) = PVE::Storage::path($storecfg, $volid);
+       my ($vtype, undef, $ownervm) = PVE::Storage::parse_volname($storecfg, $volid);
        if ($vtype eq 'iso' || $vtype eq 'vztmpl') {
            # we simply allow access 
        } elsif (defined($ownervm) && defined($vmid) && ($ownervm == $vmid)) {
@@ -306,13 +304,9 @@ sub check_volume_access {
     } else {
        die "Only root can pass arbitrary filesystem paths."
            if $user ne 'root@pam';
-
-       $path = abs_path($volid);
-       if ($path =~ m|^(/.+)$|) {
-           $path = $1; # untaint any path
-       }
     }
-    return $path;
+
+    return undef;
 }
 
 sub is_group_member {
@@ -621,6 +615,10 @@ sub get_user {
     return $self->{user};
 }
 
+sub is_worker {
+    return $WORKER_FLAG;
+}
+
 # read/update list of active workers 
 # we move all finished tasks to the archive index,
 # but keep aktive and most recent task in the active file.
@@ -683,7 +681,7 @@ sub active_workers  {
        my @arlist = ();
        foreach my $task (@ta) {
            if (!$task->{saved}) {
-               $archive .= sprintf("$task->{upid} %08X $task->{status}\n", $task->{endtime});
+               $archive .= sprintf("%s %08X %s\n", $task->{upid}, $task->{endtime}, $task->{status});
                $save = 1;
                push @arlist, $task;
                $task->{saved} = 1;
@@ -815,6 +813,7 @@ sub fork_worker {
     if (!$cpid) { # child
 
        $0 = "task $upid";
+       $WORKER_FLAG = 1;
 
        $SIG{INT} = $SIG{QUIT} = $SIG{TERM} = sub { die "received interrupt\n"; };