summaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
authorPeter Hunt <pehunt@redhat.com>2019-08-20 11:35:33 -0400
committerPeter Hunt <pehunt@redhat.com>2019-08-20 11:44:27 -0400
commitcc3d8da9683414bda2b650cb46a0b54ce0e6a263 (patch)
tree61fcea462a84857f2c8d4d0f258101fc2d3a2a5f /libpod
parent34fc1d09d245cbd0d922562860f639667c8641d6 (diff)
downloadpodman-cc3d8da9683414bda2b650cb46a0b54ce0e6a263.tar.gz
podman-cc3d8da9683414bda2b650cb46a0b54ce0e6a263.tar.bz2
podman-cc3d8da9683414bda2b650cb46a0b54ce0e6a263.zip
exec: run with user specified on container start
Before, if the container was run with a specified user that wasn't root, exec would fail because it always set to root unless respecified by user. instead, inherit the user from the container start. Signed-off-by: Peter Hunt <pehunt@redhat.com>
Diffstat (limited to 'libpod')
-rw-r--r--libpod/container_api.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/libpod/container_api.go b/libpod/container_api.go
index abcfcb271..9e59104cc 100644
--- a/libpod/container_api.go
+++ b/libpod/container_api.go
@@ -274,6 +274,11 @@ func (c *Container) Exec(tty, privileged bool, env, cmd []string, user, workDir
}
}()
+ // if the user is empty, we should inherit the user that the container is currently running with
+ if user == "" {
+ user = c.config.User
+ }
+
pid, attachChan, err := c.ociRuntime.execContainer(c, cmd, capList, env, tty, workDir, user, sessionID, streams, preserveFDs, resize, detachKeys)
if err != nil {
ec := define.ExecErrorCodeGeneric