[Samba] deny second or multiple logins

Thomas Bork tombork at web.de
Sun Apr 1 18:28:46 GMT 2007


Freitas wrote:

>     You can try here.
> http://us3.samba.org/samba/docs/man/Samba-HOWTO-Collection/AdvancedNetworkManagement.html#id386516 

Sorry for being so stupid but how should this working?


 From the above link:

preexec script = /sbin/PermitSingleLogon.sh

Okay, this script is called without parameters before the share is opened.


Here the script from the above link:

#!/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


smbstatus is called with '-u $1' (user). But no parameter for the user 
is given in the preexec script and so $1 is empty.
If correcting this with 'preexec script = /sbin/PermitSingleLogon.sh %u' 
the script is still failing.

Don't know, what

awk 'NF \
         > 6 {print $1}'

should do.
The output from 'smbstatus -S -u tb' for the user tb with open 
connection is:

deveis > smbstatus -S -u tb

Service      pid     machine       Connected at
-------------------------------------------------------
tb           965   tb3           Sun Apr  1 19:53:55 2007

deveis >


The output without open connection is:

deveis > smbstatus -S -u tb

Service      pid     machine       Connected at
-------------------------------------------------------

deveis >



In all cases RESULT from the script is empty and multiple connections 
are never blocked...


der tom


More information about the samba mailing list