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.
This commit is contained in:
Lennart Poettering
2016-04-25 12:16:02 +02:00
parent d2e5535f9d
commit ccabee0d64
3 changed files with 16 additions and 6 deletions
+5
View File
@@ -21,6 +21,7 @@
#include <stdbool.h>
#include <sys/types.h>
#include <unistd.h>
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;
}