procmail
[Top] [All Lists]

Re: Incorrect Resolution of $HOME Variable

2009-03-27 16:18:36
At 11:56 2009-03-27 -0700, James Butler wrote:

2) procmail -v
procmail v3.22 2001/09/10
...
Locking strategies:     dotlocking, fcntl(), lockf(), flock()
Default rcfile:         /etc/procmailrc
Your system mailbox:    $HOME/Maildir/username/

### NOTE: Procmail did not resolve the $HOME variable!

It doesn't.  In a C source file, $HOME is literally "$HOME".  It doesn't
expand as it would in a shell file.  However, procmail resolves it when it
goes to USE it.


Are you actually experiencing a PROBLEM, or is it merely that the version
output doesn't show the expanded form?

---
  Sean B. Straw / Professional Software Engineering

  Procmail disclaimer:
<http://www.professional.org/procmail/disclaimer.html>
  Please DO NOT carbon me on list replies.  I'll get my copy from the
list.

____________________________________________________________
procmail mailing list   Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail


Thanks! Since you asked, I'll post "The Long Note".

Table of Contents:
- Scenario / Desired Result / Actual Result
- Note
- System Info
- procmail -v (output)
- /etc/postfix/main.cf
- placeholder for postconf -v (if needed, I got it, it's big)
- /etc/procmailrc
- procmail.log (showing failure)
- Directory and Program Permissions
- procmail.log (/home:/home/user2:/home/user2/Maildir = chmod 777)

I hope my ## COMMENTING STYLE is not too hard to get around:

SCENARIO:
1) Message directed to user1
2) Procmail matches Subject, pipes to user2 and
   then to /dev/null (prevents loops when msg sent directly to user2)
DESIRED RESULT:
 3) If procmail matches, deliver to user2
 4) If no match, deliver to user1
ACTUAL RESULTS:
 5) If procmail matches, delivery fails to user2
 6) If no match, delivery succeeds to user1

FOR EXAMPLE, here's what worked with Sendmail on my previous box:
1) Message from list(_at_)law(_dot_)com to lists(_at_)mydomain(_dot_)com
2) Subject: "Law List"
3) Matches: Append to /var/spool/mail/user2
4) Send to bitbucket to prevent loop

Now that I'm using Postfix and Maildirs, I would like to do the same
thing, but I can't get past the "Error while writing to" procmail error.

Procmail is using the user to whom the message was originally sent, of
course. This causes problems when it tries to write to another user's
Maildir.

In addition to not being able to write to the user's Maildir directory,
there used to be another sign of something odd. Back when procmail was
renaming directories to "BOGUS.yaddayadda", earlier on in this
installation process, it would do so as "root:USERGROUP", not
"user:USERGROUP".

See my end comment in the "procmail -v" section.

I have tried all sorts of stuff found online without success, and started
from scratch several times. I have always used "make install" with
successful locking tests in real user Maildirs followed by "make
install-suid".

Any thoughts are greatly appreciated.

Thanks! James

== system info ==
Fedora 10
Postfix 2.5.5
Procmail 3.22
=================

I am starting with "procmail -v" output, because it looks weird and may
illuminate what I am missing:

== procmail -v ==
procmail v3.22 2001/09/10
...
Locking strategies:     dotlocking, fcntl(), lockf(), flock()
Default rcfile:         /etc/procmailrc
Your system mailbox:    $HOME/Maildir/root/

## "Your system mailbox:" SEEMS WEIRD. IT RESOLVES TO THE ABOVE
## WHEN COMPILED WITH:
##  [config.h] #define DEFmaildir "$HOME/Maildir"
##  [authenticate.c] #define MAILSPOOLDIR "$HOME/Maildir/"
##
## SHOULDN'T "Your system mailbox:" = "/home/root/Maildir/"
## WHERE "$HOME" = "/home/root" ?!? (FYI: root IS ALIASED TO user3)
## I CAN'T JUST USE "Maildir" BECAUSE IT MUST BE AN ABSOLUTE PATH,
## AND THE "Error while writing to ..." ISSUE REMAINS REGARDLESS OF
## WHETHER IT IS SET TO JUST "$HOME" OR "$HOME/Maildir"
## IF I JUST USE "$HOME", THEN I GET:
## "Your system mailbox: /var/spool/mail/root" <=NOT A Maildir/
##
## HERE IS A TYPICAL USER MAIL DIRECTORY, REFLECTING THE WEIRDNESS:
## /home/user2/Maildir
## /home/user2/Maildir/cur <=MAIL
## /home/user2/Maildir/new <=MAIL
## /home/user2/Maildir/tmp <=MAIL
## /home/user2/Maildir/.Sent
## /home/user2/Maildir/.Drafts
## /home/user2/Maildir/.Trash
## HERE ARE THE WEIRDO DIRECTORIES, WHICH I BELIEVE ARE BEING CREATED
## BECAUSE OF THE "Your system mailbox:" THINGY (SEEMS ABNORMAL):
## /home/user2/Maildir/user2 <=EMPTY EXCEPT FOR CHILD DIRs
## /home/user2/Maildir/user2/cur <=EMPTY
## /home/user2/Maildir/user2/new <=EMPTY
## /home/user2/Maildir/user2/tmp <=EMPTY
##
## NOTE THE WEIRDNESS WITH THE EMPTY DIRECTORIES. THEY WERE CREATED
## BY PROCMAIL WITH THE FIRST RECEIVED MESSAGE, EVEN THOUGH THEY
## ARE NOT BEING USED FOR MAIL. MAIL IS GOING WHERE IT SHOULD,
## UNLESS PROCMAIL MATCHES A RULE. IF IT MATCHES AND DIRECTORY
## PERMISSIONS ARE SET TO GLOBAL rw, THEN IT GOES TO
## /home/user2/Maildir - NOT TO THE PROPER /home/user2/Maildir/new
##
## /home/user2/Maildir/user2 DIRECTORY IS THE PARENT THAT WOULD
## GET RENAMED BY PROCMAIL TO "BOGUS.xxx" IF I CREATED IT. WHEN I
## LET PROCMAIL CREATE IT, NO PROBLEM. SAME WITH ITS CHILD DIRs.
## IN THAT SCENARIO, IT DIDN'T MATTER WHOSE PERMISSIONS THE DIRs
## HAD, PROCMAIL WOULD RENAME THEM TO "BOGUS.xxx" USING root:USERGROUP
## CREDENTIALS. WHEN IT IS ALLOWED TO CREATE THEM, ITSELF, PROCMAIL
## USES THE CORRECT user:USERGROUP CREDENTIALS.

================

== /etc/postfix/main.cf ==
#mailbox_command = /usr/bin/procmail -t
mailbox_command = /usr/bin/procmail -a "$EXTENSION"
==========================

== postconf -v [593 lines] ==
# READY TO POST, IF NECESSARY
=============================

== /etc/procmailrc ==

## NOT USING LOCKS BECAUSE ITS A Maildir/

MAILDIR=$HOME/Maildir
DEFAULT=$MAILDIR/
ORGMAIL=$DEFAULT
LOGFILE=$HOME/procmail.log
VERBOSE=ON
TESTMBOX=/home/user2/Maildir
DROPPRIVS=yes
SHELL=/bin/sh
:0
*^Subject.*TEST CASE
{
 :0c
 $TESTMBOX
## if the message was SENT to user3, this loops unless
## I send it to the bitbucket, so I always send it there:
 :0
 /dev/null
}
=====================

== procmail.log ==
procmail: [15091] Thu Mar 26 13:52:14 2009
procmail: Assigning "TESTMBOX=/home/user2/Maildir"
procmail: Assigning "DROPPRIVS=yes"
procmail: Assuming identity of the recipient, VERBOSE=off
procmail: Assigning "SHELL=/bin/sh"
procmail: Match on "^Subject.*TEST CASE"
procmail: Assigning "LASTFOLDER=/home/user2/Maildir"
procmail: Opening "/home/user2/Maildir"
procmail: Error while writing to "/home/user2/Maildir"
procmail: Assigning "LASTFOLDER=/dev/null"
procmail: Opening "/dev/null"
procmail: Notified comsat: "user1(_at_)0:/dev/null"
From user1(_at_)mydomain(_dot_)com  Thu Mar 26 13:52:14 2009
 Subject: TEST CASE
  Folder: /dev/null 792

## WHEN I USED "TESTMBOX=/home/user2/Maildir/" I ALSO
## RECEIVED "Unable to treat as directory:" ERRORS,
## PRIOR TO "Assigning "LASTFOLDER=..."
## "/home/user2/Maildir" (NO TRAILING SLASH) WORKS.

===================

== permissions ==
/home/user2 & /home/user2/Maildir:
 drwx------  4 user2 Staff 4096 2009-03-26 10:56 user2
 drwx------ 10 user2 Staff 9288 2009-03-26 12:12 Maildir

/usr/bin/procmail:
 -rwsr-xr-x 1 root root 73836 2009-03-20 16:25 procmail

Also tried g+s /usr/bin/procmail:
 -rwsr-sr-x 1 root root 73836 2009-03-20 16:25 procmail

## IF /home/ ON DOWN IS chmod 777 THERE IS NO ERROR,
## BUT DELIVERY GOES TO THE WRONG PLACE WITH THE WRONG NAME (below)

=================

WITH /home:/home/user2:/home/user2/Maildir = chmod 777:

== procmail.log ==
procmail: [15553] Thu Mar 26 14:39:11 2009
procmail: Assigning "TESTMBOX=/home/user2/Maildir"
procmail: Assigning "DROPPRIVS=yes"
procmail: Assuming identity of the recipient, VERBOSE=off
procmail: Assigning "SHELL=/bin/sh"
procmail: Match on "^Subject.*TEST CASE"
procmail: Assigning "LASTFOLDER=/home/user2/Maildir/msg.5PU1"
procmail: Opening "/home/user2/Maildir/msg.5PU1"
procmail: Acquiring kernel-lock
procmail: Notified comsat: "user1(_at_)0:/home/user2/Maildir/msg.5PU1"
From user1(_at_)mydomain(_dot_)com  Thu Mar 26 14:39:11 2009
 Subject: TEST CASE
  Folder: /home/user2/Maildir/msg.5PU1 799

## SHOULD HAVE GONE TO "/home/user3/Maildir/new/" AND
## "msg.5PU1" IS NOWHERE NEAR A CORRECT MAILFILE NAME. REAL
## MAILFILE NAMES ARE LIKE:
## "1238094061.15247_0.myaccount.us.server.com:2,"
## EVEN GETTING THE MESSAGE INTO THE RIGHT PLACE SCREWS THINGS UP,
## BECAUSE THE MAILBOX WON'T OPEN WITH THE BADLY-NAMED MAILFILE IN IT

===============================================================


____________________________________________________________
procmail mailing list   Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail