procmail
[Top] [All Lists]

RE: Procmail and munpack problem : could not get current directory

2004-03-18 09:11:34


-----Original Message-----
From: Martynas Buozis
Sent: Thursday, March 18, 2004 5:11 AM

Some time ago I got here an advice how to list all mail
attachments. It was
from Gary Funck and he advised me to use this :
[...]


As I am using AIX 4.3.2, so I have no mktemp command and also had
to compile
munpack by myself. That's what I did in /etc/procmailrc (no drop of
privileges are configured, procmail is suid root)  :


Although it seems likely procmail is running as 'root', it might also
be running as 'mail' or some other user. Also, if your mail system
requires that procmail be listed in /etc/smrsh or some such other access
restrictions may apply. Finally, it is possible that procmail was configured
in the mail. config to run as the user for which delivery is being made.
And, of course, /etc/procmailrc is read when local delivery is being made,
for example, when a user puts procmail in their .forward file.

Try adding:

NL="
"
LOG="USER: $USER$NL"
LOG="LOGNAME: $LOGNAME$NL"

at the top of /etc/procmailrc and look in the log to see if it gives
you the answers that you expect.

My guess is that your script is sometimes not being run as 'root',
or is always run on a per-user basis.

MUNPACK=/usr/local/procmail/bin/munpack
TMPDIR=/tmp/procmail.$$

:0 Wic
 | mkdir -p $TMPDIR

 FLIST  = `$MUNPACK -q -t -C $TMPDIR  2>/dev/null`


You don't have the assignment to TRAP, which
will ensure that the temp. directory is later removed:

TRAP="rm -rf $TMPDIR; $TRAP"

which could lead to problems when another user comes through
and attempts to recreate the temp directory, but it already
exists. It will use the old one, created by another user.

Try 'ls -l /tmp' and see if it shows various directories created
by different users of the form /tmp/procmail.#### where #### are digits.

Now sometimes (not every time!) I am getting this message :

procmail: Assigning "MUNPACK=/usr/local/procmail/bin/munpack"
procmail: Assigning "TMPDIR=/tmp/procmail.36688"
procmail: Executing "mkdir,-p,/tmp/procmail.36688"
procmail: [36688] Thu Mar 18 09:16:41 2004
procmail: Assigning "LASTFOLDER=mkdir -p /tmp/procmail.36688"
procmail: Executing "cd $TMPDIR; $MUNPACK -q -t -C $TMPDIR  2>/dev/null"

I didn't see this "cd $TMPDIR;" in the procmailrc file that you
gave above. Is the log output shown in sync. with the procmail
recipe that you listed?

shell-init: could not get current directory: getcwd: cannot access parent
directories: Permission denied
cd_links: could not get current directory: getcwd: cannot access parent
directories: Permission denied
/usr/local/bin/bash: cd: /tmp/procmail.36688: Permission denied
job-working-directory: could not get current directory: getcwd: cannot
access parent directories: Permission denied
procmail: Assigning "FLIST="

Why this error occurs sometimes ?


See above. (1) because the procmail script isn't always being run as
super-user, and (2) the temporary directories aren't being removed after
they're used.



_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

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