summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Palfrader <peter@palfrader.org>2006-06-05 01:57:56 +0000
committerweasel <weasel@bc3d92e2-beff-0310-a7cd-cc87d7ac0ede>2006-06-05 01:57:56 +0000
commit65262ede7681d64579dedb8d2e96856ee6ff3bc9 (patch)
treef9815cf597f270b16ad384b97909744ff3bd43b7
parentc2d1051ca6ef48ee99c15651b770195954716b5f (diff)
r160@danube: weasel | 2006-06-05 03:57:49 +0200
Make the approved passwords stuff a hash, and send errors if we do not have the password git-svn-id: svn+ssh://asteria.noreply.org/svn/weaselutils/trunk@119 bc3d92e2-beff-0310-a7cd-cc87d7ac0ede
-rwxr-xr-xsplit-mailman-mails-and-discard-and-save27
1 files changed, 19 insertions, 8 deletions
diff --git a/split-mailman-mails-and-discard-and-save b/split-mailman-mails-and-discard-and-save
index 79711d9..9dc5b1a 100755
--- a/split-mailman-mails-and-discard-and-save
+++ b/split-mailman-mails-and-discard-and-save
@@ -1,6 +1,7 @@
#!/usr/bin/ruby
require 'rmail'
+require 'yaml'
if ARGV[0] == "spam"
MAILIN="mail/spam-in"
@@ -13,7 +14,7 @@ elsif ARGV[0] == "ham"
MAILLEARN="mail/ham-learn"
OUTBOX="mail/outbox"
SEND_CONFIRM_MAIL = true
- APPROVE_PASSWORD = File.open('mailman-site-password').readline.chomp
+ APPROVE_PASSWORD = YAML::load( File.open( 'mailman-passwords.yaml' ) )
else
STDERR.puts "Usage: #{$0} ham|spam"
exit 1
@@ -22,6 +23,7 @@ end
DOMAIN='lists.oftc.net'
FROM="listmod@blackhole.oftc.net"
HOSTNAME=`hostname`.chop
+ERRORSTO=FROM
class Counter
@@counter = 0
@@ -83,13 +85,22 @@ def process_mail(filename)
store_in_maildir(MAILLEARN, held_part)
if SEND_CONFIRM_MAIL
- mail_request = RMail::Message.new()
- mail_request.header['From'] = FROM
- mail_request.header['To'] = request_address
- mail_request.header['Subject'] = "Re: confirm #{cookie}"
- mail_request.header['Approved'] = APPROVE_PASSWORD if APPROVE_PASSWORD
- mail_request.body = ''
- store_in_maildir(OUTBOX, mail_request)
+ if APPROVE_PASSWORD and not APPROVE_PASSWORD[request_address] then
+ mail_error = RMail::Message.new()
+ mail_error.header['From'] = FROM
+ mail_error.header['To'] = ERRORSTO
+ mail_error.header['Subject'] = "approving #{cookie} failed"
+ mail_error.body = 'Sorry, this script does not have the admin/moderator password for #{request_address}.'
+ store_in_maildir(OUTBOX, mail_request)
+ else
+ mail_request = RMail::Message.new()
+ mail_request.header['From'] = FROM
+ mail_request.header['To'] = request_address
+ mail_request.header['Subject'] = "Re: confirm #{cookie}"
+ mail_request.header['Approved'] = APPROVE_PASSWORD if APPROVE_PASSWORD
+ mail_request.body = ''
+ store_in_maildir(OUTBOX, mail_request)
+ end
end
end