mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-10 21:53:57 +08:00
runc exec: avoid stuttering in error messages
An error from strconv.Atoi already contains the text it fails to parse. Because of that, errors look way too verbose, e.g.: [root@kir-rhat runc-tst]# ./runc exec --user 1:1:1 2345 true ERRO[0000] exec failed: parsing 1:1 as int for gid failed: strconv.Atoi: parsing "1:1": invalid syntax With this patch, the error looks like this now: [root@kir-rhat runc]# ./runc exec --user 1:1:1 2345 true ERRO[0000] exec failed: bad gid: strconv.Atoi: parsing "1:1": invalid syntax Still not awesome, but better. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
@@ -251,13 +251,13 @@ func getProcess(context *cli.Context, bundle string) (*specs.Process, error) {
|
||||
if len(u) > 1 {
|
||||
gid, err := strconv.Atoi(u[1])
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("parsing %s as int for gid failed: %w", u[1], err)
|
||||
return nil, fmt.Errorf("bad gid: %w", err)
|
||||
}
|
||||
p.User.GID = uint32(gid)
|
||||
}
|
||||
uid, err := strconv.Atoi(u[0])
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("parsing %s as int for uid failed: %w", u[0], err)
|
||||
return nil, fmt.Errorf("bad uid: %w", err)
|
||||
}
|
||||
p.User.UID = uint32(uid)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user