Package: dak
Version: 1.0-8.4
Severity: wishlist
Tags: Patch
Hi,
I've implemented a backwards-compatible way to include regular
expressions in the mail whitelist for dak. To use a regular expression
instead of regular string, use a "RE:" prefix in the whitelist file.
Marc
--
BOFH #357:
I'd love to help you -- it's just that the Boss won't let me near
the computer.
diff -Nru dak-1.0/utils.py dak-1.0.new/utils.py
--- dak-1.0/utils.py 2006-01-28 14:24:20.000000000 +0100
+++ dak-1.0.new/utils.py 2007-03-04 12:41:26.000000000 +0100
@@ -380,11 +380,16 @@
message_in.close();
whitelist_in = open_file(Cnf["Dinstall::MailWhiteList"])
- whitelist = whitelist_in.readlines()
- whitelist_in.close()
+ RE_mark = re.compile(r'^RE:')
+ try:
+ for line in whitelist_in:
+ if RE_mark.match(line):
+ whitelist.append(re.compile(RE_mark.sub("", line.strip(), 1)))
+ else:
+ whitelist.append(re.compile(re.escape(line.strip())))
+ finally:
+ whitelist_in.close()
- # Remove newlines
- whitelist = map(string.strip, whitelist)
# Fields to check. Here the order is important because Bcc
# will be the last changed field
@@ -396,7 +401,12 @@
match = [];
for item in value.split(","):
(rfc822_maint, rfc2047_maint, name, email) = fix_maintainer(item.strip())
- if email not in whitelist:
+ mail_whitelisted = 0
+ for wr in whitelist:
+ if wr.match(email):
+ mail_whitelisted = 1
+ break
+ if not mail_whitelisted:
print "Skipping %s since it's not in %s" % (item, Cnf["Dinstall::MailWhiteList"])
continue
match.append(item)