slackware-current/source/a/module-init-tools/modprobe.ignore_some_suffixes.diff
Patrick J Volkerding 75a4a592e5 Slackware 13.37
Mon Apr 25 13:37:00 UTC 2011
Slackware 13.37 x86_64 stable is released!

Thanks to everyone who pitched in on this release: the Slackware team,
the folks producing upstream code, and linuxquestions.org for providing
a great forum for collaboration and testing.

The ISOs are off to be replicated, a 6 CD-ROM 32-bit set and a
dual-sided
32-bit/64-bit x86/x86_64 DVD.  Please consider supporting the Slackware
project by picking up a copy from store.slackware.com.  We're taking
pre-orders now, and offer a discount if you sign up for a subscription.

As always, thanks to the Slackware community for testing, suggestions,
and feedback.  :-)

Have fun!
2018-05-31 22:45:18 +02:00

41 lines
1.1 KiB
Diff

diff -Nur module-init-tools-3.12.orig//modprobe.c module-init-tools-3.12/modprobe.c
--- module-init-tools-3.12.orig//modprobe.c 2010-05-04 00:19:27.000000000 -0500
+++ module-init-tools-3.12/modprobe.c 2010-06-08 04:32:46.655088739 -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"
@@ -789,6 +790,20 @@
return strsep(string, delim);
}
+/* 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,
struct modprobe_conf *conf,
int dump_only,
@@ -1066,6 +1081,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))