Directories inside config directories are not supported

This was failing silent, both in libkmod and module-init-tools. Give a
warning if we created a dir inside config directories.
This commit is contained in:
Lucas De Marchi 2011-12-12 15:23:03 -02:00
parent 4782396cc4
commit 98c80f44c9

View 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 */