[Samba] Listing samba 2.2.8a (redhat 8) verables to a text file

Joel Hammer Joel at HammersHome.com
Sat Jun 28 19:54:53 GMT 2003


Here is a response I just sent to somebody else who wanted to prevent
a user from logging on twice at the same time. You may find it useful,
if you use bash. It saves the data in a file /tmp/Hello

Here is a possibly useful tool for figuring out what you want. This smb.conf
share, with the script Hello, captures all the variables passed when a user
logs on. This may help you writing your script. With the results of this
script and the output of smbstatus, you could really fine tune what you
do.
With care, just cut and paste this into your smb.conf file.


[public]
        comment = Root directory
        path = /
        read only = no
        create mask = 0777
        exec = rm /tmp/Hello;echo \"m %m \" \"G %G \" \"I %I \" \"L %L \" \"M %M \" \"N %N \" \"R %R \"                         \"T %T \" \"U %U \" \"a %a \" \"d %d \" \"h %h \" \"p %p \" \"v %v \"                         \"H %H \" \"P %P \" \"S %S \" \"g %g \" \"u %u \"  | xargs -n1 /usr/local/samba/bin/Hello;\
              echo This is my home %$(HOME) >> /tmp/Hello


The script Hello is as follows:


#!/bin/bash
 i=`echo "$1" | tr -s " "`
 index=`echo "$i" | cut -d" " -f1`
 value=`echo "$i" | sed 's/^. //'`
 case $index in
   m )  message="client machine NetBios name = $value";;

   M )  message="Internet DNS of client= $value";;

   I )  message="IP address of client = $value";;

   a )  message="Architecture of remote machine= $value";;

   U )  message="Session user name (one the client wanted)= $value";;

   L )  message="Netbios name of server = $value";;

   h )  message="Internet DNS hostname of server= $value";;

   R )  message="Protocal level = $value";;

   v )  message="Samba version= $value";;

   T )  message="Current time and date= $value";;

   G )  message="Primary goup name of U = $value";;

   N )  message="NIS home directory= $value";;

   d )  message="Process ID of current server= $value";;

   p )  message="Path of services home directory from NIS= $value";;

   H )  message="Home directory of user in u= $value";;

   P )  message="Root directory of current service = $value";;

   S )  message="Name of current service = $value";;

   g )  message="Primary group name of u in share = $value";;

   u )  message="User name of current service = $value";;
esac
echo $message \(\%$index\) >> /tmp/Hello


The output should look like this:

client machine NetBios name = hammer10 (%m)
Primary goup name of U = ftp (%G)
IP address of client = 192.168.1.10 (%I)
Netbios name of server = jhammer6 (%L)
Internet DNS of client= hammer10.jhammer.org (%M)
NIS home directory= jhammer6 (%N)
Protocal level = NT1 (%R)
Current time and date= 2003/06/26 06:56:28 (%T)
Session user name (one the client wanted)= anonymous (%U)
Architecture of remote machine= Samba (%a)
Process ID of current server= 13089 (%d)
Internet DNS hostname of server= jhammer6 (%h)
Path of services home directory from NIS= (%p)
Samba version= 2.2.1a (%v)
Home directory of user in u= /home/ftp (%H)
Root directory of current service = / (%P)
Name of current service = public (%S)
Primary group name of u in share = ftp (%g)
User name of current service = ftp (%u)
This is my home /home/jlh

The above is what I get when I log on as user jlh but ask for a guest access,
with the guest account being ftp.
Note, you have the process ID of the connection. That could be killed with
kill -15 %d if you wanted to.

Joel





More information about the samba mailing list