From: Christian Brauner Date: Sat, 19 May 2018 20:51:29 +0000 (+0200) Subject: conf: simplify write_id_mapping() X-Git-Tag: lxc-3.1.0~298^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F2337%2Fhead;p=thirdparty%2Flxc.git conf: simplify write_id_mapping() Signed-off-by: Christian Brauner --- diff --git a/src/lxc/conf.c b/src/lxc/conf.c index 0d7152b71..960711514 100644 --- a/src/lxc/conf.c +++ b/src/lxc/conf.c @@ -2702,13 +2702,13 @@ int write_id_mapping(enum idtype idtype, pid_t pid, const char *buf, buflen = sizeof("deny\n") - 1; errno = 0; ret = lxc_write_nointr(fd, "deny\n", buflen); + close(fd); if (ret != buflen) { SYSERROR("Failed to write \"deny\" to " "\"/proc/%d/setgroups\"", pid); - close(fd); return -1; } - close(fd); + TRACE("Wrote \"deny\" to \"/proc/%d/setgroups\"", pid); } } @@ -2725,13 +2725,12 @@ int write_id_mapping(enum idtype idtype, pid_t pid, const char *buf, errno = 0; ret = lxc_write_nointr(fd, buf, buf_size); + close(fd); if (ret != buf_size) { SYSERROR("Failed to write %cid mapping to \"%s\"", idtype == ID_TYPE_UID ? 'u' : 'g', path); - close(fd); return -1; } - close(fd); return 0; }