procmail
[Top] [All Lists]

Re: procmail and mail file locking

2020-05-17 06:38:24


On 5/16/20 4:59 PM, Andreas Schamanek wrote:

What Ruud posted is certainly good stuff but I got the impression from Robert's postings that this is overkill.

On Thu, 14 May 2020, at 22:26, Robert Moskowitz wrote:

Does procmail default lock the local delivery mail file as I have been told postfix and other MTAs do?

In case of files, yes.

Just to be sure, you are talking about the mbox mail file.  Your last comment seems to assure me that you mean writing to an mbox file.


If I run `procmail -f $MAILTO` where procmail is getting the mail file from STDIN.

That's fine. It does not change the default locking.

Or do I add something like the following to my script:

exec 100>/var/spool/mail$USER.lock || exit 1
flock -w 120 100 || exit 1

Not needed.

And do I also need -d $MAILTO on the above procmail call?

Not as long as $MAILTO is your own address.

On Fri, 15 May 2020, at 09:31, Robert Moskowitz wrote:

Se also https://linux.die.net/man/5/procmailrc
which mentions using lock files.

I am piping the output of a formail command into procmail.  No receipts.

Piping formail also doesn't change the fact that procmail has its default locking when delivering to files. But I did not get your remark about receipts.

I am not using receipts where I see the use of lockfile in the examples.  I have a 'simple' formail command that is then piped into procmail.


It was that man page that clued me into needing to do something about locking the access to /var/spool/mail/$USER file.

It should work in most cases. Of course there are pathological cases like spool dirs mounted on network file systems or uncommon mail delivery agents (not that I know any).

But what is the 'common' lock file name? The examples in the above mask the file which is the lock file.

/var/spool/mail/$USER.lock but see the manpages for details or run an strace if you want to be sure. I am actually not sure procmail creates a $LOCKEXT (defaults to .lock) file but I also did not bother to check. In any case quoting from procmail(1)

   Whenever procmail itself opens a file to deliver to, it
   consistently uses the following kernel locking strategies:
   fcntl(2).



thanks!
____________________________________________________________
procmail mailing list -- procmail(_at_)lists(_dot_)rwth-aachen(_dot_)de   
Procmail homepage: http://www.procmail.org/
To unsubscribe send an email to 
procmail-leave(_at_)lists(_dot_)rwth-aachen(_dot_)de
https://lists.rwth-aachen.de/postorius/lists/procmail.lists.rwth-aachen.de

<Prev in Thread] Current Thread [Next in Thread>