From: Fiona Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH v2 manager] api: create pool: force first character to be a letter for new pools
Date: Mon, 26 May 2025 16:19:41 +0200 [thread overview]
Message-ID: <20250526141941.1654201-1-f.ebner@proxmox.com> (raw)
Currently, the first character can also be a digit, '.', '-', or '_'.
Almost all other configuration IDs in Proxmox VE require starting with
a letter, so force this for new pool names too.
A pool with ID '0' can be added, but not parsed, because it will
evaluate to false in PVE/AccessControl.pm's parse_user_config():
> if (!verify_poolname($pool, 1)) {
> warn "user config - ignore pool '$pool' - invalid characters in pool name\n";
> next;
> }
It's likely that it would cause other issues as well if properly
handled there.
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
Breaking change intended for Proxmox VE 9!
Changes in v2:
* Different approach, force new pools to start with a letter.
PVE/API2/Pool.pm | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/PVE/API2/Pool.pm b/PVE/API2/Pool.pm
index 54e74455..4b5e534c 100644
--- a/PVE/API2/Pool.pm
+++ b/PVE/API2/Pool.pm
@@ -184,10 +184,13 @@ __PACKAGE__->register_method ({
my $pool = $param->{poolid};
die "pool '$pool' already exists\n" if $usercfg->{pools}->{$pool};
- if ($pool =~ m!^(.*)/[^/]+$!) {
- my $parent = $1;
+ if ($pool =~ m!^(.*)/([^/]+)$!) {
+ my ($parent, $leaf) = ($1, $2);
die "parent '$parent' of pool '$pool' does not exist\n"
if !defined($usercfg->{pools}->{$parent});
+ die "pool name must start with a letter\n" if $leaf !~ m!^[A-Za-z]!;
+ } else {
+ die "pool name must start with a letter\n" if $pool !~ m!^[A-Za-z]!;
}
$usercfg->{pools}->{$pool} = {
--
2.39.5
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
reply other threads:[~2025-05-26 14:20 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20250526141941.1654201-1-f.ebner@proxmox.com \
--to=f.ebner@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
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal