Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Podman requires --userns=keep-id to avoid AccessDeniedExceptions while building the native image #3625

Merged
merged 1 commit into from
Aug 22, 2019

Conversation

gastaldi
Copy link
Contributor

According to the podman documentation:
--userns=keep-id: creates a user namespace where the current rootless user's UID:GID are mapped to the same values in the container.

Updating to container-selinux-2.115.0-1.gitfddfbbb is also required to avoid disabling SELinux (Cannot restore segment prot after reloc: Permission denied).
More information: containers/podman#3859

@gastaldi gastaldi changed the title Podman requires --userns=keep-id to avoid AccessDeniedExceptions while building the project Podman requires --userns=keep-id to avoid AccessDeniedExceptions while building the native image Aug 21, 2019
…e building the native image

According to the podman documentation:
--userns=keep-id: creates a user namespace where the current rootless user's UID:GID are mapped to the same values in the container.

Updating to `container-selinux-2.115.0-1.gitfddfbbb` is also required to avoid disabling SELinux (Cannot restore segment prot after reloc: Permission denied).
More information: containers/podman#3859
@gsmet
Copy link
Member

gsmet commented Aug 22, 2019

@gastaldi do you see someone with Podman experience who could review it? I can approve it but I have no idea if it's the right fix or not :).

@gastaldi
Copy link
Contributor Author

@rhatdan perhaps you could review this? Thanks

@rhatdan
Copy link

rhatdan commented Aug 22, 2019

Basically this would mean the container will run as the UID of the user who runs it, meaning any content created will be owned by that user when run as rootless podman.
Docker running this command will switch to the from root.
The issue is, if the command is running as root, you really want podman to act like docker does.

I would change the check, to check if the command is being run by non root then if doing podman execute the --keep option. Otherwise use the --user option.

@gastaldi
Copy link
Contributor Author

Hm, even if the user is root, using the keep-id option will reuse the same UID from the root user, no? I am not sure I understand why the root check is needed in this case

@rhatdan
Copy link

rhatdan commented Aug 22, 2019

The following code seems to be attempting to run the container with a specifc User

                String uid = getLinuxID("-ur");
                String gid = getLinuxID("-gr");
                if (uid != null & gid != null & !"".equals(uid) & !"".equals(gid)) {
                    Collections.addAll(nativeImage, "--user", uid.concat(":").concat(gid));

Docker and Podman started as root would want to run with this user correct?

Podman run by that user would stay as that user.

@gastaldi
Copy link
Contributor Author

AFAIK that code uses the effective user and group IDs from the process that runs the Maven plugin (it runs a id -gr and id -ur), so unless I am missing something (which I probably am) keep-id should do that too.

@rhatdan
Copy link

rhatdan commented Aug 22, 2019

Ok, so if this is always running as the user, then yes this Patch LGTM.
Docker is a client server operation, so talking to the docker daemon via the docker.sock would require you to launch the container with the user.

With the change to Podman you no longer require access to the docker.sock, which would hugely increase security. Since I believe access to the docker.sock is the most dangerous thing you can do on Linux. More dangerous then giving the user sudo root without password.

https://www.projectatomic.io/blog/2014/09/granting-rights-to-users-to-use-docker-in-fedora/

@gastaldi
Copy link
Contributor Author

@rhatdan thank you very much for your comments. @gsmet this PR is good to go :)

@cescoffier cescoffier added this to the 0.22.0 milestone Aug 22, 2019
@cescoffier cescoffier added the kind/bug Something isn't working label Aug 22, 2019
@cescoffier cescoffier merged commit 0814b2e into quarkusio:master Aug 22, 2019
@gastaldi gastaldi deleted the podman branch September 11, 2019 16:51
@gsmet gsmet modified the milestones: 0.23.0, 0.22.0 Sep 13, 2019
@gsmet gsmet removed the backport? label Sep 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants