diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1999-09-03 18:11:52 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1999-09-03 18:11:52 +0000 |
commit | d506e3349de8d747ad1756bc69d1ca302d8fd0f1 (patch) | |
tree | e5e800fe4354696f828ac2149909d120582ad6ef | |
parent | 0fea0dd47ea6070fd1755262432fd2fc46562ccd (diff) |
have shutdown code run /etc/rc with arg of "shutdown"; rc.shutdown becomes completely admin-editable
-rw-r--r-- | etc/rc | 18 | ||||
-rw-r--r-- | etc/rc.shutdown | 17 | ||||
-rw-r--r-- | sbin/init/init.c | 15 | ||||
-rw-r--r-- | sbin/reboot/reboot.c | 10 | ||||
-rw-r--r-- | sbin/shutdown/pathnames.h | 4 | ||||
-rw-r--r-- | sbin/shutdown/shutdown.c | 8 |
6 files changed, 39 insertions, 33 deletions
@@ -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/etc/rc.shutdown b/etc/rc.shutdown index c0e59f28657..b249f5214ab 100644 --- a/etc/rc.shutdown +++ b/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. diff --git a/sbin/init/init.c b/sbin/init/init.c index e4e4ae18260..782bf1f6b72 100644 --- a/sbin/init/init.c +++ b/sbin/init/init.c @@ -1,4 +1,4 @@ -/* $OpenBSD: init.c,v 1.16 1999/07/06 07:54:44 deraadt Exp $ */ +/* $OpenBSD: init.c,v 1.17 1999/09/03 18:11:49 deraadt Exp $ */ /* $NetBSD: init.c,v 1.22 1996/05/15 23:29:33 jtc Exp $ */ /*- @@ -47,7 +47,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)init.c 8.2 (Berkeley) 4/28/95"; #else -static char rcsid[] = "$OpenBSD: init.c,v 1.16 1999/07/06 07:54:44 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: init.c,v 1.17 1999/09/03 18:11:49 deraadt Exp $"; #endif #endif /* not lint */ @@ -1347,8 +1347,6 @@ alrm_handler(sig) clang = 1; } -#define _PATH_RCSHUTDOWN "/etc/rc.shutdown" - /* * Bring the system down to single user nicely, after run the shutdown script. */ @@ -1371,7 +1369,7 @@ nice_death() /* NB: should send a message to the session logger to avoid blocking. */ logwtmp("~", "shutdown", ""); - if (access(_PATH_RCSHUTDOWN, R_OK) != -1) { + if (access(_PATH_RUNCOM, R_OK) != -1) { pid_t pid; struct sigaction sa; @@ -1391,9 +1389,10 @@ nice_death() sigprocmask(SIG_SETMASK, &sa.sa_mask, NULL); - execl(_PATH_BSHELL, "sh", _PATH_RCSHUTDOWN, NULL); - stall("can't exec %s for %s: %m", _PATH_BSHELL, - _PATH_RCSHUTDOWN); + execl(_PATH_BSHELL, "sh", _PATH_RUNCOM, "shutdown", + NULL); + stall("can't exec %s for %s %s: %m", _PATH_BSHELL, + _PATH_RUNCOM, "shutdown"); _exit(1); default: waitpid(pid, &status, 0); diff --git a/sbin/reboot/reboot.c b/sbin/reboot/reboot.c index 68b25587365..d8e78ad3564 100644 --- a/sbin/reboot/reboot.c +++ b/sbin/reboot/reboot.c @@ -1,4 +1,4 @@ -/* $OpenBSD: reboot.c,v 1.16 1999/08/16 18:43:11 art Exp $ */ +/* $OpenBSD: reboot.c,v 1.17 1999/09/03 18:11:50 deraadt Exp $ */ /* $NetBSD: reboot.c,v 1.8 1995/10/05 05:36:22 mycroft Exp $ */ /* @@ -44,7 +44,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)reboot.c 8.1 (Berkeley) 6/5/93"; #else -static char rcsid[] = "$OpenBSD: reboot.c,v 1.16 1999/08/16 18:43:11 art Exp $"; +static char rcsid[] = "$OpenBSD: reboot.c,v 1.17 1999/09/03 18:11:50 deraadt Exp $"; #endif #endif /* not lint */ @@ -67,7 +67,7 @@ static char rcsid[] = "$OpenBSD: reboot.c,v 1.16 1999/08/16 18:43:11 art Exp $"; void usage __P((void)); extern char *__progname; -#define _PATH_RCSHUTDOWN "/etc/rc.shutdown" +#define _PATH_RC "/etc/rc" int main(argc, argv) @@ -168,7 +168,7 @@ main(argc, argv) */ (void)signal(SIGPIPE, SIG_IGN); - if (access(_PATH_RCSHUTDOWN, R_OK) != -1) { + if (access(_PATH_RC, R_OK) != -1) { pid_t pid; struct termios t; int fd; @@ -195,7 +195,7 @@ main(argc, argv) t.c_oflag |= (ONLCR | OPOST); tcsetattr(0, TCSANOW, &t); - execl(_PATH_BSHELL, "sh", _PATH_RCSHUTDOWN, NULL); + execl(_PATH_BSHELL, "sh", _PATH_RC, "shutdown", NULL); _exit(1); default: waitpid(pid, NULL, 0); diff --git a/sbin/shutdown/pathnames.h b/sbin/shutdown/pathnames.h index de5e084083a..7f12fa54cc0 100644 --- a/sbin/shutdown/pathnames.h +++ b/sbin/shutdown/pathnames.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pathnames.h,v 1.3 1998/04/25 04:45:37 millert Exp $ */ +/* $OpenBSD: pathnames.h,v 1.4 1999/09/03 18:11:50 deraadt Exp $ */ /* $NetBSD: pathnames.h,v 1.6 1995/03/18 15:01:06 cgd Exp $ */ /* @@ -42,4 +42,4 @@ #define _PATH_HALT "/sbin/halt" #define _PATH_REBOOT "/sbin/reboot" #define _PATH_WALL "/usr/bin/wall" -#define _PATH_RCSHUTDOWN "/etc/rc.shutdown" +#define _PATH_RC "/etc/rc" diff --git a/sbin/shutdown/shutdown.c b/sbin/shutdown/shutdown.c index d30228a5921..6ada099d0cd 100644 --- a/sbin/shutdown/shutdown.c +++ b/sbin/shutdown/shutdown.c @@ -1,4 +1,4 @@ -/* $OpenBSD: shutdown.c,v 1.16 1999/07/19 00:16:38 deraadt Exp $ */ +/* $OpenBSD: shutdown.c,v 1.17 1999/09/03 18:11:51 deraadt Exp $ */ /* $NetBSD: shutdown.c,v 1.9 1995/03/18 15:01:09 cgd Exp $ */ /* @@ -44,7 +44,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)shutdown.c 8.2 (Berkeley) 2/16/94"; #else -static char rcsid[] = "$OpenBSD: shutdown.c,v 1.16 1999/07/19 00:16:38 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: shutdown.c,v 1.17 1999/09/03 18:11:51 deraadt Exp $"; #endif #endif /* not lint */ @@ -396,7 +396,7 @@ die_you_gravy_sucking_pig_dog() syslog(LOG_ERR, "shutdown: can't exec %s: %m.", _PATH_HALT); warn(_PATH_HALT); } - if (access(_PATH_RCSHUTDOWN, R_OK) != -1) { + if (access(_PATH_RC, R_OK) != -1) { pid_t pid; struct termios t; int fd; @@ -423,7 +423,7 @@ die_you_gravy_sucking_pig_dog() t.c_oflag |= (ONLCR | OPOST); tcsetattr(0, TCSANOW, &t); - execl(_PATH_BSHELL, "sh", _PATH_RCSHUTDOWN, NULL); + execl(_PATH_BSHELL, "sh", _PATH_RC, "shutdown", NULL); _exit(1); default: waitpid(pid, NULL, 0); |