Re: limiting to one login

Systems Administrator (jjohnston@u-r-online.com)
Wed, 28 May 1997 12:18:23 -0400

----------
> From: Dan Lowe <dan@multiverse.com>
> To: dkeal@primenet.com
> Cc: portmaster-users@livingston.com
> Subject: Re: limiting to one login
> Date: Tuesday, May 27, 1997 11:37 PM
>
> >Anyone out there got a good, simple way to limit multiple logins to one
> >per user? I know you cant set it in radius for an ISDN port, but how
can
> >it be done for all others?
> >
> >I've looked at the pmmon utility but would like something simpler.
>
> If you're not talking about that many users and address space isn't a
concern,
> one pretty easy way to do it is to assign them a static IP address...
> the second login won't get too far once they establish... :)
>
>
>

I use a script which I put in my crontab to run every 5 minutes. Here is
the script to those who want it. It saves having to waste Static IP
addresses on abusers of your system.

The script requires the pmwho and pmcomm utilities.

#!/bin/bash

#use fqdn if necessary
pmlist="portmaster1"

#login names allowed to do multiple
#pipe-separated list, for egrep
exempt='name|name2'

log="/var/log/booted"

umask 077

#make sure you have these commands
if [ ! -x /usr/portmaster/pmwho -o ! -x /usr/portmaster/pmcom ]; then
echo portmaster utilities not found
exit 1
fi

# checking and cleaning up workspace
if [ ! -d /tmp/.killer ]; then
rm -r /tmp/.killer
mkdir /tmp/.killer
fi

cd /tmp/.killer

rm -f killme duplicates

# make a separate pmwho file for each portmaster; tail removes two
header lines
for each in $pmlist; do
/usr/portmaster/pmwho $each | tail +3 > $each
done

#combine all, cut down to login name, and check for duplicates. greps
remove garbage
cut -c6-16 portmaster* | grep -v '\- ' | grep -v 'PPP' | grep -Ev
"$exempt" \
| sort | uniq -d > duplicates

for abuser in `cat duplicates`; do
for each in $pmlist; do
grep " $abuser " $each | tr ':' ' ' >> killme
if [ -s killme ]; then
echo ---`date`------------------------------------------- >> $log
while read port user junk;do
/usr/portmaster/pmcom -c $each "reset $port"
echo " $user disconected from $each port $port" >> $log
done < killme
echo >> $log
fi
done
done