From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,459025067aa5f387 X-Google-Attributes: gidfee84,public From: jon@qcvaxa.acc.qc.edu Subject: RE: Disabling account from script Date: 1996/06/18 Message-ID: <4q4ph6$15hb@news.cuny.edu>#1/1 X-Deja-AN: 160708957 references: ,<4pn76o$cor@tom.amherst.edu> organization: Queens College, CUNY newsgroups: comp.unix.osf.osf1 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 # 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 # 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 ---------------------------