Skip to content

Commit

Permalink
Merge pull request containers#431 from aparcar/user
Browse files Browse the repository at this point in the history
Don't use `root` as default user for exec_run
  • Loading branch information
openshift-merge-bot[bot] authored Sep 27, 2024
2 parents 1c8c5bc + 4175adf commit da8fca9
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions podman/domain/containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def exec_run(
stdin: Attach to stdin. Default: False
tty: Allocate a pseudo-TTY. Default: False
privileged: Run as privileged.
user: User to execute command as. Default: root
user: User to execute command as.
detach: If true, detach from the exec command.
Default: False
stream: Stream response data. Default: False
Expand All @@ -176,7 +176,6 @@ def exec_run(
APIError: when service reports error
"""
# pylint: disable-msg=too-many-locals
user = user or "root"
if isinstance(environment, dict):
environment = [f"{k}={v}" for k, v in environment.items()]
data = {
Expand All @@ -188,9 +187,11 @@ def exec_run(
"Env": environment,
"Privileged": privileged,
"Tty": tty,
"User": user,
"WorkingDir": workdir,
}
if user:
data["User"] = user

# create the exec instance
response = self.client.post(f"/containers/{self.name}/exec", data=json.dumps(data))
response.raise_for_status()
Expand Down

0 comments on commit da8fca9

Please sign in to comment.