From: Christian Brauner Date: Fri, 8 Feb 2019 14:11:46 +0000 (+0100) Subject: caps: check uid and euid X-Git-Tag: lxc-3.2.0~160^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=df9bf8ca39fe1c0866f5aa4c53004afd2e14f46b;p=thirdparty%2Flxc.git caps: check uid and euid When we are running inside of a user namespace getuid() will return a non-zero uid. So let's check euid as well to make sure we correctly drop capabilities Signed-off-by: Christian Brauner --- diff --git a/src/lxc/caps.c b/src/lxc/caps.c index 86baee261..1a6211a48 100644 --- a/src/lxc/caps.c +++ b/src/lxc/caps.c @@ -136,8 +136,7 @@ int lxc_ambient_caps_up(void) int last_cap = CAP_LAST_CAP; char *cap_names = NULL; - /* When we are root, we don't want to play with capabilities. */ - if (!getuid()) + if (!getuid() || geteuid()) return 0; caps = cap_get_proc(); @@ -204,8 +203,7 @@ int lxc_ambient_caps_down(void) cap_t caps; cap_value_t cap; - /* When we are root, we don't want to play with capabilities. */ - if (!getuid()) + if (!getuid() || geteuid()) return 0; ret = prctl(PR_CAP_AMBIENT, prctl_arg(PR_CAP_AMBIENT_CLEAR_ALL),