LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Procmail permission (https://www.linuxquestions.org/questions/linux-newbie-8/procmail-permission-4175735421/)

mike1950r 03-28-2024 05:25 PM

Procmail permission
 
Hi,

I cannot make procmail to write to local mailbox.
get following error message:
procmail: Error while writing to "/var/mail/...
What is missing, permission ?
Thanks for assistance.
Cheers mike

jayjwa 03-29-2024 08:47 AM

Are you using this from Sendmail?
Code:

FEATURE(`local_procmail',`',`procmail -t -f- -a $h -d $u')dnl
MAILER(procmail)dnl

Code:

file /var/mail
/var/mail: symbolic link to spool/mail

ls -la /var/mail/
total 132
drwxrwxrwt  2 root  mail  4096 Mar 28 16:07 ./
drwxr-xr-x 19 root  root  4096 Feb 23 13:15 ../


mike1950r 03-29-2024 10:07 AM

Hi jayjwa,

thanks for your reply.
I just use this:

:0
* ^Subject:.*Undelivered Mail.*Returned.*to.*Sender
/var/mail/admin


and I get following error message:

procmail: Error while writing to "/var/mail/admin"


ls -la /var/mail/
total 76
drwxrwsr-x 2 root mail 4096 Mar 29 16:15 .
drwxr-xr-x 13 root root 4096 Feb 26 2020 ..


Cheers mike

jayjwa 03-29-2024 12:09 PM

If you are not running that as root nor mail, you can't write to /var/mail as you have
Code:

drwxrwsr-x
vs
Code:

drwxrwxrwt

mike1950r 03-29-2024 12:19 PM

Ah, thanks,
so you mean that procmailrc needs root permissions?
cheers mike

scasey 03-29-2024 12:20 PM

AFAIK, procmail can’t create directories…the targets of procmail recipes must already exist.

mike1950r 03-29-2024 02:02 PM

thanks scasey,

/var/mail/admin is an existing file.

i stuck with the permissions, not very familiar for me.
anyway procmailrc file has root:root permission.

so i think it's problem with the permission of /var/mail/admin file, which i have posted above in my earlier reply.

cheers mike

mike1950r 03-29-2024 04:53 PM

Jayjwa,

could you give me perhaps the command for setting drwxrwxrwt to /var/mail/admin (file)?

Thanks for your info.
Cheers mike

MadeInGermany 03-30-2024 02:24 AM

I think it needs to create a temp file in /var/mail so /var/mail must be writable.
Code:

chmod 1777 /var/mail
chmod g+s /var/mail


mike1950r 03-30-2024 06:45 AM

thanks MadeInGermany,

get now:

ls -la /var/mail/
total 120
drwxrwsrwt 2 root mail 4096 Mar 30 12:31 .
drwxrwxr-x 13 root root 4096 Feb 26 2020 ..

btw get also:
stat -c '%A %a %n %U %G' /var/mail/
drwxrwsrwt 3777 /var/mail/ root mail

why do I get 3777 instead of 1777 ?

cheers mike

mike1950r 03-30-2024 07:00 AM

still get this result for procmailrc entry:

:0
* ^Subject:.*Undelivered Mail.*Returned.*to.*Sender
/var/mail/admin

procmail: Match on "^Subject:.*Undelivered Mail.*Returned.*to.*Sender"
procmail: Assigning "LASTFOLDER=/var/mail/admin"
procmail: Opening "/var/mail/admin"
procmail: Error while writing to "/var/mail/admin"

cheers mike

friendlysalmon8827 03-30-2024 07:38 AM

It seems to me that a possible solution to the OP's question would be if the OP were able to create a standard user and configure said user with a mailbox as a debugging step.

MadeInGermany 03-30-2024 07:42 AM

The g+s adds one bit, obviously the significant 2.
(Like the significant 1 that is the t bit. Both bits make 2+1 == 3).

Ensure the file is present with correct owner and permission: as the user (mailbox owner) do
Code:

touch /var/mail/admin
chmod 660 /var/mail/admin

Eventually rm an incorrect /var/mail/admin file first, or rmdir a /var/mail/admin directory.

mike1950r 03-30-2024 11:34 AM

thanks MadeInGermany,

permission 660 does not work.
but if i use 662 it works.

Am I missing something?

cheers mike

mike1950r 03-30-2024 03:46 PM

OK,

found the solution:

Just add user 'root' to /var/mail/admin (root is the user of procmailrc)
permission 660 is now OK for /var/mail/admin.
adding the t bit to /var/mail/ is not needed.

everything works now as wanted.

just one more question:

ls -la /var/mail/
total 76
drwxrwsr-x 2 root mail 4096 Mar 29 16:15 .
drwxr-xr-x 13 root root 4096 Feb 26 2020 ..

First entry is the permission of the folder itself.
But what is the second permission?

Thanks for a tip.

Cheers mike


All times are GMT -5. The time now is 06:17 PM.