aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2016-03-29 19:23:55 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2016-03-29 19:23:55 +0200
commit20dd49934146bdcfdfc58ee4f8f566ecda1dda77 (patch)
tree5340f169ac946538410259174ffb62c138cbfc1a
parent31c984dd6904a11b655879b3ad927bd9bf639192 (diff)
downloadbusybox-w32-20dd49934146bdcfdfc58ee4f8f566ecda1dda77.tar.gz
busybox-w32-20dd49934146bdcfdfc58ee4f8f566ecda1dda77.tar.bz2
busybox-w32-20dd49934146bdcfdfc58ee4f8f566ecda1dda77.zip
modprobe: skip non-.conf files only in subdirectories
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--modutils/modprobe.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/modutils/modprobe.c b/modutils/modprobe.c
index 997ee3c67..8130c40b7 100644
--- a/modutils/modprobe.c
+++ b/modutils/modprobe.c
@@ -214,7 +214,7 @@ static void add_probe(const char *name)
214static int FAST_FUNC config_file_action(const char *filename, 214static int FAST_FUNC config_file_action(const char *filename,
215 struct stat *statbuf UNUSED_PARAM, 215 struct stat *statbuf UNUSED_PARAM,
216 void *userdata UNUSED_PARAM, 216 void *userdata UNUSED_PARAM,
217 int depth UNUSED_PARAM) 217 int depth)
218{ 218{
219 char *tokens[3]; 219 char *tokens[3];
220 parser_t *p; 220 parser_t *p;
@@ -222,15 +222,20 @@ static int FAST_FUNC config_file_action(const char *filename,
222 int rc = TRUE; 222 int rc = TRUE;
223 const char *base, *ext; 223 const char *base, *ext;
224 224
225 /* Skip files that begin with a ".". */ 225 /* Skip files that begin with a "." */
226 base = bb_basename(filename); 226 base = bb_basename(filename);
227 if (base[0] == '.') 227 if (base[0] == '.')
228 goto error; 228 goto error;
229 229
230 /* Skip files that do not end with a ".conf". */ 230 /* In dir recursion, skip files that do not end with a ".conf"
231 ext = strrchr(base, '.'); 231 * depth==0: read_config("modules.{symbols,alias}") must work,
232 if (ext == NULL || strcmp(ext + 1, "conf")) 232 * "include FILE_NOT_ENDING_IN_CONF" must work too.
233 goto error; 233 */
234 if (depth != 0) {
235 ext = strrchr(base, '.');
236 if (ext == NULL || strcmp(ext + 1, "conf"))
237 goto error;
238 }
234 239
235 p = config_open2(filename, fopen_for_read); 240 p = config_open2(filename, fopen_for_read);
236 if (p == NULL) { 241 if (p == NULL) {
@@ -275,7 +280,7 @@ static int FAST_FUNC config_file_action(const char *filename,
275 m = get_or_add_modentry(tokens[1]); 280 m = get_or_add_modentry(tokens[1]);
276 m->options = gather_options_str(m->options, tokens[2]); 281 m->options = gather_options_str(m->options, tokens[2]);
277 } else if (strcmp(tokens[0], "include") == 0) { 282 } else if (strcmp(tokens[0], "include") == 0) {
278 /* include <filename> */ 283 /* include <filename>/<dirname> (yes, directories also must work) */
279 read_config(tokens[1]); 284 read_config(tokens[1]);
280 } else if (ENABLE_FEATURE_MODPROBE_BLACKLIST 285 } else if (ENABLE_FEATURE_MODPROBE_BLACKLIST
281 && strcmp(tokens[0], "blacklist") == 0 286 && strcmp(tokens[0], "blacklist") == 0
@@ -292,7 +297,8 @@ static int FAST_FUNC config_file_action(const char *filename,
292static int read_config(const char *path) 297static int read_config(const char *path)
293{ 298{
294 return recursive_action(path, ACTION_RECURSE | ACTION_QUIET, 299 return recursive_action(path, ACTION_RECURSE | ACTION_QUIET,
295 config_file_action, NULL, NULL, 1); 300 config_file_action, NULL, NULL,
301 /*depth:*/ 0);
296} 302}
297 303
298static const char *humanly_readable_name(struct module_entry *m) 304static const char *humanly_readable_name(struct module_entry *m)