summaryrefslogtreecommitdiff
path: root/source/a/module-init-tools/modprobe.ignore_some_suffixes.diff
blob: a65fba0ad27bc08b4c9c1baf6c8bf5deadb13216 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
diff -Nur module-init-tools-3.11.orig/modprobe.c module-init-tools-3.11.new/modprobe.c
--- module-init-tools-3.11.orig/modprobe.c	2009-10-15 04:59:28.000000000 -0500
+++ module-init-tools-3.11.new/modprobe.c	2009-10-15 08:14:12.108359199 -0500
@@ -38,6 +38,7 @@
 #include <asm/unistd.h>
 #include <sys/wait.h>
 #include <syslog.h>
+#include <regex.h>
 
 #include "util.h"
 #include "elfops.h"
@@ -861,6 +862,20 @@
 				 options, commands, aliases, blacklist);
 }
 
+/* Let's exclude a few file extensions */
+static int valid_file_name(const char *filename)
+{
+	static regex_t *re = NULL;
+
+	if (!re) {
+		re = NOFAIL(malloc(sizeof(regex_t)));
+		if (regcomp(re, "(^(\\.|\\.\\.)|\\.(new|orig|bak)$)",
+			REG_EXTENDED|REG_NOSUB) != 0)
+				fatal("regcomp failed: %s\n", strerror(errno));
+		}
+		return regexec(re, filename, 0, NULL, 0);
+}
+
 static int parse_config_scan(const char *filename,
 			     const char *name,
 			     int dump_only,
@@ -887,6 +902,8 @@
 		while ((i = readdir(dir)) != NULL) {
 			size_t len;
 
+			if (!valid_file_name(i->d_name))
+				continue;
 			if (i->d_name[0] == '.')
 				continue;
 			if (!config_filter(i->d_name))