From: Stefan Hanreich <s.hanreich@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: Re: [PATCH pve-access-control v5 5/7] fix #7520: sdn: add VNet ACL migration
Date: Wed, 15 Jul 2026 16:59:53 +0200 [thread overview]
Message-ID: <029ecefd-ae81-49ac-89c4-783dae029941@proxmox.com> (raw)
In-Reply-To: <20260707120404.73072-6-d.riley@proxmox.com>
comments inline
On 7/7/26 2:05 PM, David Riley wrote:
> Add routine to enable the relocation of ACL entries when their
> corresponding SDN resources are moved. This prevents stale entries
> when VNets are moved between zones.
>
> This is a preparatory change that does not have an immediate effect on
> its own, but lays the foundation for safely relocating ACL nodes and
> rejecting conflicting destination paths.
>
> Link: https://bugzilla.proxmox.com/show_bug.cgi?id=7520
> Signed-off-by: David Riley <d.riley@proxmox.com>
> ---
> src/PVE/AccessControl.pm | 84 ++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 84 insertions(+)
>
> diff --git a/src/PVE/AccessControl.pm b/src/PVE/AccessControl.pm
> index 1047226..4faeb8f 100644
> --- a/src/PVE/AccessControl.pm
> +++ b/src/PVE/AccessControl.pm
> @@ -2045,6 +2045,90 @@ sub remove_sdn_resource_access {
> lock_user_config($delete_resource_fn, "SDN ACL cleanup failed");
> }
>
> +sub migrate_sdn_resource_access {
> + my ($migrations) = @_;
> + # [ { src_path => 'zones/<zoney>/<vnet>', dest_path => 'zones/<zonex>/<vnet>' } ]
this claims the value is a string
> +
> + return if !$migrations;
> +
> + my $migrate_fn = sub {
> + my $usercfg = cfs_read_file("user.cfg");
> + my $modified = 0;
> +
> + my @prepared_moves = ();
> + for my $migration (@$migrations) {
> +
> + my $invalid_key = 0;
> +
> + for my $key (qw(src_path dest_path)) {
> + if (!defined($migration->{$key})) {
> + warn "Invalid '$key': must be an array reference.\n";
but this says it must be an array reference? also, if I misunderstand
and this should indeed be an array reference then we should explicitly
check for that?
> + $invalid_key = 1;
> + last;
> + }
> + }
> +
> + next if $invalid_key;
> +
> + my $src_path = "sdn/$migration->{src_path}";
> + my $dest_path = "sdn/$migration->{dest_path}";
> +
> + my ($src_parent, $src_last_key, $acl_node) =
> + find_acl_tree_node_parent($usercfg->{acl_root}, $src_path);
> +
> + if (defined($src_parent) && defined($src_last_key) && defined($acl_node)) {
> + # probe dest for conflicts
> + my (undef, undef, $existing_dest_node) =
> + find_acl_tree_node_parent($usercfg->{acl_root}, $dest_path);
> +
> + if (acl_tree_has_permissions($existing_dest_node)) {
> + my $conflict_path = "/$dest_path";
> + my $source_path = "/$src_path";
> + die
> + "Destination '$conflict_path' already has permissions configured (Source:"
> + . " '$source_path'). Please remove the target ACLs manually before"
> + . " retrying.\n";
> + }
> +
> + # stage move
> + push(
> + @prepared_moves,
> + {
> + src_parent => $src_parent,
> + src_last_key => $src_last_key,
> + dest_path => $dest_path,
> + node => $acl_node,
> + },
> + );
> + }
> + }
> +
> + for my $move (@prepared_moves) {
> + delete $move->{src_parent}->{children}->{ $move->{src_last_key} };
> +
> + my $current = $usercfg->{acl_root};
> + my @dest_segments = split('/', $move->{dest_path});
> + my $dest_last_key = pop @dest_segments;
> +
> + for my $segment (@dest_segments) {
> + $current->{children}->{$segment} = {}
> + if !defined($current->{children}->{$segment});
> +
> + $current = $current->{children}->{$segment};
> + }
> + $current->{children}->{$dest_last_key} = $move->{node};
> +
> + $modified = 1;
nit: wouldn't an early return if prepared moves is empty save us from
tracking this here?
> + }
> +
> + if ($modified) {
> + cfs_write_file("user.cfg", $usercfg);
> + }
> + };
> +
> + lock_user_config($migrate_fn, "ACL migration failed");
> +}
> +
> my $USER_CONTROLLED_TFA_TYPES = {
> u2f => 1,
> oath => 1,
next prev parent reply other threads:[~2026-07-15 15:00 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-07 12:03 [PATCH access-control/network v5 0/7] fix #7520: sdn: prune orphaned ACLs and handle VNet migrations David Riley
2026-07-07 12:03 ` [PATCH pve-access-control v5 1/7] permission: add acl tree node parent lookup without node creation David Riley
2026-07-15 14:59 ` Stefan Hanreich
2026-07-07 12:03 ` [PATCH pve-access-control v5 2/7] fix #7520: sdn: add pruning SDN resources ACLs David Riley
2026-07-07 12:04 ` [PATCH pve-access-control v5 3/7] test: add sdn acl pruning tests David Riley
2026-07-07 12:04 ` [PATCH pve-access-control v5 4/7] permission: add helper to check for active permissions David Riley
2026-07-07 12:04 ` [PATCH pve-access-control v5 5/7] fix #7520: sdn: add VNet ACL migration David Riley
2026-07-15 14:59 ` Stefan Hanreich [this message]
2026-07-07 12:04 ` [PATCH pve-access-control v5 6/7] test: add sdn acl migration tests David Riley
2026-07-07 12:04 ` [PATCH pve-network v5 7/7] fix #7520: config: prune orphaned and relocate moved VNet ACLs David Riley
2026-07-15 15:00 ` Stefan Hanreich
2026-07-15 15:11 ` [PATCH access-control/network v5 0/7] fix #7520: sdn: prune orphaned ACLs and handle VNet migrations Stefan Hanreich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=029ecefd-ae81-49ac-89c4-783dae029941@proxmox.com \
--to=s.hanreich@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox