- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: block user
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2004 05:25 PM
04-15-2004 05:25 PM
in my company there r some users who share login i want that at a time nomore than two users with same username can login..for eg:--username 'ashish' cannot be used more than two times... if any user does than a message is displayed...Please try after some time..
thanx in advance
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2004 05:39 PM
04-15-2004 05:39 PM
Re: block user
If you MUST I guess some scripting in the profile is the best I can come up with.
NUMBER=$(who | grep whoami | wc -l)
if [ $NUMBER -gt 2 ]
then
echo "Please try after some time.."
exit
fi
Regards,
Trond
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2004 05:47 PM
04-15-2004 05:47 PM
SolutionThe simplest solution is to use the .profile of the user (if using a normal posix shell, the default. If using csh, you need to use .login) to check and block multiple sessions of the user, in your case when two sessions are active.
The check would become something like this:
if [ $(who | grep ashish | wc -l) -gt 2 ]
then
echo "Too many sessions active already. Please try again later."
exit
fi
Mind that this shouldn't be editable by the users and non-interuptable! Non-interuptable can be done by ignoring all signals in the beginning of the profile:
trap "" 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
And at the end, before leaving:
trap - 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
To make in un-editable you would need to put it in /etc/profile, which is not editable for the normal users. But then you need to make sure the user trying to login is ashish too.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2004 06:03 PM
04-15-2004 06:03 PM
Re: block user
ur reply is not working, as u are trying to grep whoami text in the output of who but if u write the username in place of whoami or $(loganame)...i used $(logname) and it worked...anyway thanx for ur help.. rest of ur code was ok..
ashish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2004 06:06 PM
04-15-2004 06:06 PM
Re: block user
Think I'll need another caffee. Here is the corrected script as you pointed out.
NUMBER=$(who | grep $(whoami) | wc -l)
if [ $NUMBER -gt 2 ]
then
echo "Please try after some time.."
exit
fi
Regards,
Trond
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2004 06:18 PM
04-15-2004 06:18 PM
Re: block user
ur solution was perfect especially the trap sequence and .profile moving to /etc dir...but i thenk we can do it one more way if we change ownership of .profile to that of root and make it readonly ....will that work...bye
thanx to all who helped me
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2004 06:33 PM
04-15-2004 06:33 PM
Re: block user
mv .profile .profile.root
cat .profile.root > .profile
chmod 755 .profile
Now he is owner and can change things in it as he wishes. That's why I suggested using /etc/profile.