From 20dd49934146bdcfdfc58ee4f8f566ecda1dda77 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 29 Mar 2016 19:23:55 +0200 Subject: modprobe: skip non-.conf files only in subdirectories Signed-off-by: Denys Vlasenko --- modutils/modprobe.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'modutils') diff --git a/modutils/modprobe.c b/modutils/modprobe.c index 997ee3c..8130c40 100644 --- a/modutils/modprobe.c +++ b/modutils/modprobe.c @@ -214,7 +214,7 @@ static void add_probe(const char *name) static int FAST_FUNC config_file_action(const char *filename, struct stat *statbuf UNUSED_PARAM, void *userdata UNUSED_PARAM, - int depth UNUSED_PARAM) + int depth) { char *tokens[3]; parser_t *p; @@ -222,15 +222,20 @@ static int FAST_FUNC config_file_action(const char *filename, int rc = TRUE; const char *base, *ext; - /* Skip files that begin with a ".". */ + /* Skip files that begin with a "." */ base = bb_basename(filename); if (base[0] == '.') goto error; - /* Skip files that do not end with a ".conf". */ - ext = strrchr(base, '.'); - if (ext == NULL || strcmp(ext + 1, "conf")) - goto error; + /* In dir recursion, skip files that do not end with a ".conf" + * depth==0: read_config("modules.{symbols,alias}") must work, + * "include FILE_NOT_ENDING_IN_CONF" must work too. + */ + if (depth != 0) { + ext = strrchr(base, '.'); + if (ext == NULL || strcmp(ext + 1, "conf")) + goto error; + } p = config_open2(filename, fopen_for_read); if (p == NULL) { @@ -275,7 +280,7 @@ static int FAST_FUNC config_file_action(const char *filename, m = get_or_add_modentry(tokens[1]); m->options = gather_options_str(m->options, tokens[2]); } else if (strcmp(tokens[0], "include") == 0) { - /* include */ + /* include / (yes, directories also must work) */ read_config(tokens[1]); } else if (ENABLE_FEATURE_MODPROBE_BLACKLIST && strcmp(tokens[0], "blacklist") == 0 @@ -292,7 +297,8 @@ static int FAST_FUNC config_file_action(const char *filename, static int read_config(const char *path) { return recursive_action(path, ACTION_RECURSE | ACTION_QUIET, - config_file_action, NULL, NULL, 1); + config_file_action, NULL, NULL, + /*depth:*/ 0); } static const char *humanly_readable_name(struct module_entry *m) -- cgit v1.1