]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
fix lxc.mount.auto clearing
authorSerge Hallyn <serge.hallyn@ubuntu.com>
Thu, 9 Oct 2014 15:54:51 +0000 (10:54 -0500)
committerSerge Hallyn <serge.hallyn@ubuntu.com>
Thu, 9 Oct 2014 17:31:46 +0000 (12:31 -0500)
the way config_mount was structured, sending 'lxc.mount.auto = '
ended up actually clearing all lxc.mount.entrys.  Fix that by
moving the check for an empty value to after the subkey checks.
Then, actually do the clearing of auto_mounts in config_mount_auto.

The 'strlen(subkey)' check being removed was bogus - the subkey
either known to be 'lxc.mount.entry', else subkey would have been
NULL (and forced a return in the block above).

This would have been clearer if the config_mount() and helper
fns were structured like the rest of confile.c.  It's tempting
to switch it over, but there are subtleties in there so it's
not something to do without a lot of thought and testing.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
src/lxc/confile.c

index 0722a37ead0b930e365649f946381bd62001f0a3..09eb94dbc6963de5f10212bc7c45c7b715d0900e 100644 (file)
@@ -1403,6 +1403,8 @@ out:
 static int config_fstab(const char *key, const char *value,
                        struct lxc_conf *lxc_conf)
 {
+       if (!value || strlen(value) == 0)
+               return -1;
        return config_path_item(&lxc_conf->fstab, value);
 }
 
@@ -1434,8 +1436,10 @@ static int config_mount_auto(const char *key, const char *value,
        int i;
        int ret = -1;
 
-       if (!strlen(value))
-               return -1;
+       if (!value || strlen(value) == 0) {
+               lxc_conf->auto_mounts = 0;
+               return 0;
+       }
 
        autos = strdup(value);
        if (!autos) {
@@ -1469,6 +1473,12 @@ static int config_mount_auto(const char *key, const char *value,
        return ret;
 }
 
+/*
+ * TODO
+ * This fn is handling lxc.mount, lxc.mount.entry, and lxc.mount.auto.
+ * It should probably be split into 3 separate functions indexed by
+ * the config[] entries at top.
+ */
 static int config_mount(const char *key, const char *value,
                        struct lxc_conf *lxc_conf)
 {
@@ -1479,9 +1489,6 @@ static int config_mount(const char *key, const char *value,
        char *mntelem;
        struct lxc_list *mntlist;
 
-       if (!value || strlen(value) == 0)
-               return lxc_clear_mount_entries(lxc_conf);
-
        subkey = strstr(key, token);
 
        if (!subkey) {
@@ -1499,8 +1506,9 @@ static int config_mount(const char *key, const char *value,
                return config_mount_auto(key, value, lxc_conf);
        }
 
-       if (!strlen(subkey))
-               return -1;
+       /* At this point we definately have key = lxc.mount.entry */
+       if (!value || strlen(value) == 0)
+               return lxc_clear_mount_entries(lxc_conf);
 
        mntlist = malloc(sizeof(*mntlist));
        if (!mntlist)