mirror of
https://github.com/NixOS/nix
synced 2025-06-25 06:31:14 +02:00
functional-tests: skip tests if the kernel restricts unprivileged user namespaces
Update tests/functional/common/functions.sh Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
This commit is contained in:
parent
f1187cb696
commit
da7f7ba810
12 changed files with 22 additions and 6 deletions
|
@ -345,4 +345,15 @@ count() {
|
|||
|
||||
trap onError ERR
|
||||
|
||||
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue