From: Serge Hallyn Date: Thu, 8 Feb 2018 18:06:39 +0000 (-0600) Subject: define am_guest_unpriv X-Git-Tag: lxc-3.0.0.beta1~43^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=477aa378e9050ed5d7de22b6ff05a83f38824036;p=thirdparty%2Flxc.git 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 --- 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;