LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Prevent a single user from multiple simultaneous logins (https://www.linuxquestions.org/questions/linux-networking-3/prevent-a-single-user-from-multiple-simultaneous-logins-452544/)

MichaelP 06-07-2006 05:40 PM

Prevent a single user from multiple simultaneous logins
 
How do I prevent a single user from multiple simultaneous logins?

Server: CentOS 4.3 with Samba, Clients: Win98, Win2000

When I do maintenance I log in on all the windows 98 and 2000 client machines as the same administrative user and do my job. But, this is a school environment and I do not want students sharing passwords during a test and sharing the same file. So i need to prevent the same user from logging on more than once at the same time.
Oh ... Exams begin next week.... Help :confused:

bulliver 06-07-2006 06:19 PM

Code:

# echo "* L1" >> /etc/limits
See man 5 limits...

MichaelP 06-07-2006 06:42 PM

Thanks

I will try tomorrow when I get access to the server. I also noticed some other restrictions/limits I could apply.

bulliver 06-07-2006 09:56 PM

No Prob.

I am not sure if the '*' wildcard to specify the user includes root so watch for that...

MichaelP 06-08-2006 06:42 AM

Can't seem to get man limits in CentOS not FC5 or maybe i am up to early. Help anyone

MichaelP 06-08-2006 07:21 AM

I found /etc/security/limits.conf in CentOS. Looks like what I am looking for.

MichaelP 03-12-2008 10:11 AM

The Limits idea did not work. Maybe I am not too sure on how to do, however I found a solution for
Limiting Logon Connections at http://us4.samba.org/samba/docs/man/...html#id2655826 and this is what I did but need help understanding what I did.

I created/copied a script "PermitSingleLogon.sh" with permissions 755 and placed it in the /etc/samba directory. Here is the script

#!/bin/bash

IFS="-"
RESULT=$(smbstatus -S -u $1 2> /dev/null | awk 'NF > 6 {print $1}' | sort | uniq -d)

if [ "X${RESULT}" == X ]; then
exit 0
else
exit 1
fi

Then I added the two lines to my netlogon share in the smb.conf file

[netlogon]
...
preexec script = /etc/samba/PermitSingleLogon.sh
preexec close = Yes

...

This works but only if the user tries to logon on the different machines within a few minutes after the initial logon (I will time this later). The Samba-HOW-TO link I used says "This is not a perfect solution because Windows clients can drop idle connections with an auto-reconnect capability that could result in the appearance that a share is no longer in use, while actually it is"

QUESTIONS:
1. How do I stop Windows form dropping the connection?
2. I have already checked the man pages but still need to know,
What does this part of the above script do? awk 'NF > 6 {print $1}'
and if [ "X${RESULT}" == X ]


All times are GMT -5. The time now is 09:08 PM.