summaryrefslogtreecommitdiff
path: root/src/basic/user-util.h
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2016-04-22 14:10:09 +0200
committerSven Eden <yamakuzure@gmx.net>2017-06-16 10:12:58 +0200
commit0cd13b4c1f6a68b1fe79409bf6c5b8fa9351e376 (patch)
treef293c1aab17395ada7df001ddc15883bcd0c4a04 /src/basic/user-util.h
parent39d737918769db8ef3901e813ecb4b74f0a507b0 (diff)
nspawn: make -U a tiny bit smarter
With this change -U will turn on user namespacing only if the kernel actually supports it and otherwise gracefully degrade to non-userns mode.
Diffstat (limited to 'src/basic/user-util.h')
-rw-r--r--src/basic/user-util.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/basic/user-util.h b/src/basic/user-util.h
index 8e652584d..d010b2bf5 100644
--- a/src/basic/user-util.h
+++ b/src/basic/user-util.h
@@ -21,6 +21,7 @@
#include <stdbool.h>
#include <sys/types.h>
+#include <unistd.h>
bool uid_is_valid(uid_t uid);
@@ -69,3 +70,7 @@ int take_etc_passwd_lock(const char *root);
#define PTR_TO_GID(p) ((gid_t) (((uintptr_t) (p))-1))
#define GID_TO_PTR(u) ((void*) (((uintptr_t) (u))+1))
+
+static inline bool userns_supported(void) {
+ return access("/proc/self/uid_map", F_OK) >= 0;
+}