Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

Samba HowTo Guide
Prev Home Next

Limiting Logon Connections

Sometimes it is necessary to limit the number of concurrent connections to a Samba shared resource. For example, a site may wish to permit only one network logon per user.

The Samba preexec script parameter can be used to permit only one connection per user. Though this method is not foolproof and may have side effects, the following contributed method may inspire someone to provide a better solution.

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. Even so, it demonstrates the principle of use of the preexec script parameter.

The following share configuration demonstrates use of the script shown in ???.

[myshare]
	...
	preexec script = /sbin/PermitSingleLogon.sh
	preexec close = Yes
	...

Example24.1.Script to Enforce Single Resource Logon

#!/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
Samba HowTo Guide
Prev Home Next

 
 
  Published under the terms fo the GNU General Public License Design by Interspire