From e5cc2e755192c8ae89e4806512f11e695b9eca49 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Tue, 30 Jun 2026 10:49:54 +0200 Subject: [PATCH] user: GetExecUser: use strings.Cut to split user:group This was using parseParts to split the colon-separated strings, but this required both converting to a byte-slice, and an intermediate slice (split by colon). Use strings.Cut, which makes it more transparent what's done and to reduce allocations. Signed-off-by: Sebastiaan van Stijn --- user/user.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/user/user.go b/user/user.go index 857711e..03f1df4 100644 --- a/user/user.go +++ b/user/user.go @@ -305,9 +305,8 @@ func GetExecUser(userSpec string, defaults *ExecUser, passwd, group io.Reader) ( user.Sgids = []int{} } - // Allow for userArg to have either "user" syntax, or optionally "user:group" syntax - var userArg, groupArg string - parseLine([]byte(userSpec), &userArg, &groupArg) + // Allow for userSpec to have either "user", or optionally "user:group" syntax. + userArg, groupArg, _ := strings.Cut(userSpec, ":") // Convert userArg and groupArg to be numeric, so we don't have to execute // Atoi *twice* for each iteration over lines.