Re: /etc/init.d/opendkim fails to start opendkim when run over ssh with a pseudo-tty

From: Sam Umbach <sumbach_at_gmail.com>
Date: Sun, 17 Apr 2011 16:10:29 -0400

> Does anything get logged during the failure to start?

When the daemon fails to start, nothing is logged or written to STDERR
or STDOUT.

> Maybe I need to read up on something, but I can't imagine why allocating a
> pty prior to fork() and exec() of opendkim would prevent it from starting or
> operating properly, especially since it replaces descriptors 0, 1 and 2 with
> /dev/null and calls setsid() immediately after it fork()s into the
> background.

Based on my tests today, I strongly suspect there is a race condition
when the daemon is started from a pty. This affects both opendkim and
dk-filter, and I have seen the same results on Ubuntu 10.04 (lucid),
10.10 (maverick), and 11.04 beta 2 (natty). I'm not sure whether the
issue lies in the opendkim and dk-filter executables,
start-stop-daemon, or elsewhere.

maverick, non-root user w/ passwordless sudo, no pty
result: SUCCESS, started opendkim daemon on 10 of 10 attempts
    ssh -T ubuntu_at_maverick 'sudo /etc/init.d/opendkim stop'
    ssh -T ubuntu_at_maverick 'pidof opendkim'
    ssh -T ubuntu_at_maverick 'sudo /etc/init.d/opendkim start'
    ssh -T ubuntu_at_maverick 'pidof opendkim'

maverick, root user, no sudo, no pty
result: SUCCESS, started opendkim daemon on 10 of 10 attempts
    ssh -T root_at_maverick '/etc/init.d/opendkim stop'
    ssh -T root_at_maverick 'pidof opendkim'
    ssh -T root_at_maverick '/etc/init.d/opendkim start'
    ssh -T root_at_maverick 'pidof opendkim'

maverick, non-root user w/ passwordless sudo, pty
result: FAIL, started opendkim daemon on 5 of 10 attempts
    ssh -tt ubuntu_at_maverick 'sudo /etc/init.d/opendkim stop'
    ssh -tt ubuntu_at_maverick 'pidof opendkim'
    ssh -tt ubuntu_at_maverick 'sudo /etc/init.d/opendkim start'
    ssh -tt ubuntu_at_maverick 'pidof opendkim'

maverick, root user, no sudo, pty
result: FAIL, started opendkim daemon on 7 of 10 attempts
    ssh -tt root_at_maverick '/etc/init.d/opendkim stop'
    ssh -tt root_at_maverick 'pidof opendkim'
    ssh -tt root_at_maverick '/etc/init.d/opendkim start'
    ssh -tt root_at_maverick 'pidof opendkim'

Mixed results (inconsistent behavior starting the daemon over ssh w/ a
pty) in the following environments:
* opendkim on lucid (FAILED 10 of 10 attempts)
* dk-filter on maverick (FAILED 1 of 10 attempts)
* dk-filter on lucid (FAILED 10 of 10 attempts)
* opendkim on natty (using `sudo service opendkim start`, FAILED 10 of
10 attempts)
* dk-filter on natty (using `sudo service dk-filter start`, FAILED 10
of 10 attempts)

Interestingly, dk-filter on Ubuntu 9.10 karmic succeeded on 10 of 10
attempts. This is obviously a timing issue, but it is possible this
issue was introduced between karmic and lucid. I'm going to raise
this with the Ubuntu maintainers and try to determine whether opendkim
and dk-filter are "at fault" or if this is an issue with the Ubuntu or
Debian distro.

As a workaround, I've added '&& sleep 1' to my start commands. This
works consistently for opendkim and dk-filter on all four Ubuntu
releases tested.

-Sam
Received on Sun Apr 17 2011 - 20:10:42 PST

This archive was generated by hypermail 2.3.0 : Mon Oct 29 2012 - 23:20:17 PST