Bug 1860126

Summary: podman run namespace in man page ambiguous
Product: Red Hat Enterprise Linux 8 Reporter: Aleksandar Kostadinov <akostadi>
Component: podmanAssignee: Jindrich Novy <jnovy>
Status: CLOSED ERRATA QA Contact: atomic-bugs <atomic-bugs>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 8.2CC: ajia, bbaude, dwalsh, gscrivan, jligon, jnovy, lsm5, mheon, tsweeney, ypu
Target Milestone: rcFlags: pm-rhel: mirror+
Target Release: 8.4   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: podman-2.0.4-3.el8 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-11-04 03:06:49 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Aleksandar Kostadinov 2020-07-23 18:16:27 UTC
Description of problem:
Man page unclear what is default namespace behavior for podman run. One can see that in first paragraph default is disabled namespaces. Then under `host` it claims to be the default. Finally `private` also claims to be the default.

Please make more clear what is default user namespace behavior for root and non-root user.

>        --userns=auto|host|keep-id|container:id|ns:namespace
> 
>        Set the user namespace mode for the container.  It defaults to the
>        PODMAN_USERNS environment variable.  An empty value means user
>        namespaces are disabled.
> 
>        · auto: automatically create a namespace.  It is possible to specify
>          other options to auto.  The supported options are size=SIZE to
>          specify an explicit size for the automatic user namespace.  e.g.
>          --userns=auto:size=8192.  If size is not specified, auto will guess a
>          size for the user namespace.  uidmapping=HOST_UID:CONTAINER_UID:SIZE
>          to force a UID mapping to be present in the user namespace.
>          gidmapping=HOST_UID:CONTAINER_UID:SIZE to force a GID mapping to be
>          present in the user namespace.
> 
>        · host: run in the user namespace of the caller. This is the default if
>          no user namespace options are set. The processes running in the
>          container will have the same privileges on the host as any other
>          process launched by the calling user.
> 
>        · keep-id: creates a user namespace where the current rootless user's
>          UID:GID are mapped to the same values in the container. This option
>          is ignored for containers created by the root user.
> 
>        · ns: run the container in the given existing user namespace.
> 
>        · private: create a new namespace for the container (default)
> 
>        · container: join the user namespace of the specified container.
> 
>        This option is incompatible with --gidmap, --uidmap, --subuid and

While on it, is information about `--user` correct?

>        --user, -u=[user | user:group | uid | uid:gid | user:gid | uid:group ]
> 
>        Sets the username or UID used and optionally the groupname or GID for
>        the specified command.
> 
>        Without this argument the command will be run as root in the container.

Namely should lack of `--user` option result in container running as specified by `USER` in Dockerfile? This is what I observe.

Version-Release number of selected component (if applicable):
podman-1.9.3-2.module+el8.2.1+6867+366c07d6.x86_64

How reproducible:
always

Steps to Reproduce:
1. man podman

Comment 1 Tom Sweeney 2020-07-23 23:36:01 UTC
Based on my understanding of the way things work, I've created this PR upstream to address this issue: https://github.com/containers/podman/pull/7075.

However, Matt Heon and Giuseppe Scrivano may adjust the verbiage to have it better reflect reality if I'm off base.

Comment 2 Tom Sweeney 2020-08-10 21:31:11 UTC
As https://github.com/containers/podman/pull/7075 has merged, I'm setting this BZ to POST and assigning to Jindrich for any packaging/BZ needs.  This fix will go out when upstream Podman is rolled into RHEL again, most likely RHEL 8.4.

Comment 4 Daniel Walsh 2020-08-17 17:57:08 UTC
Yes we should get this in RHEL8.3.

Comment 9 Alex Jia 2020-08-25 17:01:51 UTC
This bug has been verified on podman-2.0.4-3.module+el8.3.0+7716+ce654703.


[ajia@hpe-dl380pgen8-02-vm-15 ~]$ rpm -q podman podman-catatonit
podman-2.0.4-3.module+el8.3.0+7716+ce654703.x86_64
podman-catatonit-2.0.4-3.module+el8.3.0+7716+ce654703.x86_64

[ajia@hpe-dl380pgen8-02-vm-15 ~]$ man podman-run | grep -A5 "Without this argument"
       Without this argument, the command will run as the user specified in the container image. Unless overridden by a USER command in the Containerfile or by a value passed to this
       option, this user generally defaults to root.

       When a user namespace is not in use, the UID and GID used within the container and on the host will match. When user namespaces are in use, however, the UID and GID in the
       container may correspond to another UID and GID on the host. In rootless containers, for example, a user namespace is always used, and root in the container will by default
       correspond to the UID and GID of the user invoking Podman.
[ajia@hpe-dl380pgen8-02-vm-15 ~]$ man podman-run | grep -A1 "Set the user namespace mode"
       Set the user namespace mode for the container.  It defaults to the PODMAN_USERNS environment variable.  An empty value ("") means user namespaces are disabled unless an
       explicit mapping is set with they --uidmapping and --gidmapping options.
[ajia@hpe-dl380pgen8-02-vm-15 ~]$ man podman-run | grep -A1 "user namespace of the caller"
       · host: run in the user namespace of the caller. The processes running in the container will have the same privileges on the host as any other process launched by the calling
         user (default).

[ajia@hpe-dl380pgen8-02-vm-15 ~]$ man podman-run | grep -B2 "private: create a new namespace"|grep -v default
       · ns:path: path to a network namespace to join;

--
       · host: use the host's PID namespace for the container. Note the host mode gives the container full access to local PID and is therefore considered insecure;

--
       · ns: run the container in the given existing user namespace.

       · private: create a new namespace for the container.
--
       · host: use the host's UTS namespace inside the container.

Comment 12 errata-xmlrpc 2020-11-04 03:06:49 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (Moderate: container-tools:rhel8 security, bug fix, and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2020:4694