Package: bcron / 0.11-8

0003-Have-bcron-update-ignore-files-that-are-outside-Debia.diff Patch series | download
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
From bdd26a3940ed4c00baaf0d0080fad77a788daad1 Mon Sep 17 00:00:00 2001
From: Gerrit Pape <pape@smarden.org>
Date: Tue, 8 May 2007 08:59:14 +0000
Subject: [PATCH] Have bcron-update ignore files that are outside Debian
 namespace.

On Debian, if path is a directory, bcron-spool skips files in this
directory with names that do not solely consist of lower- and uppercase
letters ('a'-'z', 'A'-'Z'), digits ('0'-'9'), underscores ('_'), and
hyphens ('-').
---
 bcron-update.8 |  8 ++++++++
 bcron-update.c | 13 +++++++++++++
 2 files changed, 21 insertions(+)

diff --git a/bcron-update.8 b/bcron-update.8
index 9bed66d..5726f5b 100644
--- a/bcron-update.8
+++ b/bcron-update.8
@@ -15,6 +15,14 @@ those changes into the crontab spool directory.
 .B bcron-update
 runs as root in order to be able to read system files that would
 potentially be unreadable otherwise.
+.P
+On Debian, if
+.I path
+is a directory,
+.B bcron-update
+skips files in this directory with names that do not solely consist of
+lower- and uppercase letters ('a'-'z', 'A'-'Z'), digits ('0'-'9'),
+underscores ('_'), and hyphens ('-').
 .SH EXAMPLES
 To mirror modern vixie-cron's behavior, use:
 .EX
diff --git a/bcron-update.c b/bcron-update.c
index 7bf6c6f..23bc8ce 100644
--- a/bcron-update.c
+++ b/bcron-update.c
@@ -136,8 +136,21 @@ static int check_dir(struct arg* a, struct ministat* st)
     while ((e = readdir(a->dir)) != 0) {
       struct statcache_entry* se;
       const char* name = e->d_name;
+      char *c;
       if (name[0] == '.')
 	continue;
+      /* check Debian cron files namespace */
+      for (c = e->d_name; *c; ++c) {
+        if (*c == '-') continue;
+        if (*c < '0') break;
+        if (*c <= '9') continue;
+        if (*c < 'A') break;
+        if (*c <= 'Z') continue;
+        if (*c == '_') continue;
+        if (*c < 'a') break;
+        if (*c > 'z') break;
+      }
+      if (*c) continue;
       if ((se = statcache_get(&a->entries, &name)) == 0) {
 	/* File is new. */
 	ministat2(a->path, name, st);
-- 
2.0.1