From: Serge Hallyn Date: Thu, 8 Feb 2018 18:06:39 +0000 (-0600) Subject: define am_guest_unpriv X-Git-Tag: lxc-2.0.10~344 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dcc035de84379d4b701adf8127325c32ee1d6ef8;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 9c01c5d3a..260738d85 100644 --- a/src/lxc/utils.h +++ b/src/lxc/utils.h @@ -423,9 +423,15 @@ extern void *lxc_strmmap(void *addr, size_t length, int prot, int flags, int fd, /* munmap() wrapper. Use it to free memory mmap()ed with lxc_strmmap(). */ extern int lxc_strmunmap(void *addr, size_t length); -//initialize rand with urandom +/* 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_unpriv(void) { FILE *f;