From owner-freebsd-current@FreeBSD.ORG Tue Sep 29 09:55:16 2009 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5BD79106566B for ; Tue, 29 Sep 2009 09:55:16 +0000 (UTC) (envelope-from cmdlnkid@gmail.com) Received: from mail-qy0-f176.google.com (mail-qy0-f176.google.com [209.85.221.176]) by mx1.freebsd.org (Postfix) with ESMTP id 0E5CD8FC16 for ; Tue, 29 Sep 2009 09:55:15 +0000 (UTC) Received: by qyk6 with SMTP id 6so2536112qyk.3 for ; Tue, 29 Sep 2009 02:55:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:date:from:to:cc:subject :in-reply-to:message-id:references:user-agent:x-openpgp-key-id :x-openpgp-key-fingerprint:mime-version:content-type; bh=WQl9V3vgCGBnlxfQS6sUNwjcACgtS5oIBB2ZCJ7Sios=; b=TBjvLALPjk5GiY/GLtAbuLbSRjNX/IbVw+nlNAQLlH7/RYtw1wANH9L7NU/xxDMUq5 Jv9bgj2hWu+fuzCZamDsIr7kQVpW6fxi21+yE77bQiuQXluelQsO04zGhNMthKSoFFut 9vEb3such+/1prvJubmOj0vmzjFpdEbPkttzs= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:in-reply-to:message-id:references :user-agent:x-openpgp-key-id:x-openpgp-key-fingerprint:mime-version :content-type; b=E1+RMTrwF+WMo5bc5SPM1Q+DSyUeG01lM3jILR6jpb98ugewPU2DelfVTd0UiF97oE R05VVq5h3wCoXGI0acpml3r/5pX7w/WvRtBXY34jtJaO2lT1ykzQ1CkoaA2lAW0EoftS bJdfXyiC8C+3dxTBVKdEsZ4W99tQZPlyQ4abY= Received: by 10.224.46.79 with SMTP id i15mr3631305qaf.58.1254218114867; Tue, 29 Sep 2009 02:55:14 -0700 (PDT) Received: from dimension.5p.local (adsl-99-35-15-84.dsl.klmzmi.sbcglobal.net [99.35.15.84]) by mx.google.com with ESMTPS id 8sm1108500qwj.24.2009.09.29.02.55.13 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 29 Sep 2009 02:55:14 -0700 (PDT) Date: Tue, 29 Sep 2009 05:55:05 -0400 From: CmdLnKid To: Daniel Braniss In-Reply-To: Message-ID: References: <4AC141B0.4090705@delphij.net> User-Agent: Alpine 2.00 (BSF 1167 2008-08-23) X-OpenPGP-Key-Id: 0xFAD8B467 X-OpenPGP-Key-Fingerprint: D197 8B5A C1BC AD25 33C9 16DF 2C68 DCDE FAD8 B467 MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: FreeBSD Current , d@delphij.net Subject: Re: [PATCH] Shutdown cooloff feature X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Sep 2009 09:55:16 -0000 On Tue, 29 Sep 2009 04:16 -0000, danny wrote: > >> Hi, >> >> I'm not sure if anyone would find this useful: >> >> - If a shutdown is initiated from a tty -and- >> - It's not a restart -and- >> - The time parameter is set to "now" >> >> Then, the shutdown(8) program would give something like this: >> >> Shutting down NOW, press ^C within 5 seconds to cancel... >> >> So the user would get a chance to terminate it before it's too late. >> > I know we are living in a virtual world, where even shutting down > a computer is just a 'wish', but lets keep some sanity, now means now. > On the other hand, you could make it conditional, say an environment > variable 'GREENOPERATOR', in which case now would mean soon ... :-) > > danny > >> Cheers, >> - -- >> Xin LI http://www.delphij.net/ >> FreeBSD - The Power to Serve! >> -----BEGIN PGP SIGNATURE----- >> Version: GnuPG v2.0.12 (FreeBSD) >> >> iEYEARECAAYFAkrBQa8ACgkQi+vbBBjt66D5iQCgmISna2P4CbX9qob5SuetGuoy >> nUUAn0BtA/67Lyy8+91JppokUE57c/Ew >> =Aytq >> -----END PGP SIGNATURE----- >> >> --------------090504090807040407080107 >> Content-Type: text/plain; >> name="shutdown-cooloff.diff" >> Content-Transfer-Encoding: 7bit >> Content-Disposition: inline; >> filename="shutdown-cooloff.diff" >> >> Index: shutdown.c >> =================================================================== >> --- shutdown.c (revision 197578) >> +++ shutdown.c (working copy) >> @@ -103,6 +103,7 @@ static void timewarn(int); >> static void usage(const char *); >> >> extern const char **environ; >> +static char hostname[MAXHOSTNAMELEN]; >> >> int >> main(int argc, char **argv) >> @@ -159,6 +160,7 @@ main(int argc, char **argv) >> if (nosync != NULL && !oflag) >> usage("-n requires -o"); >> >> + gethostname(hostname, sizeof(hostname)); >> getoffset(*argv++); >> >> if (*argv) { >> @@ -193,8 +195,22 @@ main(int argc, char **argv) >> >> if (offset) >> (void)printf("Shutdown at %.24s.\n", ctime(&shuttime)); >> - else >> + else { >> + /* >> + * Safe belt when the operation is going to happen >> + * immediately from a tty. >> + */ >> + if (doreboot != 1) { >> + if (isatty(STDIN_FILENO)) { >> + printf("Shutting down %s NOW, press ^C within " >> + "5 seconds to cancel...", hostname); >> + fflush(stdout); >> + sleep(5); >> + printf(" going ahead!\n"); >> + } >> + } >> (void)printf("Shutdown NOW!\n"); >> + } >> >> if (!(whom = getlogin())) >> whom = (pw = getpwuid(getuid())) ? pw->pw_name : "???"; >> @@ -271,14 +287,9 @@ static const char *restricted_environ[] = { >> static void >> timewarn(int timeleft) >> { >> - static int first; >> - static char hostname[MAXHOSTNAMELEN + 1]; >> FILE *pf; >> char wcmd[MAXPATHLEN + 4]; >> >> - if (!first++) >> - (void)gethostname(hostname, sizeof(hostname)); >> - >> /* undoc -n option to wall suppresses normal wall banner */ >> (void)snprintf(wcmd, sizeof(wcmd), "%s -n", _PATH_WALL); >> environ = restricted_environ; >> >> --------------090504090807040407080107 >> Content-Type: text/plain; charset="us-ascii" >> MIME-Version: 1.0 >> Content-Transfer-Encoding: 7bit >> Content-Disposition: inline >> >> _______________________________________________ >> freebsd-current@freebsd.org mailing list >> http://lists.freebsd.org/mailman/listinfo/freebsd-current >> To unsubscribe, send any mail to "freebsd-current-unsubscribe@freebsd.org" >> --------------090504090807040407080107-- >> > > > _______________________________________________ > freebsd-current@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-current > To unsubscribe, send any mail to "freebsd-current-unsubscribe@freebsd.org" > How about adding this as a kernel tunable that could be placed in /boot/loader.conf or tuned via sysctl during operation and then instead of having it act upon someone issuing the shutdown command which is a pretty hard thing to accidentally do, have it act on the three finger salute aka: ctrl+alt+del. Personally I would love to have something like this in place that could have a adjustable time limit or reasonable default time limit that could actually give a sysop time to react. Just my thoughts. -- - (2^(N-1))