]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
conf: cleanup macros suggest_default_idmap
authorChristian Brauner <christian.brauner@ubuntu.com>
Tue, 19 Feb 2019 22:49:14 +0000 (23:49 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Tue, 19 Feb 2019 22:50:25 +0000 (23:50 +0100)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/conf.c

index f089679bab4b5d1f8f537b417420fa9c0ce002be..14f8f963e37795334739f10593482ccfa7f6677e 100644 (file)
@@ -4655,27 +4655,22 @@ static char *getgname(void)
 /* not thread-safe, do not use from api without first forking */
 void suggest_default_idmap(void)
 {
-       char *uname, *gname;
+       __do_free char *gname = NULL, *line = NULL, *uname = NULL;
        FILE *f;
        unsigned int uid = 0, urange = 0, gid = 0, grange = 0;
        size_t len = 0;
-       char *line = NULL;
 
        uname = getuname();
        if (!uname)
                return;
 
        gname = getgname();
-       if (!gname) {
-               free(uname);
+       if (!gname)
                return;
-       }
 
        f = fopen(subuidfile, "r");
        if (!f) {
                ERROR("Your system is not configured with subuids");
-               free(gname);
-               free(uname);
                return;
        }
 
@@ -4714,8 +4709,6 @@ void suggest_default_idmap(void)
        f = fopen(subgidfile, "r");
        if (!f) {
                ERROR("Your system is not configured with subgids");
-               free(gname);
-               free(uname);
                return;
        }
 
@@ -4751,13 +4744,9 @@ void suggest_default_idmap(void)
        }
        fclose(f);
 
-       free(line);
-
        if (!urange || !grange) {
                ERROR("You do not have subuids or subgids allocated");
                ERROR("Unprivileged containers require subuids and subgids");
-               free(uname);
-               free(gname);
                return;
        }
 
@@ -4767,9 +4756,6 @@ void suggest_default_idmap(void)
        ERROR("lxc.include = %s", LXC_DEFAULT_CONFIG);
        ERROR("lxc.idmap = u 0 %u %u", uid, urange);
        ERROR("lxc.idmap = g 0 %u %u", gid, grange);
-
-       free(gname);
-       free(uname);
 }
 
 static void free_cgroup_settings(struct lxc_list *result)