From: "Fabian Grünbichler" <f.gruenbichler@proxmox.com>
To: Wolfgang Bumiller <w.bumiller@proxmox.com>
Cc: pve-devel@lists.proxmox.com
Subject: Re: [pve-devel] [PATCH access-control 2/2] pools: record parent/subpool information
Date: Fri, 17 Nov 2023 16:29:22 +0100 (CET) [thread overview]
Message-ID: <1066010498.4111.1700234962992@webmail.proxmox.com> (raw)
In-Reply-To: <lkbhuyb7rigabgjeq3fonsnw2gqpk6ljygxdk3rjpqb4v3fbon@ajxlwrlpkkdm>
> Wolfgang Bumiller <w.bumiller@proxmox.com> hat am 17.11.2023 11:10 CET geschrieben:
>
>
> On Thu, Nov 16, 2023 at 04:31:26PM +0100, Fabian Grünbichler wrote:
> > and ensure a missing intermediate pool exists at all times.
> >
> > Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
> > ---
> >
> > Notes:
> > a "missing link" should never happen when modifying via the API (both deletion
> > with children and addition without the parent existing is blocked there), but
> > it could happen when manually editing the config.
> >
> > src/PVE/AccessControl.pm | 14 +++++++++++++-
> > src/test/parser_writer.pl | 4 ++++
> > 2 files changed, 17 insertions(+), 1 deletion(-)
> >
> > diff --git a/src/PVE/AccessControl.pm b/src/PVE/AccessControl.pm
> > index d9ae611..e33f844 100644
> > --- a/src/PVE/AccessControl.pm
> > +++ b/src/PVE/AccessControl.pm
> > @@ -1529,7 +1529,19 @@ sub parse_user_config {
> > }
> >
> > # make sure to add the pool (even if there are no members)
> > - $cfg->{pools}->{$pool} = { vms => {}, storage => {} } if !$cfg->{pools}->{$pool};
> > + $cfg->{pools}->{$pool} = { vms => {}, storage => {}, pools => {} } if !$cfg->{pools}->{$pool};
> > +
> > + if ($pool =~ m!/!) {
> > + my $curr = $pool;
> > + while ($curr =~ m!^(.*)/[^/]+$!) {
>
> I wonder if we should use `.+` instead of `.*`.
> This way it would work the same even with a leading slash.
> That said, we don't allow leading slashes and there's a verify_poolname
> further up in the function so it doesn't really matter much.
> We just need to be careful that we never allow/introduce leading slashes
> anywhere, otherwise this runs with a final iteration where $parent is an
> empty string.
ack.
> > + # ensure nested pool info is correctly recorded
> > + my $parent = $1;
> > + $cfg->{pools}->{$curr}->{parent} = $parent;
> > + $cfg->{pools}->{$parent} = { vms => {}, storage => {}, pools => {} } if !$cfg->{pools}->{$parent};
>
> (could use //= instead of the suffix if, IMO a bit easier to read (and
> doesn't break the 100 char limit :p)
that style is used across the whole parser here, I am always a bit hesitant to mix styles within a sub as IMHO that makes it harder to parse.
move the post-if to its own line, and optional follow-up to convert the whole parser to drop post ifs for initialization? ;)
next prev parent reply other threads:[~2023-11-17 15:29 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-16 15:31 [pve-devel] [RFC access-control/manager 0/4] fix #1148: nested pools Fabian Grünbichler
2023-11-16 15:31 ` [pve-devel] [PATCH access-control 1/2] allow up to three levels of pool nesting Fabian Grünbichler
2023-11-17 10:00 ` Wolfgang Bumiller
2023-11-17 15:31 ` Fabian Grünbichler
2023-11-16 15:31 ` [pve-devel] [PATCH access-control 2/2] pools: record parent/subpool information Fabian Grünbichler
2023-11-17 10:10 ` Wolfgang Bumiller
2023-11-17 15:29 ` Fabian Grünbichler [this message]
2023-11-16 15:33 ` Fabian Grünbichler
2023-11-16 15:54 ` [pve-devel] [RFC access-control/manager 0/4] fix #1148: nested pools Philipp Hufnagl
2023-11-17 7:09 ` [pve-devel] [PATCH manager 1/2] api: pools: support " Fabian Grünbichler
2023-11-17 7:09 ` [pve-devel] [PATCH manager 2/2] ui: pools: switch to new API endpoints Fabian Grünbichler
2023-11-17 11:58 ` [pve-devel] [PATCH manager 1/2] api: pools: support nested pools Wolfgang Bumiller
2023-11-17 15:27 ` Fabian Grünbichler
2023-11-20 7:22 [pve-devel] [PATCH access-control/manager 0/4] fix #1148: " Fabian Grünbichler
2023-11-20 7:22 ` [pve-devel] [PATCH access-control 2/2] pools: record parent/subpool information Fabian Grünbichler
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=1066010498.4111.1700234962992@webmail.proxmox.com \
--to=f.gruenbichler@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
--cc=w.bumiller@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal