Hi once again everyone,
I have had several requests to mail or post the various scripts that people
sent me, so here they are.
Hope you find them useful, and once again thanks to those who shared them.
Glenn.
--------------------------------------------------------------------------------
Jude T. Cruz sent this one, this is the one that I used.
You can add this line in your .profile file
LOGIN_COUNT=`who -u | cut -d ' ' -f1 | fgrep -x $LOGNAME | wc -l`
if [ $LOGIN_COUNT -gt 1 ]; then
echo " Warning ! more than 1 user login attempted"
exit
fi
--------------------------------------------------------------------------------
Richard Sharpe sent this one.
You will want to do things like:
who | grep `whoami` | wc | tr -s ' ' ' ' | cut -f2 -d\
which will count the number of occurrences of yourself logged on. Then you
check the result and if greater than one, kill yourself
ps -ax | grep for the last two chars on your `tty` and then kill the
process that is a login shell (has -ksh as its command ...)
--------------------------------------------------------------------------------
Michael Bradford sent this one.
We do this by running a program in /etc/profile which checks the number
of processes attributed to the user that are not run from their current
connection. The bare bones of the script are :
#
# Find login user name.
MY_SELF=`id -un`
#
# Never bother root!
if [ $MY_SELF = "root" ]
then
exit 0
fi
#
# `tty -s` returns TRUE if standard output is a display.
# We continue only if there is a tty connected to the process.
# This may be a weakness if batchjobs are not to be allowed
# to run while the user is logged in, then on the other hand
# there are requirements for interaction.
#
if tty -s
then
# Find the login tty,
MY_TTY=`tty`
# and get its filename.
MY_TTY=`basename $MY_TTY`
#
# Find all processes owned by the login user,
# exclude all processes connected to the login tty,
# and show them to the user. Return the number of lines.
#
ps -u $MY_SELF | grep -v $MY_TTY |tail +2| awk '{print $0} END{exit
NR}'
MY_EXIT=$?
#
# Ask the user if to kill, only if there is prey.
#
if [ $MY_EXIT -gt 0 ]
then
--------------------------------------------------------------------------------
Britton Johnson sent this which might be worth a look.
You might also take a look at 'idled.' (ftp.cs.hope.edu/pub/idled/) This
is a pretty well known daemon for booting idlers, but it also contains
code for restricting simultaneous logins. It works great for me, (for
some reason OSF doesn't like the 'warning' feature though.. I've disabled
that part as they recommend and it works like a charm.)
--------------------------------------------------------------------------------
B&D Australia - The garage door people.
.
,--_|\ Glenn Newbery Email : glenn_at_bnd.com.au
/ B&D \ Systems Administrator Voice : +612 9722 5631
\_,--\_/ Fax : +612 9772 3830
v
Received on Tue Feb 24 1998 - 00:43:43 NZDT