internal/app: less strict username regex
Some checks failed
Test / Create distribution (push) Failing after 31s
Test / Sandbox (push) Failing after 46s
Test / Hakurei (race detector) (push) Failing after 51s
Test / Hpkg (push) Failing after 50s
Test / Sandbox (race detector) (push) Failing after 59s
Test / Hakurei (push) Failing after 1m3s
Test / Flake checks (push) Has been skipped

Use the default value of NAME_REGEX from adduser. Should not hurt compatibility while being less strict.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
2025-08-28 00:22:55 +09:00
parent 22b33e0375
commit 1067775a5b
2 changed files with 19 additions and 12 deletions

12
internal/app/username.go Normal file
View File

@@ -0,0 +1,12 @@
package app
import "regexp"
// nameRegex is the default NAME_REGEX value from adduser.
var nameRegex = regexp.MustCompilePOSIX(`^[a-zA-Z][a-zA-Z0-9_-]*\$?$`)
// isValidUsername returns whether the argument is a valid username
func isValidUsername(username string) bool {
return len(username) < sysconf(_SC_LOGIN_NAME_MAX) &&
nameRegex.MatchString(username)
}