summaryrefslogtreecommitdiff
path: root/sbin/shutdown/shutdown.c
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1999-07-19 00:16:39 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1999-07-19 00:16:39 +0000
commit58f9378e19970786357a220ad8cef03195923722 (patch)
treeaf35bf55a2895417f8eb8e1985dd844491cf843a /sbin/shutdown/shutdown.c
parent8b8cf47e3eb837dd96a8d3f144e64cf16776e1b5 (diff)
if we run /etc/rc.shutdown ourselves, do it on /dev/console
Diffstat (limited to 'sbin/shutdown/shutdown.c')
-rw-r--r--sbin/shutdown/shutdown.c27
1 files changed, 24 insertions, 3 deletions
diff --git a/sbin/shutdown/shutdown.c b/sbin/shutdown/shutdown.c
index 63d2a8f1d84..d30228a5921 100644
--- a/sbin/shutdown/shutdown.c
+++ b/sbin/shutdown/shutdown.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: shutdown.c,v 1.15 1999/04/29 22:25:04 alex Exp $ */
+/* $OpenBSD: shutdown.c,v 1.16 1999/07/19 00:16:38 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.15 1999/04/29 22:25:04 alex Exp $";
+static char rcsid[] = "$OpenBSD: shutdown.c,v 1.16 1999/07/19 00:16:38 deraadt Exp $";
#endif
#endif /* not lint */
@@ -55,6 +55,7 @@ static char rcsid[] = "$OpenBSD: shutdown.c,v 1.15 1999/04/29 22:25:04 alex Exp
#include <ctype.h>
#include <fcntl.h>
+#include <sys/termios.h>
#include <pwd.h>
#include <setjmp.h>
#include <signal.h>
@@ -397,13 +398,33 @@ die_you_gravy_sucking_pig_dog()
}
if (access(_PATH_RCSHUTDOWN, R_OK) != -1) {
pid_t pid;
+ struct termios t;
+ int fd;
switch ((pid = fork())) {
case -1:
break;
case 0:
+ if (revoke(_PATH_CONSOLE) == -1)
+ perror("revoke");
+ if (setsid() == -1)
+ perror("setsid");
+ fd = open(_PATH_CONSOLE, O_RDWR);
+ if (fd == -1)
+ perror("open");
+ dup2(fd, 0);
+ dup2(fd, 1);
+ dup2(fd, 2);
+ if (fd > 2)
+ close(fd);
+
+ /* At a minimum... */
+ tcgetattr(0, &t);
+ t.c_oflag |= (ONLCR | OPOST);
+ tcsetattr(0, TCSANOW, &t);
+
execl(_PATH_BSHELL, "sh", _PATH_RCSHUTDOWN, NULL);
- exit(1);
+ _exit(1);
default:
waitpid(pid, NULL, 0);
}