Skip to content

Commit

Permalink
confile: cleanup set_config_cap_keep()
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 8, 2020
1 parent 48c367c commit bd7c537
Showing 1 changed file with 9 additions and 16 deletions.
25 changes: 9 additions & 16 deletions src/lxc/confile.c
Expand Up @@ -2235,16 +2235,16 @@ int add_elem_to_mount_list(const char *value, struct lxc_conf *lxc_conf) {
static int set_config_cap_keep(const char *key, const char *value,
struct lxc_conf *lxc_conf, void *data)
{
char *keepcaps, *token;
struct lxc_list *keeplist;
int ret = -1;
__do_free char *keepcaps = NULL;
__do_free struct lxc_list *keeplist = NULL;
char *token;

if (lxc_config_value_empty(value))
return lxc_clear_config_keepcaps(lxc_conf);

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

/* In case several capability keep is specified in a single line
* split these caps in a single element for the list.
Expand All @@ -2255,23 +2255,16 @@ static int set_config_cap_keep(const char *key, const char *value,

keeplist = malloc(sizeof(*keeplist));
if (!keeplist)
goto on_error;
return ret_errno(ENOMEM);

keeplist->elem = strdup(token);
if (!keeplist->elem) {
free(keeplist);
goto on_error;
}
if (!keeplist->elem)
return ret_errno(ENOMEM);

lxc_list_add_tail(&lxc_conf->keepcaps, keeplist);
lxc_list_add_tail(&lxc_conf->keepcaps, move_ptr(keeplist));
}

ret = 0;

on_error:
free(keepcaps);

return ret;
return 0;
}

static int set_config_cap_drop(const char *key, const char *value,
Expand Down

0 comments on commit bd7c537

Please sign in to comment.