Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
From: jon@qcvaxa.acc.qc.edu
Subject: RE: Disabling account from script
Date: 1996/06/18	[thread overview]
Message-ID: <4q4ph6$15hb@news.cuny.edu> (raw)
In-Reply-To: 4pn76o$cor@tom.amherst.edu


From: pdchapin@unix.amherst.edu (PAUL D. CHAPIN)
> Is there a quick and easy way for a script to prevent a user from
> logging on awhile?  It's easy enough to do with XIsso interactively,
> and I could always reset the shell and/or password, but it seems there
> ought to be a simple way to do what XIsso does from the command line.
> I don't want to shut everybody down, just a few people one at a time.

I wrote a set of simple scripts to lock and unlock user accounts from 
the command line.  These routines are "XIsso compatible" so if you lock 
an account using my Lock routine, you can unlock it using either Unlock
or XIsso.  I hope this is what you were looking for.

Jon Leong
Systems Manager
Queens College, NYC

File: /usr/sbin/Lock
--------------------------- BEGIN CUT HERE ---------------------------
#!/bin/ksh
#
# This script allows you to lock a user's account without using XIsso.
# Syntax:       Lock <username>
# Example:      Lock pest
#							Jon Leong - 2/96

# See if this is a valid user name
ULETTER=`expr "${1}" : '\(.\)'`
AUTHDIR="/tcb/files/auth/${ULETTER}"
if [ ! -f "${AUTHDIR}/${1}" ]
   then
	echo "...Error - Invalid user name: ${1}"
	echo " "
	exit 1
fi

# Make sure account is not already locked
grep -q u_lock@ "${AUTHDIR}/${1}"
if [ $? != 0 ]
   then
	echo "...${1}'s account is already locked"
	echo " "
	exit 1
fi

# Lock account by modifying the user's auth file
ed -s "${AUTHDIR}/${1}" < /usr/sbin/Lock.ed_commands
echo "...Account locked"
echo " "
----------------------- END - CUT HERE ---------------------------


The Lock script uses a file called Lock.ed_commands which contains the 
ed commands that do the actual work.

/usr/sbin/Lock.ed_commands
----------------------- BEGIN - CUT HERE ---------------------------
1,$s/u_lock@:/:/
w
q
----------------------- END - CUT HERE ---------------------------



The Unlock and Unlock.ed_commands are used to unlock accounts locked by
Lock (NOTE: Unlock does not handle all lock conditions).

/usr/sbin/Unlock
----------------------- BEGIN - CUT HERE -------------------------
#!/bin/ksh
#
# This script allows you to unlock a user's account that was locked by Lock.
# Syntax:       Unlock <username>
# Example:      Unlock pest
# 
#							Jon Leong - 2/96

# See if this is a valid user name
ULETTER=`expr "${1}" : '\(.\)'`
AUTHDIR="/tcb/files/auth/${ULETTER}"
if [ ! -f "${AUTHDIR}/${1}" ]
   then
	echo "...Error - Invalid user name: ${1}"
	echo " "
	exit 1
fi

# Make sure account is really locked
grep -q u_lock@ "${AUTHDIR}/${1}"
if [ $? = 0 ]
   then
	echo "...${1}'s account was not locked"
	echo " "
	exit 1
fi

# Unlock account by modifying the user's auth file
ed -s "${AUTHDIR}/${1}" < /usr/sbin/Unlock.ed_commands
echo "...Account unlocked"
echo " "
----------------------- END - CUT HERE ---------------------------


/usr/sbin/Unlock.ed_commands
----------------------- BEGIN - CUT HERE -------------------------
1,$s/chkent:/u_lock@:chkent:/
w
q
----------------------- END - CUT HERE ---------------------------



      reply	other threads:[~1996-06-18  4:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-06-12  4:00 Disabling account from script PAUL D. CHAPIN
1996-06-18  4:00 ` jon [this message]
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox