conf: cleanup macros suggest_default_idmap

parent 4f410b2a
...@@ -4655,27 +4655,22 @@ static char *getgname(void) ...@@ -4655,27 +4655,22 @@ static char *getgname(void)
/* not thread-safe, do not use from api without first forking */ /* not thread-safe, do not use from api without first forking */
void suggest_default_idmap(void) void suggest_default_idmap(void)
{ {
char *uname, *gname; __do_free char *gname = NULL, *line = NULL, *uname = NULL;
FILE *f; FILE *f;
unsigned int uid = 0, urange = 0, gid = 0, grange = 0; unsigned int uid = 0, urange = 0, gid = 0, grange = 0;
size_t len = 0; size_t len = 0;
char *line = NULL;
uname = getuname(); uname = getuname();
if (!uname) if (!uname)
return; return;
gname = getgname(); gname = getgname();
if (!gname) { if (!gname)
free(uname);
return; return;
}
f = fopen(subuidfile, "r"); f = fopen(subuidfile, "r");
if (!f) { if (!f) {
ERROR("Your system is not configured with subuids"); ERROR("Your system is not configured with subuids");
free(gname);
free(uname);
return; return;
} }
...@@ -4714,8 +4709,6 @@ void suggest_default_idmap(void) ...@@ -4714,8 +4709,6 @@ void suggest_default_idmap(void)
f = fopen(subgidfile, "r"); f = fopen(subgidfile, "r");
if (!f) { if (!f) {
ERROR("Your system is not configured with subgids"); ERROR("Your system is not configured with subgids");
free(gname);
free(uname);
return; return;
} }
...@@ -4751,13 +4744,9 @@ void suggest_default_idmap(void) ...@@ -4751,13 +4744,9 @@ void suggest_default_idmap(void)
} }
fclose(f); fclose(f);
free(line);
if (!urange || !grange) { if (!urange || !grange) {
ERROR("You do not have subuids or subgids allocated"); ERROR("You do not have subuids or subgids allocated");
ERROR("Unprivileged containers require subuids and subgids"); ERROR("Unprivileged containers require subuids and subgids");
free(uname);
free(gname);
return; return;
} }
...@@ -4767,9 +4756,6 @@ void suggest_default_idmap(void) ...@@ -4767,9 +4756,6 @@ void suggest_default_idmap(void)
ERROR("lxc.include = %s", LXC_DEFAULT_CONFIG); ERROR("lxc.include = %s", LXC_DEFAULT_CONFIG);
ERROR("lxc.idmap = u 0 %u %u", uid, urange); ERROR("lxc.idmap = u 0 %u %u", uid, urange);
ERROR("lxc.idmap = g 0 %u %u", gid, grange); ERROR("lxc.idmap = g 0 %u %u", gid, grange);
free(gname);
free(uname);
} }
static void free_cgroup_settings(struct lxc_list *result) static void free_cgroup_settings(struct lxc_list *result)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment