Mailing List Archive

Debian-Bug not stopping exim
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

Hi Folks,

did anybody already debug and fix the problem in debian that exim is not
stopped with stop action anymore?

Problem is, that /etc/init.d/exim4 seems to call killproc which calls
start-stop-daemon to stop the daemon in stop or restart. When the return
state is 0 it removes the PIDFILE.

Unfortunately, start-stop-daemon seems to refuse the daemon when given a
pidfile. But it does not error out than just return with 0. So the
pidfile is gone afterwards.

This is pretty annoing as logrotate does not stop the daemon and a new
daemon cannot start as port 25 is already in use. So it panics out.

Regards
Klaus

Ps. I will not file a debian bug anymore. Since some time, they don't
care about bug reports anymore and you just earn insults; especially
from two systemd evangelists.
- --
Klaus Ethgen http://www.ethgen.ch/
pub 4096R/4E20AF1C 2011-05-16 Klaus Ethgen <Klaus@Ethgen.ch>
Fingerprint: 85D4 CA42 952C 949B 1753 62B3 79D0 B06F 4E20 AF1C
-----BEGIN PGP SIGNATURE-----
Comment: Charset: ISO-8859-1

iQGzBAEBCgAdFiEEMWF28vh4/UMJJLQEpnwKsYAZ9qwFAlxanwIACgkQpnwKsYAZ
9qwFsQv+Ois4Ji0AOhw/aXUXB/jWnJtoKrJP5LnMh+JjoP6UO9qX/PYZRPStEIoc
/MTvfMKAkyJfNTT1mWe20ZSn48T1yyhGyEa+OFy1iqqDbPemKaaWS5WaJcHRPRlL
FGXL3ZZGM7rNH+qpmPBlUNkNP+zVpFjekS6YdtIwj1pK8FrZ49xj4IzfE0R2DjcD
5Q137zGOLvTQY+n9aDOmTPXjdrvYOwjoCkdrBTci3erzVDLLM0CRxn/MBBokJNNw
TgiMGC/GPTmUNrHxxHm/6yqgq2mUbsNBy4g0udNsc3wmvxVi0DHxXMmBpuNaw/oh
XpWpC76y6j3YjsWe9O3pnKHHhRJ3rp3tzfrRW4lssYrRLrLpY2Z5NrkLACE4aMdR
KAUz3OelPpBIKojaxfS4FKMzLYKPmbDoiw/pkqsiLU+NGFoZ8wD9R/cpbt2uyRwT
jYs0RLiKTPUU+6XVKfdslvxMNGXdipHdyviG4sJqApLUO+UMMdwH1pb1QEkCh9MZ
ChR4UXvZ
=rEHU
-----END PGP SIGNATURE-----

--
## List details at https://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/
Re: Debian-Bug not stopping exim [ In reply to ]
On Wed, Feb 06, 2019 at 09:47:04AM +0100, Klaus Ethgen via Exim-users wrote:
> Hi Folks,
>
> did anybody already debug and fix the problem in debian that exim is not
> stopped with stop action anymore?
>
> Problem is, that /etc/init.d/exim4 seems to call killproc which calls
> start-stop-daemon to stop the daemon in stop or restart. When the return
> state is 0 it removes the PIDFILE.

Yes, pidfile is removed on "stop" action. But I see no problem so far.

> Unfortunately, start-stop-daemon seems to refuse the daemon when given a
> pidfile.

Do you mean that start-stop-daemon does not search for a process by
its name if pidfile is given? It's right, but it's unusual situation
if you have listening daemon running with pid != pidfile.
You have better to ask yourself how it could happen.

> But it does not error out than just return with 0. So the
> pidfile is gone afterwards.

In this case pidfile was gone BEFORE start-stop-daemon invocation.
This is exceptional situation, it requires manual dignostics.

It's not good thing to "resolve" such situations automatically
unless you clearly understand what happens and why it can't be
resolved in other ways.
--
Eugene Berdnikov

--
## List details at https://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/
Re: Debian-Bug not stopping exim [ In reply to ]
On 06/02/2019 08:47, Klaus Ethgen via Exim-users wrote:> This is pretty
annoing as logrotate does not stop the daemon

Exim should not care about logfiles being rotated underneath it.
--
Cheers,
Jeremy

--
## List details at https://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/
Re: Debian-Bug not stopping exim [ In reply to ]
On 2019-02-06 09:47, Klaus Ethgen wrote:

> did anybody already debug and fix the problem in debian that exim is
> not stopped with stop action anymore?

I run debian on my server but I compile exim from upstream source, so I
had to write my own initscript. I append it below; it seems to work
fine for my situation. It starts a combined port 25 daemon and queue
runner.

TBH, I don't use rotating logs with Exim; instead I use the setting that
makes it log into a file named after the current year and month. So the
reloading function in the initscript doesn't get much testing.

--
Please don't Cc: me privately on mailing lists and Usenet,
if you also post the followup to the list or newsgroup.
To reply privately _only_ on Usenet and on broken lists
which rewrite From, fetch the TXT record for no-use.mooo.com.

#!/bin/sh

### BEGIN INIT INFO
# Provides: mail_transport_agent
# Required-Start: $local_fs $remote_fs $network $named $time
# Required-Stop: $local_fs $remote_fs $network $named $time
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Exim initscript
# Description: Manages the Exim MTA
### END INIT INFO

# Author: Ian Zimmerman <itz@no-use.mooo.com>
#
# Please remove the "Author" lines above and replace them
# with your own name if you copy and modify this script.

DESC="Exim MTA"
DAEMON=/usr/local/packages/exim/bin/exim
NAME=exim
PIDFILE=/var/spool/exim4/exim-daemon.pid
DAEMON_ARGS="-bd -q20m"
EXIM_LOG_DIR=/var/log/exim4

test_exim_up()
{
sleep 2
SS_OUT=`ss -nH -f inet -t state listening '( sport = 25 )'`
case "$SS_OUT" in
('') return 2 ;;
(?*) return 0 ;;
esac
}

do_reload()
{
log_daemon_msg "Reloading $DESC configuration files" "$NAME"
$DAEMON -bV >/dev/null 2>/dev/null && \
start-stop-daemon --oknodo --stop --signal HUP --quiet \
--pidfile "$PIDFILE" --exec "$DAEMON"
EXIM_HUP_STATUS=$?
test_exim_up || EXIM_HUP_STATUS=1
log_end_msg $EXIM_HUP_STATUS
}

# 0 if daemon has been started
# 1 if daemon was already running
# 2 if daemon could not be started
do_start_cmd_override() {
start-stop-daemon --start --quiet ${PIDFILE:+--pidfile ${PIDFILE}} \
$START_ARGS \
--startas $DAEMON --name $NAME --exec $DAEMON --test > /dev/null \
|| return 1
$DAEMON -bV >/dev/null 2>/dev/null || return 2
start-stop-daemon --start --quiet ${PIDFILE:+--pidfile ${PIDFILE}} \
$START_ARGS \
--startas $DAEMON --name $NAME --exec $DAEMON -- $DAEMON_ARGS \
|| return 2
test_exim_up
}

# kFreeBSD do not accept scripts as interpreters, using #!/bin/sh and sourcing.
if [ true != "$INIT_D_SCRIPT_SOURCED" ] ; then
set "$0" "$@"; INIT_D_SCRIPT_SOURCED=true . /lib/init/init-d-script
fi

--
## List details at https://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/
Re: Debian-Bug not stopping exim [ In reply to ]
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

Hi,

Am Mi den 6. Feb 2019 um 10:45 schrieb Evgeniy Berdnikov via Exim-users:
> On Wed, Feb 06, 2019 at 09:47:04AM +0100, Klaus Ethgen via Exim-users wrote:
> > did anybody already debug and fix the problem in debian that exim is not
> > stopped with stop action anymore?
> >
> > Problem is, that /etc/init.d/exim4 seems to call killproc which calls
> > start-stop-daemon to stop the daemon in stop or restart. When the return
> > state is 0 it removes the PIDFILE.
>
> Yes, pidfile is removed on "stop" action. But I see no problem so far.

So far I also don't see a problem.

> > Unfortunately, start-stop-daemon seems to refuse the daemon when given a
> > pidfile.
>
> Do you mean that start-stop-daemon does not search for a process by
> its name if pidfile is given? It's right, but it's unusual situation
> if you have listening daemon running with pid != pidfile.
> You have better to ask yourself how it could happen.

Well, the relevant part of the init-script is:
if [ -f "$QRPIDFILE" ]; then
killproc -p "$QRPIDFILE" "$DAEMON"
# exim does not remove the pidfile
if [ $? -eq 0 ] ; then rm -f "$QRPIDFILE" ; fi
log_progress_msg "exim4_queuerunner"
fi
if [ -f "$PIDFILE" ]; then
killproc -p "$PIDFILE" "$DAEMON"
# exim does not remove the pidfile
if [ $? -eq 0 ] ; then rm -f "$PIDFILE" ; fi
log_progress_msg "exim4_listener"
fi

That looks promising and ok.

Now for the definition of killproc:
killproc () {
local pidfile sig status base name_param is_term_sig OPTIND
pidfile=
name_param=
is_term_sig=

OPTIND=1
while getopts p: opt ; do
case "$opt" in
p) pidfile="$OPTARG";;
esac
done
shift $(($OPTIND - 1))

base=${1##*/}
if [ ! $pidfile ]; then
name_param="--name $base --pidfile /var/run/$base.pid"
else
name_param="--pidfile $pidfile"
fi

sig=$(echo ${2:-} | sed -e 's/^-\(.*\)/\1/')
sig=$(echo $sig | sed -e 's/^SIG\(.*\)/\1/')
if [ "$sig" = 15 ] || [ "$sig" = TERM ]; then
is_term_sig="terminate_signal"
fi
status=0
if [ ! "$is_term_sig" ]; then
if [ -n "$sig" ]; then
/sbin/start-stop-daemon --stop --signal "$sig" \
--quiet $name_param || status="$?"
else
/sbin/start-stop-daemon --stop \
--retry 5 \
--quiet $name_param || status="$?"
fi
else
/sbin/start-stop-daemon --stop --quiet \
--oknodo $name_param || status="$?"
fi
if [ "$status" = 1 ]; then
if [ -z "$sig" ]; then
return 0
fi
return 3 # program is not running
fi

if [ "$status" = 0 ] && [ "$is_term_sig" ] && [ "$pidfile" ]; then
pidofproc -p "$pidfile" "$1" >/dev/null || rm -f "$pidfile"
fi
return 0
}

But, and that did change somewhen in the past months, start-stop-daemon
seems to _not_ stop exim with that anymore. Both definitions above did
not change for longer times. Just start-stop-daemon did.

I checked, before I do a "/etc/init.d/exim4 stop", the pid file contains
the correct PID of the exim process. And the rights are:
~> ll -a /run/exim4
insgesamt 4,0K
drwxr-x--- 2 Debian-exim Debian-exim 60 Feb 6 09:21 .
drwxr-xr-x 27 root root 980 Feb 6 10:14 ..
-rw-r--r-- 1 root Debian-exim 6 Feb 6 09:21 exim.pid

After the stop, exim is still running but the pid file is gone.

And I get the message on the console:
~> /etc/init.d/exim4 stop
[....] Stopping MTA:/sbin/start-stop-daemon: matching only on non-root pidfile /run/exim4/exim.pid is insecure
[ ok 4_listener.

> > But it does not error out than just return with 0. So the
> > pidfile is gone afterwards.
>
> In this case pidfile was gone BEFORE start-stop-daemon invocation.

Nope.

> This is exceptional situation, it requires manual dignostics.

That is what I do currently.

> It's not good thing to "resolve" such situations automatically
> unless you clearly understand what happens and why it can't be
> resolved in other ways.

Well, it is clearly not a fine situation why since some days a restart
of exim fills my paniclog.

For the record, exim is not restarted for logrotation but from
needrestart or manualy.

So there was a bug introduced in the last few weeks in start-stop-daemon
that I have to find a way around. The current situation is not
acceptable.

Regards
Klaus
- --
Klaus Ethgen http://www.ethgen.ch/
pub 4096R/4E20AF1C 2011-05-16 Klaus Ethgen <Klaus@Ethgen.ch>
Fingerprint: 85D4 CA42 952C 949B 1753 62B3 79D0 B06F 4E20 AF1C
-----BEGIN PGP SIGNATURE-----
Comment: Charset: ISO-8859-1

iQGzBAEBCgAdFiEEMWF28vh4/UMJJLQEpnwKsYAZ9qwFAlxbWbEACgkQpnwKsYAZ
9qyo+Av9Exi0LKQB32ov2p2ppaRvYNYYQS/UwBkwgeTFd17ytNaUejLOysOmxLIq
mfH4mz1kcQVtLPivzoxLIQ/53KLBRomqRwFnSFDY9uVMCSppg1MKRe2yQRnHaqEY
OhgcGxxdCEf3sn5k4PGX1AqxuGb3LPU/o0MSxUd88QcQ9tEpv4qlPzEYej8t69Tq
SAt6sag8M2gXBFDq8ThU0abKi1wc1OQUQSfkY73GMlY5giNRpwL+B7hlRMd3qJWL
SPjiij6QbouC9XggisKg90961a1QXozcamNpjbdP5FO5nMz1FpMP6UU4D8oVwldv
j6Dgc4Oksgyqa24YfPOY4YrDNF2+USsFxCLqcr7XNGDbd+3ntpHo+/ASkds5XFF9
lp0hHnYVLo97DOyqn2yXu8ecuh0rm7iZNTmnxZ6WwbZCu/5ipUmu8C11nSC+fP27
Xdf0aSMX8/MoLUNMA/2ZgDh/zSy0Vp4o2z62Ilu2x4C0yKe+jaxHPF8hql0hLnCj
8Rf3ni1t
=kxl3
-----END PGP SIGNATURE-----

--
## List details at https://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/
Re: Debian-Bug not stopping exim [ In reply to ]
On 6 Feb 2019, at 22:03, Klaus Ethgen via Exim-users <exim-users@exim.org> wrote:
> So there was a bug introduced in the last few weeks in start-stop-daemon
> that I have to find a way around. The current situation is not
> acceptable.

At this point I’m going to be the person who says “this is not an Exim problem”.

It’s affecting exim, I don’t doubt that - but start-stop-daemon is a feature of the init system in Debian, so you do need to raise it with them despite your misgivings about doing so.

Graeme
--
## List details at https://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/
Re: Debian-Bug not stopping exim [ In reply to ]
On Wed, Feb 6, 2019 at 11:56 PM Graeme Fowler via Exim-users <
exim-users@exim.org> wrote:

> On 6 Feb 2019, at 22:03, Klaus Ethgen via Exim-users <exim-users@exim.org>
> wrote:
> > So there was a bug introduced in the last few weeks in start-stop-daemon
> > that I have to find a way around. The current situation is not
> > acceptable.
>
> At this point I’m going to be the person who says “this is not an Exim
> problem”.
>
> It’s affecting exim, I don’t doubt that - but start-stop-daemon is a
> feature of the init system in Debian, so you do need to raise it with them
> despite your misgivings about doing so.
>
>
Additionally, as Exim in Debian still uses SYSV init scripts, this would
probably work better if rewritten to work with systemd, which was
introduced with Jessie several years ago. I see more issues with "mongrel"
init scripts (scripts run using systemd's SYSV compatibility thingy) than
with definitions written for systemd in the first place.

I'll see if I can find the tuits for a proposed change to the package
maintainers!
--
Jan
--
## List details at https://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/
Re: Debian-Bug not stopping exim [ In reply to ]
On 2019-02-06 22:47, Graeme Fowler via Exim-users wrote:
> On 6 Feb 2019, at 22:03, Klaus Ethgen via Exim-users
> <exim-users@exim.org> wrote:
>> So there was a bug introduced in the last few weeks in
>> start-stop-daemon
>> that I have to find a way around. The current situation is not
>> acceptable.
>
> At this point I’m going to be the person who says “this is not an Exim
> problem”.
>
> It’s affecting exim, I don’t doubt that - but start-stop-daemon is a
> feature of the init system in Debian, so you do need to raise it with
> them despite your misgivings about doing so.

For the record, that's already been done by the exim package maintainer.

Regards,

Adam

--
## List details at https://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/
Re: Debian-Bug not stopping exim [ In reply to ]
On Wed, Feb 06, 2019 at 11:03:34PM +0100, Klaus Ethgen via Exim-users wrote:
> But, and that did change somewhen in the past months, start-stop-daemon
> seems to _not_ stop exim with that anymore. Both definitions above did
> not change for longer times. Just start-stop-daemon did.
>
> I checked, before I do a "/etc/init.d/exim4 stop", the pid file contains
> the correct PID of the exim process. And the rights are:
> ~> ll -a /run/exim4
> insgesamt 4,0K
> drwxr-x--- 2 Debian-exim Debian-exim 60 Feb 6 09:21 .
> drwxr-xr-x 27 root root 980 Feb 6 10:14 ..
> -rw-r--r-- 1 root Debian-exim 6 Feb 6 09:21 exim.pid
>
> After the stop, exim is still running but the pid file is gone.
>
> And I get the message on the console:
> ~> /etc/init.d/exim4 stop
> [....] Stopping MTA:/sbin/start-stop-daemon: matching only on non-root pidfile /run/exim4/exim.pid is insecure
> [ ok 4_listener.

The message "matching only on non-root pid file /run/exim4/exim.pid
is insecure" is very strange in your context, isn't it?
Strange because file exim.pid is owned by root.

I have no such message on stop with my Debian systems. And never seen,
while Exims under Debians are running for years. For most hosts now
start-stop-daemon is from dpkg-1.19.2 (i386 and amd64 are used).

So you have to study why start-stop-daemon ejects this strange message.
BTW, its binary does not contain strings with "matching only", maybe
some old versions of start-stop-daemon have relevant code.

Note that problem is not located so far. Maybe start-stop-daemon fails
to send signal to Exim, maybe Exim receives signal, but ignores.
So first step should be running strace on both to locate the fault.

> So there was a bug introduced in the last few weeks in start-stop-daemon
> that I have to find a way around. The current situation is not
> acceptable.

History of updates for Debian packages is stored in /var/log/dpkg.log.

Before submitting bug reports you have better to compare behaviour
of you system versus clean and fresh Debian. Otherwise you can waste
your time discussing upgrade problems.
--
Eugene Berdnikov

--
## List details at https://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/
Re: Debian-Bug not stopping exim [ In reply to ]
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

Am Do den 7. Feb 2019 um 8:26 schrieb Jan Ingvoldstad via Exim-users:
> Additionally, as Exim in Debian still uses SYSV init scripts, this would
> probably work better if rewritten to work with systemd, which was
> introduced with Jessie several years ago. I see more issues with "mongrel"
> init scripts (scripts run using systemd's SYSV compatibility thingy) than
> with definitions written for systemd in the first place.

I have no systemd anywhere on my systems. On server systems there is no
place for this crap.

I did also not say, that it is a exim problem. I just asked if someone
else already debugged it on debian systems. (It is clearly a debian
problem as start-stop-daemon is part of dpkg. But as I told, since the
systemd evangelists took over debian, it is a nightmare to file bugs
there so if one (as me) uses debian, you are on your own and need to fix
troubles by yourself as debian is no help anymore.)

Regards
Klaus
- --
Klaus Ethgen http://www.ethgen.ch/
pub 4096R/4E20AF1C 2011-05-16 Klaus Ethgen <Klaus@Ethgen.ch>
Fingerprint: 85D4 CA42 952C 949B 1753 62B3 79D0 B06F 4E20 AF1C
-----BEGIN PGP SIGNATURE-----
Comment: Charset: ISO-8859-1

iQGzBAEBCgAdFiEEMWF28vh4/UMJJLQEpnwKsYAZ9qwFAlxcBOkACgkQpnwKsYAZ
9qz5zAv9GjGuyGuCLTSU79ofFVuhbITOGVMqn3cyzC9mj9SNofCsr9u+OWTHWfv0
/KEplom0xd70JDPpsNanyyzCtwN2S42mNiWdGYnxLP/Nn9p9wOwpyw9PBlR9dE/c
ypZh0E6K9MBr2cxZFXorZfPyeFbJB9prpA0NDanaGyoffQJvLvE4kV5GcaYK9ST9
6xM5jH/C9Bk2rz3KB0s1WzFSrx7mCSuY1JHAhG5OZFinWde8F63Vwr9g37TPig96
PSJogyQZA5kwqLwaitfMtu/lB9KT8sqr/WZqgeMawT6P29V2ESqO92begKSK9p50
9JytjCsmrWXSTRCxBCjK6aBwhbx030EYANkE8r01Y5MrBe/oLvIGY5k9C/f1fDEb
x08x0l1jXjkJdm+wNhdYsYksmCsXqsVzHJUlO5ZDaQ1+qzivt3OiBBwc9ZBBwpeQ
xmUOdCc+6fuwdhXuaP+dlmmt2vjRm2oOn9SuNorhSjiz9WtdYArXPyTHNtZM7jqk
RhazsCNy
=NLUp
-----END PGP SIGNATURE-----

--
## List details at https://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/
Re: Debian-Bug not stopping exim [ In reply to ]
Klaus Ethgen via Exim-users <exim-users@exim.org> wrote:
[...]
> did anybody already debug and fix the problem in debian that exim is not
> stopped with stop action anymore?

That is #921205, should be fixed now.

https://salsa.debian.org/exim-team/exim4/commit/7d69adc64e5006ce1d033acbd51681dc8aa3640d

cu Andreas


--
## List details at https://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/