]> git.madduck.net Git - etc/mailfilter.git/commitdiff

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Merge branch 'master' of ssh://git.madduck.net/~/git/pub/etc/mailfilter
authormartin f. krafft <madduck@madduck.net>
Wed, 21 Nov 2007 23:22:41 +0000 (00:22 +0100)
committermartin f. krafft <madduck@madduck.net>
Wed, 21 Nov 2007 23:22:41 +0000 (00:22 +0100)
12 files changed:
bin/retrain
config/justme-address-exceptions
config/skip-spamchecks
config/spamtraps
crm114/.gitignore [deleted file]
crm114/nonspam.css [new symlink]
crm114/spam.css [new symlink]
procmail/delay-delivery
procmail/deliver
procmail/logging
procmail/msgid-index
procmail/record-delayed-mail [new file with mode: 0644]

index b1ccca172cee26d35c754ff8e32b5fb100fa146f..784f17ea262a6ca9853b8fe9373166c8e353e081 100755 (executable)
@@ -10,18 +10,22 @@ PAUSETIME=10
 
 HAM=0
 SPAM=0
-MAILDIR=
 
+maildir=
+files=
 for i in "$@"; do
   case "$i" in
     --ham) HAM=1;;
     --spam) SPAM=1;;
     *)
-      if [ -n "$MAILDIR" ]; then
-        echo "E: Maildir already specified: $i" >&2
-        exit 1
+      if [ -f "$i" ] && [ -r "$i" ]; then
+        files="$files $i"
       elif [ -d "$i"/cur ] && [ -d "$i"/new ] && [ -d "$i"/tmp ]; then
-        MAILDIR="$i"
+        if [ -n "$maildir" ]; then
+          echo "E: Maildir already specified: $i" >&2
+          exit 1
+        fi
+        maildir="$i"
       else
         echo "E: unknown argument: $i" >&2
         exit 255
@@ -44,14 +48,18 @@ case "$HAM/$SPAM" in
   1/0) ARG=--ham;;
 esac
 
-LOCKFILE="$MAILDIR/.retrain.lock"
-trap "rm -f $LOCKFILE" 1 2 3 4 5 6 7 8 10 11 12 13 14 15
-if ! lockfile -0 -r0 -l 3600 "$LOCKFILE" 2>/dev/null; then
-  echo "E: another retrain process is already running over that Maildir." >&2
-  exit 1
+if [ -n "$maildir" ]; then
+  LOCKFILE="$maildir/.retrain.lock"
+  trap "rm -f $LOCKFILE" 1 2 3 4 5 6 7 8 10 11 12 13 14 15
+  if ! lockfile -0 -r0 -l 3600 "$LOCKFILE" 2>/dev/null; then
+    echo "E: another retrain process is already running over that Maildir." >&2
+    exit 1
+  fi
+
+  files="$files $(find $MAILDIR/cur $MAILDIR/new -type f)"
 fi
 
-find $MAILDIR/cur $MAILDIR/new -type f | while read msg; do
+for msg in $files; do
   $NICE ${0%/*}/train $ARG "$msg" | $RESUBMIT || ret=$?
   case "${ret:-0}" in
     0|75) :;;
@@ -64,7 +72,9 @@ find $MAILDIR/cur $MAILDIR/new -type f | while read msg; do
   sleep $PAUSETIME
 done
 
-rm -f "$LOCKFILE"
-trap - 1 2 3 4 5 6 7 8 10 11 12 13 14 15
+if [ -n "${LOCKFILE:-}" ]; then
+  rm -f "$LOCKFILE"
+  trap - 1 2 3 4 5 6 7 8 10 11 12 13 14 15
+fi
 
 exit 0
index d025d47136c8ced64050dd13048b0c9220736a51..fe1cb8c7023229fb1f8d174f868cb300e53b724d 100644 (file)
@@ -8,6 +8,7 @@
 ^(community|discuss)=opensource\.mit\.edu@mass\.madduck\.net$
 ^debian\.ch=fortytwo\.ch@mass\.madduck\.net$
 ^crm114-discuss=lists\.sourceforge\.net@mass\.madduck\.net$
+^libkdtree-devel=lists\.alioth\.debian\.org@mass\.madduck\.net$
 ^logcheck-devel=lists\.alioth\.debian\.org@mass\.madduck\.net$
 ^pkg-mdadm-devel=lists\.alioth\.debian\.org@mass\.madduck\.net$
 ^debconf-(team|press)=lists\.debconf\.org@mass\.madduck\.net$
index 0e4b46dc78eaa0085d60c706f417c6a93bec98fc..4ebe9806b91adb1d284e8bbdb6f1c319e7fd63f4 100644 (file)
@@ -9,6 +9,7 @@
 ^To:.*\<immoscout24\.ch@pobox\.madduck\.net\>
 ^To:.*\<homegate\.ch@pobox\.madduck\.net\>
 ^To:.*\<lufthansa\.com@pobox\.madduck\.net\>
+^To:.*\<miles-and-more\.com@pobox\.madduck\.net\>
 ^To:.*\<united\.com@pobox\.madduck\.net\>
 ^To:.*\<easyjet\.com@pobox\.madduck\.net\>
 ^To:.*\<thaiair\.com@pobox\.madduck\.net\>
@@ -22,6 +23,7 @@
 ^To:.*\<acm\.org@pobox\.madduck\.net\>
 ^To:.*\<immoscout24\.ch@pobox\.madduck\.net\>
 ^To:.*\<amazon\.com@pobox\.madduck\.net\>
+^To:.*\<padi\.com@pobox\.madduck\.net\>
 ^To:.*\<klarmobil.de@pobox\.madduck\.net\>
 ^From:.*\<logcheck@
 ^From:.*\<installer@ftp-master\.debian\.org\>
@@ -29,3 +31,4 @@
 ^From:.*\<swsupport@pimlicosoftware\.com\>
 ^From:.*\<root@.+[[:space:]]+\<Cron Daemon\>
 ^From:.*\<(leader|secretary)@debian\.org\>
+^X-Original-To: \<[^[:space:]]+@r2e.madduck.net$
index 6466d2ca5066cef61ca76fb84f63142b6970d92d..c9c5f402349101dcf58f2e46b10c5d4070e7d9af 100644 (file)
@@ -6,7 +6,7 @@
 ^(webmaster|info|sales)@madduck\.(ch|net|eu)$
 ^(webmaster|info|sales)@martin-krafft\.(de|com|net|eu|ch)$
 ^(webmaster|info|sales)@pantsfullofunix\.net$
-^(webmaster|sales)@debian-?(book|system)\.info$
+^(contact|webmaster|sales)@debian-?(book|system)\.info$
 ^3dpostfix\.org@mass\.madduck\.net$
 ^adultfriendfinder\.com@pobox\.madduck\.net$
 ^alt\.cellular\.nokia@usenet\.madduck\.net$
@@ -51,8 +51,6 @@
 ^mass\+snns@madduck\.net$
 ^mass\+zope-users@madduck\.net$
 ^metrodate\.com@pobox\.madduck\.net$
-^moveon\.org@pobox\.madduck\.net$
-^opengroup\.org@pobox\.madduck\.net$
 ^sales@sudetia\.de$
 ^someone_else@pantsfullofunix\.net$
 ^superbookdeals\.com@pobox\.madduck\.net$
diff --git a/crm114/.gitignore b/crm114/.gitignore
deleted file mode 100644 (file)
index b3a5267..0000000
+++ /dev/null
@@ -1 +0,0 @@
-*.css
diff --git a/crm114/nonspam.css b/crm114/nonspam.css
new file mode 120000 (symlink)
index 0000000..ab4d1b9
--- /dev/null
@@ -0,0 +1 @@
+../../../.var/crm114/nonspam.css
\ No newline at end of file
diff --git a/crm114/spam.css b/crm114/spam.css
new file mode 120000 (symlink)
index 0000000..4b422a8
--- /dev/null
@@ -0,0 +1 @@
+../../../.var/crm114/spam.css
\ No newline at end of file
index c1ca0c0df69e48e8b18d8afb3a61ec775df2f8f8..381771577a1fb8cddf7fb9c1759b4f258a38e503 100644 (file)
@@ -1,6 +1,3 @@
-# create table messages (msgid text unique not null, filename text
-# primary key not null unique, release_ts integer not null);
-
 #TODO: create config/delay-(disabled|tonight|weekend)
 
 :0
 
     LOG="delay:       delay delivery of $MSGID until $RELEASE_TIME$NL"
 
-    DELAYED_QUEUE_DB=$PMVAR/delayed-queue.sqlite
-    DO_QUERY="$SQLITE $DELAYED_QUEUE_DB"
-
-    DATA="$MSGID"
-    INCLUDERC=$PMDIR/sql-escape
-
-    Q="insert into messages values
-      ($DATA, '\\'\$DESTFILE\\'', $RELEASE_TS)"
-    TRAP="$TRAP; $DO_QUERY '$Q'"
-
     :0 fw
     |$FORMAIL -I "X-Delayed: $RELEASE_TS ($RELEASE_TIME)"
 
+    INCLUDERC=$PMDIR/record-delayed-mail
+
     :0
     $DELAYED_QUEUE
   }
index 4417af67a3ee44a97f39fbce9bd17fc19959cea8..ca6bef4477ee9da82034e8cc113e8ddbbb7c7e9e 100644 (file)
 :0 E
 { DEST=".$DEST" }
 
-TRAP="$TRAP; echo \"delivered:   \$DESTFILE\" >> '$THISLOGFILE'"
-
-LOG="deliver:     delivering message $MSGID to $DEST$NL"
 :0
-$BASE/$DEST
+{
+  LOG="deliver:     delivering message $MSGID to $DEST$NL"
+  TRAP="$TRAP; echo \"delivered:   \$DESTFILE\" >> '$THISLOGFILE'"
+
+  :0
+  $BASE/$DEST
+}
index a606b2a5b1df442e77b5096c698cf6faa3130db6..3695b7167db975d82511e366cde8b461d63b8bba 100644 (file)
@@ -21,7 +21,9 @@ original-to: $ORIGINAL_TO
 subject:     $SUBJECT$NL"
 
 TRAP="DESTFILE=\"\${LASTFOLDER#$BASE/}\";
-      echo >> '$THISLOGFILE';
-      egrep -v '^XX(procmail:)?[[:space:]\"]' '$THISLOGFILE' >> $MASTERLOGFILE"
+      /usr/bin/lockfile -4 -r50 -l180 $PMVAR/lock;
+      trap \"echo >> '$THISLOGFILE';
+             /bin/cat '$THISLOGFILE' >> $MASTERLOGFILE;
+             /bin/rm -f $PMVAR/lock\" 0"
 
 #VERBOSE=yes
index 67606faa83da7c3a65e90e7091cf0d24675872a5..102dacc0f9fb7f1b222ca8c58f9861f6c3d895f3 100644 (file)
@@ -1,5 +1,5 @@
 # create table messages (sender text not null, recipient text not null,
-# subject text not null, msgid text unique not null, filename text primary key
+# subject text not null, msgid text not null, filename text primary key
 # not null unique, timestamp integer, dest text not null);
 #
 # create trigger insert_messages_timestamp after insert on messages begin
@@ -14,8 +14,10 @@ DATA="$FROM,$NL$ORIGINAL_TO,$NL$SUBJECT,$NL$MSGID"
 INCLUDERC=$PMDIR/sql-escape
 
 QUERY="insert into messages (sender, recipient, subject, msgid, filename, dest) values (
-  $DATA, '\\'$THISLOGFILE_REL\\'', '\\'\$DESTFILE\\'')"
-TRAP="$TRAP; $DO_QUERY '$QUERY'"
+  $DATA, '\\'$THISLOGFILE_REL\\'', '\\'\$DESTFILE\\'');
+       select * from messages where filename = '\\'$THISLOGFILE_REL\\''"
+TRAP="$TRAP; case \"$($DO_QUERY '$QUERY')\" in '') 
+      echo 'msgid-index: failed to insert reference into database';; esac"
 
 QUERY
 DATA
diff --git a/procmail/record-delayed-mail b/procmail/record-delayed-mail
new file mode 100644 (file)
index 0000000..72ff6b8
--- /dev/null
@@ -0,0 +1,19 @@
+# create table messages (msgid text unique not null, filename text
+# primary key not null unique, release_ts integer not null);
+
+DELAYED_QUEUE_DB=$PMVAR/delayed-queue.sqlite
+
+DO_QUERY="$SQLITE $DELAYED_QUEUE_DB"
+
+DATA="$MSGID"
+INCLUDERC=$PMDIR/sql-escape
+
+QUERY="insert into messages values ($DATA, '\\'\$DESTFILE\\'', $RELEASE_TS);
+       select * from messages where msgid = $DATA"
+TRAP="$TRAP; case \"$($DO_QUERY '$QUERY')\" in '') 
+      echo 'delay:       failed to insert reference into database';; esac"
+
+QUERY
+DATA
+DO_QUERY
+DELAYED_QUEUE_DB