From 5036ff64b2fdf360b6e45fdf0a8b95e4630ab5f6 Mon Sep 17 00:00:00 2001 From: Linh Luong Date: Thu, 30 May 2024 23:58:25 +0700 Subject: [PATCH] issue 2117: disallow admin username Signed-off-by: Linh Luong --- pkg/osutil/user.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/osutil/user.go b/pkg/osutil/user.go index 98a987b7fea6..bb506e6194f0 100644 --- a/pkg/osutil/user.go +++ b/pkg/osutil/user.go @@ -35,7 +35,7 @@ var ( // regexUsername matches user and group names to be valid for `useradd`. // `useradd` allows names with a trailing '$', but it feels prudent to map those // names to the fallback user as well, so the regex does not allow them. -var regexUsername = regexp.MustCompile("^[a-z_][a-z0-9_-]*$") +var regexUsername = regexp.MustCompile("^(?!admin$)[a-z_][a-z0-9_-]*$") // regexPath detects valid Linux path. var regexPath = regexp.MustCompile("^[/a-zA-Z0-9_-]+$")