]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
confile: allow including nonexisting directories 3896/head
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Mon, 5 Jul 2021 08:53:41 +0000 (10:53 +0200)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Mon, 5 Jul 2021 08:53:41 +0000 (10:53 +0200)
If an include directive ends with a trailing slash, we now
always assume it is a directory and do not treat the
non-existence as an error.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
src/lxc/confile.c

index 6e2b68b1cf727bfabcd69e49283f1c31cfe7e77d..7f4fb13fb0ef2fb64ce97b85d84f0afe8d990dcb 100644 (file)
@@ -2689,7 +2689,7 @@ static int do_includedir(const char *dirp, struct lxc_conf *lxc_conf)
 
        dir = opendir(dirp);
        if (!dir)
-               return -errno;
+               return errno == ENOENT ? 0 : -errno;
 
        while ((direntp = readdir(dir))) {
                const char *fnam;
@@ -2726,7 +2726,7 @@ static int set_config_includefiles(const char *key, const char *value,
                return 0;
        }
 
-       if (is_dir(value))
+       if (value[strlen(value)-1] == '/' || is_dir(value))
                return do_includedir(value, lxc_conf);
 
        return lxc_config_read(value, lxc_conf, true);