LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-28-2024, 05:25 PM   #1
mike1950r
LQ Newbie
 
Registered: Oct 2021
Posts: 24

Rep: Reputation: Disabled
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
 
Old 03-29-2024, 08:47 AM   #2
jayjwa
Member
 
Registered: Jul 2003
Location: NY
Distribution: Slackware, Termux
Posts: 774

Rep: Reputation: 243Reputation: 243Reputation: 243
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 ../
 
1 members found this post helpful.
Old 03-29-2024, 10:07 AM   #3
mike1950r
LQ Newbie
 
Registered: Oct 2021
Posts: 24

Original Poster
Rep: Reputation: Disabled
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

Last edited by mike1950r; 03-29-2024 at 10:26 AM.
 
Old 03-29-2024, 12:09 PM   #4
jayjwa
Member
 
Registered: Jul 2003
Location: NY
Distribution: Slackware, Termux
Posts: 774

Rep: Reputation: 243Reputation: 243Reputation: 243
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
 
Old 03-29-2024, 12:19 PM   #5
mike1950r
LQ Newbie
 
Registered: Oct 2021
Posts: 24

Original Poster
Rep: Reputation: Disabled
Ah, thanks,
so you mean that procmailrc needs root permissions?
cheers mike
 
Old 03-29-2024, 12:20 PM   #6
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,727

Rep: Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211
AFAIK, procmail can’t create directories…the targets of procmail recipes must already exist.
 
Old 03-29-2024, 02:02 PM   #7
mike1950r
LQ Newbie
 
Registered: Oct 2021
Posts: 24

Original Poster
Rep: Reputation: Disabled
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
 
Old 03-29-2024, 04:53 PM   #8
mike1950r
LQ Newbie
 
Registered: Oct 2021
Posts: 24

Original Poster
Rep: Reputation: Disabled
Jayjwa,

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

Thanks for your info.
Cheers mike
 
Old 03-30-2024, 02:24 AM   #9
MadeInGermany
Senior Member
 
Registered: Dec 2011
Location: Simplicity
Posts: 2,796

Rep: Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201
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
 
1 members found this post helpful.
Old 03-30-2024, 06:45 AM   #10
mike1950r
LQ Newbie
 
Registered: Oct 2021
Posts: 24

Original Poster
Rep: Reputation: Disabled
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
 
Old 03-30-2024, 07:00 AM   #11
mike1950r
LQ Newbie
 
Registered: Oct 2021
Posts: 24

Original Poster
Rep: Reputation: Disabled
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

Last edited by mike1950r; 03-30-2024 at 07:10 AM.
 
Old 03-30-2024, 07:38 AM   #12
friendlysalmon8827
Member
 
Registered: Dec 2023
Distribution: Anfroid,Debian
Posts: 85

Rep: Reputation: 5
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.
 
Old 03-30-2024, 07:42 AM   #13
MadeInGermany
Senior Member
 
Registered: Dec 2011
Location: Simplicity
Posts: 2,796

Rep: Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201
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.

Last edited by MadeInGermany; 03-30-2024 at 07:46 AM.
 
1 members found this post helpful.
Old 03-30-2024, 11:34 AM   #14
mike1950r
LQ Newbie
 
Registered: Oct 2021
Posts: 24

Original Poster
Rep: Reputation: Disabled
thanks MadeInGermany,

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

Am I missing something?

cheers mike

Last edited by mike1950r; 03-30-2024 at 11:58 AM.
 
Old 03-30-2024, 03:46 PM   #15
mike1950r
LQ Newbie
 
Registered: Oct 2021
Posts: 24

Original Poster
Rep: Reputation: Disabled
Wink

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

Last edited by mike1950r; 03-31-2024 at 10:12 AM.
 
  


Reply

Tags
mailbox, procmailrc



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Procmail on Rocky Linux using Postfix and Maildir - Procmail not working for Spamassassin cmstechnical Linux - Newbie 1 05-02-2022 05:24 AM
procmail: Skipped "{" and procmail: Closing brace unexpected mike1950r Linux - Software 5 10-23-2021 01:18 PM
/usr/bin/procmail Permission denied-sendmail? sunram Solaris / OpenSolaris 4 02-29-2008 12:53 PM
Problem with mail delivery procmail>cyrus imap (using sendmail,procmail,cyrus,imap) bwana Linux - Software 2 03-24-2005 07:01 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:41 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration