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

WIP: pkg/rootless: do not use shortcut with --tmpdir #18057

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion pkg/rootless/rootless_linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,15 @@ can_use_shortcut (char **argv)
for (argc = 0; argv[argc]; argc++)
{
if (argc == 0 || argv[argc][0] == '-')
continue;
{
// --tmpdir changes the location of the pause.pid file, so we need to prevent
// us from joining the wrong process and let the podman go code handle it
// https://github.com/containers/podman/issues/17903#issuecomment-1497232184
if (strcmp(argv[argc], "--tmpdir") == 0)
return false;
continue;
}


if (strcmp (argv[argc], "mount") == 0
|| strcmp (argv[argc], "machine") == 0
Expand Down
28 changes: 28 additions & 0 deletions test/system/550-pause-process.bats
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)
}