forked from containers/podman
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pkg/rootless: do not use shortcut with --tmpdir
When using --tmpdir for the podman cli we use this as location for the pause.pid file. However the c shortcut code has no idea about this option and always assumes XDG_RUNTIME_DIR/libpod/tmp. This can cause us to join the wrong user namespace which leads to very weird issues as mounts are missing there. Fixes containers#17903 Signed-off-by: Paul Holzinger <[email protected]>
- Loading branch information
Showing
2 changed files
with
37 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/usr/bin/env bats -*- bats -*- | ||
# | ||
# test to make sure we use the correct podman pause process | ||
# | ||
|
||
load helpers | ||
|
||
# Test for https://github.com/containers/podman/issues/17903 | ||
@test "podman uses different pause process with --tmpdir" { | ||
skip_if_not_rootless "pause process is only used as rootless" | ||
skip_if_remote "--tmpdir not supported via remote" | ||
|
||
# There are nasty bugs when we are not in the correct userns, | ||
# we have good reproducer to see how things can go wrong here: | ||
# https://github.com/containers/podman/issues/17903#issuecomment-1497232184 | ||
# However in CI test I rather not kill the pause process, this likely just | ||
# causes more tests bugs, instead we will compare the actual namespace values | ||
|
||
run_podman unshare readlink /proc/self/ns/user | ||
default_ns="$output" | ||
|
||
run_podman --root $PODMAN_TMPDIR/root --runroot $PODMAN_TMPDIR/runroot --tmpdir $PODMAN_TMPDIR/tmp \ | ||
unshare readlink /proc/self/ns/user | ||
assert "$output" != "$default_ns" "different --tmpdir must use different ns" | ||
|
||
# kill the pause process from our custom tmpdir so we do not leak it forever | ||
kill -9 $(cat $PODMAN_TMPDIR/tmp/pause.pid) | ||
} |