]> git.proxmox.com Git - pve-access-control.git/blobdiff - PVE/RPCEnvironment.pm
new plugin architecture for Auth modules
[pve-access-control.git] / PVE / RPCEnvironment.pm
index 8cafdd182978c706b878869e724d2bc69052cbc2..7532e9eca0245dd76f11d75dcd3c9c85081c840f 100644 (file)
@@ -14,6 +14,7 @@ use PVE::INotify;
 use PVE::Cluster;
 use PVE::ProcFSTools;
 use PVE::AccessControl;
+use Cwd 'abs_path';
 use CGI;
 
 # we use this singleton class to pass RPC related environment values
@@ -282,13 +283,14 @@ sub check_vm_perm {
     return $self->check_full($user, "/vms/$vmid", $privs, $any, $noerr);
 };
 
-sub check_volume_access = sub {
+sub check_volume_access {
     my ($self, $user, $storecfg, $vmid, $volid) = @_;
 
     # test if we have read access to volid
 
     my $path;
-    if (my ($sid, $volname) = PVE::Storage::parse_volume_id($volid, 1)) {
+    my ($sid, $volname) = PVE::Storage::parse_volume_id($volid, 1);
+    if ($sid) {
        my ($ownervm, $vtype);
        ($path, $ownervm, $vtype) = PVE::Storage::path($storecfg, $volid);
        if ($vtype eq 'iso' || $vtype eq 'vztmpl') {
@@ -421,12 +423,12 @@ sub exec_api2_perm_check {
        }
        return 1;
     } elsif ($test eq 'userid-param') {
-       my ($userid, undef, $realm) = verify_username($param->{userid});
-       return if !$self->check_user_exist($userid, $noerr);
+       my ($userid, undef, $realm) = PVE::AccessControl::verify_username($param->{userid});
        my ($t, $subtest) = @$check;
        die "missing parameters" if !$subtest;
        if ($subtest eq 'self') {
-           return 1 if $username eq 'userid';
+           return 0 if !$self->check_user_exist($userid, $noerr);
+           return 1 if $username eq $userid;
            return 0 if $noerr;
            raise_perm_exc();
        } elsif ($subtest eq 'Realm.AllocateUser') {
@@ -818,14 +820,14 @@ sub check_worker {
 # STDOUT,STDERR are redirected to the filename returned by upid_decode
 # NOTE: we simulate running in foreground if ($self->{type} eq 'cli')
 sub fork_worker {
-    my ($self, $dtype, $id, $user, $function) = @_;
+    my ($self, $dtype, $id, $user, $function, $background) = @_;
 
     $dtype = 'unknown' if !defined ($dtype);
     $id = '' if !defined ($id);
 
     $user = 'root@pve' if !defined ($user);
 
-    my $sync = $self->{type} eq 'cli' ? 1 : 0;
+    my $sync = ($self->{type} eq 'cli' && !$background) ? 1 : 0;
 
     local $SIG{INT} = 
        local $SIG{QUIT} =