From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id C345C99E93 for ; Thu, 4 May 2023 10:25:14 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id ABCF61B495 for ; Thu, 4 May 2023 10:24:44 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Thu, 4 May 2023 10:24:44 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id C6BD947285 for ; Thu, 4 May 2023 10:24:43 +0200 (CEST) Date: Thu, 04 May 2023 10:24:38 +0200 From: Fabian =?iso-8859-1?q?Gr=FCnbichler?= To: Proxmox VE development discussion References: <20230425102136.85334-1-m.frank@proxmox.com> <20230425102136.85334-3-m.frank@proxmox.com> In-Reply-To: <20230425102136.85334-3-m.frank@proxmox.com> MIME-Version: 1.0 User-Agent: astroid/0.16.0 (https://github.com/astroidmail/astroid) Message-Id: <1683187127.i3oot16wx3.astroid@yuna.none> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-SPAM-LEVEL: Spam detection results: 0 AWL 0.075 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record T_SCC_BODY_TEXT_LINE -0.01 - Subject: Re: [pve-devel] [PATCH access-control v4 2/6] added acls for Shared Files Directories X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 May 2023 08:25:14 -0000 On April 25, 2023 12:21 pm, Markus Frank wrote: > Signed-off-by: Markus Frank > --- > src/PVE/API2/Directory.pm | 68 +++++++++++++++++++++++++++++++++++++++ this parts seems to be included by accident? ;) > src/PVE/AccessControl.pm | 16 +++++++++ > src/PVE/RPCEnvironment.pm | 12 ++++++- > 3 files changed, 95 insertions(+), 1 deletion(-) > create mode 100644 src/PVE/API2/Directory.pm >=20 > diff --git a/src/PVE/API2/Directory.pm b/src/PVE/API2/Directory.pm > new file mode 100644 > index 0000000..b44ba9d > --- /dev/null > +++ b/src/PVE/API2/Directory.pm > @@ -0,0 +1,68 @@ > +package PVE::API2::Directory; > + > +use strict; > +use warnings; > + > +use PVE::Exception qw(raise raise_perm_exc raise_param_exc); > +use PVE::Cluster qw (cfs_read_file cfs_write_file); > +use PVE::Tools qw(split_list extract_param); > +use PVE::JSONSchema qw(get_standard_option register_standard_option); > +use PVE::SafeSyslog; > + > +use PVE::AccessControl; > +use PVE::Auth::Plugin; > +use PVE::TokenConfig; > + > +use PVE::RESTHandler; > +use PVE::DirConfig; > + > +use base qw(PVE::RESTHandler); > + > +__PACKAGE__->register_method ({ > + name =3D> 'index', > + path =3D> '', > + method =3D> 'GET', > + description =3D> "simple return value of parameter 'text'", > + parameters =3D> { > + additionalProperties =3D> 0, > + properties =3D> { > + node =3D> { > + type =3D> 'string', > + } > + }, > + }, > + returns =3D> { > + type =3D> 'string', > + }, > + code =3D> sub { > + my ($param) =3D @_; > + return $param->{node}; > + } > +}); > + > + > +__PACKAGE__->register_method ({ > + name =3D> 'add_dir', > + path =3D> 'add', > + method =3D> 'POST', > + description =3D> "simple return value of parameter 'text'", > + parameters =3D> { > + additionalProperties =3D> 0, > + properties =3D> { > + directory =3D> { > + type =3D> 'string', > + }, > + node =3D> { > + type =3D> 'string', > + } > + }, > + }, > + returns =3D> { > + type =3D> 'string', > + }, > + code =3D> sub { > + my ($param) =3D @_; > + > + return $param->{node}; > + } > +}); > diff --git a/src/PVE/AccessControl.pm b/src/PVE/AccessControl.pm > index 5690a1f..6530753 100644 > --- a/src/PVE/AccessControl.pm > +++ b/src/PVE/AccessControl.pm > @@ -1133,6 +1133,18 @@ my $privgroups =3D { > 'Pool.Audit', > ], > }, > + Map =3D> { > + root =3D> [], > + admin =3D> [ > + 'Map.Modify', > + ], > + user =3D> [ > + 'Map.Use', > + ], > + audit =3D> [ > + 'Map.Audit', > + ], > + }, the priv names need coordination with Dominik, we definitely don't want two sets! > }; > =20 > my $valid_privs =3D {}; > @@ -1166,6 +1178,8 @@ sub create_roles { > } > =20 > $special_roles->{"PVETemplateUser"} =3D { 'VM.Clone' =3D> 1, 'VM.Aud= it' =3D> 1 }; > + > + delete($special_roles->{"PVEAdmin"}->{'Map.Modify'}); this is something were Dominik had some ideas as well IIRC ;) > }; > =20 > create_roles(); > @@ -1262,6 +1276,8 @@ sub check_path { > |/storage/[[:alnum:]\.\-\_]+ > |/vms > |/vms/[1-9][0-9]{2,} > + |/map/dirs > + |/map/dirs/[[:alnum:]\.\-\_]+ > )$!xs; > } > =20 > diff --git a/src/PVE/RPCEnvironment.pm b/src/PVE/RPCEnvironment.pm > index 8586938..42ff287 100644 > --- a/src/PVE/RPCEnvironment.pm > +++ b/src/PVE/RPCEnvironment.pm > @@ -187,10 +187,11 @@ sub compute_api_permission { > nodes =3D> qr/Sys\.|Permissions\.Modify/, > sdn =3D> qr/SDN\.|Permissions\.Modify/, > dc =3D> qr/Sys\.Audit|SDN\./, > + map =3D> qr/Map\.Modify/ why Modify? I think Map. and Permissions.Modify would make more sense? > }; > map { $res->{$_} =3D {} } keys %$priv_re_map; > =20 > - my $required_paths =3D ['/', '/nodes', '/access/groups', '/vms', '/s= torage', '/sdn']; > + my $required_paths =3D ['/', '/nodes', '/access/groups', '/vms', '/s= torage', '/sdn', '/map']; > my $defined_paths =3D []; > PVE::AccessControl::iterate_acl_tree("/", $usercfg->{acl_root}, sub = { > my ($path, $node) =3D @_; > @@ -245,6 +246,7 @@ sub get_effective_permissions { > '/sdn' =3D> 1, > '/storage' =3D> 1, > '/vms' =3D> 1, > + '/map' =3D> 1, > }; > =20 > my $cfg =3D $self->{user_cfg}; > @@ -361,6 +363,14 @@ sub check_vm_perm { > return $self->check_full($user, "/vms/$vmid", $privs, $any, $noerr); > }; > =20 > +sub check_dir_perm { > + my ($self, $user, $dirid, $privs, $any, $noerr) =3D @_; > + > + my $cfg =3D $self->{user_cfg}; > + > + return $self->check_full($user, "/map/dirs/$dirid", $privs, $any, $n= oerr); > +}; I don't think this helper brings anything to the table? check_vm_perm is special in that it handles pools, and we want that in a single place, but this is just hardcoding the ACL prefix? > + > sub is_group_member { > my ($self, $group, $user) =3D @_; > =20 > --=20 > 2.30.2 >=20 >=20 >=20 > _______________________________________________ > pve-devel mailing list > pve-devel@lists.proxmox.com > https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel >=20 >=20 >=20