Package: dkimproxy Version: 1.0.1-6 Severity: normal Tags: patch Hello,
I have made several improvements to /etc/init.d/dkimproxy. Many of the problems I found are interrelated, so please forgive me for not sending individual patches. I've tested the patch on my system, and so far it seems to work, but I haven't actually started using dkimproxy yet. If I or anybody else finds problems, I'll try to revise my patch later. Changes: * Source /etc/default/dkimproxy so that the user can override relevant variables used in the init script. * Build argument lists differently so that variables can be unset in /etc/default/default/dkimproxy. This allows the user to specify those variables in the dkimproxy configuration files. * Support variables in /etc/default/dkimproxy to enable/disable starting the individual dkimproxy daemons. * Use "dkimproxy --daemonize" instead of "start-stop-daemon --background". With the previous version, start-stop-daemon cannot check exit status, and failures starting dkimproxy are silent with no way to tell what is causing a failure. * Don't exit immediately if dkimproxy.in fails to start, and clean/fix error checking logic. This was masked by the previous bug. * Use 'dkimproxy --pidfile" instead of "start-stop-daemon --make-pidfile" so the pid is correctly written to the pid file; otherwise, start-stop-daemon cannot stop/restart dkimproxy. * Remove pid files on the "stop" action. If anybody wants to test the patch, the following commands should suffice (modify them accordingly): # cd /etc # cp -p init.d/dkimproxy init.d/dkimproxy.orig # patch init.d/dkimproxy /tmp/init_dkimproxy.diff # mv /tmp/default_dkimproxy default/dkimproxy Note that if dkimproxy is already running, you'll need to kill it manually since the PID wasn't properly stored. Thanks, Corey -- System Information: Debian Release: lenny/sid APT prefers testing APT policy: (990, 'testing'), (500, 'unstable') Architecture: amd64 (x86_64) Kernel: Linux 2.6.16.29-xen (SMP w/4 CPU cores) Locale: LANG=en_US, LC_CTYPE=en_US (charmap=ISO-8859-1) Shell: /bin/sh linked to /bin/bash Versions of packages dkimproxy depends on: ii adduser 3.108 add and remove users and groups ii liberror-perl 0.17-1 Perl module for error/exception ha ii libmail-dkim-perl 0.32-1 cryptographically identify the sen ii libnet-server-perl 0.97-1 An extensible, general perl server ii libtext-wrapper-perl 1.02-1 Simple word wrapping routine ii lsb-base 3.2-12 Linux Standard Base 3.2 init scrip ii openssl 0.9.8g-10.1 Secure Socket Layer (SSL) binary a ii perl 5.10.0-11 Larry Wall's Practical Extraction Versions of packages dkimproxy recommends: ii amavisd-new 1:2.6.0.dfsg-2 Interface between MTA and virus sc dkimproxy suggests no packages. -- no debconf information
# Default configuration for dkimproxy. # which daemons whould be run; anything other than '1' will disable a daemon # default: 1 #RUN_DKIMPROXY_OUT=1 #RUN_DKIMPROXY_IN=1 # The following variables specify configuration to be passed as arguments to # the dkimproxy daemons. If a variable is commented out, the default value # within the /etc/init.d/dkimproxy script will be used. If a variable is unset # or set to an empty value, the corresponding argument will be omitted from # the dkimproxy command line, and dkimproxy is free to read a value from its # own configuration file or use its own default value. # configuration file to use for dkimproxy.in # default: "/etc/dkimproxy/dkimproxy_in.conf" #DKIMRPOXY_IN_CONF="/etc/dkimproxy/dkimproxy_in.conf" # configuration file to use for dkimproxy.out # default: "/etc/dkimproxy/dkimproxy_ount.conf" #DKIMRPOXY_OUT_CONF="/etc/dkimproxy/dkimproxy_out.conf" # user and group of the dkimproxy daemons # default: dkimproxy #DKIMPROXYUSER=dkimproxy #DKIMPROXYGROUP=dkimproxy # private key to use for signing # default: "/var/lib/dkimproxy/private.key" #DKIMPROXY_OUT_PRIVKEY="/var/lib/dkimproxy/private.key" # hostname for verification "Authentication-Results" header # default: `hostname -f` #DKIM_HOSTNAME=`hostname -f` # domains to sign for; specify multiple domains separated by commas # default: `hostname -d` and domains parsed from /var/lib/dtc/etc/local_domains #DOMAIN=`hostname -d`
--- dkimproxy.orig 2008-04-19 09:41:10.000000000 -0500 +++ dkimproxy 2008-08-04 21:15:59.000000000 -0500 @@ -21,6 +21,9 @@ . /lib/lsb/init-functions +DKIMPROXY_IN_CONF="/etc/dkimproxy/dkimproxy_in.conf" +DKIMPROXY_OUT_CONF="/etc/dkimproxy/dkimproxy_out.conf" + DKIMPROXYUSER=dkimproxy DKIMPROXYGROUP=dkimproxy DKIMPROXY_OUT_PRIVKEY="/var/lib/dkimproxy/private.key" @@ -39,14 +42,33 @@ fi DOMAIN=${DTC_DOMAIN}${HOST_DOMAIN} -DKIMPROXY_IN_ARGS="--hostname=${DKIM_HOSTNAME} --conf_file /etc/dkimproxy/dkimproxy_in.conf --user=${DKIMPROXYUSER} --group=${DKIMPROXYGROUP}" -DKIMPROXY_OUT_ARGS="--domain=${DOMAIN} --method=simple --conf_file /etc/dkimproxy/dkimproxy_out.conf --user=${DKIMPROXYUSER} --group=${DKIMPROXYGROUP}" - DKIMPROXY_IN_BIN="/usr/sbin/dkimproxy.in" DKIMPROXY_OUT_BIN="/usr/sbin/dkimproxy.out" PIDDKIMPROXY_IN="/var/run/dkimproxy.in" PIDDKIMPROXY_OUT="/var/run/dkimproxy.out" +RUN_DKIMPROXY_IN=1 +RUN_DKIMPROXY_OUT=1 + +# source default file, possibly overriding variables set above +DEFAULT_FILE="/etc/default/dkimproxy" +[ -f "${DEFAULT_FILE}" ] && . "${DEFAULT_FILE}" + +# Build arguments based on configuration variables; empty variables result in +# the argument being omitted. +[ -n "${DKIMPROXY_IN_CONF}" ] && DKIMPROXY_IN_CONF_ARG="--conf_file=${DKIMPROXY_IN_CONF}" +[ -n "${DKIMPROXY_OUT_CONF}" ] && DKIMPROXY_OUT_CONF_ARG="--conf_file=${DKIMPROXY_OUT_CONF}" +[ -n "${DKIMPROXYUSER}" ] && DKIMPROXYUSER_ARG="--user=${DKIMPROXYUSER}" +[ -n "${DKIMPROXYGROUP}" ] && DKIMPROXYGROUP_ARG="--group=${DKIMPROXYGROUP}" +[ -n "${DKIMPROXY_OUT_PRIVKEY}" ] && DKIMPROXY_OUT_PRIVKEY_ARG="--keyfile=${DKIMPROXY_OUT_PRIVKEY}" +[ -n "${DKIM_HOSTNAME}" ] && DKIM_HOSTNAME_ARG="--hostname=${DKIM_HOSTNAME}" +[ -n "${DOMAIN}" ] && DOMAIN_ARG="--domain=${DOMAIN}" + +COMMON_ARGS="${DKIMPROXYUSER_ARG} ${DKIMPROXYGROUP_ARG} --daemonize" +DKIMPROXY_IN_ARGS="${COMMON_ARGS} ${DKIMPROXY_IN_CONF_ARG} ${DKIM_HOSTNAME_ARG} --pidfile=${PIDDKIMPROXY_IN}" +DKIMPROXY_OUT_ARGS="${COMMON_ARGS} ${DKIMPROXY_OUT_CONF_ARG} ${DOMAIN_ARG} --pidfile=${PIDDKIMPROXY_OUT}" + + if [ -x /sbin/start-stop-daemon ] ; then STRT_STP_DMN=/sbin/start-stop-daemon else @@ -58,27 +80,30 @@ case "$1" in start) - log_daemon_msg "Starting inbound DomainKeys-filter" "dkimproxy.in" - ${STRT_STP_DMN} --background --make-pidfile --start -p ${PIDDKIMPROXY_IN} -u ${DKIMPROXYUSER} -g ${DKIMPROXYGROUP} -x ${DKIMPROXY_IN_BIN} -- ${DKIMPROXY_IN_ARGS} - RETVAL=$? - START_ERROR=${RETVAL} - log_end_msg ${RETVAL} - if ! [ "${RETVAL}" -eq 0 ] ; then - exit ${RETVAL} - fi - - log_daemon_msg "Starting outbound DomainKeys-filter" "dkimproxy.out" - ${STRT_STP_DMN} --background --make-pidfile --start -p ${PIDDKIMPROXY_OUT} -u ${DKIMPROXYUSER} -g ${DKIMPROXYGROUP} -x ${DKIMPROXY_OUT_BIN} -- ${DKIMPROXY_OUT_ARGS} - RETVAL=$? - log_end_msg ${RETVAL} - if ! [ "${RETVAL}" -eq 0 -a "${START_ERROR}" -eq 0 ] ; then + if [ -n "${RUN_DKIMPROXY_IN}" ] && [ "${RUN_DKIMPROXY_IN}" = "1" ] ; then + log_daemon_msg "Starting inbound DomainKeys-filter" "dkimproxy.in" + ${STRT_STP_DMN} --start -p ${PIDDKIMPROXY_IN} -u ${DKIMPROXYUSER} -g ${DKIMPROXYGROUP} -x ${DKIMPROXY_IN_BIN} -- ${DKIMPROXY_IN_ARGS} + RETVAL=$? + log_end_msg ${RETVAL} if ! [ ${RETVAL} -eq 0 ] ; then echo "Error ${RETVAL} when starting ${DKIMPROXY_IN_BIN}" fi - if ! [ "${START_ERROR}" -eq 0 ] ; then + else + echo "Inbound DomainKeys-filter disabled in ${DEFAULT_FILE}" + fi + + if [ -n "${RUN_DKIMPROXY_OUT}" ] && [ "${RUN_DKIMPROXY_OUT}" = "1" ] ; then + log_daemon_msg "Starting outbound DomainKeys-filter" "dkimproxy.out" + ${STRT_STP_DMN} --start -p ${PIDDKIMPROXY_OUT} -u ${DKIMPROXYUSER} -g ${DKIMPROXYGROUP} -x ${DKIMPROXY_OUT_BIN} -- ${DKIMPROXY_OUT_ARGS} + RETVAL=$? + log_end_msg ${RETVAL} + if ! [ "${RETVAL}" -eq 0 ] ; then echo "Error ${START_ERROR} when starting ${DKIMPROXY_OUT_BIN}" fi + else + echo "Outbound DomainKeys-filter disabled in ${DEFAULT_FILE}" fi + ;; stop) @@ -98,6 +123,7 @@ echo "Error ${RETVALOUT} when shutting down ${PIDDKIMPROXY_OUT}" fi fi + rm -f "${PIDDKIMPROXY_IN}" "${PIDDKIMPROXY_OUT}" ;; force-reload) $0 stop