mirror of
https://github.com/containers/podman.git
synced 2025-09-25 07:44:24 +08:00
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>
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user