Sunday, August 24, 2014

centos6 - When running postfix & dovecot, who should own /var/mail and what permissions should it have?




I had an issue where either postfix or dovecot did not have permission to create user directories in /var/mail.



Doing ls -l '/var/mail' showed me that the owner and group was root root.



1 root root 10 May 27 13:48 /var/mail -> spool/mail


I tried changing owner and group to postfix, and then dovecot, and both times when I did a ls -l the owner and group remained as root. (this is while logged in as root).



Somebody recommended the chmod needed to be 644, so I changed it to that, and still, the server wouldn't create the user directories in the mail folders.




In the meantime, I changed chmod to 777 and everything started working, but now I have a big security concern.



Why didn't the owner and group change from root when I told it to?



Who should own /var/mail? and what chmod does it need?


Answer




Who should own /var/mail? and what chmod does it need?





it would depend on postfix/dovecot settings. I'm using special user virtual



# groupadd -g 1981 virtual 
# useradd -g virtual -s /sbin/nologin -u 1981 virtual

# chown virtual:virtual /var/spool/mail/
# chmod 750 /var/spool/mail/



And then use the user in postfix



virtual_gid_maps = static:1981
virtual_uid_maps = static:1981


and Dovecot



first_valid_gid = 1981
last_valid_gid = 1981


No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...