Operating System - HP-UX
1834486 Members
3289 Online
110067 Solutions
New Discussion

Re: is there a way to reduce the amount of logins per user?

 
Martin Christov
Advisor

is there a way to reduce the amount of logins per user?

Hello,
I would like to reduce the amount of login-sessions for some users. Is there a way to do it under HPUX-11.00?
Regards:
Martin
sudo question
5 REPLIES 5
Rainer von Bongartz
Honored Contributor

Re: is there a way to reduce the amount of logins per user?


Sorry, no built in functionality for this .

You can do this from within /etc/profile by checking
if another session for this user already exists

i.e.

sess=`who | grep $LOGNAME | wc`

then check to see if $sess > 1
He's a real UNIX Man, sitting in his UNIX LAN making all his UNIX plans for nobody ...
Martin Christov
Advisor

Re: is there a way to reduce the amount of logins per user?

what about trusted system?
sudo question
federico_3
Honored Contributor

Re: is there a way to reduce the amount of logins per user?

Rob Smith
Respected Contributor

Re: is there a way to reduce the amount of logins per user?

Hi, try this:

num=1
u=$LOGNAME
case "$u" in

# Admin etc allowed multiple logins
'rsmith' |'root')
num=1;;

# All other users get 1 login only !
*)
num=`who | cut -d" " -f1 | grep "^$LOGNAME"$|wc -l`
esac

if [ $num -gt 1 ]
then
echo You are already logged into this system
echo Please close your existing session before
echo trying again.
exit
fi

Hope this helps.

Rob

Learn the rules so you can break them properly.
Paula J Frazer-Campbell
Honored Contributor

Re: is there a way to reduce the amount of logins per user?

Hi

You can control user logins by the use of the free text field in the passwd file.

Enter the max number of logins allowed for that user in that field.

When they login push them via their .profile through a check script:- count their logins, who -u|grep |wc -l and compare this with the number in the password file.

So if greater than then:- "Sorry your maximum number of logins has been exceeded" and exit them.

Another option is to hold the user login names in a seperate file with the max number next to it:-

So:-

freddy 3
billy 2
sarah 4


And when they login refer to this file.

I have used both methods and both work well.

HTH

Paula
If you can spell SysAdmin then you is one - anon