-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Skip tests on systems with restricted usernamespaces (backport #12051) #12183
base: 2.24-maintenance
Are you sure you want to change the base?
Conversation
…r namespaces Update tests/functional/common/functions.sh Co-authored-by: Robert Hensing <[email protected]> (cherry picked from commit da7f7ba) # Conflicts: # tests/functional/common/vars-and-functions.sh # tests/functional/supplementary-groups.sh
Cherry-pick of da7f7ba has failed:
To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Mic92 I have verified such changes do work on my machine.
<<<<<<< HEAD:tests/functional/common/vars-and-functions.sh | ||
fi # COMMON_VARS_AND_FUNCTIONS_SH_SOURCED | ||
======= | ||
requiresUnprivilegedUserNamespaces() { | ||
if [[ -f /proc/sys/kernel/apparmor_restrict_unprivileged_userns ]] && [[ $(< /proc/sys/kernel/apparmor_restrict_unprivileged_userns) -eq 1 ]]; then | ||
skipTest "Unprivileged user namespaces are disabled. Run 'sudo sysctl -w /proc/sys/kernel/apparmor_restrict_unprivileged_userns=0' to allow, and run these tests." | ||
fi | ||
} | ||
|
||
execUnshare () { | ||
requiresUnprivilegedUserNamespaces | ||
exec unshare --mount --map-root-user "$SHELL" "$@" | ||
} | ||
|
||
fi # COMMON_FUNCTIONS_SH_SOURCED | ||
>>>>>>> da7f7ba81 (functional-tests: skip tests if the kernel restricts unprivileged user namespaces):tests/functional/common/functions.sh |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<<<<<<< HEAD:tests/functional/common/vars-and-functions.sh | |
fi # COMMON_VARS_AND_FUNCTIONS_SH_SOURCED | |
======= | |
requiresUnprivilegedUserNamespaces() { | |
if [[ -f /proc/sys/kernel/apparmor_restrict_unprivileged_userns ]] && [[ $(< /proc/sys/kernel/apparmor_restrict_unprivileged_userns) -eq 1 ]]; then | |
skipTest "Unprivileged user namespaces are disabled. Run 'sudo sysctl -w /proc/sys/kernel/apparmor_restrict_unprivileged_userns=0' to allow, and run these tests." | |
fi | |
} | |
execUnshare () { | |
requiresUnprivilegedUserNamespaces | |
exec unshare --mount --map-root-user "$SHELL" "$@" | |
} | |
fi # COMMON_FUNCTIONS_SH_SOURCED | |
>>>>>>> da7f7ba81 (functional-tests: skip tests if the kernel restricts unprivileged user namespaces):tests/functional/common/functions.sh | |
requiresUnprivilegedUserNamespaces() { | |
if [[ -f /proc/sys/kernel/apparmor_restrict_unprivileged_userns ]] && [[ $(< /proc/sys/kernel/apparmor_restrict_unprivileged_userns) -eq 1 ]]; then | |
skipTest "Unprivileged user namespaces are disabled. Run 'sudo sysctl -w /proc/sys/kernel/apparmor_restrict_unprivileged_userns=0' to allow, and run these tests." | |
fi | |
} | |
execUnshare () { | |
requiresUnprivilegedUserNamespaces | |
exec unshare --mount --map-root-user "$SHELL" "$@" | |
} | |
fi # COMMON_VARS_AND_FUNCTIONS_SH_SOURCED |
<<<<<<< HEAD | ||
unshare --mount --map-root-user bash <<EOF | ||
======= | ||
execUnshare <<EOF | ||
>>>>>>> da7f7ba81 (functional-tests: skip tests if the kernel restricts unprivileged user namespaces) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<<<<<<< HEAD | |
unshare --mount --map-root-user bash <<EOF | |
======= | |
execUnshare <<EOF | |
>>>>>>> da7f7ba81 (functional-tests: skip tests if the kernel restricts unprivileged user namespaces) | |
execUnshare <<EOF |
Depends on #12050
This makes ci pass: https://github.com/NixOS/nix/actions/runs/12329995455/job/34414955507?pr=12051
even on systems that have restricted usernamespaces: 6642863
This is an automatic backport of pull request #12051 done by Mergify.