POSTFIX main.cf permission denied
Solution 1:
In my case, the other answers didn't helped me, because I already had the context for those files correctly. Even if the file's correct context are applied, you'll also need to be sure the Apache user has SELinux permission to send mails. Specifically there is a SELinux configuration that need to be turned on.
- Verify if the setting is on or off:
getsebool httpd_can_sendmail
- If you got
httpd_can_sendmail --> off
you can enable this setting this way:sudo setsebool -P httpd_can_sendmail 1
-P in the above command means Persistent (across reboots)
Solution 2:
Almost certainly to do with SELinux. I bet you moved your main.cf into that location.
Try running restorecon -v /etc/postfix/main.cf
to fix the labelling.
Solution 3:
This is most likely related to SELinux access control. CentOS has "Enforcing" SELinux mode by default. Please check the status of SELinux with comnand:
# sestatus
If the output something like this:
SELinux status: enabled
SELinuxfs mount: /selinux
Current mode: enforcing
Mode from config file: enforcing
Policy version: 24
Policy from config file: targeted
You need to to change security context for main.cf and probably other postfix configuration flies. On my machine it is set to:
-rw-r--r--. root root system_u:object_r:postfix_etc_t:s0 /etc/postfix/main.cf
Try these to set proper context:
# chcon -v -u system_u -r object_r -t postfix_etc_t /etc/postfix/main.cf
# restorecon -v -R /etc/postfix/
To verify:
# ls -Z /etc/postfix/