11 years agoUNTESTED: Filter spam into 3 different folders based on score. master [Tue, 28 Apr 2009 05:58:49 +0000 (22:58 -0700)]
UNTESTED: Filter spam into 3 different folders based on score.

(spam_level): Rename from is_spam .  Return 0 for not spam, and 1, 2, or 3 for
  exceeding 1, 2, or 3 * the user's configured threshold.
(process): Construct spam folder name with the spam_level .

11 years agoTurn on qmail integration by default. [Tue, 10 Mar 2009 21:38:21 +0000 (14:38 -0700)]
Turn on qmail integration by default.

The odds of anyone but me ever using this are just about nil anyway, may as
well make sure I don't forget to turn this on again...

11 years agoInstall the processor. [Sun, 8 Mar 2009 09:23:59 +0000 (01:23 -0800)]
Install the processor.

11 years agoUpdate libspam.[ch] utils.[ch] from spamassassin 3.1.0 to 3.2.5 . [Sun, 8 Mar 2009 09:20:24 +0000 (01:20 -0800)]
Update libspam.[ch] utils.[ch] from spamassassin 3.1.0 to 3.2.5 .

11 years agoDrop gratuitous differences from 3.1.0 . [Sun, 8 Mar 2009 09:16:30 +0000 (01:16 -0800)]
Drop gratuitous differences from 3.1.0 .

Earlier I said this was based on 3.1.3, but actually it's 3.1.0 .

* config.h
  Add this, as libspamc.c expects to include it.  Define autoconf macros it
  expects.  Move includes and declarations for my code here.

* libspamc.c
  Drop gratuitous differences.

* libspamc.h
  Only declare libspamc_log if libspamc_log isn't defined as macro (in
  config.h), same as libspamc.c .

11 years agoBegin upgrading processor from spamassassin 3.1.3 to 3.2.5. [Sun, 8 Mar 2009 08:43:41 +0000 (00:43 -0800)]
Begin upgrading processor from spamassassin 3.1.3 to 3.2.5.

(get_transport): Initialize the transport with transport_init (should have
  already been doing this).  Set connect_retries and retry_sleep to the
  hard-coded settings from 3.1.3.

11 years agoFix installation modes. [Sun, 8 Mar 2009 07:08:49 +0000 (23:08 -0800)]
Fix installation modes.

12 years agoExplicitly use the file names during man page generation, since the $<
dsp [Wed, 23 Jan 2008 04:47:45 +0000 (04:47 +0000)]
Explicitly use the file names during man page generation, since the $<
internal macro only applies to inference rules with BSD make.

12 years agoFlesh out the Makefile to support building the mdeliver(1) man page, and
dsp [Wed, 23 Jan 2008 04:40:25 +0000 (04:40 +0000)]
Flesh out the Makefile to support building the mdeliver(1) man page, and
installing both the mdeliver binary and man page.  To simplify the pod2man
command, mdeliver.1.pod was renamed mdeliver.pod.

12 years agoFall back to finding the home directory using getpwuid(3) if the HOME
dsp [Tue, 22 Jan 2008 23:15:31 +0000 (23:15 +0000)]
Fall back to finding the home directory using getpwuid(3) if the HOME
environment variable isn't set.

14 years agoOops, r1946 only made this exit(0) on non-fatal errors; pass -1 to
epg [Thu, 20 Apr 2006 22:55:44 +0000 (22:55 +0000)]
Oops, r1946 only made this exit(0) on non-fatal errors; pass -1 to
_err, not 0!

14 years agoOuch, was bombing when talking to spamd failed for any reason, leaving
epg [Wed, 19 Apr 2006 19:41:22 +0000 (19:41 +0000)]
Ouch, was bombing when talking to spamd failed for any reason, leaving
messages in mdp.  spamd failures aren't hard failures, just consider
messages where that happens not to be spam.

14 years agoUse an actual maildir called spam, not simply a subdir beside 'new'.
epg [Thu, 13 Apr 2006 01:44:31 +0000 (01:44 +0000)]
Use an actual maildir called spam, not simply a subdir beside 'new'.

14 years agotiny correction
epg [Thu, 30 Mar 2006 18:59:37 +0000 (18:59 +0000)]
tiny correction

14 years agoAdd a sample processor. This talks to spamassassin spamd to find out
epg [Thu, 30 Mar 2006 02:28:59 +0000 (02:28 +0000)]
Add a sample processor.  This talks to spamassassin spamd to find out
if a message is spam.  If so, it moves it to maildir/spam, else it
moves it to maildir/new.

{libspamc,utils}.[ch] are icky, icky bits from spamassassin's spamc.
The only substantial change is to make libspamc.c:_message_read_raw
mmap the message instead of reading the entire thing into memory (wtf
were they thinking?!).

14 years agoDefine and use try_unlink macro instead of save_errno(unlink) all over
epg [Thu, 30 Mar 2006 02:09:04 +0000 (02:09 +0000)]
Define and use try_unlink macro instead of save_errno(unlink) all over
the place.

(_err): Don't use the wrong errno if some printing fails.

14 years agoSupport qmail if the QMAIL macro is defined. This entails exiting 111
epg [Thu, 30 Mar 2006 01:59:47 +0000 (01:59 +0000)]
Support qmail if the QMAIL macro is defined.  This entails exiting 111
on failure, not having to worry about dumbass /^From /, and handling


s/TMPNAMLEN/LEN_FILENAME/; it's not just used for the tmp file.

Random cleanup:
- drop some redundant comments
- s/statbuf/st/
- cleanup error messages
- other style nits

Drop <err.h> and implement custom err and errx, which doesn't need to
be passed an exit code.

Implement and use full_sleep to really sleep the specified time.

(get_filename): Don't break when gethostname truncates.

(strip_from): Don't even compile this for QMAIL.

(deliver): Take a new parameter, the subdirectory to deliver to,
instead of "new".  #ifdef QMAIL, write RPLINE and DTLINE to tmp file
before copying stdin.

(deliver): Also had a huge problem: it was using the logic i came up
with for minc, to open an empty file for the target and then rename
onto that.  That's fine for mh, which already loses mail this way
(once i switch refile to be like minc this will be fine), but since
other Maildir MDAs follow the official algorithm, this could clobber
mail.  Switch to the official algorithm.

(run_processor): Use better error message format.

(main): If .mdeliver-processor exists, pass deliver "mdb" as the
subdirectory and then call run_processor, else pass "new".

14 years ago(run_processor): r1901 was a little off; this should only _exit when
epg [Wed, 29 Mar 2006 05:09:18 +0000 (05:09 +0000)]
(run_processor): r1901 was a little off; this should only _exit when
the fork succeeded, and we cannot use vfork, as we need to write an
error message if the exec failed.

14 years ago(get_filename): Wtf was i thinking switching to gmtime_r, just sprintf
epg [Wed, 29 Mar 2006 05:05:54 +0000 (05:05 +0000)]
(get_filename): Wtf was i thinking switching to gmtime_r, just sprintf
the whole thing in one go.

14 years ago(get_filename): Use gmtime_r.
epg [Wed, 29 Mar 2006 02:30:07 +0000 (02:30 +0000)]
(get_filename): Use gmtime_r.

14 years agoYikes. run_processor was having the child return back to main if exec
epg [Tue, 28 Mar 2006 23:23:04 +0000 (23:23 +0000)]
Yikes.  run_processor was having the child return back to main if exec
fails.  Fix that, and switch to vfork.

16 years agoInitial draft of mdeliver(1) man page.
dsp [Thu, 14 Oct 2004 20:13:01 +0000 (20:13 +0000)]
Initial draft of mdeliver(1) man page.

17 years agoRename the rcsid variable to ident, since this isn't an "RCS Id" after
epg [Thu, 10 Apr 2003 03:47:32 +0000 (03:47 +0000)]
Rename the rcsid variable to ident, since this isn't an "RCS Id" after

17 years agomdeliver/current/mdeliver.c:
epg [Sun, 19 Jan 2003 03:11:14 +0000 (03:11 +0000)]
    (deliver): In rev 1582 i changed this from using rename(2) to
    the recommended link(2) + unlink(2).  But in minc i was using
    open(2) + rename(2) instead, which is just as safe as link +
    unlink but with one advantage.  So switch to that model.

    (store_message): Document the open + rename procedure and
    explain why it is used instead of link + unlink.

17 years ago(strip_from): I added a comment about my confidence in the
epg [Thu, 16 Jan 2003 20:40:57 +0000 (20:40 +0000)]
(strip_from): I added a comment about my confidence in the
read-first-five-bytes or fail bit a long time ago, but never
committed it.

17 years ago(deliver): Stick closer to the standard maildir delivery algorithm by
epg [Thu, 16 Jan 2003 17:59:18 +0000 (17:59 +0000)]
(deliver): Stick closer to the standard maildir delivery algorithm by
using link(2) + unlink(2) instead of rename(2) to get the message file
from tmp to new.  rename(2) will clobber an existing file, which we
don't want; link(2) will not.

Strictly speaking this is an impossible scenario for mdeliver, for
which one process delivers no more than one message.  It is, however,
not outside the realm of possibility that a filename identical to the
one chosen by mdeliver came into existence for some unrelated reason
(though the odds of this happening must be staggering).

Perhaps more importantly, it has been reported on the qmail list that
OpenBSD 3.2 will reuse the same PID in the same second, which would
mean this was a real problem on that system.

Whatever the case, this addresses any potential problems.

17 years agoGo back to using fork(2), since using vfork caused a segfault.
epg [Sat, 30 Nov 2002 08:11:36 +0000 (08:11 +0000)]
Go back to using fork(2), since using vfork caused a segfault.
Maybe i misunderstood something.  Worry about it later.

18 years ago(TMPNAMLEN): Whoops, forgot to account for the two dots in the temp
epg [Sat, 30 Nov 2002 07:25:13 +0000 (07:25 +0000)]
(TMPNAMLEN): Whoops, forgot to account for the two dots in the temp
file name.

18 years agoUse vfork(2) instead of fork(2).
epg [Tue, 17 Sep 2002 12:45:16 +0000 (12:45 +0000)]
Use vfork(2) instead of fork(2).

18 years agoMake run_processor work again.
epg [Fri, 13 Sep 2002 02:16:06 +0000 (02:16 +0000)]
Make run_processor work again.

18 years ago(run_processor): While there's nothing we can do if any of the
epg [Fri, 13 Sep 2002 01:49:16 +0000 (01:49 +0000)]
(run_processor): While there's nothing we can do if any of the
err-file-writing steps fail, there's no reason we can't be a little
more careful in doing it.  Do so (including using fflush, fsync,
and close).

18 years ago(run_processor): Now only takes a single argument, the filename of the
epg [Fri, 13 Sep 2002 01:43:09 +0000 (01:43 +0000)]
(run_processor): Now only takes a single argument, the filename of the
new message.  The process to run is now hard-coded to be a dot-file in
the user's home directory.

(main): Now unconditionally call run_processor.

18 years agoRename copy_message to copy_file, document it, and make it slightly
epg [Wed, 11 Sep 2002 02:12:04 +0000 (02:12 +0000)]
Rename copy_message to copy_file, document it, and make it slightly
more generic.  Now i can share it with other programs (for example, my
portable install(1)).

18 years ago(run_processor): New function.
epg [Sun, 8 Sep 2002 07:52:40 +0000 (07:52 +0000)]
(run_processor): New function.

(main): Move the logic of running the optional message processor to
the new run_processor function.

18 years ago(main): If running the optional program on the newly delivered message
epg [Fri, 6 Sep 2002 07:19:16 +0000 (07:19 +0000)]
(main): If running the optional program on the newly delivered message
fails, save errno before getting to work on creating an error file.

18 years ago(save_errno): New macro.
epg [Fri, 6 Sep 2002 07:08:49 +0000 (07:08 +0000)]
(save_errno): New macro.

Use save_errno to protect errno in the 101 places i was calling
unlink(2) and then err(3), possibly reporting the wrong error message.

18 years ago(get_filename): Handle failure cases for time(3) and gmtime(3).
epg [Fri, 6 Sep 2002 06:32:49 +0000 (06:32 +0000)]
(get_filename): Handle failure cases for time(3) and gmtime(3).

18 years ago(get_filename): Restore errno before returning.
epg [Fri, 6 Sep 2002 06:29:47 +0000 (06:29 +0000)]
(get_filename): Restore errno before returning.

18 years agoOnly include <sysexits.h> if MDELIVER_EXITCODE is not defined, and if
epg [Fri, 6 Sep 2002 05:58:27 +0000 (05:58 +0000)]
Only include <sysexits.h> if MDELIVER_EXITCODE is not defined, and if
it isn't defined, define it to EX_TEMPFAIL.  Change all references to

18 years ago(strip_from): DOH! This will teach me to code at 2:30 in the middle
epg [Sun, 25 Aug 2002 07:39:04 +0000 (07:39 +0000)]
(strip_from): DOH!  This will teach me to code at 2:30 in the middle
of the night.  Use strncmp(3) correctly.

18 years agoDocument the get_filename, strip_from, and copy_message functions.
epg [Sun, 25 Aug 2002 07:22:41 +0000 (07:22 +0000)]
Document the get_filename, strip_from, and copy_message functions.

18 years ago(get_filename): Check gethostname(3) return value.
epg [Sun, 25 Aug 2002 07:11:23 +0000 (07:11 +0000)]
(get_filename): Check gethostname(3) return value.

18 years agoReorganize the deliver function, splitting out logical units into the
epg [Sun, 25 Aug 2002 07:05:50 +0000 (07:05 +0000)]
Reorganize the deliver function, splitting out logical units into the
separate functions deliver, get_filename, strip_from, and

(get_filename): Move deliver's filename-getting code to this new

(strip_from): Move deliver's busted-from-line stripping code to this
new function.

(copy_message): Move deliver's stdin-to-new-file-copying code to this
new function.

(deliver): Call the above new functions appropriately.

18 years ago(deliver): Check for and strip 'From ' line that some broken mailers
epg [Sun, 25 Aug 2002 06:50:37 +0000 (06:50 +0000)]
(deliver): Check for and strip 'From ' line that some broken mailers
(such as Postfix) add as the first line of input.

18 years ago(deliver): Handle errors from read(2) on stdin.
epg [Sun, 25 Aug 2002 06:27:11 +0000 (06:27 +0000)]
(deliver): Handle errors from read(2) on stdin.

18 years ago(deliver): Create message files with mode 0600 instead of 0644.
epg [Sun, 25 Aug 2002 02:44:45 +0000 (02:44 +0000)]
(deliver): Create message files with mode 0600 instead of 0644.

18 years ago(main): Create the err directory before trying to store an error
epg [Sat, 24 Aug 2002 18:19:05 +0000 (18:19 +0000)]
(main): Create the err directory before trying to store an error
message in it.

18 years ago(main): Don't assume the current directory is the user's home
epg [Thu, 22 Aug 2002 04:08:30 +0000 (04:08 +0000)]
(main): Don't assume the current directory is the user's home
directory.  Get the HOME environment variable and chdir(2) there.

18 years ago(LDFLAGS): Set to -static.
epg [Thu, 22 Aug 2002 03:26:50 +0000 (03:26 +0000)]
(LDFLAGS): Set to -static.

18 years agoAdd program description comment at the top.
epg [Thu, 22 Aug 2002 03:25:28 +0000 (03:25 +0000)]
Add program description comment at the top.

18 years ago(rcsid): New global char[].
epg [Wed, 21 Aug 2002 07:20:34 +0000 (07:20 +0000)]
(rcsid): New global char[].

(main): Print rcsid and exit if -v is the first argument.

18 years agoSet svn:keywords to 'Id'.
epg [Wed, 21 Aug 2002 06:45:09 +0000 (06:45 +0000)]
Set svn:keywords to 'Id'.

18 years ago(main): Use execv(3) instead of execvp(3).
epg [Tue, 20 Aug 2002 22:36:00 +0000 (22:36 +0000)]
(main): Use execv(3) instead of execvp(3).

18 years agoInclude <limits.h>.
epg [Tue, 20 Aug 2002 05:46:34 +0000 (05:46 +0000)]
Include <limits.h>.

Define HOST_NAME_MAX if not set.  Use it instead of 64 for

Create new macro TMPNAMLEN for declaring maildir filename strings.

18 years agoNew program.
epg [Tue, 20 Aug 2002 05:07:37 +0000 (05:07 +0000)]
New program.

18 years ago(no commit message)
<> [Tue, 20 Aug 2002 05:07:36 +0000 (05:07 +0000)]