Opps i wasn't done,

On Fri, 30 Jul 1999, Axalon wrote:

> 
> 
> On Fri, 30 Jul 1999, Theo Brinkman wrote:
> 
> > Ok, you guys are getting a bit over my head at this point.   I'm very
> > much a newbie at scripting stuff, so some examples would be nice.
> > 
> > Here's the script as it stands:
> > - -
> > #!/bin/sh
> > # Shutdown on Ctrl+Alt+Delete based on User.
> > 
> > if [ id -u == 0 ]; then             #if user is administrator
> >     halt
> > else
> >     logout
> > fi
> > - -
> > 
> > I've got a few questions about it.
> > 
> > 1.  Might a check against 'id -g' work better?  (In case you have more
> > than one login in the 'root' group)
> > 
> > 2.  I'm not familiar enough with gawk to do any scripting with it yet,
> > anybody feel like taking a crack at either of the two gawk related
> > suggestions?
> > 
> > 
> > I love an educational process.  Thanks guys.
> > 
> >     - Theo
>  
 Uhh, no not really.
 -=-=
 #!/bin/bash
 DEBUG=1
 if [ "$DEBUG"x = "1"x ]; then
        TEST="logger -is "
 else
        TEST=""
 fi
 # Shutdown on Ctrl+Alt+Delete based on UID
 IAM=`id -u`
 if [ "$DEBUG"x = "1"x ]; then
        $TEST "$IAM"
        $TEST `tty`
 fi
 if [ "$IAM"x = "0"x ]; then
        $TEST "halt "   #Is root
 else
        $TEST "logout "  #Not root
 fi
-=-=




> > Axalon wrote:
> > > 
> > > On Fri, 30 Jul 1999, Andy Goth wrote:
> > > 
> > > > > > How about creating a quick script '/etc/threefingersalute', like the one
> > > > > > below:
> > > > > > - -
> > > > > > if [ $USERNAME = "ROOT" ]; then
> > > > >
> > > > > $USER $USERNAME or $LOGNAME, bash manpages will give you info on what each
> > > > > is, the "ROOT" should be "root" it's case sensitive. This might work, but
> > > > > without double checking i'm pretty sure it'll be a problem that init runs
> > > > > as root and this does not actualy run on the current console when you
> > > > > call it with.
> > > >
> > > > It doesn't have to be root.  If you wanted to, you could change root's
> > > > name to something else by hacking the /etc/passwd file.  The superuser
> > > > (usually root) is the one with the user id of 0.  You could write a GAWK
> > > > program that would scan for the line with the user id of 0 and print the
> > > > corresponding username (and you would capture the output and compare it
> > > > to $USERNAME).
> > > >
> > > > Hmm.  Maybe root isn't the only user who wants to shut down the system
> > > > when he presses Ctrl+Alt+Del.  Try comparing the $USERNAME against the
> > > > names in shutdown.allow (a la a GAWK script).  Would that work, guys?
> > > >
> > > 
> > > why not just compare 'id -u' with zero then?
> > 
> 
> 

Reply via email to