]> git.proxmox.com Git - mirror_lxc.git/blobdiff - src/tests/parse_config_file.c
tests: use busybox in lxc-test-unpriv
[mirror_lxc.git] / src / tests / parse_config_file.c
index f6fda5a05d47ed52930b10a44f5a9a11b0011096..8b5b1b0d295079f636067b8cb0d40554c65f218b 100644 (file)
 #include <unistd.h>
 #include <libgen.h>
 
+#include "conf.h"
 #include "confile_utils.h"
 #include "lxc/state.h"
 #include "lxctest.h"
+#include "utils.h"
 
 static int set_get_compare_clear_save_load(struct lxc_container *c,
                                           const char *key, const char *value,
@@ -106,6 +108,16 @@ static int set_and_clear_complete_netdev(struct lxc_container *c)
                return -1;
        }
 
+       if (!c->set_config_item(c, "lxc.net.1.ipv4.gateway", "auto")) {
+               lxc_error("%s\n", "lxc.net.1.ipv4.gateway");
+               return -1;
+       }
+
+       if (!c->set_config_item(c, "lxc.net.1.ipv4.gateway", "dev")) {
+               lxc_error("%s\n", "lxc.net.1.ipv4.gateway");
+               return -1;
+       }
+
        if (!c->set_config_item(c, "lxc.net.1.ipv6.address",
                                "2003:db8:1:0:214:1234:fe0b:3596/64")) {
                lxc_error("%s\n", "lxc.net.1.ipv6.address");
@@ -118,6 +130,16 @@ static int set_and_clear_complete_netdev(struct lxc_container *c)
                return -1;
        }
 
+       if (!c->set_config_item(c, "lxc.net.1.ipv6.gateway", "auto")) {
+               lxc_error("%s\n", "lxc.net.1.ipv6.gateway");
+               return -1;
+       }
+
+       if (!c->set_config_item(c, "lxc.net.1.ipv6.gateway", "dev")) {
+               lxc_error("%s\n", "lxc.net.1.ipv6.gateway");
+               return -1;
+       }
+
        if (!c->set_config_item(c, "lxc.net.1.flags", "up")) {
                lxc_error("%s\n", "lxc.net.1.flags");
                return -1;
@@ -133,6 +155,16 @@ static int set_and_clear_complete_netdev(struct lxc_container *c)
                return -1;
        }
 
+       if (!c->set_config_item(c, "lxc.net.1.veth.ipv4.route", "192.0.2.1/32")) {
+               lxc_error("%s\n", "lxc.net.1.veth.ipv4.route");
+               return -1;
+       }
+
+       if (!c->set_config_item(c, "lxc.net.1.veth.ipv6.route", "2001:db8::1/128")) {
+               lxc_error("%s\n", "lxc.net.1.veth.ipv6.route");
+               return -1;
+       }
+
        if (!c->set_config_item(c, "lxc.net.1.hwaddr",
                                "52:54:00:80:7a:5d")) {
                lxc_error("%s\n", "lxc.net.1.hwaddr");
@@ -171,11 +203,6 @@ static int set_invalid_netdev(struct lxc_container *c) {
                return -1;
        }
 
-       if (c->set_config_item(c, "lxc.network.0.", "veth")) {
-               lxc_error("%s\n", "lxc.network.0. should be invalid");
-               return -1;
-       }
-
        c->clear_config(c);
        c->lxc_conf = NULL;
 
@@ -301,16 +328,16 @@ static int set_get_compare_clear_save_load_network(
 
 int main(int argc, char *argv[])
 {
+       int ret;
        struct lxc_container *c;
-       int fd = -1;
-       int ret = EXIT_FAILURE;
+       int fd = -1, fret = EXIT_FAILURE;
        char tmpf[] = "lxc-parse-config-file-XXXXXX";
        char retval[4096] = {0};
 
-       fd = mkstemp(tmpf);
+       fd = lxc_make_tmpfile(tmpf, false);
        if (fd < 0) {
                lxc_error("%s\n", "Could not create temporary file");
-               exit(ret);
+               exit(fret);
        }
        close(fd);
 
@@ -320,129 +347,55 @@ int main(int argc, char *argv[])
                exit(EXIT_FAILURE);
        }
 
-       /* lxc.arch */
        if (set_get_compare_clear_save_load(c, "lxc.arch", "x86_64", tmpf,
                                            true) < 0) {
                lxc_error("%s\n", "lxc.arch");
                goto non_test_error;
        }
 
-       /* REMOVE IN LXC 3.0
-          legacy ps keys
-        */
-       if (set_get_compare_clear_save_load(c, "lxc.pts", "1000", tmpf, true) <
-           0) {
-               lxc_error("%s\n", "lxc.pts");
-               goto non_test_error;
-       }
-
-       /* lxc.pty.max */
-       if (set_get_compare_clear_save_load(c, "lxc.pty.max", "1000", tmpf, true) <
-           0) {
+       if (set_get_compare_clear_save_load(c, "lxc.pty.max", "1000", tmpf, true) < 0) {
                lxc_error("%s\n", "lxc.pty.max");
                goto non_test_error;
        }
 
-       /* REMOVE IN LXC 3.0
-          legacy tty.max keys
-        */
-       if (set_get_compare_clear_save_load(c, "lxc.tty", "4", tmpf, true) <
-           0) {
-               lxc_error("%s\n", "lxc.tty");
-               goto non_test_error;
-       }
-
-       /* lxc.tty.max */
-       if (set_get_compare_clear_save_load(c, "lxc.tty.max", "4", tmpf, true) <
-           0) {
+       if (set_get_compare_clear_save_load(c, "lxc.tty.max", "4", tmpf, true) < 0) {
                lxc_error("%s\n", "lxc.tty.max");
                goto non_test_error;
        }
 
-       /* REMOVE IN LXC 3.0
-          legacy devttydir keys
-        */
-       if (set_get_compare_clear_save_load(c, "lxc.devttydir", "not-dev", tmpf,
-                                           true) < 0) {
-               lxc_error("%s\n", "lxc.devttydir");
-               goto non_test_error;
-       }
-
-       /* lxc.tty.dir */
-       if (set_get_compare_clear_save_load(c, "lxc.tty.dir", "not-dev", tmpf,
-                                           true) < 0) {
+       if (set_get_compare_clear_save_load(c, "lxc.tty.dir", "not-dev", tmpf, true) < 0) {
                lxc_error("%s\n", "lxc.tty.dir");
                goto non_test_error;
        }
 
-       /* REMOVE IN LXC 3.0
-          legacy security keys
-        */
-       if (set_get_compare_clear_save_load(c, "lxc.aa_profile", "unconfined",
-                                           tmpf, true) < 0) {
-               lxc_error("%s\n", "lxc.aa_profile");
-               goto non_test_error;
-       }
-
-       /* REMOVE IN LXC 3.0
-          legacy security keys
-        */
-       if (set_get_compare_clear_save_load(c, "lxc.aa_allow_incomplete", "1",
-                                           tmpf, true) < 0) {
-               lxc_error("%s\n", "lxc.aa_allow_incomplete");
-               goto non_test_error;
-       }
-
-       /* REMOVE IN LXC 3.0
-          legacy security keys
-        */
-       if (set_get_compare_clear_save_load(c, "lxc.se_context", "system_u:system_r:lxc_t:s0:c22",
-                                           tmpf, true) < 0) {
-               lxc_error("%s\n", "lxc.se_context");
-               goto non_test_error;
-       }
-
-       /* lxc.apparmor.profile */
-       if (set_get_compare_clear_save_load(c, "lxc.apparmor.profile", "unconfined",
-                                           tmpf, true) < 0) {
+       if (set_get_compare_clear_save_load(c, "lxc.apparmor.profile", "unconfined", tmpf, true) < 0) {
                lxc_error("%s\n", "lxc.apparmor.profile");
                goto non_test_error;
        }
 
-       /* lxc.apparmor.allow_incomplete */
-       if (set_get_compare_clear_save_load(c, "lxc.apparmor.allow_incomplete", "1",
-                                           tmpf, true) < 0) {
+       if (set_get_compare_clear_save_load(c, "lxc.apparmor.allow_incomplete", "1", tmpf, true) < 0) {
                lxc_error("%s\n", "lxc.apparmor.allow_incomplete");
                goto non_test_error;
        }
 
-       /* lxc.selinux.context */
-       if (set_get_compare_clear_save_load(c, "lxc.selinux.context", "system_u:system_r:lxc_t:s0:c22",
-                                           tmpf, true) < 0) {
+       if (set_get_compare_clear_save_load(c, "lxc.selinux.context", "system_u:system_r:lxc_t:s0:c22", tmpf, true) < 0) {
                lxc_error("%s\n", "lxc.selinux.context");
                goto non_test_error;
        }
 
-       /* lxc.cgroup.cpuset.cpus */
        if (set_get_compare_clear_save_load(c, "lxc.cgroup.cpuset.cpus",
                                            "1-100", tmpf, false) < 0) {
                lxc_error("%s\n", "lxc.cgroup.cpuset.cpus");
                goto non_test_error;
        }
 
-       /* lxc.cgroup */
        if (!c->set_config_item(c, "lxc.cgroup.cpuset.cpus", "1-100")) {
-               lxc_error("%s\n", "failed to set config item "
-                                 "\"lxc.cgroup.cpuset.cpus\" to \"1-100\"");
+               lxc_error("%s\n", "failed to set config item \"lxc.cgroup.cpuset.cpus\" to \"1-100\"");
                return -1;
        }
 
-       if (!c->set_config_item(c, "lxc.cgroup.memory.limit_in_bytes",
-                               "123456789")) {
-               lxc_error(
-                   "%s\n",
-                   "failed to set config item "
-                   "\"lxc.cgroup.memory.limit_in_bytes\" to \"123456789\"");
+       if (!c->set_config_item(c, "lxc.cgroup.memory.limit_in_bytes", "123456789")) {
+               lxc_error("%s\n", "failed to set config item \"lxc.cgroup.memory.limit_in_bytes\" to \"123456789\"");
                return -1;
        }
 
@@ -454,110 +407,45 @@ int main(int argc, char *argv[])
        c->clear_config(c);
        c->lxc_conf = NULL;
 
-       /* lxc.id_map
-        * We can't really save the config here since save_config() wants to
-        * chown the container's directory but we haven't created an on-disk
-        * container. So let's test set-get-clear.
-        */
-       if (set_get_compare_clear_save_load(
-               c, "lxc.id_map", "u 0 100000 1000000000", NULL, false) < 0) {
-               lxc_error("%s\n", "lxc.id_map");
-               goto non_test_error;
-       }
-
-       if (!c->set_config_item(c, "lxc.id_map", "u 1 100000 10000000")) {
-               lxc_error("%s\n", "failed to set config item "
-                                 "\"lxc.id_map\" to \"u 1 100000 10000000\"");
-               return -1;
-       }
-
-       if (!c->set_config_item(c, "lxc.id_map", "g 1 100000 10000000")) {
-               lxc_error("%s\n", "failed to set config item "
-                                 "\"lxc.id_map\" to \"g 1 100000 10000000\"");
-               return -1;
-       }
-
-       if (!c->get_config_item(c, "lxc.id_map", retval, sizeof(retval))) {
-               lxc_error("%s\n", "failed to get config item \"lxc.cgroup\"");
-               return -1;
-       }
-
        /* lxc.idmap
         * We can't really save the config here since save_config() wants to
         * chown the container's directory but we haven't created an on-disk
         * container. So let's test set-get-clear.
         */
-       if (set_get_compare_clear_save_load(
-               c, "lxc.idmap", "u 0 100000 1000000000", NULL, false) < 0) {
+       if (set_get_compare_clear_save_load(c, "lxc.idmap", "u 0 100000 1000000000", NULL, false) < 0) {
                lxc_error("%s\n", "lxc.idmap");
                goto non_test_error;
        }
 
        if (!c->set_config_item(c, "lxc.idmap", "u 1 100000 10000000")) {
-               lxc_error("%s\n", "failed to set config item "
-                                 "\"lxc.idmap\" to \"u 1 100000 10000000\"");
+               lxc_error("%s\n", "failed to set config item \"lxc.idmap\" to \"u 1 100000 10000000\"");
                return -1;
        }
 
        if (!c->set_config_item(c, "lxc.idmap", "g 1 100000 10000000")) {
-               lxc_error("%s\n", "failed to set config item "
-                                 "\"lxc.idmap\" to \"g 1 100000 10000000\"");
+               lxc_error("%s\n", "failed to set config item \"lxc.idmap\" to \"g 1 100000 10000000\"");
                return -1;
        }
 
        if (!c->get_config_item(c, "lxc.idmap", retval, sizeof(retval))) {
-               lxc_error("%s\n", "failed to get config item \"lxc.cgroup\"");
+               lxc_error("%s\n", "failed to get config item \"lxc.idmap\"");
                return -1;
        }
 
        c->clear_config(c);
        c->lxc_conf = NULL;
 
-       /* REMOVE IN LXC 3.0
-          legacy lxc.loglevel key
-        */
-       if (set_get_compare_clear_save_load(c, "lxc.loglevel", "DEBUG", tmpf,
-                                           true) < 0) {
-               lxc_error("%s\n", "lxc.loglevel");
-               goto non_test_error;
-       }
-
-       /* REMOVE IN LXC 3.0
-          legacy lxc.logfile key
-        */
-       if (set_get_compare_clear_save_load(c, "lxc.logfile", "/some/path",
-                                           tmpf, true) < 0) {
-               lxc_error("%s\n", "lxc.logfile");
-               goto non_test_error;
-       }
-
-
-       /* lxc.log.level */
-       if (set_get_compare_clear_save_load(c, "lxc.log.level", "DEBUG", tmpf,
-                                           true) < 0) {
+       if (set_get_compare_clear_save_load(c, "lxc.log.level", "DEBUG", tmpf, true) < 0) {
                lxc_error("%s\n", "lxc.log.level");
                goto non_test_error;
        }
 
-       /* lxc.log */
-       if (set_get_compare_clear_save_load(c, "lxc.log.file", "/some/path",
-                                           tmpf, true) < 0) {
+       if (set_get_compare_clear_save_load(c, "lxc.log.file", "/some/path", tmpf, true) < 0) {
                lxc_error("%s\n", "lxc.log.file");
                goto non_test_error;
        }
 
-       /* REMOVE IN LXC 3.0
-          legacy lxc.mount key
-        */
-       if (set_get_compare_clear_save_load(c, "lxc.mount", "/some/path", NULL,
-                                           true) < 0) {
-               lxc_error("%s\n", "lxc.mount");
-               goto non_test_error;
-       }
-
-       /* lxc.mount.fstab */
-       if (set_get_compare_clear_save_load(c, "lxc.mount.fstab", "/some/path", NULL,
-                                           true) < 0) {
+       if (set_get_compare_clear_save_load(c, "lxc.mount.fstab", "/some/path", NULL, true) < 0) {
                lxc_error("%s\n", "lxc.mount.fstab");
                goto non_test_error;
        }
@@ -566,9 +454,7 @@ int main(int argc, char *argv[])
         * Note that we cannot compare the values since the getter for
         * lxc.mount.auto does not preserve ordering.
         */
-       if (set_get_compare_clear_save_load(c, "lxc.mount.auto",
-                                           "proc:rw sys:rw cgroup-full:rw",
-                                           tmpf, false) < 0) {
+       if (set_get_compare_clear_save_load(c, "lxc.mount.auto", "proc:rw sys:rw cgroup-full:rw", tmpf, false) < 0) {
                lxc_error("%s\n", "lxc.mount.auto");
                goto non_test_error;
        }
@@ -577,377 +463,200 @@ int main(int argc, char *argv[])
         * Note that we cannot compare the values since the getter for
         * lxc.mount.entry appends newlines.
         */
-       if (set_get_compare_clear_save_load(
-               c, "lxc.mount.entry",
-               "/dev/dri dev/dri none bind,optional,create=dir", tmpf,
-               false) < 0) {
+       if (set_get_compare_clear_save_load(c, "lxc.mount.entry", "/dev/dri dev/dri none bind,optional,create=dir", tmpf, false) < 0) {
                lxc_error("%s\n", "lxc.mount.entry");
                goto non_test_error;
        }
 
-       /* REMOVE IN LXC 3.0
-          legacy lxc.rootfs key
-        */
-       if (set_get_compare_clear_save_load(c, "lxc.rootfs", "/some/path", tmpf,
-                                           true) < 0) {
-               lxc_error("%s\n", "lxc.rootfs");
-               goto non_test_error;
-       }
-
-       /* lxc.rootfs.path */
-       if (set_get_compare_clear_save_load(c, "lxc.rootfs.path", "/some/path", tmpf,
-                                           true) < 0) {
+       if (set_get_compare_clear_save_load(c, "lxc.rootfs.path", "/some/path", tmpf, true) < 0) {
                lxc_error("%s\n", "lxc.rootfs.path");
                goto non_test_error;
        }
 
-       /* lxc.rootfs.mount */
-       if (set_get_compare_clear_save_load(c, "lxc.rootfs.mount", "/some/path",
-                                           tmpf, true) < 0) {
+       if (set_get_compare_clear_save_load(c, "lxc.rootfs.mount", "/some/path", tmpf, true) < 0) {
                lxc_error("%s\n", "lxc.rootfs.mount");
                goto non_test_error;
        }
 
-       /* lxc.rootfs.options */
-       if (set_get_compare_clear_save_load(c, "lxc.rootfs.options",
-                                           "ext4,discard", tmpf, true) < 0) {
+       if (set_get_compare_clear_save_load(c, "lxc.rootfs.options", "ext4,discard", tmpf, true) < 0) {
                lxc_error("%s\n", "lxc.rootfs.options");
                goto non_test_error;
        }
 
-       /* REMOVE IN LXC 3.0
-          legacy lxc.utsname key
-        */
-       if (set_get_compare_clear_save_load(c, "lxc.utsname", "the-shire", tmpf,
-                                           true) < 0) {
-               lxc_error("%s\n", "lxc.utsname");
-               goto non_test_error;
-       }
-
-       /* lxc.uts.name */
-       if (set_get_compare_clear_save_load(c, "lxc.uts.name", "the-shire", tmpf,
-                                           true) < 0) {
+       if (set_get_compare_clear_save_load(c, "lxc.uts.name", "the-shire", tmpf, true) < 0) {
                lxc_error("%s\n", "lxc.uts.name");
                goto non_test_error;
        }
 
-       /* lxc.hook.pre-start */
        if (set_get_compare_clear_save_load(
                c, "lxc.hook.pre-start", "/some/pre-start", tmpf, false) < 0) {
                lxc_error("%s\n", "lxc.hook.pre-start");
                goto non_test_error;
        }
 
-       /* lxc.hook.pre-mount */
        if (set_get_compare_clear_save_load(
                c, "lxc.hook.pre-mount", "/some/pre-mount", tmpf, false) < 0) {
                lxc_error("%s\n", "lxc.hook.pre-mount");
                goto non_test_error;
        }
 
-       /* lxc.hook.mount */
-       if (set_get_compare_clear_save_load(c, "lxc.hook.mount", "/some/mount",
-                                           tmpf, false) < 0) {
+       if (set_get_compare_clear_save_load(c, "lxc.hook.mount", "/some/mount", tmpf, false) < 0) {
                lxc_error("%s\n", "lxc.hook.mount");
                goto non_test_error;
        }
 
-       /* lxc.hook.autodev */
-       if (set_get_compare_clear_save_load(c, "lxc.hook.autodev",
-                                           "/some/autodev", tmpf, false) < 0) {
+       if (set_get_compare_clear_save_load(c, "lxc.hook.autodev", "/some/autodev", tmpf, false) < 0) {
                lxc_error("%s\n", "lxc.hook.autodev");
                goto non_test_error;
        }
 
-       /* lxc.hook.start */
-       if (set_get_compare_clear_save_load(c, "lxc.hook.start", "/some/start",
-                                           tmpf, false) < 0) {
+       if (set_get_compare_clear_save_load(c, "lxc.hook.start", "/some/start", tmpf, false) < 0) {
                lxc_error("%s\n", "lxc.hook.start");
                goto non_test_error;
        }
 
-       /* lxc.hook.stop */
-       if (set_get_compare_clear_save_load(c, "lxc.hook.stop", "/some/stop",
-                                           tmpf, false) < 0) {
+       if (set_get_compare_clear_save_load(c, "lxc.hook.stop", "/some/stop", tmpf, false) < 0) {
                lxc_error("%s\n", "lxc.hook.stop");
                goto non_test_error;
        }
 
-       /* lxc.hook.post-stop */
-       if (set_get_compare_clear_save_load(
-               c, "lxc.hook.post-stop", "/some/post-stop", tmpf, false) < 0) {
+       if (set_get_compare_clear_save_load(c, "lxc.hook.post-stop", "/some/post-stop", tmpf, false) < 0) {
                lxc_error("%s\n", "lxc.hook.post-stop");
                goto non_test_error;
        }
 
-       /* lxc.hook.clone */
-       if (set_get_compare_clear_save_load(c, "lxc.hook.clone", "/some/clone",
-                                           tmpf, false) < 0) {
+       if (set_get_compare_clear_save_load(c, "lxc.hook.clone", "/some/clone", tmpf, false) < 0) {
                lxc_error("%s\n", "lxc.hook.clone");
                goto non_test_error;
        }
 
-       /* lxc.hook.destroy */
-       if (set_get_compare_clear_save_load(c, "lxc.hook.destroy",
-                                           "/some/destroy", tmpf, false) < 0) {
+       if (set_get_compare_clear_save_load(c, "lxc.hook.destroy", "/some/destroy", tmpf, false) < 0) {
                lxc_error("%s\n", "lxc.hook.destroy");
                goto non_test_error;
        }
 
-       /* lxc.cap.drop */
-       if (set_get_compare_clear_save_load(c, "lxc.cap.drop",
-                                           "sys_module mknod setuid net_raw",
-                                           tmpf, false) < 0) {
+       if (set_get_compare_clear_save_load(c, "lxc.cap.drop", "sys_module mknod setuid net_raw", tmpf, false) < 0) {
                lxc_error("%s\n", "lxc.cap.drop");
                goto non_test_error;
        }
 
-       /* lxc.cap.keep */
-       if (set_get_compare_clear_save_load(c, "lxc.cap.keep",
-                                           "sys_module mknod setuid net_raw",
-                                           tmpf, false) < 0) {
+       if (set_get_compare_clear_save_load(c, "lxc.cap.keep", "sys_module mknod setuid net_raw", tmpf, false) < 0) {
                lxc_error("%s\n", "lxc.cap.keep");
                goto non_test_error;
        }
 
-       /* REMOVE IN LXC 3.0
-          legacy lxc.console key
-        */
-       if (set_get_compare_clear_save_load(c, "lxc.console", "none", tmpf,
-                                           true) < 0) {
-               lxc_error("%s\n", "lxc.console");
-               goto non_test_error;
-       }
-
-       /* lxc.console.path */
-       if (set_get_compare_clear_save_load(c, "lxc.console.path", "none", tmpf,
-                                           true) < 0) {
+       if (set_get_compare_clear_save_load(c, "lxc.console.path", "none", tmpf, true) < 0) {
                lxc_error("%s\n", "lxc.console.path");
                goto non_test_error;
        }
 
-       /* lxc.console.logfile */
-       if (set_get_compare_clear_save_load(c, "lxc.console.logfile",
-                                           "/some/logfile", tmpf, true) < 0) {
+       if (set_get_compare_clear_save_load(c, "lxc.console.logfile", "/some/logfile", tmpf, true) < 0) {
                lxc_error("%s\n", "lxc.console.logfile");
                goto non_test_error;
        }
 
-       /* REMOVE IN LXC 3.0
-          legacy seccomp key
-        */
-       if (set_get_compare_clear_save_load(
-               c, "lxc.seccomp", "/some/seccomp/file", tmpf, true) < 0) {
-               lxc_error("%s\n", "lxc.seccomp");
+       if (set_get_compare_clear_save_load(c, "lxc.seccomp.profile", "/some/seccomp/file", tmpf, true) < 0) {
+               lxc_error("%s\n", "lxc.seccomp.profile");
                goto non_test_error;
        }
 
-       /* lxc.seccomp.profile */
-       if (set_get_compare_clear_save_load(
-               c, "lxc.seccomp.profile", "/some/seccomp/file", tmpf, true) < 0) {
-               lxc_error("%s\n", "lxc.seccomp.profile");
+       if (set_get_compare_clear_save_load(c, "lxc.autodev.tmpfs.size", "1", tmpf, true) < 0) {
+               lxc_error("%s\n", "lxc.autodev.tmpfs.size");
                goto non_test_error;
        }
 
-       /* lxc.autodev */
        if (set_get_compare_clear_save_load(c, "lxc.autodev", "1", tmpf, true) <
            0) {
                lxc_error("%s\n", "lxc.autodev");
                goto non_test_error;
        }
 
-       /* REMOVE IN LXC 3.0
-          legacy lxc.haltsignal key
-        */
-       if (set_get_compare_clear_save_load(c, "lxc.haltsignal", "1", tmpf,
-                                           true) < 0) {
-               lxc_error("%s\n", "lxc.haltsignal");
-               goto non_test_error;
-       }
-
-       /* lxc.signal.halt */
-       if (set_get_compare_clear_save_load(c, "lxc.signal.halt", "1", tmpf,
-                                           true) < 0) {
+       if (set_get_compare_clear_save_load(c, "lxc.signal.halt", "1", tmpf, true) < 0) {
                lxc_error("%s\n", "lxc.signal.halt");
                goto non_test_error;
        }
 
-       /* REMOVE IN LXC 3.0
-          legacy lxc.rebootsignal key
-        */
-       if (set_get_compare_clear_save_load(c, "lxc.rebootsignal", "1", tmpf,
-                                           true) < 0) {
-               lxc_error("%s\n", "lxc.rebootsignal");
-               goto non_test_error;
-       }
-
-       /* lxc.signal.reboot */
-       if (set_get_compare_clear_save_load(c, "lxc.signal.reboot", "1", tmpf,
-                                           true) < 0) {
+       if (set_get_compare_clear_save_load(c, "lxc.signal.reboot", "1", tmpf, true) < 0) {
                lxc_error("%s\n", "lxc.signal.reboot");
                goto non_test_error;
        }
 
-       /* REMOVE IN LXC 3.0
-          legacy lxc.stopsignal key
-        */
-       if (set_get_compare_clear_save_load(c, "lxc.stopsignal", "1", tmpf,
-                                           true) < 0) {
-               lxc_error("%s\n", "lxc.stopsignal");
-               goto non_test_error;
-       }
-
-       /* lxc.signal.stop */
-       if (set_get_compare_clear_save_load(c, "lxc.signal.stop", "1", tmpf,
-                                           true) < 0) {
+       if (set_get_compare_clear_save_load(c, "lxc.signal.stop", "1", tmpf, true) < 0) {
                lxc_error("%s\n", "lxc.signal.stop");
                goto non_test_error;
        }
 
-       /* lxc.start.auto */
-       if (set_get_compare_clear_save_load(c, "lxc.start.auto", "1", tmpf,
-                                           true) < 0) {
+       if (set_get_compare_clear_save_load(c, "lxc.start.auto", "1", tmpf, true) < 0) {
                lxc_error("%s\n", "lxc.start.auto");
                goto non_test_error;
        }
 
-       /* lxc.start.delay */
-       if (set_get_compare_clear_save_load(c, "lxc.start.delay", "5", tmpf,
-                                           true) < 0) {
+       if (set_get_compare_clear_save_load(c, "lxc.start.delay", "5", tmpf, true) < 0) {
                lxc_error("%s\n", "lxc.start.delay");
                goto non_test_error;
        }
 
-       /* lxc.start.order */
-       if (set_get_compare_clear_save_load(c, "lxc.start.order", "1", tmpf,
-                                           true) < 0) {
+       if (set_get_compare_clear_save_load(c, "lxc.start.order", "1", tmpf, true) < 0) {
                lxc_error("%s\n", "lxc.start.order");
                goto non_test_error;
        }
 
-       /* lxc.log.syslog */
-       if (set_get_compare_clear_save_load(c, "lxc.log.syslog", "local0", tmpf,
-                                           true) < 0) {
+       if (set_get_compare_clear_save_load(c, "lxc.log.syslog", "local0", tmpf, true) < 0) {
                lxc_error("%s\n", "lxc.log.syslog");
                goto non_test_error;
        }
 
-       /* lxc.utsname */
-       if (set_get_compare_clear_save_load(c, "lxc.utsname", "get-schwifty",
-                                           tmpf, true) < 0) {
-               lxc_error("%s\n", "lxc.utsname");
-               goto non_test_error;
-       }
-
-       /* lxc.monitor.unshare */
-       if (set_get_compare_clear_save_load(c, "lxc.monitor.unshare", "1", tmpf,
-                                           true) < 0) {
+       if (set_get_compare_clear_save_load(c, "lxc.monitor.unshare", "1", tmpf, true) < 0) {
                lxc_error("%s\n", "lxc.monitor.unshare");
                goto non_test_error;
        }
 
-       /* lxc.group */
-       if (set_get_compare_clear_save_load(
-               c, "lxc.group", "some,container,groups", tmpf, false) < 0) {
+       if (set_get_compare_clear_save_load(c, "lxc.group", "some,container,groups", tmpf, false) < 0) {
                lxc_error("%s\n", "lxc.group");
                goto non_test_error;
        }
 
-       /* lxc.environment */
-       if (set_get_compare_clear_save_load(c, "lxc.environment", "FOO=BAR",
-                                           tmpf, false) < 0) {
+       if (set_get_compare_clear_save_load(c, "lxc.environment", "FOO=BAR", tmpf, false) < 0) {
                lxc_error("%s\n", "lxc.environment");
                goto non_test_error;
        }
 
-       /* REMOVE IN LXC 3.0
-          legacy lxc.init_cmd key
-        */
-       if (set_get_compare_clear_save_load(c, "lxc.init_cmd", "/bin/bash",
-                                           tmpf, true) < 0) {
-               lxc_error("%s\n", "lxc.init_cmd");
-               goto non_test_error;
-       }
-
-       /* lxc.init.cmd */
-       if (set_get_compare_clear_save_load(c, "lxc.init.cmd", "/bin/bash",
-                                           tmpf, true) < 0) {
+       if (set_get_compare_clear_save_load(c, "lxc.init.cmd", "/bin/bash", tmpf, true) < 0) {
                lxc_error("%s\n", "lxc.init.cmd");
                goto non_test_error;
        }
 
-       /* REMOVE IN LXC 3.0
-          legacy lxc.init_uid key
-        */
-       if (set_get_compare_clear_save_load(c, "lxc.init_uid", "1000", tmpf,
-                                           true) < 0) {
-               lxc_error("%s\n", "lxc.init_uid");
-               goto non_test_error;
-       }
-
-       /* lxc.init.uid */
-       if (set_get_compare_clear_save_load(c, "lxc.init.uid", "1000", tmpf,
-                                           true) < 0) {
+       if (set_get_compare_clear_save_load(c, "lxc.init.uid", "1000", tmpf, true) < 0) {
                lxc_error("%s\n", "lxc.init.uid");
                goto non_test_error;
        }
 
-       /* REMOVE IN LXC 3.0
-          legacy lxc.init_gid key
-        */
-       if (set_get_compare_clear_save_load(c, "lxc.init_gid", "1000", tmpf,
-                                           true) < 0) {
-               lxc_error("%s\n", "lxc.init_gid");
-               goto non_test_error;
-       }
-
-       /* lxc.init.gid */
-       if (set_get_compare_clear_save_load(c, "lxc.init.gid", "1000", tmpf,
-                                           true) < 0) {
+       if (set_get_compare_clear_save_load(c, "lxc.init.gid", "1000", tmpf, true) < 0) {
                lxc_error("%s\n", "lxc.init.gid");
                goto non_test_error;
        }
 
-       /* lxc.ephemeral */
-       if (set_get_compare_clear_save_load(c, "lxc.ephemeral", "1", tmpf,
-                                           true) < 0) {
+       if (set_get_compare_clear_save_load(c, "lxc.ephemeral", "1", tmpf, true) < 0) {
                lxc_error("%s\n", "lxc.ephemeral");
                goto non_test_error;
        }
 
-       /* lxc.no_new_privs */
-       if (set_get_compare_clear_save_load(c, "lxc.no_new_privs", "1", tmpf,
-                                           true) < 0) {
+       if (set_get_compare_clear_save_load(c, "lxc.no_new_privs", "1", tmpf, true) < 0) {
                lxc_error("%s\n", "lxc.no_new_privs");
                goto non_test_error;
        }
 
-       /* lxc.sysctl */
-       if (set_get_compare_clear_save_load(c, "lxc.sysctl.net.core.somaxconn", "256", tmpf,
-                                           true) < 0) {
+       if (set_get_compare_clear_save_load(c, "lxc.sysctl.net.core.somaxconn", "256", tmpf, true) < 0) {
                lxc_error("%s\n", "lxc.sysctl.net.core.somaxconn");
                goto non_test_error;
        }
 
-       /* lxc.proc */
-       if (set_get_compare_clear_save_load(c, "lxc.proc.oom_score_adj", "10", tmpf,
-                                           true) < 0) {
+       if (set_get_compare_clear_save_load(c, "lxc.proc.oom_score_adj", "10", tmpf, true) < 0) {
                lxc_error("%s\n", "lxc.proc.oom_score_adj");
                goto non_test_error;
        }
 
-       /* REMOVE IN LXC 3.0
-          legacy lxc.limit.* key
-        */
-       if (set_get_compare_clear_save_load(c, "lxc.limit.nofile", "65536",
-                                           tmpf, true) < 0) {
-               lxc_error("%s\n", "lxc.limit.nofile");
-               goto non_test_error;
-       }
-
-       /* lxc.prlimit.nofile */
-       if (set_get_compare_clear_save_load(c, "lxc.prlimit.nofile", "65536",
-                                           tmpf, true) < 0) {
+       if (set_get_compare_clear_save_load(c, "lxc.prlimit.nofile", "65536", tmpf, true) < 0) {
                lxc_error("%s\n", "lxc.prlimit.nofile");
                goto non_test_error;
        }
@@ -957,145 +666,197 @@ int main(int argc, char *argv[])
                goto non_test_error;
        }
 
-       if (set_get_compare_clear_save_load(c, "lxc.net.0.type", "veth",
-                                           tmpf, true)) {
+       if (set_get_compare_clear_save_load(c, "lxc.net.0.type", "veth", tmpf, true)) {
                lxc_error("%s\n", "lxc.net.0.type");
                goto non_test_error;
        }
 
-       if (set_get_compare_clear_save_load(c, "lxc.net.2.type", "none",
-                                           tmpf, true)) {
+       if (set_get_compare_clear_save_load(c, "lxc.net.2.type", "none", tmpf, true)) {
                lxc_error("%s\n", "lxc.net.2.type");
                goto non_test_error;
        }
 
-       if (set_get_compare_clear_save_load(c, "lxc.net.3.type", "empty",
-                                           tmpf, true)) {
+       if (set_get_compare_clear_save_load(c, "lxc.net.3.type", "empty", tmpf, true)) {
                lxc_error("%s\n", "lxc.net.3.type");
                goto non_test_error;
        }
 
-       if (set_get_compare_clear_save_load(c, "lxc.net.4.type", "vlan",
-                                           tmpf, true)) {
+       if (set_get_compare_clear_save_load(c, "lxc.net.4.type", "vlan", tmpf, true)) {
                lxc_error("%s\n", "lxc.net.4.type");
                goto non_test_error;
        }
 
-       if (set_get_compare_clear_save_load(c, "lxc.net.0.type", "macvlan",
-                                           tmpf, true)) {
+       if (set_get_compare_clear_save_load(c, "lxc.net.0.type", "macvlan", tmpf, true)) {
                lxc_error("%s\n", "lxc.net.0.type");
                goto non_test_error;
        }
 
-       if (set_get_compare_clear_save_load(c, "lxc.net.1000.type", "phys",
-                                           tmpf, true)) {
+       if (set_get_compare_clear_save_load(c, "lxc.net.0.type", "ipvlan", tmpf, true)) {
+               lxc_error("%s\n", "lxc.net.0.type");
+               goto non_test_error;
+       }
+
+       if (set_get_compare_clear_save_load(c, "lxc.net.1000.type", "phys", tmpf, true)) {
                lxc_error("%s\n", "lxc.net.1000.type");
                goto non_test_error;
        }
 
-       if (set_get_compare_clear_save_load(c, "lxc.net.0.flags", "up",
-                                           tmpf, true)) {
+       if (set_get_compare_clear_save_load(c, "lxc.net.0.flags", "up", tmpf, true)) {
                lxc_error("%s\n", "lxc.net.0.flags");
                goto non_test_error;
        }
 
-       if (set_get_compare_clear_save_load(c, "lxc.net.0.name", "eth0",
-                                           tmpf, true)) {
+       if (set_get_compare_clear_save_load(c, "lxc.net.0.name", "eth0", tmpf, true)) {
                lxc_error("%s\n", "lxc.net.0.name");
                goto non_test_error;
        }
 
-       if (set_get_compare_clear_save_load(c, "lxc.net.0.link", "bla",
-                                           tmpf, true)) {
+       if (set_get_compare_clear_save_load(c, "lxc.net.0.link", "bla", tmpf, true)) {
                lxc_error("%s\n", "lxc.net.0.link");
                goto non_test_error;
        }
 
-       if (set_get_compare_clear_save_load_network(
-               c, "lxc.net.0.macvlan.mode", "private", tmpf, true,
-               "macvlan")) {
+       if (set_get_compare_clear_save_load_network(c, "lxc.net.0.macvlan.mode", "private", tmpf, true, "macvlan")) {
                lxc_error("%s\n", "lxc.net.0.macvlan.mode");
                goto non_test_error;
        }
 
-       if (set_get_compare_clear_save_load_network(
-               c, "lxc.net.0.macvlan.mode", "vepa", tmpf, true,
-               "macvlan")) {
+       if (set_get_compare_clear_save_load_network(c, "lxc.net.0.macvlan.mode", "vepa", tmpf, true, "macvlan")) {
                lxc_error("%s\n", "lxc.net.0.macvlan.mode");
                goto non_test_error;
        }
 
-       if (set_get_compare_clear_save_load_network(
-               c, "lxc.net.0.macvlan.mode", "bridge", tmpf, true,
-               "macvlan")) {
+       if (set_get_compare_clear_save_load_network(c, "lxc.net.0.macvlan.mode", "bridge", tmpf, true, "macvlan")) {
                lxc_error("%s\n", "lxc.net.0.macvlan.mode");
                goto non_test_error;
        }
 
-       if (set_get_compare_clear_save_load_network(
-               c, "lxc.net.0.veth.pair", "clusterfuck", tmpf, true,
-               "veth")) {
+       if (set_get_compare_clear_save_load_network(c, "lxc.net.0.ipvlan.mode", "l3", tmpf, true, "ipvlan")) {
+               lxc_error("%s\n", "lxc.net.0.ipvlan.mode");
+               goto non_test_error;
+       }
+
+       if (set_get_compare_clear_save_load_network(c, "lxc.net.0.ipvlan.mode", "l3s", tmpf, true, "ipvlan")) {
+               lxc_error("%s\n", "lxc.net.0.ipvlan.mode");
+               goto non_test_error;
+       }
+
+       if (set_get_compare_clear_save_load_network(c, "lxc.net.0.ipvlan.mode", "l2", tmpf, true, "ipvlan")) {
+               lxc_error("%s\n", "lxc.net.0.ipvlan.mode");
+               goto non_test_error;
+       }
+
+       if (set_get_compare_clear_save_load_network(c, "lxc.net.0.ipvlan.isolation", "bridge", tmpf, true, "ipvlan")) {
+               lxc_error("%s\n", "lxc.net.0.ipvlan.isolation");
+               goto non_test_error;
+       }
+
+       if (set_get_compare_clear_save_load_network(c, "lxc.net.0.ipvlan.isolation", "private", tmpf, true, "ipvlan")) {
+               lxc_error("%s\n", "lxc.net.0.ipvlan.isolation");
+               goto non_test_error;
+       }
+
+       if (set_get_compare_clear_save_load_network(c, "lxc.net.0.ipvlan.isolation", "vepa", tmpf, true, "ipvlan")) {
+               lxc_error("%s\n", "lxc.net.0.ipvlan.isolation");
+               goto non_test_error;
+       }
+
+       if (set_get_compare_clear_save_load_network(c, "lxc.net.0.veth.pair", "clusterfuck", tmpf, true, "veth")) {
                lxc_error("%s\n", "lxc.net.0.veth.pair");
                goto non_test_error;
        }
 
-       if (set_get_compare_clear_save_load(c, "lxc.net.0.script.up",
-                                           "/some/up/path", tmpf, true)) {
+       if (set_get_compare_clear_save_load_network(c, "lxc.net.0.veth.ipv4.route", "192.0.2.1/32", tmpf, true, "veth")) {
+               lxc_error("%s\n", "lxc.net.0.veth.ipv4.route");
+               return -1;
+       }
+
+       if (set_get_compare_clear_save_load_network(c, "lxc.net.0.veth.ipv6.route", "2001:db8::1/128", tmpf, true, "veth")) {
+               lxc_error("%s\n", "lxc.net.0.veth.ipv6.route");
+               return -1;
+       }
+
+       if (set_get_compare_clear_save_load_network(c, "lxc.net.0.veth.vlan.id", "none", tmpf, false, "veth")) {
+               lxc_error("%s\n", "lxc.net.0.veth.vlan.id");
+               return -1;
+       }
+
+       if (set_get_compare_clear_save_load_network(c, "lxc.net.0.veth.vlan.id", "2", tmpf, true, "veth")) {
+               lxc_error("%s\n", "lxc.net.0.veth.vlan.id");
+               return -1;
+       }
+
+       if (set_get_compare_clear_save_load_network(c, "lxc.net.0.veth.vlan.tagged.id", "2", tmpf, true, "veth")) {
+               lxc_error("%s\n", "lxc.net.0.veth.vlan.tagged.id");
+               return -1;
+       }
+
+       if (set_get_compare_clear_save_load(c, "lxc.net.0.script.up", "/some/up/path", tmpf, true)) {
                lxc_error("%s\n", "lxc.net.0.script.up");
                goto non_test_error;
        }
 
-       if (set_get_compare_clear_save_load(c, "lxc.net.0.script.down",
-                                           "/some/down/path", tmpf, true)) {
+       if (set_get_compare_clear_save_load(c, "lxc.net.0.script.down", "/some/down/path", tmpf, true)) {
                lxc_error("%s\n", "lxc.net.0.script.down");
                goto non_test_error;
        }
 
-       if (set_get_compare_clear_save_load(c, "lxc.net.0.hwaddr",
-                                           "52:54:00:80:7a:5d", tmpf, true)) {
+       if (set_get_compare_clear_save_load(c, "lxc.net.0.hwaddr", "52:54:00:80:7a:5d", tmpf, true)) {
                lxc_error("%s\n", "lxc.net.0.hwaddr");
                goto non_test_error;
        }
 
-       if (set_get_compare_clear_save_load(c, "lxc.net.0.mtu", "2000",
-                                           tmpf, true)) {
+       if (set_get_compare_clear_save_load(c, "lxc.net.0.mtu", "2000", tmpf, true)) {
                lxc_error("%s\n", "lxc.net.0.mtu");
                goto non_test_error;
        }
 
-       if (set_get_compare_clear_save_load_network(c, "lxc.net.0.vlan.id",
-                                                   "2", tmpf, true, "vlan")) {
+       if (set_get_compare_clear_save_load_network(c, "lxc.net.0.vlan.id", "2", tmpf, true, "vlan")) {
                lxc_error("%s\n", "lxc.net.0.vlan.id");
                goto non_test_error;
        }
 
-       if (set_get_compare_clear_save_load(c, "lxc.net.0.ipv4.gateway",
-                                           "10.0.2.2", tmpf, true)) {
+       if (set_get_compare_clear_save_load(c, "lxc.net.0.ipv4.gateway", "10.0.2.2", tmpf, true)) {
                lxc_error("%s\n", "lxc.net.0.ipv4.gateway");
                goto non_test_error;
        }
 
-       if (set_get_compare_clear_save_load(c, "lxc.net.0.ipv6.gateway",
-                                           "2003:db8:1::1", tmpf, true)) {
+       if (set_get_compare_clear_save_load(c, "lxc.net.0.ipv4.gateway", "auto", tmpf, true)) {
+               lxc_error("%s\n", "lxc.net.0.ipv4.gateway");
+               goto non_test_error;
+       }
+
+       if (set_get_compare_clear_save_load(c, "lxc.net.0.ipv4.gateway", "dev", tmpf, true)) {
+               lxc_error("%s\n", "lxc.net.0.ipv4.gateway");
+               goto non_test_error;
+       }
+
+       if (set_get_compare_clear_save_load(c, "lxc.net.0.ipv6.gateway", "2003:db8:1::1", tmpf, true)) {
                lxc_error("%s\n", "lxc.net.0.ipv6.gateway");
                goto non_test_error;
        }
 
-       if (set_get_compare_clear_save_load(c, "lxc.net.0.ipv4.address",
-                                           "10.0.2.3/24", tmpf, true)) {
+       if (set_get_compare_clear_save_load(c, "lxc.net.0.ipv6.gateway", "auto", tmpf, true)) {
+               lxc_error("%s\n", "lxc.net.0.ipv6.gateway");
+               goto non_test_error;
+       }
+
+       if (set_get_compare_clear_save_load(c, "lxc.net.0.ipv6.gateway", "dev", tmpf, true)) {
+               lxc_error("%s\n", "lxc.net.0.ipv6.gateway");
+               goto non_test_error;
+       }
+
+       if (set_get_compare_clear_save_load(c, "lxc.net.0.ipv4.address", "10.0.2.3/24", tmpf, true)) {
                lxc_error("%s\n", "lxc.net.0.ipv4.address");
                goto non_test_error;
        }
 
-       if (set_get_compare_clear_save_load(
-               c, "lxc.net.0.ipv6.address", "2003:db8:1:0:214:1234:fe0b:3596/64",
-               tmpf, true)) {
+       if (set_get_compare_clear_save_load(c, "lxc.net.0.ipv6.address", "2003:db8:1:0:214:1234:fe0b:3596/64", tmpf, true)) {
                lxc_error("%s\n", "lxc.net.0.ipv6.address");
                goto non_test_error;
        }
 
-       if (set_get_compare_clear_save_load(c, "lxc.cgroup.dir", "lxd", tmpf,
-                                           true)) {
+       if (set_get_compare_clear_save_load(c, "lxc.cgroup.dir", "lxd", tmpf, true)) {
                lxc_error("%s\n", "lxc.cgroup.dir");
                goto non_test_error;
        }
@@ -1110,10 +871,47 @@ int main(int argc, char *argv[])
                goto non_test_error;
        }
 
-       ret = EXIT_SUCCESS;
+       ret = set_get_compare_clear_save_load(c, "lxc.hook.version", "1", tmpf, true);
+       if (ret < 0) {
+               lxc_error("%s\n", "lxc.hook.version");
+               goto non_test_error;
+       }
+
+       if (c->set_config_item(c, "lxc.hook.version", "2")) {
+               lxc_error("%s\n", "Managed to set to set invalid config item \"lxc.hook.version\" to \"2\"");
+               goto non_test_error;
+       }
+
+       if (!c->set_config_item(c, "lxc.monitor.signal.pdeath", "SIGKILL")) {
+               lxc_error("%s\n", "Failed to set to set invalid config item \"lxc.monitor.signal.pdeath\" to \"SIGKILL\"");
+               goto non_test_error;
+       }
+
+       if (set_get_compare_clear_save_load(c, "lxc.rootfs.managed", "1", tmpf, true) < 0) {
+               lxc_error("%s\n", "lxc.rootfs.managed");
+               goto non_test_error;
+       }
+
+       if (c->set_config_item(c, "lxc.notaconfigkey", "invalid")) {
+               lxc_error("%s\n", "Managed to set to set invalid config item \"lxc.notaconfigkey\" to \"invalid\"");
+               return -1;
+       }
+
+       if (c->set_config_item(c, "lxc.log.file=", "./")) {
+               lxc_error("%s\n", "Managed to set to set invalid config item \"lxc.log.file\" to \"./\"");
+               return -1;
+       }
+
+       if (c->set_config_item(c, "lxc.hook.versionasdfsadfsadf", "1")) {
+               lxc_error("%s\n", "Managed to set to set invalid config item \"lxc.hook.versionasdfsadfsadf\" to \"2\"");
+               goto non_test_error;
+       }
+
+       fret = EXIT_SUCCESS;
+
 non_test_error:
        (void)unlink(tmpf);
        (void)rmdir(dirname(c->configfile));
        lxc_container_put(c);
-       exit(ret);
+       exit(fret);
 }