]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
conf: port apparmor to new list type
authorChristian Brauner <christian.brauner@ubuntu.com>
Fri, 27 Aug 2021 12:51:01 +0000 (14:51 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Fri, 27 Aug 2021 12:52:18 +0000 (14:52 +0200)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/conf.c
src/lxc/conf.h
src/lxc/confile.c
src/lxc/lsm/apparmor.c

index 5937b0c76209fdaf862223170af406c0afd37cf5..dc14708cd73d5a9dc77646becc7ea9828b5a8611 100644 (file)
@@ -3378,7 +3378,7 @@ struct lxc_conf *lxc_conf_init(void)
        lxc_list_init(&new->groups);
        INIT_LIST_HEAD(&new->state_clients);
        new->lsm_aa_profile = NULL;
-       lxc_list_init(&new->lsm_aa_raw);
+       INIT_LIST_HEAD(&new->lsm_aa_raw);
        new->lsm_se_context = NULL;
        new->lsm_se_keyring_context = NULL;
        new->keyring_disable_session = false;
@@ -4716,15 +4716,15 @@ int lxc_clear_hooks(struct lxc_conf *c, const char *key)
 
 int lxc_clear_apparmor_raw(struct lxc_conf *c)
 {
-       struct lxc_list *it, *next;
+       struct string_entry *entry, *nentry;
 
-       lxc_list_for_each_safe (it, &c->lsm_aa_raw, next) {
-               lxc_list_del(it);
-               free(it->elem);
-               free(it);
+       list_for_each_entry_safe(entry, nentry, &c->lsm_aa_raw, head) {
+               list_del(&entry->head);
+               free(entry->val);
+               free(entry);
        }
 
-       lxc_list_init(&c->lsm_aa_raw);
+       INIT_LIST_HEAD(&c->lsm_aa_raw);
        return 0;
 }
 
index 53075b3f8c351125f98c0e81caec9ca87a5a66c1..af5de4dc24171c6a054b866f245bde288d72954f 100644 (file)
@@ -424,7 +424,7 @@ struct lxc_conf {
        bool lsm_aa_profile_created;
        unsigned int lsm_aa_allow_nesting;
        unsigned int lsm_aa_allow_incomplete;
-       struct lxc_list lsm_aa_raw;
+       struct list_head lsm_aa_raw;
        char *lsm_se_context;
        char *lsm_se_keyring_context;
        bool keyring_disable_session;
index 03bdef07793e7cab46ae20a33333fcbbfe76041f..c2f9a0bc2e1d003fad829248bd54cfa874be3ce2 100644 (file)
@@ -1642,21 +1642,22 @@ static int set_config_apparmor_raw(const char *key,
 {
 #if HAVE_APPARMOR
        __do_free char *elem = NULL;
-       __do_free struct lxc_list *list = NULL;
+       __do_free struct string_entry *entry = NULL;
 
        if (lxc_config_value_empty(value))
                return lxc_clear_apparmor_raw(lxc_conf);
 
-       list = lxc_list_new();
-       if (!list)
+       entry = zalloc(sizeof(struct string_entry));
+       if (!entry)
                return ret_errno(ENOMEM);
 
        elem = strdup(value);
        if (!elem)
                return ret_errno(ENOMEM);
 
-       list->elem = move_ptr(elem);
-       lxc_list_add_tail(&lxc_conf->lsm_aa_raw, move_ptr(list));
+       entry->val = move_ptr(elem);
+       list_add_tail(&entry->head, &lxc_conf->lsm_aa_raw);
+       move_ptr(entry);
 
        return 0;
 #else
@@ -3774,7 +3775,7 @@ static int get_config_apparmor_raw(const char *key, char *retv,
 {
 #if HAVE_APPARMOR
        int len;
-       struct lxc_list *it;
+       struct string_entry *entry;
        int fulllen = 0;
 
        if (!retv)
@@ -3782,8 +3783,8 @@ static int get_config_apparmor_raw(const char *key, char *retv,
        else
                memset(retv, 0, inlen);
 
-       lxc_list_for_each(it, &c->lsm_aa_raw) {
-               strprint(retv, inlen, "%s\n", (char *)it->elem);
+       list_for_each_entry(entry, &c->lsm_aa_raw, head) {
+               strprint(retv, inlen, "%s\n", entry->val);
        }
 
        return fulllen;
index 63d122591e16bb8e9d0c2b71f81d002e2b2bef70..0667526d41e4a033a48eed1993573bdf610be78a 100644 (file)
@@ -755,7 +755,7 @@ static char *get_apparmor_profile_content(struct lsm_ops *ops, struct lxc_conf *
 {
        char *profile, *profile_name_full;
        size_t size;
-       struct lxc_list *it;
+       struct string_entry *rule;
 
        profile_name_full = apparmor_profile_full(conf->name, lxcpath);
 
@@ -815,8 +815,8 @@ static char *get_apparmor_profile_content(struct lsm_ops *ops, struct lxc_conf *
                must_append_sized(&profile, &size, AA_PROFILE_UNPRIVILEGED,
                                  STRARRAYLEN(AA_PROFILE_UNPRIVILEGED));
 
-       lxc_list_for_each(it, &conf->lsm_aa_raw) {
-               const char *line = it->elem;
+       list_for_each_entry(rule, &conf->lsm_aa_raw, head) {
+               const char *line = rule->val;
 
                must_append_sized_full(&profile, &size, line, strlen(line), true);
        }