[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#942808: ITP: dropbear-rescue -- A set of initramfs scripts to add and run dropbear when the system boots in rescue mode




On 2019-10-25 7:50 p.m., Guilhem Moulin wrote:
Control: retitle -1 race condition: init-bottom script doesn't abort/cleanup configure_networking()
Control: tag -1 pending

On Fri, 25 Oct 2019 at 02:26:39 +0200, Guilhem Moulin wrote:
Ah right, I understand the problem now.  Whether configure_networking()
is run (at premount stage) in the background or not depends on the boot
method.  On local (non-NFS) mounts it's done in the background, and
should be interrupted at bottom stage.  However if no other script is
waiting for interactive user input the bottom script might run before
dropbear had a chance to run yielding a race condition at bottom stage.
This is a bug.
Implemented a fix at https://salsa.debian.org/debian/dropbear/commit/1ab168b9 ,
could you please confirm that it solves the race for you?

It appears that ipconfig doesn't react to SIGTERM, so I've not been able
to properly abort configure_networking().  Instead, the init-bottom
script now waits (for up to 1min) until dropbear is started before
bringing the network down.  Of course it's a bit of a waste as it
needlessly delays the boot process (it's no longer possible to log in at
that stage anyway), but at least when execution is handed over to init(1)
it's with a clean network stack and not with a running ipconfig process.

A quick note:

I use this code snippet to show the user how to continue the boot process in case he logins remotely.
https://github.com/lukavia/dropbear-rescue/blob/8b84e98c8e7c892250906bb167d3828046619ade/src/hooks/dropbear-rescue#L75

This is in the initramfs build hook file:

echo "echo --------------------------------" >> "$home/.profile"
echo 'echo To continue booting execute: kill -1$(ps -o pid,args | grep "sh -i" | grep -v grep | cut -d" " -f-3)' >> "$home/.profile"

I'm sure it could be written better, but I think it would be nice addition.

Best Regards


Reply to: