From 477aa378e9050ed5d7de22b6ff05a83f38824036 Mon Sep 17 00:00:00 2001 From: Serge Hallyn Date: Thu, 8 Feb 2018 12:06:39 -0600 Subject: [PATCH] define am_guest_unpriv Sometimes we want to know whether we are privileged wrt our namespaces, and sometimes we want to know whether we are priv wrt init_user_ns. Signed-off-by: Serge Hallyn --- src/lxc/utils.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/lxc/utils.h b/src/lxc/utils.h index 4d129d137..048995475 100644 --- a/src/lxc/utils.h +++ b/src/lxc/utils.h @@ -435,6 +435,12 @@ extern int lxc_strmunmap(void *addr, size_t length); /* initialize rand with urandom */ extern int randseed(bool); +/* are we unprivileged with respect to our namespaces */ +inline static bool am_guest_unpriv(void) { + return geteuid() != 0; +} + +/* are we unprivileged with respect to init_user_ns */ inline static bool am_host_unpriv(void) { FILE *f; -- 2.47.2