Skip to content

Commit

Permalink
confile: cleanup set_config_namespace_clone()
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
  • Loading branch information
Christian Brauner committed Dec 15, 2020
1 parent 40d3781 commit a349bb6
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions src/lxc/confile.c
Expand Up @@ -2514,34 +2514,28 @@ static int set_config_uts_name(const char *key, const char *value,
static int set_config_namespace_clone(const char *key, const char *value,
struct lxc_conf *lxc_conf, void *data)
{
char *ns, *token;
__do_free char *ns = NULL;
char *token;
int cloneflag = 0;

if (lxc_config_value_empty(value))
return clr_config_namespace_clone(key, lxc_conf, data);

if (lxc_conf->ns_keep != 0) {
errno = EINVAL;
SYSERROR("Cannot set both \"lxc.namespace.clone\" and "
"\"lxc.namespace.keep\"");
return -EINVAL;
}
if (lxc_conf->ns_keep != 0)
return log_error_errno(-EINVAL, EINVAL, "Cannot set both \"lxc.namespace.clone\" and \"lxc.namespace.keep\"");

ns = strdup(value);
if (!ns)
return -1;
return ret_errno(ENOMEM);

lxc_iterate_parts(token, ns, " \t") {
token += lxc_char_left_gc(token, strlen(token));
token[lxc_char_right_gc(token, strlen(token))] = '\0';
cloneflag = lxc_namespace_2_cloneflag(token);
if (cloneflag < 0) {
free(ns);
return -EINVAL;
}
if (cloneflag < 0)
return ret_errno(EINVAL);
lxc_conf->ns_clone |= cloneflag;
}
free(ns);

return 0;
}
Expand Down

0 comments on commit a349bb6

Please sign in to comment.