From 5e54c51bd5accc6c31d9c28a74c851dd05fa34e9 Mon Sep 17 00:00:00 2001 From: deraadt <> Date: Fri, 3 Sep 1999 18:11:48 +0000 Subject: [PATCH] have shutdown code run /etc/rc with arg of "shutdown"; rc.shutdown becomes completely admin-editable --- src/etc/rc | 18 +++++++++++++++++- src/etc/rc.shutdown | 17 ++++------------- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/src/etc/rc b/src/etc/rc index 460958ae..90042626 100644 --- a/src/etc/rc +++ b/src/etc/rc @@ -1,4 +1,4 @@ -# $OpenBSD: rc,v 1.107 1999/08/31 03:47:16 deraadt Exp $ +# $OpenBSD: rc,v 1.108 1999/09/03 18:11:48 deraadt Exp $ # System startup script run by init on autoboot # or after single-user. @@ -16,6 +16,22 @@ HOME=/; export HOME PATH=/sbin:/bin:/usr/sbin:/usr/bin export PATH +if [ $1x = shutdownx ]; then + dd if=/dev/urandom of=/var/db/host.random bs=1024 count=64 >/dev/null 2>&1 + chmod 600 /var/db/host.random >/dev/null 2>&1 + if [ $? -eq 0 -a -f /etc/rc.shutdown ]; then + echo /etc/rc.shutdown in progress... + . /etc/rc.shutdown + echo /etc/rc.shutdown complete. + if [ "X${powerdown}" = X"YES" ]; then + exit 2 + fi + else + echo single user: not running /etc/rc.shutdown + fi + exit 0 +fi + # Configure ccd devices. if [ -f /etc/ccd.conf ]; then ccdconfig -C diff --git a/src/etc/rc.shutdown b/src/etc/rc.shutdown index c0e59f28..b249f521 100644 --- a/src/etc/rc.shutdown +++ b/src/etc/rc.shutdown @@ -1,21 +1,12 @@ -# $OpenBSD: rc.shutdown,v 1.4 1999/07/25 19:32:17 deraadt Exp $ +# $OpenBSD: rc.shutdown,v 1.5 1999/09/03 18:11:48 deraadt Exp $ # # If it exists, this script is run at system-shutdown by reboot(8), -# halt(8). -# If the architecture supports keyboard requested halting, it is also -# run by init(8) when such an event happens. +# halt(8). If the architecture supports keyboard requested halting, +# it is also run by init(8) when such an event happens. # -echo /etc/rc.shutdown in progress... - -# save part of our entropy pool for reuse on reboot -dd if=/dev/urandom of=/var/db/host.random bs=1024 count=64 >/dev/null 2>&1 -chmod 600 /var/db/host.random >/dev/null 2>&1 +powerdown=NO # set to YES for powerdown # # Your shell code goes here # - - -echo shutdown complete. -exit 0 # An exit code of 2 will cause init(8) to attempt powerdown.