~ubuntu-branches/ubuntu/lucid/acpid/lucid-updates

« back to all changes in this revision

Viewing changes to debian/patches/event.c.diff

  • Committer: Bazaar Package Importer
  • Author(s): Michael Meskes
  • Date: 2009-11-17 14:50:01 UTC
  • mfrom: (2.1.12 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091117145001-y5hevyg7gcg6uwjk
Tags: 1.0.10-4
Updated netlink patch to version 6.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
--- acpid-1.0.8.orig/event.c
 
2
+++ acpid-1.0.8/event.c
 
3
@@ -23,6 +23,7 @@
 
4
 #include <sys/types.h>
 
5
 #include <sys/stat.h>
 
6
 #include <sys/wait.h>
 
7
+#include <libgen.h>
 
8
 #include <sys/poll.h>
 
9
 #include <fcntl.h>
 
10
 #include <unistd.h>
 
11
@@ -92,6 +93,8 @@
 
12
        struct dirent *dirent;
 
13
        char *file = NULL;
 
14
        int nrules = 0;
 
15
+       char *basen = NULL;
 
16
+       regex_t preg;
 
17
 
 
18
        lock_rules();
 
19
 
 
20
@@ -141,10 +144,19 @@
 
21
                        continue; /* skip non-regular files */
 
22
                }
 
23
 
 
24
-               r = parse_file(file);
 
25
-               if (r) {
 
26
-                       enlist_rule(&cmd_list, r);
 
27
-                       nrules++;
 
28
+               /* check for run-parts style filename */
 
29
+               basen = basename(file);
 
30
+               if (regcomp(&preg, "^[a-zA-Z0-9_-]+$", RULE_REGEX_FLAGS) == 0){
 
31
+                       if (regexec(&preg, basen, 0, NULL, 0) == 0){
 
32
+                               r = parse_file(file);
 
33
+                               if (r) {
 
34
+                                       enlist_rule(&cmd_list, r);
 
35
+                                       nrules++;
 
36
+                               }
 
37
+                       } else {
 
38
+                               acpid_log(LOG_DEBUG, "ignoring conf file %s\n", file);
 
39
+                       }
 
40
+
 
41
                }
 
42
                free(file);
 
43
        }