Skip to content

Commit

Permalink
test/system: Ensure that process started by 'podman exec' has all groups
Browse files Browse the repository at this point in the history
Commit 15173f8 exposed a bug in crun(1) [1] where the process
started directly by 'podman exec --user ...' inside the Toolbx container
would not have the supplementary groups attached to the user by the
entry point.

This could be observed by differences in id(1):
  ⬢$ id
  uid=1000(user) gid=1000(user) groups=1000(user)
  ⬢$ id user
  uid=1000(user) gid=1000(user) groups=1000(user),10(wheel)

... and could be worked around by starting a new session with sudo(8).

[1] crun commit 9effaebb429a1aed
    containers/crun@9effaebb429a1aed
    containers/crun#644
    containers/podman#9986

#608
  • Loading branch information
debarshiray committed Feb 9, 2024
1 parent 0669a85 commit 641b04a
Showing 1 changed file with 231 additions and 0 deletions.
231 changes: 231 additions & 0 deletions test/system/206-user.bats
Original file line number Diff line number Diff line change
Expand Up @@ -525,3 +525,234 @@ teardown() {
# shellcheck disable=SC2154
assert [ ${#stderr_lines[@]} -eq 0 ]
}

@test "user: id(1) for $USER inside the default container" {
create_default_container

run --keep-empty-lines --separate-stderr "$TOOLBX" run id

assert_success

if check_bats_version 1.10.0; then
assert [ ${#lines[@]} -eq 1 ]
else
assert [ ${#lines[@]} -eq 2 ]
fi

local output_id="${lines[0]}"

# shellcheck disable=SC2154
assert [ ${#stderr_lines[@]} -eq 0 ]

run --keep-empty-lines --separate-stderr "$TOOLBX" run id "$USER"

assert_success
assert_line --index 0 "$output_id"

if check_bats_version 1.10.0; then
assert [ ${#lines[@]} -eq 1 ]
else
assert [ ${#lines[@]} -eq 2 ]
fi

# shellcheck disable=SC2154
assert [ ${#stderr_lines[@]} -eq 0 ]
}

@test "user: id(1) for $USER inside Arch Linux" {
create_distro_container arch latest arch-toolbox-latest

run --keep-empty-lines --separate-stderr "$TOOLBX" run --distro arch id

assert_success

if check_bats_version 1.10.0; then
assert [ ${#lines[@]} -eq 1 ]
else
assert [ ${#lines[@]} -eq 2 ]
fi

local output_id="${lines[0]}"

# shellcheck disable=SC2154
assert [ ${#stderr_lines[@]} -eq 0 ]

run --keep-empty-lines --separate-stderr "$TOOLBX" run --distro arch id "$USER"

assert_success
assert_line --index 0 "$output_id"

if check_bats_version 1.10.0; then
assert [ ${#lines[@]} -eq 1 ]
else
assert [ ${#lines[@]} -eq 2 ]
fi

# shellcheck disable=SC2154
assert [ ${#stderr_lines[@]} -eq 0 ]
}

@test "user: id(1) for $USER inside Fedora 34" {
create_distro_container fedora 34 fedora-toolbox-34

run --keep-empty-lines --separate-stderr "$TOOLBX" run --distro fedora --release 34 id

assert_success

if check_bats_version 1.10.0; then
assert [ ${#lines[@]} -eq 1 ]
else
assert [ ${#lines[@]} -eq 2 ]
fi

local output_id="${lines[0]}"

# shellcheck disable=SC2154
assert [ ${#stderr_lines[@]} -eq 0 ]

run --keep-empty-lines --separate-stderr "$TOOLBX" run --distro fedora --release 34 id "$USER"

assert_success
assert_line --index 0 "$output_id"

if check_bats_version 1.10.0; then
assert [ ${#lines[@]} -eq 1 ]
else
assert [ ${#lines[@]} -eq 2 ]
fi

# shellcheck disable=SC2154
assert [ ${#stderr_lines[@]} -eq 0 ]
}

@test "user: id(1) for $USER inside RHEL 8.9" {
create_distro_container rhel 8.9 rhel-toolbox-8.9

run --keep-empty-lines --separate-stderr "$TOOLBX" run --distro rhel --release 8.9 id

assert_success

if check_bats_version 1.10.0; then
assert [ ${#lines[@]} -eq 1 ]
else
assert [ ${#lines[@]} -eq 2 ]
fi

local output_id="${lines[0]}"

# shellcheck disable=SC2154
assert [ ${#stderr_lines[@]} -eq 0 ]

run --keep-empty-lines --separate-stderr "$TOOLBX" run --distro rhel --release 8.9 id "$USER"

assert_success
assert_line --index 0 "$output_id"

if check_bats_version 1.10.0; then
assert [ ${#lines[@]} -eq 1 ]
else
assert [ ${#lines[@]} -eq 2 ]
fi

# shellcheck disable=SC2154
assert [ ${#stderr_lines[@]} -eq 0 ]
}

@test "user: id(1) for $USER inside Ubuntu 16.04" {
create_distro_container ubuntu 16.04 ubuntu-toolbox-16.04

run --keep-empty-lines --separate-stderr "$TOOLBX" run --distro ubuntu --release 16.04 id

assert_success

if check_bats_version 1.10.0; then
assert [ ${#lines[@]} -eq 1 ]
else
assert [ ${#lines[@]} -eq 2 ]
fi

local output_id="${lines[0]}"

# shellcheck disable=SC2154
assert [ ${#stderr_lines[@]} -eq 0 ]

run --keep-empty-lines --separate-stderr "$TOOLBX" run --distro ubuntu --release 16.04 id "$USER"

assert_success
assert_line --index 0 "$output_id"

if check_bats_version 1.10.0; then
assert [ ${#lines[@]} -eq 1 ]
else
assert [ ${#lines[@]} -eq 2 ]
fi

# shellcheck disable=SC2154
assert [ ${#stderr_lines[@]} -eq 0 ]
}

@test "user: id(1) for $USER inside Ubuntu 18.04" {
create_distro_container ubuntu 18.04 ubuntu-toolbox-18.04

run --keep-empty-lines --separate-stderr "$TOOLBX" run --distro ubuntu --release 18.04 id

assert_success

if check_bats_version 1.10.0; then
assert [ ${#lines[@]} -eq 1 ]
else
assert [ ${#lines[@]} -eq 2 ]
fi

local output_id="${lines[0]}"

# shellcheck disable=SC2154
assert [ ${#stderr_lines[@]} -eq 0 ]

run --keep-empty-lines --separate-stderr "$TOOLBX" run --distro ubuntu --release 18.04 id "$USER"

assert_success
assert_line --index 0 "$output_id"

if check_bats_version 1.10.0; then
assert [ ${#lines[@]} -eq 1 ]
else
assert [ ${#lines[@]} -eq 2 ]
fi

# shellcheck disable=SC2154
assert [ ${#stderr_lines[@]} -eq 0 ]
}

@test "user: id(1) for $USER inside Ubuntu 20.04" {
create_distro_container ubuntu 20.04 ubuntu-toolbox-20.04

run --keep-empty-lines --separate-stderr "$TOOLBX" run --distro ubuntu --release 20.04 id

assert_success

if check_bats_version 1.10.0; then
assert [ ${#lines[@]} -eq 1 ]
else
assert [ ${#lines[@]} -eq 2 ]
fi

local output_id="${lines[0]}"

# shellcheck disable=SC2154
assert [ ${#stderr_lines[@]} -eq 0 ]

run --keep-empty-lines --separate-stderr "$TOOLBX" run --distro ubuntu --release 20.04 id "$USER"

assert_success
assert_line --index 0 "$output_id"

if check_bats_version 1.10.0; then
assert [ ${#lines[@]} -eq 1 ]
else
assert [ ${#lines[@]} -eq 2 ]
fi

# shellcheck disable=SC2154
assert [ ${#stderr_lines[@]} -eq 0 ]
}

0 comments on commit 641b04a

Please sign in to comment.