mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-11 06:03:57 +08:00
tests: integration: add helper to check if we're in a userns
Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
This commit is contained in:
@@ -368,6 +368,12 @@ function rootless_cgroup() {
|
||||
[[ "$ROOTLESS_FEATURES" == *"cgroup"* || -v RUNC_USE_SYSTEMD ]]
|
||||
}
|
||||
|
||||
function in_userns() {
|
||||
# The kernel guarantees the root userns inode number (and thus the value of
|
||||
# the magic-link) is always the same value (PROC_USER_INIT_INO).
|
||||
[[ "$(readlink /proc/self/ns/user)" != "user:[$((0xEFFFFFFD))]" ]]
|
||||
}
|
||||
|
||||
# Check if criu is available and working.
|
||||
function have_criu() {
|
||||
command -v criu &>/dev/null || return 1
|
||||
@@ -396,7 +402,7 @@ function requires() {
|
||||
fi
|
||||
;;
|
||||
root)
|
||||
if [ $EUID -ne 0 ]; then
|
||||
if [ $EUID -ne 0 ] || in_userns; then
|
||||
skip_me=1
|
||||
fi
|
||||
;;
|
||||
|
||||
Reference in New Issue
Block a user