Bug#791814: sasl2-bin: fails to start saslauthd
yassine chaouche
yacinechaouche at algerian-radio.dz
Mon Mar 28 18:10:03 UTC 2016
Package: sasl2-bin
Version: 2.1.26.dfsg1-13+deb8u1
Followup-For: Bug #791814
Adding "/" didn't resolve the problem.
Oddly enough, executing the script from /etc/init.d/ and from a local directory changes everything, and I think the problem has something to do with systemd. Here's why :
========================================
root at messagerie[10.10.10.20] ~ # /etc/init.d/saslauthd start
[ ok ] Starting saslauthd (via systemctl): saslauthd.service.
root at messagerie[10.10.10.20] ~ # pgrep -a saslauthd
root at messagerie[10.10.10.20] ~ #
========================================
Here, we see that systemd is invoked. Let's try to copy that file to a local folder and run it from there :
========================================
root at messagerie[10.10.10.20] ~ # cp /etc/init.d/saslauthd TEST/
cp: overwrite ‘TEST/saslauthd’? y
root at messagerie[10.10.10.20] ~ # cd TEST/
root at messagerie[10.10.10.20] ~/TEST # chmod +x saslauthd
root at messagerie[10.10.10.20] ~/TEST # ./saslauthd start
[ ok ] Starting SASL Authentication Daemon: saslauthd.
root at messagerie[10.10.10.20] ~/TEST # pgrep -a saslauthd
5231 /usr/sbin/saslauthd -a rimap -c -m /var/run/saslauthd -O localhost -n 5
5232 /usr/sbin/saslauthd -a rimap -c -m /var/run/saslauthd -O localhost -n 5
5233 /usr/sbin/saslauthd -a rimap -c -m /var/run/saslauthd -O localhost -n 5
5234 /usr/sbin/saslauthd -a rimap -c -m /var/run/saslauthd -O localhost -n 5
5236 /usr/sbin/saslauthd -a rimap -c -m /var/run/saslauthd -O localhost -n 5
root at messagerie[10.10.10.20] ~/TEST #
========================================
Here, we see that systemd was not invoked.
Another interesting information is that I tried to debug the /etc/init.d/saslauthd script by puting echo statements at different places. The echo isn't being printed in this case :
==================================================
#! /bin/sh
### BEGIN INIT INFO
# Provides: saslauthd
# Required-Start: $local_fs $remote_fs
# Required-Stop: $local_fs $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: saslauthd startup script
# Description: This script starts the saslauthd daemon. It is
# configured using the file /etc/default/saslauthd.
### END INIT INFO
# Author: Fabian Fagerholm <fabbe at debian.org>
# Do NOT "set -e"
# PATH should only include /usr/* if it runs after the mountnfs.sh script
PATH=/sbin:/usr/sbin:/bin:/usr/bin
# Global variables
DAEMON=/usr/sbin/saslauthd
DEFAULT_FILES=`find /etc/default/ -regex '/etc/default/saslauthd[_a-zA-Z0-9\-]*$' -print | sort`
# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0
# Load the VERBOSE setting and other rcS variables
.. /lib/init/vars.sh
echo "this is printed"
# Define LSB log_* functions.
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
.. /lib/lsb/init-functions
echo "this is not printed"
==================================================
So probably /lib/lsb/init-functions has something to do with it ?
Here's the trace :
==================================================
root at messagerie[10.10.10.20] ~/TEST # pkill saslauthd
root at messagerie[10.10.10.20] ~/TEST # pgrep -a saslauthd
root at messagerie[10.10.10.20] ~/TEST # /etc/init.d/saslauthd start
this is printed
[....] Starting saslauthd (via systemctl): saslauthd.serviceWarning: Unit file of saslauthd.service changed on disk, 'systemctl daemon-reload' recommended.
.. ok
root at messagerie[10.10.10.20] ~/TEST #
==================================================
Yassine.
-- System Information:
Debian Release: 8.3
APT prefers stable-updates
APT policy: (500, 'stable-updates'), (500, 'stable')
Architecture: amd64 (x86_64)
Kernel: Linux 3.16.0-4-amd64 (SMP w/8 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8) (ignored: LC_ALL set to en_US.UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
Versions of packages sasl2-bin depends on:
ii db-util 5.3.0
ii debconf [debconf-2.0] 1.5.56
ii libc6 2.19-18+deb8u3
ii libcomerr2 1.42.12-1.1
ii libdb5.3 5.3.28-9
ii libgssapi-krb5-2 1.12.1+dfsg-19+deb8u1
ii libk5crypto3 1.12.1+dfsg-19+deb8u1
ii libkrb5-3 1.12.1+dfsg-19+deb8u1
ii libldap-2.4-2 2.4.40+dfsg-1+deb8u2
ii libpam0g 1.1.8-3.1+deb8u1
ii libsasl2-2 2.1.26.dfsg1-13+deb8u1
ii libssl1.0.0 1.0.1k-3+deb8u2
sasl2-bin recommends no packages.
sasl2-bin suggests no packages.
-- Configuration Files:
/etc/default/saslauthd changed:
START=yes
DESC="SASL Authentication Daemon"
NAME="saslauthd"
MECHANISMS="rimap"
MECH_OPTIONS=""
THREADS=5
OPTIONS="-c -m /var/run/saslauthd -O localhost"
/etc/init.d/saslauthd changed:
PATH=/sbin:/usr/sbin:/bin:/usr/bin
DAEMON=/usr/sbin/saslauthd
DEFAULT_FILES=`find /etc/default -regex '/etc/default/saslauthd[_a-zA-Z0-9\-]*$' -print | sort`
[ -x "$DAEMON" ] || exit 0
.. /lib/init/vars.sh
.. /lib/lsb/init-functions
do_startall()
{
for instance in $DEFAULT_FILES
do
start_instance $instance
done
}
do_stopall()
{
for instance in $DEFAULT_FILES
do
stop_instance $instance
done
}
do_reloadall()
{
for instance in $DEFAULT_FILES
do
reload_instance $instance
done
}
do_checkall()
{
for instance in $DEFAULT_FILES
do
check_instance $instance
done
}
start_instance()
{
# Load defaults file for this instance.
. $1
# If the daemon is not enabled, give the user a warning and stop.
if [ "$START" != "yes" ]; then
log_warning_msg "To enable $NAME, edit $1 and set START=yes"
return 0
fi
# If the short name of this instance is undefined, warn the user
# but choose a default name.
if [ -z "$NAME" ]; then
log_warning_msg "Short name (NAME) undefined in $1, using default"
NAME=default
fi
log_daemon_msg "Starting $DESC" "$NAME"
# Check to see if the debug option is specified; fail if it is
if [ `expr match "$OPTIONS" '-d'` -ne 0 ]; then
log_failure_msg "The debug option (-d) has been set in /etc/default/saslauthd or elsewhere, not starting"
return 1
fi
# Set OPTIONS to a default value, as noted in the defaults file
if [ -z "$OPTIONS" ]; then
log_warning_msg "Options (OPTIONS) undefined in $1, using default (-c -m /var/run/saslauthd)"
OPTIONS="-c -m /var/run/saslauthd"
fi
# Determine run directory and pid file location by looking
# for an -m option.
RUN_DIR=`echo "$OPTIONS" | xargs -n 1 echo | sed -n '/^-m$/{n;p}'`
if [ -z "$RUN_DIR" ]; then
# No run directory defined in defaults file, fail.
log_failure_msg "No run directory defined for $NAME (did you forget to set OPTIONS=\"-c -m /var/run/saslauthd\" in the defaults file?), not starting"
return 1
fi
PIDFILE=$RUN_DIR/saslauthd.pid
# If no mechanisms are defined, fail.
if [ -z "$MECHANISMS" ]; then
log_failure_msg "No mechanisms defined in $1, not starting $NAME"
return 1
fi
# If there are mechanism options defined, prepare them for use with
# the -O flag.
if [ -n "$MECH_OPTIONS" ]; then
MECH_OPTIONS="-O $MECH_OPTIONS"
fi
# If there is a threads option defined, prepare it for use with
# the -n flag.
if [ -n "$THREADS" ]; then
THREAD_OPTIONS="-n $THREADS"
fi
# Construct argument string.
DAEMON_ARGS="-a $MECHANISMS $MECH_OPTIONS $OPTIONS $THREAD_OPTIONS"
# If there is a statoverride for the run directory, then pull
# permission and ownership information from it and create the directory.
# Otherwise, we create the directory with default permissions and
# ownership (root:sasl, 710).
if dpkg-statoverride --list $RUN_DIR > /dev/null; then
createdir `dpkg-statoverride --list $RUN_DIR`
else
createdir root sasl 710 $RUN_DIR
fi
# Start the daemon, phase 1: see if it is already running.
start-stop-daemon --start --quiet --pidfile $PIDFILE --name $NAME \
--exec $DAEMON --test > /dev/null
if [ "$?" != "0" ]; then
log_progress_msg "(already running)"
log_end_msg 0
return 0
fi
# Start the daemon, phase 2: it was not running, so actually start it now.
start-stop-daemon --start --quiet --pidfile $PIDFILE --name $NAME \
--exec $DAEMON -- $DAEMON_ARGS
if [ "$?" -ne "0" ]; then
log_end_msg 1
return 1
fi
# Started successfully.
log_end_msg 0
return 0
}
stop_instance()
{
# Load defaults file for this instance.
. $1
# If the short name of this instance is undefined, warn the user
# but choose a default name.
if [ -z "$NAME" ]; then
log_warning_msg "Short name (NAME) undefined in $1, using default"
NAME=default
fi
# Set OPTIONS to a default value, as noted in the defaults file
if [ -z "$OPTIONS" ]; then
log_warning_msg "Options (OPTIONS) undefined in $1, using default (-c -m /var/run/saslauthd)"
OPTIONS="-c -m /var/run/saslauthd"
fi
# Determine run directory and pid file location by looking
# for an -m option.
RUN_DIR=`echo "$OPTIONS" | xargs -n 1 echo | sed -n '/^-m$/{n;p}'`
if [ -z "$RUN_DIR" ]; then
# No run directory defined in defaults file, fail.
log_failure_msg "No run directory defined for $NAME (did you forget to set OPTIONS=\"-c -m /var/run/saslauthd\" in the defaults file?), not starting"
return 2
fi
PIDFILE=$RUN_DIR/saslauthd.pid
log_daemon_msg "Stopping $DESC" "$NAME"
start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 \
--pidfile $PIDFILE --exec $DAEMON
if [ "$?" -eq "2" ]; then
# Failed to stop.
log_end_msg 1
return 2
fi
if [ "$?" -eq "1" ]; then
# Already stopped.
log_progress_msg "(not running)"
fi
# Many daemons don't delete their pidfiles when they exit.
rm -f $PIDFILE
# Stopped successfully.
log_end_msg 0
return $RETVAL
}
reload_instance()
{
# Load defaults file for this instance.
. $1
# If the short name of this instance is undefined, warn the user
# but choose a default name.
if [ -z "$NAME" ]; then
log_warning_msg "Short name (NAME) undefined in $1, using default"
NAME=default
fi
# Set OPTIONS to a default value, as noted in the defaults file
if [ -z "$OPTIONS" ]; then
log_warning_msg "Options (OPTIONS) undefined in $1, using default (-c -m /var/run/saslauthd)"
OPTIONS="-c -m /var/run/saslauthd"
fi
# Determine run directory and pid file location by looking
# for an -m option.
RUN_DIR=`echo "$OPTIONS" | xargs -n 1 echo | sed -n '/^-m$/{n;p}'`
if [ -z "$RUN_DIR" ]; then
# No run directory defined in defaults file, fail.
log_failure_msg "No run directory defined for $NAME (did you forget to set OPTIONS=\"-c -m /var/run/saslauthd\" in the defaults file?), not starting"
return 2
fi
PIDFILE=$RUN_DIR/saslauthd.pid
log_daemon_msg "Reloading $DESC" "$NAME"
# Reload the daemon. First, see if it is already running.
start-stop-daemon --start --quiet --pidfile $PIDFILE \
--exec $DAEMON --test > /dev/null
if [ "$?" -eq "0" ]; then
# Not running, signal this and stop.
log_progress_msg "(not running)"
log_end_msg 0
return 0
fi
start-stop-daemon --stop --signal 1 \
--pidfile $PIDFILE --exec $DAEMON
log_end_msg $?
}
check_instance()
{
# Load defaults file for this instance.
. $1
# If the short name of this instance is undefined, warn the user
# but choose a default name.
if [ -z "$NAME" ]; then
log_warning_msg "Short name (NAME) undefined in $1, using default"
NAME=default
fi
# Determine run directory and pid file location by looking
# for an -m option.
RUN_DIR=`echo "$OPTIONS" | xargs -n 1 echo | sed -n '/^-m$/{n;p}'`
if [ -z "$RUN_DIR" ]; then
# No run directory defined in defaults file, fail.
log_failure_msg "No run directory defined for $NAME, cannot check"
return 2
fi
PIDFILE=$RUN_DIR/saslauthd.pid
log_daemon_msg "Checking $DESC" "$NAME"
# Reload the daemon. First, see if it is already running.
start-stop-daemon --start --quiet --pidfile $PIDFILE \
--exec $DAEMON --test > /dev/null
if [ "$?" -eq "0" ]; then
# Not running, signal this and stop.
log_progress_msg "(not running)"
log_end_msg 3
return 3
fi
log_progress_msg "(running)"
log_end_msg $?
return 0
}
createdir()
{
# In the future, use -P/-Z to have SE Linux enhancement
install -d --group="$2" --mode="$3" --owner="$1" "$4"
[ -x /sbin/restorecon ] && /sbin/restorecon "$4"
}
case "$1" in
start)
do_startall
;;
stop)
do_stopall
;;
reload|force-reload)
do_reloadall
;;
restart)
do_stopall
do_startall
;;
status)
do_checkall
exit $?
;;
start-instance)
if [ -f /etc/default/$2 ]; then
start_instance /etc/default/$2
else
log_failure_msg "Instance $2 does not exist."
fi
;;
stop-instance)
if [ -f /etc/default/$2 ]; then
stop_instance /etc/default/$2
else
log_failure_msg "Instance $2 does not exist."
fi
;;
reload-instance|force-reload-instance)
if [ -f /etc/default/$2 ]; then
reload_instance /etc/default/$2
else
log_failure_msg "Instance $2 does not exist."
fi
;;
restart-instance)
if [ -f /etc/default/$2 ]; then
stop_instance /etc/default/$2
start_instance /etc/default/$2
else
log_failure_msg "Instance $2 does not exist."
fi
;;
*)
SCRIPTNAME=$0
echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
echo " or {start-instance|stop-instance|restart-instance|" >&2
echo " reload-instance|force-reload-instance} " \
"<instance name>" >&2
exit 3
;;
esac
:
-- debconf information:
cyrus-sasl2/upgrade-sasldb2-failed:
cyrus-sasl2/purge-sasldb2: false
cyrus-sasl2/upgrade-sasldb2-backup-failed:
cyrus-sasl2/backup-sasldb2: /var/backups/sasldb2.bak
More information about the Pkg-cyrus-sasl2-debian-devel
mailing list