X-Git-Url: https://git.proxmox.com/?p=pve-access-control.git;a=blobdiff_plain;f=PVE%2FRPCEnvironment.pm;h=52c5f64ce0cf577b1785ba390afef9a97a179e43;hp=eb7b3c7645da60ca19106f5ec0281b9da2b13224;hb=3e5bfdf60f255a432956ba0f77d6f840708d9619;hpb=e5ae548727ea87783f1f6bfaac9181133981d2e9 diff --git a/PVE/RPCEnvironment.pm b/PVE/RPCEnvironment.pm index eb7b3c7..52c5f64 100644 --- a/PVE/RPCEnvironment.pm +++ b/PVE/RPCEnvironment.pm @@ -14,8 +14,6 @@ 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 @@ -288,11 +286,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)) { @@ -307,13 +303,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 { @@ -528,51 +520,6 @@ sub get { return $pve_env; } -sub parse_params { - my ($self, $enable_upload) = @_; - - if ($self->{request_rec}) { - my $cgi; - if ($enable_upload) { - $cgi = CGI->new($self->{request_rec}); - } else { - # disable upload using empty upload_hook - $cgi = CGI->new($self->{request_rec}, sub {}, undef, 0); - } - $self->{cgi} = $cgi; - my $params = $cgi->Vars(); - return PVE::Tools::decode_utf8_parameters($params); - } elsif ($self->{params}) { - return $self->{params}; - } else { - die "no parameters registered"; - } -} - -sub get_upload_info { - my ($self, $param) = @_; - - my $cgi = $self->{cgi}; - die "CGI not initialized" if !$cgi; - - my $pd = $cgi->param($param); - die "unable to get cgi parameter info\n" if !$pd; - my $info = $cgi->uploadInfo($pd); - die "unable to get cgi upload info\n" if !$info; - - my $res = { %$info }; - - my $tmpfilename = $cgi->tmpFileName($pd); - die "unable to get cgi upload file name\n" if !$tmpfilename; - $res->{tmpfilename} = $tmpfilename; - - #my $hndl = $cgi->upload($param); - #die "unable to get cgi upload handle\n" if !$hndl; - #$res->{handle} = $hndl->handle; - - return $res; -} - # init_request - must be called before each RPC request sub init_request { my ($self, %params) = @_; @@ -585,11 +532,6 @@ sub init_request { foreach my $p (keys %params) { if ($p eq 'userconfig') { $userconfig = $params{$p}; - } elsif ($p eq 'request_rec') { - # pass Apache2::RequestRec - $self->{request_rec} = $params{$p}; - } elsif ($p eq 'params') { - $self->{params} = $params{$p}; } else { die "unknown parameter '$p'"; }