]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
conf: simplify write_id_mapping() 2337/head
authorChristian Brauner <christian.brauner@ubuntu.com>
Sat, 19 May 2018 20:51:29 +0000 (22:51 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Sat, 19 May 2018 20:51:29 +0000 (22:51 +0200)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/conf.c

index 0d7152b711e85b5a15bd1f4a4bfc3456e58e009a..960711514d902929778714ad934a095d39243197 100644 (file)
@@ -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;
 }