Date: 01 Sep 2003 22:25:42 -0400 From: Christopher Nehren <apeiron@comcast.net> To: hackers@freebsd.org Subject: Addition to reboot(8): reboot / halt reasons Message-ID: <1062469541.642.6.camel@prophecy.velum>
index | next in thread | raw e-mail
[-- Attachment #1 --]
While playing around with Win2K3 recently, I noticed that it brings up a
dialog at every reboot / shutdown and asks for a reason for said reboot
/ shutdown. So I was bored tonight, and decided to implement that
feature in FreeBSD's reboot(8) with a -r flag. Here's a diff against a
-CURRENT reboot.c, checked out about five minutes ago.
[-- Attachment #2 --]
--- reboot.c.old Sat May 3 14:41:59 2003
+++ reboot.c Mon Sep 1 22:23:56 2003
@@ -69,9 +69,10 @@
main(int argc, char *argv[])
{
struct passwd *pw;
- int ch, howto, i, fd, kflag, lflag, nflag, qflag, pflag, sverrno;
+ int ch, howto, i, fd, kflag, lflag, nflag, qflag, pflag, rflag;
+ int sverrno;
u_int pageins;
- char *kernel, *p;
+ char *kernel, *p, *reason;
const char *user;
if (strstr((p = rindex(*argv, '/')) ? p + 1 : *argv, "halt")) {
@@ -79,8 +80,8 @@
howto = RB_HALT;
} else
howto = 0;
- kflag = lflag = nflag = qflag = 0;
- while ((ch = getopt(argc, argv, "dk:lnpq")) != -1)
+ kflag = lflag = nflag = qflag = rflag = 0;
+ while ((ch = getopt(argc, argv, "dk:lnpqr:")) != -1)
switch(ch) {
case 'd':
howto |= RB_DUMP;
@@ -103,6 +104,10 @@
case 'q':
qflag = 1;
break;
+ case 'r':
+ rflag = 1;
+ reason = optarg;
+ break;
case '?':
default:
usage();
@@ -140,10 +145,10 @@
pw->pw_name : "???";
if (dohalt) {
openlog("halt", 0, LOG_AUTH | LOG_CONS);
- syslog(LOG_CRIT, "halted by %s", user);
+ syslog(LOG_CRIT, "halted by %s: %s", user, rflag ? reason : "no reason");
} else {
openlog("reboot", 0, LOG_AUTH | LOG_CONS);
- syslog(LOG_CRIT, "rebooted by %s", user);
+ syslog(LOG_CRIT, "rebooted by %s: %s", user, rflag ? reason : "no reason");
}
}
logwtmp("~", "shutdown", "");
help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1062469541.642.6.camel>
