*BSD News Article 45296


Return to BSD News archive

Xref: sserve comp.sys.sun.admin:48321 comp.unix.admin:29536 comp.unix.bsd:16643 comp.unix.shell:22870 comp.unix.solaris:39351 comp.unix.ultrix:25425 comp.unix.xenix:10637 comp.security.unix:13487
Path: sserve!newshost.anu.edu.au!harbinger.cc.monash.edu.au!simtel!news.kei.com!news.mathworks.com!uunet!in1.uu.net!tembel!not-for-mail
From: shields@tembel.org (Michael Shields)
Newsgroups: comp.sys.sun.admin,comp.unix.admin,comp.unix.bsd,comp.unix.shell,comp.unix.solaris,comp.unix.ultrix,comp.unix.xenix,comp.security.unix
Subject: Re: Shutdown Account
Date: 9 Jun 1995 01:09:52 -0000
Organization: Tembel's Hedonic Commune
Lines: 45
Distribution: inet
Message-ID: <3r8710$msp@yage.tembel.org>
References: <3r2j7f$7p4@apakabar.cc.columbia.edu> <m0sJEXa-000DJrC@yage.tembel.org> <Pine.SUN.3.91.950608133632.5338L-100000@konichiwa.cc.columbia.edu>
NNTP-Posting-Host: yage.tembel.org
NNTP-Posting-User: shields

In article <Pine.SUN.3.91.950608133632.5338L-100000@konichiwa.cc.columbia.edu>,
Data  <czen@columbia.edu> wrote:
> > You might want to use a wrapper that double-checks that it's being
> > run from the console, and exec's halt without arguments.  This adds
> > redundant security, and also prevents anyone from su'ing to it when not
> > on the console.
> 
> thatz a great idea! are there any sample wrappers on the net that i might 
> borrow and mutate? 

Off the top of my head:

#!/usr/bin/perl
#
# Secure shutdown-account shell, 1995-06-08
# Michael Shields <shields@tembel.org>
#
# Public domain.  Absolutely NO WARRANTY.
#

require 'syslog.pl';

open(SECURETTY, '/etc/securetty')
    || die "Couldn't open /etc/securetty: $!\n";

openlog('-shutdown', 'cons', 'auth');

while (<SECURETTY>) {
    chop;
    $securep{$_}++;
}

$tty = `/usr/bin/tty`;
chop $tty;
$tty =~ s,^.*/,,;

# Necessary to prevent su'ing to the account.
unless ($securep{$tty}) {
    syslog('warning', "Shutdown refused on insecure $tty by " . getpwuid($<));
    die "Refused; you can only shutdown from the console\n";
}

exec '/usr/etc/halt', '-halt';
-- 
Shields.