From 15977278148c621d123b3ed876181bd933ebb221 Mon Sep 17 00:00:00 2001 From: Juan RP Date: Mon, 9 Mar 2015 12:34:57 +0100 Subject: [PATCH] xbps-uunshare: do not fail if /proc/self/setgroups does not exist. 3.16 supports user_namespaces(7) but does not have /proc/self/setgroups. Found by @cheneukirchen. --- NEWS | 3 +++ bin/xbps-uunshare/main.c | 11 +++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/NEWS b/NEWS index 1758510b..40275547 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,8 @@ xbps-0.44.1 (???): + * xbps-uunshare(8): do not fail if we cannot disable setgroups; some kernels + might not support it. Found by @cheneukirchen on 3.16. + * xbps-reconfigure(8): added -i/--ignore to usage(), by Christian Neukirchen. * Updated zsh completions, by Christian Neukirchen. diff --git a/bin/xbps-uunshare/main.c b/bin/xbps-uunshare/main.c index c964c373..f2523eae 100644 --- a/bin/xbps-uunshare/main.c +++ b/bin/xbps-uunshare/main.c @@ -147,12 +147,11 @@ main(int argc, char **argv) close(fd); - if ((fd = open("/proc/self/setgroups", O_RDWR)) == -1) - die("failed to open /proc/self/setgroups rw"); - if (write(fd, "deny", 4) == -1) - die("failed to write to /proc/self/setgroups"); - - close(fd); + if ((fd = open("/proc/self/setgroups", O_RDWR)) == 0) { + if (write(fd, "deny", 4) == -1) + die("failed to write to /proc/self/setgroups"); + close(fd); + } if ((fd = open("/proc/self/gid_map", O_RDWR)) == -1) die("failed to open /proc/self/gid_map rw");