Confirm CTRL-ALT-DEL before rebooting

Mark msalists at gmx.net
Wed Sep 8 01:54:51 UTC 2004


Hi,

I wanted to force a user to confirm that eh really wants to reboot after
hitting CTRL-ALT-DEL at the console.
I tried to call my own script from within /etc/inittab like this:
ca::ctrlaltdel:/usr/local/sbin/confirmed_reboot

My confirmed_reboot script looks like this:
----------------------------------------------------
expected_string='ReBoOt';
prompt="\nEnter '$expected_string' (case-sensitive) followed by <ENTER> to
reboot machine.\nHit <CTRL>-C to cancel and c
ontinue.\n"
read -t 10 -p "$prompt" reply
if [ "$reply" == "$expected_string" ]; then
  echo "\nRebooting...\n"
  #/sbin/shutdown -t3 -r now
else
  echo "\nWrong confirmation, not rebooting.\n"
fi
----------------------------------------------------


This works halfway as long as the user is not logged into the console, with
the exception that the "read" and the regular logon prompt somehow fight for
the keyboard input and I sometimes have to enter the confirmation string
twice, because the first one is read by the logon process as userid or
password.
If the user is logged in when pressing CTRL-ALT-DEL, however, all keyboard
input goes the the regular console prompt rather than to my script and my
script's read operation times out after 10 seconds.

How can I make sure that my script's read operation gets the highest
priority for keyboard entry???
Or is there some other way to not totally disable reboot upon CTRL-ALT-DEL,
but make it more secure by requiring some kind of a confirmation (entering a
string or pressing CTRL-ALT-DEL 3 times instead of just once, or something
like that...)

Thanks,

MARK





More information about the users mailing list