From owner-freebsd-hackers@FreeBSD.ORG Mon Sep 1 19:25:44 2003 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 8EA2716A4C1 for ; Mon, 1 Sep 2003 19:25:44 -0700 (PDT) Received: from rwcrmhc11.comcast.net (rwcrmhc11.comcast.net [204.127.198.35]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6860B43FBF for ; Mon, 1 Sep 2003 19:25:43 -0700 (PDT) (envelope-from apeiron@comcast.net) Received: from [192.168.0.5] (pcp05043495pcs.levtwn01.pa.comcast.net[68.86.252.216](untrusted sender)) by comcast.net (rwcrmhc11) with SMTP id <2003090202254201300qaouve>; Tue, 2 Sep 2003 02:25:42 +0000 From: Christopher Nehren To: hackers@freebsd.org Content-Type: multipart/mixed; boundary="=-/lxmoucE5VFrAKLJKnKG" Message-Id: <1062469541.642.6.camel@prophecy.velum> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.3 Date: 01 Sep 2003 22:25:42 -0400 Subject: Addition to reboot(8): reboot / halt reasons X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Sep 2003 02:25:44 -0000 --=-/lxmoucE5VFrAKLJKnKG Content-Type: text/plain Content-Transfer-Encoding: 7bit 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. --=-/lxmoucE5VFrAKLJKnKG Content-Disposition: attachment; filename=reboot.c.patch Content-Type: text/plain; name=reboot.c.patch; charset=UTF-8 Content-Transfer-Encoding: 7bit --- 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", ""); --=-/lxmoucE5VFrAKLJKnKG--