]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
define am_guest_unpriv
authorSerge Hallyn <shallyn@cisco.com>
Thu, 8 Feb 2018 18:06:39 +0000 (12:06 -0600)
committerChristian Brauner <christian.brauner@ubuntu.com>
Mon, 12 Feb 2018 16:05:30 +0000 (17:05 +0100)
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 <shallyn@cisco.com>
src/lxc/utils.h

index 9c01c5d3a429d7f0f0db85f7c778cb2da4bff07f..260738d85261a0ed9e26930b3d042b523e07366f 100644 (file)
@@ -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;