Add --additional-gids to runc exec.
This flag allows specifying additional gids for the process. Without this flag, the user will have to provide process.json which allows additional gids. Closes #1306 Signed-off-by: Sumit Sanghrajka <sumit.sanghrajka@gmail.com>
This commit is contained in:
parent
beb8716fcb
commit
7a386c2b60
13
exec.go
13
exec.go
|
@ -50,6 +50,10 @@ following will output a list of processes running in the container:
|
|||
Name: "user, u",
|
||||
Usage: "UID (format: <uid>[:<gid>])",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "additional-gids, g",
|
||||
Usage: "additional gids separated by comma",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "process, p",
|
||||
Usage: "path to the process.json",
|
||||
|
@ -208,5 +212,14 @@ func getProcess(context *cli.Context, bundle string) (*specs.Process, error) {
|
|||
}
|
||||
p.User.UID = uint32(uid)
|
||||
}
|
||||
if context.String("additional-gids") != "" {
|
||||
for _, i := range strings.Split(context.String("additional-gids"), ",") {
|
||||
gid, err := strconv.Atoi(i)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("parsing %s as int for gid failed: %v", i, err)
|
||||
}
|
||||
p.User.AdditionalGids = append(p.User.AdditionalGids, uint32(gid))
|
||||
}
|
||||
}
|
||||
return p, nil
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ following will output a list of processes running in the container:
|
|||
--env value, -e value set environment variables
|
||||
--tty, -t allocate a pseudo-TTY
|
||||
--user value, -u value UID (format: <uid>[:<gid>])
|
||||
--additional-gids value, -g value additional gids separated by comma
|
||||
--process value, -p value path to the process.json
|
||||
--detach, -d detach from the container's process
|
||||
--pid-file value specify the file to write the process id to
|
||||
|
|
|
@ -112,3 +112,16 @@ function teardown() {
|
|||
|
||||
[[ "${output}" == "uid=1000 gid=1000"* ]]
|
||||
}
|
||||
|
||||
@test "runc exec --additional-gids" {
|
||||
# run busybox detached
|
||||
runc run -d --console-socket $CONSOLE_SOCKET test_busybox
|
||||
[ "$status" -eq 0 ]
|
||||
|
||||
wait_for_container 15 1 test_busybox
|
||||
|
||||
runc exec --user 1000:1000 --additional-gids 100 test_busybox id
|
||||
[ "$status" -eq 0 ]
|
||||
|
||||
[[ ${output} == "uid=1000 gid=1000 groups=100(users)" ]]
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue