From ccabee0d6465f06b9d339cf449fd8eea0db13373 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 22 Apr 2016 14:10:09 +0200 Subject: 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. --- src/basic/user-util.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/basic') diff --git a/src/basic/user-util.h b/src/basic/user-util.h index c23f1d485d..8026eca3f4 100644 --- a/src/basic/user-util.h +++ b/src/basic/user-util.h @@ -21,6 +21,7 @@ #include #include +#include bool uid_is_valid(uid_t uid); @@ -63,3 +64,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; +} -- cgit v1.2.3-54-g00ecf