conf: cleanup macros suggest_default_idmap

parent 640dfcdc
...@@ -4547,7 +4547,7 @@ static char *getgname(void) ...@@ -4547,7 +4547,7 @@ static char *getgname(void)
void suggest_default_idmap(void) void suggest_default_idmap(void)
{ {
__do_free char *gname = NULL, *line = NULL, *uname = NULL; __do_free char *gname = NULL, *line = NULL, *uname = NULL;
FILE *f; __do_fclose FILE *subuid_f = NULL, *subgid_f = NULL;
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;
...@@ -4559,13 +4559,13 @@ void suggest_default_idmap(void) ...@@ -4559,13 +4559,13 @@ void suggest_default_idmap(void)
if (!gname) if (!gname)
return; return;
f = fopen(subuidfile, "r"); subuid_f = fopen(subuidfile, "r");
if (!f) { if (!subuid_f) {
ERROR("Your system is not configured with subuids"); ERROR("Your system is not configured with subuids");
return; return;
} }
while (getline(&line, &len, f) != -1) { while (getline(&line, &len, subuid_f) != -1) {
char *p, *p2; char *p, *p2;
size_t no_newline = 0; size_t no_newline = 0;
...@@ -4595,15 +4595,14 @@ void suggest_default_idmap(void) ...@@ -4595,15 +4595,14 @@ void suggest_default_idmap(void)
if (lxc_safe_uint(p2, &urange) < 0) if (lxc_safe_uint(p2, &urange) < 0)
WARN("Could not parse UID range"); WARN("Could not parse UID range");
} }
fclose(f);
f = fopen(subgidfile, "r"); subgid_f = fopen(subgidfile, "r");
if (!f) { if (!subgid_f) {
ERROR("Your system is not configured with subgids"); ERROR("Your system is not configured with subgids");
return; return;
} }
while (getline(&line, &len, f) != -1) { while (getline(&line, &len, subgid_f) != -1) {
char *p, *p2; char *p, *p2;
size_t no_newline = 0; size_t no_newline = 0;
...@@ -4633,7 +4632,6 @@ void suggest_default_idmap(void) ...@@ -4633,7 +4632,6 @@ void suggest_default_idmap(void)
if (lxc_safe_uint(p2, &grange) < 0) if (lxc_safe_uint(p2, &grange) < 0)
WARN("Could not parse GID range"); WARN("Could not parse GID range");
} }
fclose(f);
if (!urange || !grange) { if (!urange || !grange) {
ERROR("You do not have subuids or subgids allocated"); ERROR("You do not have subuids or subgids allocated");
......
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