Package: postfix Severity: important Tags: patch I have a suggestion to a patch for the rc-init.d script for postfix in Sarge. Patch at the end of this email.
The patch solves the problem when you have enabled virtual delivery in postfix thru an external source like a database or ldap and postfix runs in chroot mode, which is the default configuration in Sarge. The problem is that you in this situation will have to create a hardlink from the external sources socket into the jail but at this moment this is not done automatically which means you have to do this by hand after the server has started. On several occasions I have restarted the server but forgotten this which led to a stalled mail delivery system until I did it. To prevent this situation in happening again I have made this patch for the init script. At present it only handles mysql, which I use, but could be easily extended to postgresql and openldap. One requirement though is that the start order of postfix and the external source is important so to make sure postfix starts after the external sources it's start order should be 21 instead of 20. --- postfix 2005-06-24 23:53:03.800662433 +0200 +++ postfix-2.1.5-sarge 2005-06-24 23:51:40.296970844 +0200 @@ -18,6 +18,11 @@ test -x $DAEMON && test -f /etc/postfix/main.cf || exit 0 +virtual=$(postconf -h virtual_alias_maps | cut -d: -f1) +if [ "$virtual" = $(postconf -h virtual_alias_maps) ]; then + virtual="" +fi + case "$1" in start) echo -n "Starting mail transport agent: Postfix" @@ -39,6 +44,23 @@ chmod a+r etc/passwd fi fi + # Handle virtual delivery of mails + if ["$virtual" ]; then + case "$virtual" in + mysql) + # Make a hard link from mysqld.sock to jail + if [ ! -d var/run/mysqld]; then + mkdir -p var/run/mysqld + else + rm -f var/run/mysqld/mysqld.sock + fi + ln /var/run/mysqld/mysqld.sock var/run/mysqld + ;; + *) + echo "Cannot handle this virtual table automatically. You must handle it manually." + ;; + esac + fi FILES="etc/localtime etc/services etc/resolv.conf etc/hosts \ etc/nsswitch.conf" for file in $FILES; do @@ -63,6 +85,20 @@ ${DAEMON} stop 2>&1 | (grep -v 'stopping the Postfix' 1>&2 || /bin/true) echo "." + if [ "$virtual" ]; then + cd $(postconf -h queue_directory) + case "$virtual" in + mysql) + # Remove the hard link to mysqld.sock in jail + if [ -d var/run/mysqld ]; then + rm -f var/run/mysqld/mysqld.sock + fi + ;; + *) + echo "Unknown virtual mail handling. You must remove it manually." + ;; + esac + fi ;; restart) -- System Information: Debian Release: testing/unstable APT prefers unstable APT policy: (990, 'unstable') Architecture: i386 (i686) Shell: /bin/sh linked to /bin/bash Kernel: Linux 2.6.11-1-686 Locale: LANG=en_DK, LC_CTYPE=en_DK (charmap=ISO-8859-1)
--- postfix 2005-06-24 23:53:03.800662433 +0200 +++ postfix-2.1.5-sarge 2005-06-24 23:51:40.296970844 +0200 @@ -18,6 +18,11 @@ test -x $DAEMON && test -f /etc/postfix/main.cf || exit 0 +virtual=$(postconf -h virtual_alias_maps | cut -d: -f1) +if [ "$virtual" = $(postconf -h virtual_alias_maps) ]; then + virtual="" +fi + case "$1" in start) echo -n "Starting mail transport agent: Postfix" @@ -39,6 +44,23 @@ chmod a+r etc/passwd fi fi + # Handle virtual delivery of mails + if [ "$virtual" ]; then + case "$virtual" in + mysql) + # Make a hard link from mysqld.sock to jail + if [ ! -d var/run/mysqld ]; then + mkdir -p var/run/mysqld + else + rm -f var/run/mysqld/mysqld.sock + fi + ln /var/run/mysqld/mysqld.sock var/run/mysqld + ;; + *) + echo "Cannot handle this virtual table automatically. You must handle it manually." + ;; + esac + fi FILES="etc/localtime etc/services etc/resolv.conf etc/hosts \ etc/nsswitch.conf" for file in $FILES; do @@ -63,6 +85,20 @@ ${DAEMON} stop 2>&1 | (grep -v 'stopping the Postfix' 1>&2 || /bin/true) echo "." + if [ "$virtual" ]; then + cd $(postconf -h queue_directory) + case "$virtual" in + mysql) + # Remove the hard link to mysqld.sock in jail + if [ -d var/run/mysqld ]; then + rm -f var/run/mysqld/mysqld.sock + fi + ;; + *) + echo "Unknown virtual mail handling. You must remove it manually." + ;; + esac + fi ;; restart)