[pmg-devel] [PATCH pmg-api] Registration: Restrict special characters in usernames when creating a new user

Moayad Almalat m.almalat at proxmox.com
Tue Mar 28 11:33:11 CEST 2023


From: Moayad Almalat <m.almalat at .proxmox.com>

Signed-off-by: Moayad Almalat <m.almalat at proxmox.com>
---
 src/PMG/Utils.pm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/PMG/Utils.pm b/src/PMG/Utils.pm
index 6405934..41b47c7 100644
--- a/src/PMG/Utils.pm
+++ b/src/PMG/Utils.pm
@@ -92,7 +92,7 @@ sub verify_username {
     # slash is not allowed because it is used as pve API delimiter
     # also see "man useradd"
     my $realm_list = join('|', @$valid_pmg_realms);
-    if ($username =~ m!^([^\s:/]+)\@(${realm_list})$!) {
+    if ($username =~ m!^([A-Za-z0-9_\-.]+)\@(${realm_list})$!) {
 	return wantarray ? ($username, $1, $2) : $username;
     }
 
-- 
2.30.2




More information about the pmg-devel mailing list