Bug#502444: sshd fails at boot-time following reload by /etc/network/if-up.d/openssh-server presumably due to race condition
On Tue, Jan 13, 2009 at 08:17:26PM +0100, Kevin Price wrote:
> I ran into this bug on a HP ProLiant DL360 G5, after upgrading the
> entire userspace from etch to lenny. s/reload/restart/g does the trick
> for me too.
>
> It makes the openssh-server package useless and it happens reliably,
> which justifies the grave severity IMHO.
>
> Please let me know what I can do to help debugging.
Could you try applying this patch to /etc/network/if-up.d/openssh-server
(after undoing your s/reload/restart/g change) and retesting for me?
Based on my reading of sshd's startup sequence I think it should avoid
the race.
Thanks,
--
Colin Watson [cjwatson@debian.org]
--- /etc/network/if-up.d/openssh-server 13 Jun 2007 22:43:48 -0000 1.2
+++ /etc/network/if-up.d/openssh-server 13 Jan 2009 20:18:14 -0000 1.3
@@ -25,6 +25,11 @@ if [ ! -e /usr/sbin/sshd ]; then
exit 0
fi
+if [ ! -f /var/run/sshd.pid ] || \
+ [ "$(ps -p "$(cat /var/run/sshd.pid)" -o comm=)" != sshd ]; then
+ exit 0
+fi
+
/etc/init.d/ssh reload >/dev/null 2>&1 || true
exit 0
Reply to: