public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH container] api: config: permission checks: fix check for 'nesting' feature
@ 2025-02-07 16:38 Fiona Ebner
  2025-02-10 15:57 ` [pve-devel] applied: " Thomas Lamprecht
  0 siblings, 1 reply; 2+ messages in thread
From: Fiona Ebner @ 2025-02-07 16:38 UTC (permalink / raw)
  To: pve-devel

As reported in the community forum [0], remote migration for a container
with 'features: nesting=0' would fail with a confusing error message

> changing feature flags (except nesting) is only allowed for root@pam

This is because of a faulty check during container creation that would
only detect 'nesting=1', but not 'nesting=0'. Fix it by properly
checking if only the 'nesting' property is affected via an 'exists'
check for the hash key.

The check for deleting the feature is also broken, so fix it too.

The check for modifying the feature already works correctly.

[0]: https://forum.proxmox.com/threads/161432/

Fixes: 88ef170 ("allow nesting to be changed for VM.Allocate on unprivileged containers")
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
 src/PVE/LXC.pm | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/PVE/LXC.pm b/src/PVE/LXC.pm
index 4d20645..64f8564 100644
--- a/src/PVE/LXC.pm
+++ b/src/PVE/LXC.pm
@@ -1474,7 +1474,7 @@ sub check_ct_modify_config_perm {
 		    }
 		} else {
 		    # new container or no features defined
-		    if (scalar(keys %$features) == 1 && $features->{nesting}) {
+		    if (scalar(keys %$features) == 1 && exists($features->{nesting})) {
 			$nesting_changed = 1;
 		    } elsif (scalar(keys %$features) > 0) {
 			$other_changed = 1;
@@ -1482,7 +1482,7 @@ sub check_ct_modify_config_perm {
 		}
 	    } else {
 		my $features = PVE::LXC::Config->parse_features($oldconf->{$opt});
-		if (scalar(keys %$features) == 1 && $features->{nesting}) {
+		if (scalar(keys %$features) == 1 && exists($features->{nesting})) {
 		    $nesting_changed = 1;
 		} elsif (scalar(keys %$features) > 0) {
 		    $other_changed = 1;
-- 
2.39.5



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-02-10 15:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-02-07 16:38 [pve-devel] [PATCH container] api: config: permission checks: fix check for 'nesting' feature Fiona Ebner
2025-02-10 15:57 ` [pve-devel] applied: " Thomas Lamprecht

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal