[SunHELP] Allowing 1 telnet login session per userid.

Ajit P. Datey adatey at yahoo.com
Thu Jun 13 10:11:08 CDT 2002


Hi Bob! I have done something similar, except that I am using the who command.
I cannot use the wtmpx file since it stores information about past logins even
those where the login is no longer active. For eg. if I grep for my userid
then I get information from 5 days ago also. Using who -u I can get currently
logged on users and check if this user is already logged on. The problem here
is that if the network connection drops the user loses the telnet session. Now
if the network comes up before the server has closed out the telnet login
session the user will not be able to log in unless the old session is manually
killed OR the users waits for the old session to die out. This kind of a thing
happening is very rare but it did happen once. After that I reduced the tcp
time out parameters.

Ajit
  ----- Original Message -----
  From: Bob Kryger
  To: Ajit P. Datey ; sunhelp at sunhelp.org
  Sent: Wednesday, June 12, 2002 9:56 PM
  Subject: Re: [SunHELP] Allowing 1 telnet login session per userid.


    I can write a check and put it into /etc/profile but its not a very neat
    solution.


  Why is this not a very near solution. It would be very simple in the
/etc/profile to check the wtmp file via the last command.  Something similar
to ...

          LOGINS=$(last | grep $USER | wc -l)
            if [[ $LOGINS >= $MAX_LOGINS ]]
            then
                  kill -9 <mypid>
            fi

  You might want to output a message, and possibly log and also limit this to
specific users (i.e. not root and you)

  Sounds pretty clean to me.

  Bob

  Robert F. Kryger, Jr.
  10 Tuttle Street, Apt 2G
  Stamford, CT 06902

  Home: +1-203-358-9976     Cell: +1-203-981-4018
  Personal E-mail: bobk at panix.com, bobk at frodo.com, bkryger at optonline.net
  AOL Instant Messanger: BobKryger, KrygerFamily
  PGP Key:
http://pgpkeys.mit.edu:11371/pks/lookup?op=get&search=bkryger%40home.com



More information about the SunHELP mailing list