- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Stop user login
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
Discussions
Discussions
Forums
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
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
тАО06-25-2007 04:21 PM
тАО06-25-2007 04:21 PM
I want to lock out all but three users (root, admin1 and admin2) from a system during a maintenance window.
I have considered using the NOLOGIN=1 in /etc/default/security and /etc/nologin . Since I cannot allow admin1 and admin2 to login when this has been set I have ruled it out.
My current plan was to use following script in /etc/profile
user=`whoami`
if [ $user != root ] -o [ $user != admin1 ] -o [ $user != admin2 ]
then
echo "System is currently undergoing maintenance"
exit
fi
However the test is not behaving as I thought it would. Can somebody please help me with my code or suggest an alternative solution?
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-25-2007 05:32 PM
тАО06-25-2007 05:32 PM
Re: Stop user login
happened. ("[N]ot behaving as I thought it
would" is not as informative as you might
think.) I'll assume that it prints out the
message for the low-class users, and then
continues as if nothing were special. I'd
guess that that's because "exit" in a script
like this is what happens normally. Perhaps
"logout", or "kill -HUP 0", or something
comparably vicious (depending on the shell)
would do something new and different.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-25-2007 05:54 PM
тАО06-25-2007 05:54 PM
Re: Stop user login
Exit is working as expected. It├в s the test for the if statement that├в s not working.
It only checks the first condition[ $user != root ] and does not consider the second or third test.
From my interpretation it should read
If $user not equal to root OR $user not equal to admin1 OR $user not equal to admin2
# at this point it only checks the first test
then
echo "System is currently undergoing maintenance"
exit
fi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-25-2007 06:37 PM
тАО06-25-2007 06:37 PM
SolutionThe correct logic is:
if [ $user != root ] -a [ $user != admin1 ] -a [ $user != admin2 ]; then
Or better yet if you have problems with boolean arithmetic: ;-)
if [ $user = root ] -o [ $user = admin1 ] -o [ $user != admin2 ]; then
: # allow VIPs
else
echo "System is currently undergoing maintenance"
exit
fi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-25-2007 06:40 PM
тАО06-25-2007 06:40 PM
Re: Stop user login
Your condition is wrong. You will allow NOBODY to login!
The correct logic is:
if [ $user != root -a $user != admin1 -a $user != admin2 ]; then
Or better yet if you have problems with boolean arithmetic: ;-)
if [ $user = root -o $user = admin1 -o $user != admin2 ]; then
: # allow VIPs
else
echo "System is currently undergoing maintenance"
exit
fi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-26-2007 11:48 AM
тАО06-26-2007 11:48 AM
Re: Stop user login
If anyone is interested this is the final product
user=`whoami`
if [ $user != root -a $user != admin1 -a $user != admin2 ]
then
echo "System is currently undergoing maintenance"
exit
fi
Thanks for the help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-26-2007 12:53 PM
тАО06-26-2007 12:53 PM
Re: Stop user login
Or better yet if you have problems with boolean arithmetic: ;-)
if [ $user = root -o $user = admin1 -o $user = admin2 ]; then