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 CBE508A836 for ; Wed, 27 Jul 2022 11:07:53 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id C38B63613 for ; Wed, 27 Jul 2022 11:07:23 +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 ; Wed, 27 Jul 2022 11:07:22 +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 92C3242C82 for ; Wed, 27 Jul 2022 11:07:22 +0200 (CEST) Date: Wed, 27 Jul 2022 11:07:15 +0200 From: Fabian =?iso-8859-1?q?Gr=FCnbichler?= To: Oguz Bektas , pve-devel@lists.proxmox.com References: <20220602072450.55209-1-o.bektas@proxmox.com> <20220602072450.55209-9-o.bektas@proxmox.com> In-Reply-To: <<20220602072450.55209-9-o.bektas@proxmox.com> MIME-Version: 1.0 User-Agent: astroid/0.15.0 (https://github.com/astroidmail/astroid) Message-Id: <1658910664.89576tpomn.astroid@nora.none> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-SPAM-LEVEL: Spam detection results: 0 AWL 0.163 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% 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 Subject: Re: [pve-devel] [PATCH v4 qemu-server 08/18] api: allow superusers to use 'skiplock' option 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: Wed, 27 Jul 2022 09:07:53 -0000 On June 2, 2022 9:24 am, Oguz Bektas wrote: > also mark the intentionally root-only migration related options > in param descriptions and leave a reminder comment. how are these changes related? please split them up into two patches (or=20 merge the comment part into the other path that adds similar comments) >=20 > Suggested-by: Fabian Gr=C3=BCnbichler > Signed-off-by: Oguz Bektas > --- > PVE/API2/Qemu.pm | 71 ++++++++++++++++++++++++++++++++---------------- > 1 file changed, 48 insertions(+), 23 deletions(-) >=20 > diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm > index 2e75ab6..198e736 100644 > --- a/PVE/API2/Qemu.pm > +++ b/PVE/API2/Qemu.pm > @@ -1337,8 +1337,8 @@ my $update_vm_api =3D sub { > my $is_superuser =3D $rpcenv->check($authuser, "/vms/$vmid", ['Super= User'], 1); > =20 > my $skiplock =3D extract_param($param, 'skiplock'); > - raise_param_exc({ skiplock =3D> "Only root may use this option." }) > - if $skiplock && $authuser ne 'root@pam'; > + raise_param_exc({ skiplock =3D> "Only superusers may use this option= ." }) > + if $skiplock && !$is_superuser; > =20 > my $delete_str =3D extract_param($param, 'delete'); > =20 > @@ -1864,9 +1864,11 @@ __PACKAGE__->register_method({ > my $authuser =3D $rpcenv->get_user(); > my $vmid =3D $param->{vmid}; > =20 > + my $is_superuser =3D $rpcenv->check($authuser, "/vms/$vmid", ['SuperUse= r'], 1); > + > my $skiplock =3D $param->{skiplock}; > - raise_param_exc({ skiplock =3D> "Only root may use this option." }) > - if $skiplock && $authuser ne 'root@pam'; > + raise_param_exc({ skiplock =3D> "Only superusers may use this option." = }) > + if $skiplock && !$is_superuser; > =20 > my $early_checks =3D sub { > # test if VM exists > @@ -2474,25 +2476,27 @@ __PACKAGE__->register_method({ > migration_type =3D> { > type =3D> 'string', > enum =3D> ['secure', 'insecure'], > - description =3D> "Migration traffic is encrypted using an SSH " . > + description =3D> "Migration-internal parameter. Migration traffic is e= ncrypted using an SSH " . > "tunnel by default. On secure, completely private networks " . > "this can be disabled to increase performance.", > optional =3D> 1, > }, > migration_network =3D> { > type =3D> 'string', format =3D> 'CIDR', > - description =3D> "CIDR of the (sub) network that is used for migration= .", > + description =3D> "Migration-internal parameter. CIDR of the (sub)netwo= rk " . > + "that is used for migration.", > optional =3D> 1, > }, > machine =3D> get_standard_option('pve-qemu-machine'), > 'force-cpu' =3D> { > - description =3D> "Override QEMU's -cpu argument with the given string.= ", > + description =3D> "Migration-internal parameter. Override QEMU's" . > + "-cpu argument with the given string.", > type =3D> 'string', > optional =3D> 1, > }, > targetstorage =3D> get_standard_option('pve-targetstorage'), > timeout =3D> { > - description =3D> "Wait maximal timeout seconds.", > + description =3D> "Migration-internal parameter. Wait maximal timeout s= econds.", > type =3D> 'integer', > minimum =3D> 0, > default =3D> 'max(30, vm memory in GiB)', > @@ -2514,6 +2518,14 @@ __PACKAGE__->register_method({ > my $timeout =3D extract_param($param, 'timeout'); > my $machine =3D extract_param($param, 'machine'); > =20 > + my $is_superuser =3D $rpcenv->check($authuser, "/vms/$vmid", ['SuperUse= r'], 1); > + > + my $skiplock =3D extract_param($param, 'skiplock'); > + raise_param_exc({ skiplock =3D> "Only superusers may use this option." = }) > + if $skiplock && !$is_superuser; > + > + # since they are only used for migration-internal flows, > + # these parameters are still intentionally limited to root@pam > my $get_root_param =3D sub { > my $value =3D extract_param($param, $_[0]); > raise_param_exc({ "$_[0]" =3D> "Only root may use this option." }) > @@ -2522,7 +2534,6 @@ __PACKAGE__->register_method({ > }; > =20 > my $stateuri =3D $get_root_param->('stateuri'); > - my $skiplock =3D $get_root_param->('skiplock'); > my $migratedfrom =3D $get_root_param->('migratedfrom'); > my $migration_type =3D $get_root_param->('migration_type'); > my $migration_network =3D $get_root_param->('migration_network'); > @@ -2662,9 +2673,11 @@ __PACKAGE__->register_method({ > my $node =3D extract_param($param, 'node'); > my $vmid =3D extract_param($param, 'vmid'); > =20 > + my $is_superuser =3D $rpcenv->check($authuser, "/vms/$vmid", ['SuperUse= r'], 1); > + > my $skiplock =3D extract_param($param, 'skiplock'); > - raise_param_exc({ skiplock =3D> "Only root may use this option." }) > - if $skiplock && $authuser ne 'root@pam'; > + raise_param_exc({ skiplock =3D> "Only superusers may use this option." = }) > + if $skiplock && !$is_superuser; > =20 > my $keepActive =3D extract_param($param, 'keepActive'); > raise_param_exc({ keepActive =3D> "Only root may use this option." }) > @@ -2739,9 +2752,11 @@ __PACKAGE__->register_method({ > =20 > my $vmid =3D extract_param($param, 'vmid'); > =20 > + my $is_superuser =3D $rpcenv->check($authuser, "/vms/$vmid", ['SuperUse= r'], 1); > + > my $skiplock =3D extract_param($param, 'skiplock'); > - raise_param_exc({ skiplock =3D> "Only root may use this option." }) > - if $skiplock && $authuser ne 'root@pam'; > + raise_param_exc({ skiplock =3D> "Only superusers may use this option." = }) > + if $skiplock && !$is_superuser; > =20 > die "VM $vmid not running\n" if !PVE::QemuServer::check_running($vmid); > =20 > @@ -2806,9 +2821,11 @@ __PACKAGE__->register_method({ > my $node =3D extract_param($param, 'node'); > my $vmid =3D extract_param($param, 'vmid'); > =20 > + my $is_superuser =3D $rpcenv->check($authuser, "/vms/$vmid", ['SuperUse= r'], 1); > + > my $skiplock =3D extract_param($param, 'skiplock'); > - raise_param_exc({ skiplock =3D> "Only root may use this option." }) > - if $skiplock && $authuser ne 'root@pam'; > + raise_param_exc({ skiplock =3D> "Only superusers may use this option." = }) > + if $skiplock && !$is_superuser; > =20 > my $keepActive =3D extract_param($param, 'keepActive'); > raise_param_exc({ keepActive =3D> "Only root may use this option." }) > @@ -2965,9 +2982,11 @@ __PACKAGE__->register_method({ > =20 > my $statestorage =3D extract_param($param, 'statestorage'); > =20 > + my $is_superuser =3D $rpcenv->check($authuser, "/vms/$vmid", ['SuperUse= r'], 1); > + > my $skiplock =3D extract_param($param, 'skiplock'); > - raise_param_exc({ skiplock =3D> "Only root may use this option." }) > - if $skiplock && $authuser ne 'root@pam'; > + raise_param_exc({ skiplock =3D> "Only superusers may use this option." = }) > + if $skiplock && !$is_superuser; > =20 > die "VM $vmid not running\n" if !PVE::QemuServer::check_running($vmid); > =20 > @@ -3037,9 +3056,11 @@ __PACKAGE__->register_method({ > =20 > my $vmid =3D extract_param($param, 'vmid'); > =20 > + my $is_superuser =3D $rpcenv->check($authuser, "/vms/$vmid", ['SuperUse= r'], 1); > + > my $skiplock =3D extract_param($param, 'skiplock'); > - raise_param_exc({ skiplock =3D> "Only root may use this option." }) > - if $skiplock && $authuser ne 'root@pam'; > + raise_param_exc({ skiplock =3D> "Only superusers may use this option." = }) > + if $skiplock && !$is_superuser; > =20 > my $nocheck =3D extract_param($param, 'nocheck'); > raise_param_exc({ nocheck =3D> "Only root may use this option." }) > @@ -3109,9 +3130,11 @@ __PACKAGE__->register_method({ > =20 > my $vmid =3D extract_param($param, 'vmid'); > =20 > + my $is_superuser =3D $rpcenv->check($authuser, "/vms/$vmid", ['SuperUse= r'], 1); > + > my $skiplock =3D extract_param($param, 'skiplock'); > - raise_param_exc({ skiplock =3D> "Only root may use this option." }) > - if $skiplock && $authuser ne 'root@pam'; > + raise_param_exc({ skiplock =3D> "Only superusers may use this option." = }) > + if $skiplock && !$is_superuser; > =20 > PVE::QemuServer::vm_sendkey($vmid, $skiplock, $param->{key}); > =20 > @@ -4372,9 +4395,11 @@ __PACKAGE__->register_method({ > =20 > my $sizestr =3D extract_param($param, 'size'); > =20 > + my $is_superuser =3D $rpcenv->check($authuser, "/vms/$vmid", ['SuperUse= r'], 1); > + > my $skiplock =3D extract_param($param, 'skiplock'); > - raise_param_exc({ skiplock =3D> "Only root may use this option."= }) > - if $skiplock && $authuser ne 'root@pam'; > + raise_param_exc({ skiplock =3D> "Only superusers may use this op= tion." }) > + if $skiplock && !$is_superuser; > =20 > my $storecfg =3D PVE::Storage::config(); > =20 > --=20 > 2.30.2 >=20 >=20