-
Notifications
You must be signed in to change notification settings - Fork 324
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
/dev/std*
don't work with --userns=auto
#1019
Comments
That's what the file looks like, it uses the special symlink dereference handling for pipes: # nsenter -t 702369 -m /bin/sh -c '/bin/ls -lah /proc/1/fd/1'
l-wx------ 1 1000000 1000000 64 Oct 3 06:23 /proc/1/fd/1 -> pipe:[5284174] The proc man page also has some information about this:
this leads me to think that whoever creates the pipe creates it with the wrong permissions because the user-namespace isn't being considered. Am I right in that the pipe gets created by the container runtime? For me that'd be |
okay so I did the following test (rootless): # nsenter -t 707087 -a /bin/sh -c '/bin/echo hello > /proc/1/fd/1'
/bin/sh: can't create /proc/1/fd/1: Permission denied
# nsenter -t 707087 -m /bin/sh -c '/bin/stat -L /proc/1/fd/1'
File: /proc/1/fd/1
Size: 0 Blocks: 0 IO Block: 4096 fifo
Device: dh/13d Inode: 5617919 Links: 1
Access: (0600/prw-------) Uid: ( 1000/ UNKNOWN) Gid: ( 1000/ UNKNOWN)
Access: 2022-10-03 07:44:12.110595051 +0000
Modify: 2022-10-03 07:44:12.110595051 +0000
Change: 2022-10-03 07:44:12.110595051 +0000
# nsenter -t 707087 -m /bin/sh -c '/bin/chown 1000000:1000000 /proc/1/fd/1'
# nsenter -t 707087 -a /bin/sh -c '/bin/echo hello > /proc/1/fd/1' That seems to confirm, that the pipe is simply owned by the wrong user. The weird part is that crun should be doing this already: #755 |
@giuseppe PTAL |
what happens is that the
conmon creates the pipe so it is a bit more complicated to get a clue about the user namespace there. Let me try if I can solve it in crun. |
attempt to chown the std streams file descriptors before joining the user namespace. The files' owner might not be mapped inside the user namespace, thus causing the chown inside the user namespace to fail. Closes: containers#1019 Signed-off-by: Giuseppe Scrivano <[email protected]>
here the proposed fix: #1020 |
Is this a BUG REPORT or FEATURE REQUEST? (leave only one on its own line)
/kind bug
Description
When using
--userns=auto
and NOT allocating a tty, podman will use pipes for stdout and stderr. Those work fine when using them through the file descriptors(1, 2) inherited from the parent. But you get an error when you try to open them through/dev/stderr
or/dev/stdout
.This is e.g. used by the nginx container.
error.log
is a symlink to/dev/stderr
.Steps to reproduce the issue:
podman run --rm --userns=auto:size=65534 alpine sh -c 'echo hello >> /dev/stdout'
Describe the results you received:
/bin/sh: can't create /dev/stdout: Permission denied
Describe the results you expected:
hello
Additional information you deem important (e.g. issue happens only occasionally):
Output of
podman version
:Output of
podman info
:Package info (e.g. output of
rpm -q podman
orapt list podman
orbrew info podman
):Have you tested with the latest version of Podman and have you checked the Podman Troubleshooting Guide? (https://github.com/containers/podman/blob/main/troubleshooting.md)
(arch uses the latest version already)
Yes
Additional environment details (AWS, VirtualBox, physical, etc.):
The text was updated successfully, but these errors were encountered: