[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Installing a package downloaded from snapshot - was [Re: Mate error message under Debian 8.6.0]

On Thu, Feb 02, 2017 at 05:59:57PM +0000, Lisi Reisz wrote:
> [redacted]'s rudeness and unpleasantness to anyone and everyone who tries to help 
> him does get a bit wearing.

Speaking of which, I'll share the solution I came up with to implement
a mailing list killfile (ignore list), but I fear it may not be of wide
interest.  qmail's popularity has dwindled in the last decade or so,
and I'm using some tools that are not installed in Debian by default.
I couldn't find anything like this in a few minutes of Google searching,
so I had to write it entirely from scratch.

This technique only applies to people receiving email on a qmail system,
where you have normal Unix user powers.  If your email goes to your ISP's
system, where you don't have a shell, just an IMAP login, then this is
not going to work for you.

To understand how it works at all, you have to read two of qmail's
man pages.  First, dot-qmail(5):

      (2)  A program line begins with a vertical bar:

                |preline /usr/ucb/vacation djb

           qmail-local takes the rest of the line as a command to supply to
           sh.  See qmail-command(8) for further information.

Second, qmail-command(8):

      command's exit codes are interpreted as follows: 0 means that the
      delivery was successful; 99 means that the delivery was successful,
      but that qmail-local should ignore all further delivery instructions;

So, armed with that knowledge, I constructed my ~/.qmail file as


The system this is running on forwards email to another system, hence
the &address there.  If you're doing this on your final destination
host, then the second line would be something like ./Maildir/ instead.

The important point is that you have two lines, with the first being
a program, and the second being a delivery instruction.  The program
runs first, and if it exits with code 99, then the delivery instruction
is NOT used.

Now all that remains is to write such a program.  You can do it in any
language you like.  I chose Tcl:


# Load regexes from ~/.killfile
set regexes {}
set killfile [open ~/.killfile r]
while {[gets $killfile line] >= 0} {
    lappend regexes $line
close $killfile

# Examine headers.
set kill 0
while {[gets stdin line] >= 0} {
    lappend out $line
    if {$line eq ""} break
    if {$kill} continue
    foreach r $regexes {
        if {[regexp $r $line]} {set kill 1; break}
if {! $kill} {exit 0}

# Spew headers and the rest of stdin (body) into the spam pipe.
set spam [open "|/usr/local/bin/maildir Spamdir" w]
puts $spam [join $out \n]
puts $spam [read stdin]
close $spam

# Exiting 99 means "don't read the rest of the dot-qmail file".
exit 99

Don't forget to chmod +x.

This program doesn't just drop the killed email on the floor.  Instead,
it delivers it (locally) to a maildir named Spamdir.  So, I created
that, using the command /var/qmail/bin/maildirmake ~/Spamdir

Note also the use of /usr/local/bin/maildir to perform the delivery.
This is a utility that comes from a package named safecat.  However, DO
NOT USE the safecat that Debian provides.  The Debian maintainer does
not install the entire package; specifically, he does not install the
program named maildir, not its man page, both of which are installed by
the upstream package if you build it yourself.  (And he closed my bug

Of course, that's irrelevant if you don't choose to save the killed
emails.  Dropping them on the floor is easier, and won't require safecat.

Finally, since my program uses a file named ~/.killfile to contain the
actual ignore instructions, I created that:

^From:.*User Name

Make sure you use the correct type of regular expressions for your
program.  There are many different varieties.  Tcl (recent versions)
uses these: http://www.tcl.tk/man/tcl8.6/TclCmd/re_syntax.htm
Perl has its own superset of Extended Regular Expressions, and so on.

My killfile is just that single line for now, but I made the program
flexible so that I can add to it later if the need arises.

Finally, please note that messing with your ~/.qmail file may cause you
to lose mail if you screw something up, so take appropriate cautionary
steps while doing this.  I actually started out by creating a file
named ~/.qmail-foo for testing purposes, and sent messages to
myname-foo at my.domain (*) for testing.  When I was satisfied that it was
working, I moved .qmail-foo to .qmail (while also setting the sticky
bit on $HOME as advised by dot-qmail(5)).

(*) Munged because some list archives may censor email addresses, or
apparent email addresses, in a way that renders the sentence unreadable.

Reply to: