diff options
author | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2018-01-24T16·17+0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-24T16·17+0100 |
commit | 98f3c75a0e16f5aaaecb25a46f988580efb04d19 (patch) | |
tree | c4046a447b18e8aa73d1f94fab212112d9771253 /tests/common.sh.in | |
parent | 479692a068ce40965067173992392b4f65f410ce (diff) | |
parent | 59086e459c2650b7dc42bd2fc4a9a98b23aaf6e7 (diff) |
Merge pull request #1797 from dezgeg/userns-tests-fix
Fix tests using user namespaces on kernels that don't have it
Diffstat (limited to 'tests/common.sh.in')
-rw-r--r-- | tests/common.sh.in | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/common.sh.in b/tests/common.sh.in index 83643d8b06bb..186f9d6b9553 100644 --- a/tests/common.sh.in +++ b/tests/common.sh.in @@ -87,6 +87,24 @@ killDaemon() { trap "" EXIT } +canUseSandbox() { + if [[ $(uname) != Linux ]]; then return 1; fi + + if [ ! -L /proc/self/ns/user ]; then + echo "Kernel doesn't support user namespaces, skipping this test..." + return 1 + fi + + if [ -e /proc/sys/kernel/unprivileged_userns_clone ]; then + if [ "$(cat /proc/sys/kernel/unprivileged_userns_clone)" != 1 ]; then + echo "Unprivileged user namespaces disabled by sysctl, skipping this test..." + return 1 + fi + fi + + return 0 +} + fail() { echo "$1" exit 1 |