webmin: chrooted postfix and saslauthd run into problems in Debian 7
Hello
Seems the current deployed configuration is not compatible when enabling chroot on Postfix, resulting such these errors:
postfix/smtpd[8673]: connect from [127.0.0.1] postfix/smtpd[8673]: warning: SASL authentication failure: cannot connect to saslauthd server: No such file or directory postfix/smtpd[8673]: warning: [127.0.0.1]: SASL LOGIN authentication failed: generic failure postfix/smtpd[8673]: disconnect from [127.0.0.1]
The problem arises because postfix insists on looking up saslauthd lock files in /var/run/saslauthd, yet these have moved to /var/spool/postfix/var/run/saslauthd.
Even after adding:
saslauthd_path: /var/spool/postfix/var/run/saslauthd/mux
or
saslauthd_path: /var/run/saslauthd/mux
to /etc/postfix/sasl/smtpd.conf the problem persists (tried remote SMTP mail clients and roundcube).
You may say, this can be fixed with a symlink or mount bind - this is partially true and will work until the next reboot. Then the system clears /var/run and new directory has to be created with respective symlink or mount bind. Permanent entry in /etc/fstab still won’t solve it and you’l end up with a boot hang (press ctrl+d).
Instead of chrooting saslauthd, the fix seems to be leave it at default path, and then changing the /etc/default/saslauthd options accordingly. This hovewer leaves saslauthd out of the chroot, so a mount bind will be required.
SEE LAST POSTS FOR FINAL FIXES
Note that Symlinks do not work on chroot. The following method is inefective - you’l have to use a mount bind.
Create directory for new mount point:
mkdir -p /var/spool/postfix/var/run
Set ownership and permissions:
chown -R root:sasl /var/spool/postfix/var/
dpkg-statoverride --add root sasl 710 /var/spool/postfix/var
adduser postfix sasl
Create symlink for chrooted saslauthd:
ln -s /var/run/saslauthd /var/spool/postfix/var/run/saslauthd
chown -h root:sasl /var/spool/postfix/var/run/saslauthd
These also won’t work because the symlinks are reversed: http://blog.wains.be/2006/11/18/postfix-chroot-sasl-authentication-saslauthd/ http://www.jimmy.co.at/weblog/?p=52
About this issue
- Original URL
- State: open
- Created 11 years ago
- Comments: 15
Final configuration for a non-chrooted saslauthd and (optional) chrooted Postfix follows in this comment. The setup will work wether postfix is chrooted or not – when chrooted, just apply the additional optional config, which should make postfix safer to use.
from here on, mandatory for both chrooted and non-chrooted postfix
saslauthd non-chrooted:
Reminder: saslauthd should be non-chrooted for the setup to be simple and work.
Set parameters for saslauthd in /etc/default/saslauthd: Before (Incorrect):
After (Correct):
Standard Postfix configuration:
Create a pam file for smtp/postfix, equal to dovecot. The missing file will result in login failure of postfix in pam if other’s file is hardened (/etc/pam.d/smtp):
This probably should be a separate issue but i’ll include here as it’s related.
Add postfix user to the sasl group:
adduser postfix saslfrom here on, optional…(chrooted postfix)
Add binding for saslauthd in Postfix chroot:
Add a permanent mount point to /etc/fstab:
/var/run/saslauthd /var/spool/postfix/var/run/saslauthd bind defaults,nodev,noauto,bind 0 0Note: noauto = no attempt to mount what can’t be mounted on early boot = no error/hangCreate directory for new mount point:
mkdir -p /var/spool/postfix/var/run/saslauthdSet ownership and permissions:
Then mount it:
mount /var/spool/postfix/var/run/saslauthdAdd mount command /etc/rc.local to be run at boot (after all daemons):
https://wiki.debian.org/PostfixAndSASL http://blog.brachium-system.net/archives/16-Postfix-with-SASL-Authentication-in-Debian.html
Finish Postfix chrooted configuration:
Configure sasl binding for postfix (/etc/postfix/sasl/smtpd.conf): Incorrect:
saslauthd_path: /var/spool/postfix/var/run/saslauthd/muxor nothing Correct:saslauthd_path: /var/run/saslauthd/muxConfigure postfix to work in chrooted environment (/etc/postfix/master.cf):
Debian stock configuration (unsecure):
Virtualmin configuration (sasl only):
New configuration (also added TLS):
Notes:
EDIT: fixed some settings
END
FWIW, on a fresh install of Ubuntu 18.04 and Webmin/Virtualmin (latest), Postfix is not running in chroot and this simplified subset sufficed:
/var/spool/postfix/var/run/saslauthdwith/var/run/saslauthdin/etc/default/saslauthdsystemctl restart saslauthdAlways weird when you get a notification on a bug from over a decade ago that’s still open.
this post realy helped me out. but when using debian, there is no rc.local anymore but there are workarrounds.
i created a service for this as followed:
nano /etc/systemd/system/saslauthd_mount_bind.service
systemctl enable saslauthd_mount_bind.service
systemctl start saslauthd_mount_bind.service