mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-11 06:03:57 +08:00
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:
committed by
Michael Crosby
parent
beb8716fcb
commit
7a386c2b60
@@ -50,6 +50,10 @@ following will output a list of processes running in the container:
|
|||||||
Name: "user, u",
|
Name: "user, u",
|
||||||
Usage: "UID (format: <uid>[:<gid>])",
|
Usage: "UID (format: <uid>[:<gid>])",
|
||||||
},
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "additional-gids, g",
|
||||||
|
Usage: "additional gids separated by comma",
|
||||||
|
},
|
||||||
cli.StringFlag{
|
cli.StringFlag{
|
||||||
Name: "process, p",
|
Name: "process, p",
|
||||||
Usage: "path to the process.json",
|
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)
|
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
|
return p, nil
|
||||||
}
|
}
|
||||||
|
|||||||
+14
-13
@@ -14,16 +14,17 @@ following will output a list of processes running in the container:
|
|||||||
# runc exec <container-id> ps
|
# runc exec <container-id> ps
|
||||||
|
|
||||||
# OPTIONS
|
# OPTIONS
|
||||||
--console value specify the pty slave path for use with the container
|
--console value specify the pty slave path for use with the container
|
||||||
--cwd value current working directory in the container
|
--cwd value current working directory in the container
|
||||||
--env value, -e value set environment variables
|
--env value, -e value set environment variables
|
||||||
--tty, -t allocate a pseudo-TTY
|
--tty, -t allocate a pseudo-TTY
|
||||||
--user value, -u value UID (format: <uid>[:<gid>])
|
--user value, -u value UID (format: <uid>[:<gid>])
|
||||||
--process value, -p value path to the process.json
|
--additional-gids value, -g value additional gids separated by comma
|
||||||
--detach, -d detach from the container's process
|
--process value, -p value path to the process.json
|
||||||
--pid-file value specify the file to write the process id to
|
--detach, -d detach from the container's process
|
||||||
--process-label value set the asm process label for the process commonly used with selinux
|
--pid-file value specify the file to write the process id to
|
||||||
--apparmor value set the apparmor profile for the process
|
--process-label value set the asm process label for the process commonly used with selinux
|
||||||
--no-new-privs set the no new privileges value for the process
|
--apparmor value set the apparmor profile for the process
|
||||||
--cap value, -c value add a capability to the bounding set for the process
|
--no-new-privs set the no new privileges value for the process
|
||||||
--no-subreaper disable the use of the subreaper used to reap reparented processes
|
--cap value, -c value add a capability to the bounding set for the process
|
||||||
|
--no-subreaper disable the use of the subreaper used to reap reparented processes
|
||||||
|
|||||||
@@ -112,3 +112,16 @@ function teardown() {
|
|||||||
|
|
||||||
[[ "${output}" == "uid=1000 gid=1000"* ]]
|
[[ "${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)" ]]
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user