]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
Directories inside config directories are not supported
authorLucas De Marchi <lucas.demarchi@profusion.mobi>
Mon, 12 Dec 2011 17:23:03 +0000 (15:23 -0200)
committerLucas De Marchi <lucas.demarchi@profusion.mobi>
Mon, 12 Dec 2011 17:26:59 +0000 (15:26 -0200)
This was failing silent, both in libkmod and module-init-tools. Give a
warning if we created a dir inside config directories.

libkmod/libkmod-config.c

index 605e02116eef4cc0d84046c54a6dd42fe86cdc93..94d9ccdeb83c3fec6b49052591adda6cfc90641c 100644 (file)
@@ -363,10 +363,11 @@ void kmod_config_free(struct kmod_config *config)
        free(config);
 }
 
-static bool conf_files_filter_out(struct kmod_ctx *ctx, const char *path,
-                                                               const char *fn)
+static bool conf_files_filter_out(struct kmod_ctx *ctx, DIR *d,
+                                       const char *path, const char *fn)
 {
        size_t len = strlen(fn);
+       struct stat st;
 
        if (fn[0] == '.')
                return 1;
@@ -379,6 +380,14 @@ static bool conf_files_filter_out(struct kmod_ctx *ctx, const char *path,
                return 1;
        }
 
+       fstatat(dirfd(d), fn, &st, 0);
+
+       if (S_ISDIR(st.st_mode)) {
+               ERR(ctx, "Directories inside directories are not supported: "
+                                                       "%s/%s\n", path, fn);
+               return 1;
+       }
+
        return 0;
 }
 
@@ -415,7 +424,7 @@ static DIR *conf_files_list(struct kmod_ctx *ctx, struct kmod_list **list,
                if (entp == NULL)
                        break;
 
-               if (conf_files_filter_out(ctx, path, entp->d_name) == 1)
+               if (conf_files_filter_out(ctx, d, path, entp->d_name) == 1)
                        continue;
 
                /* insert sorted */