Peter Atkin
2003-Jun-28 18:50 UTC
[Samba] Listing samba 2.2.8a (redhat 8) verables to a text file
I have been using samba for a while now with great sucesses it has replaced my Windows 2000 server completely, I am using a mix of windows98, 2000 and XP with no problems. However i would like to do two things, 1) print samba veriables to a log file in a location of my choice 2) When a windows test user logs on, i would like to display a windowed dialog box showing the verious samba veriable stats. Can this be down without melting my brain, I have tried verious options without much sucsess. Just for refernace here is my current current smb.conf file. # Computer Facilities # currently and always under delvelopment using samba 2.2.8a on linux 8 # /etc/samba/smb.conf # last edit date was 22/06/2003 (D/M/Y) [Global] workgroup = cfu netbios name = linuxserver server string = Samba %v File Server on %L domain logons = yes domain master = yes dns proxy = No preferred master = yes local master = yes os level = 99 security = user domain admin group = @admin domain logons = Yes ;socket options = TCP_NODELAY SO_SNDBUF=20480 SO_RCVBUF=20480 IPTOS_LOWDELAY lock spin time = 15 lock spin count = 100 level2 oplocks = no oplocks = no getwd cache = yes log level = 3 log file = "/var/log/samba/%U-%m.log" max log size = 0 logon path logon home logon drive = H: logon home = "\\Nas_server\User\%u" logon script = "%u.bat" browseable = no default case = lower case sensitive = no preserve case = no encrypt passwords = yes deadtime = 15 time server = yes hosts allow = 10.0.0.0/255.255.255.0 127.0.0.1 EXCEPT 10.0.0.100 10.0.0.4 10.0.0.1 hosts deny = 0.0.0.0/0 hide unreadable = yes interfaces = 10.0.0.0/255.255.255.0 127.0.0.1 bind interfaces only = Yes unix password sync = true passwd program = /usr/bin/passwd %u passwd chat = *New*UNIX*password* %n\n *ReType*new*UNIX*password* %n *passwd:*all*authentication*tokens*updated*successfully* add user script = /usr/sbin/useradd -d /dev/null \ -d /dev/null \ -g machines \ -s /bin/false \ -M %u [homes] comment = Users network home directory path = /mnt/nas/users/u% ;read only = no ;create mode = 0600 ;directory mode = 0700 [netlogon] comment = Network Logon Service path = /mnt/nas/logon write list = @admin guest ok = no [backup] path = /backup valid users = @admin read only = yes write list = @admin force create mode = 0775 force group = admin directory mask = 0775 [source] browseable = yes path = /mnt/nas/source valid users = @admin read only = yes write list = @admin, root force create mode = 0775 force group = admin directory mask = 0775 [public] browseable = yes path = /mnt/nas/public valid users = @admin read only = yes write list = @admin, root force create mode = 0775 force group = admin directory mask = 0775 [music] comment = MP3 Music browseable = yes path = /mnt/nas/music valid users = @staff read only = yes write list = @admin force create mode = 0775 force group = admin directory mask = 0775 Kind Regards Peter
Joel Hammer
2003-Jun-28 19:54 UTC
[Samba] Listing samba 2.2.8a (redhat 8) verables to a text file
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
Thomas Bork
2003-Jun-28 21:18 UTC
[Samba] Listing samba 2.2.8a (redhat 8) verables to a text file
Hi Peter Atkin, you wrote:> However i would like to do two things, > > 1) print samba veriables to a log file in a location of my choice > 2) When a windows test user logs on, i would like to display a > windowed dialog box showing the verious samba veriable stats.this is what I do in my samba package for www.eisfair.org (adapted from Joel ;): #! /bin/sh #---------------------------------------------------------------------- ------ # /usr/local/bin/smbinfo - write info to /tmp/smbinfo # # Copyright (c) 2001-2003 Thomas Bork <tom@fli4l.de> # # Creation: 28.07.2002 tb # Last Update: 12.11.2002 tb # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. #---------------------------------------------------------------------- ------ i=`echo "$1" | tr -s " "` index=`echo "$i" | cut -d" " -f1` value=`echo "$i" | sed 's/^. //'` case $index in T ) message="Datum/Zeit (%$index) = $value";; d ) message="PID des Servers (%$index) = $value";; v ) message="Samba-Version (%$index) = $value";; h ) message="(Internet)Hostname des Servers (%$index) = $value";; L ) message="NETBIOS-Name des Servers (%$index) = $value";; N ) message="NIS Heimat-Verzeichnis (%$index) = $value";; p ) message="Pfad des NIS-Heimatverzeichnisses (%$index) = $value";; R ) message="Ausgehandeltes Protokoll-Level (%$index) = $value";; S ) message="Name der aktuellen Freigabe (%$index) = $value";; P ) message="Hauptverzeichnis der aktuellen Freigabe (%$index) = $value";; U ) message="Vom Client angeforderter Benutzername (%$index) = $value";; G ) message="Primaere Gruppe des angeforderten Benutzers (%$index) = $value";; u ) message="Name des effektiven Benutzers (%$index) = $value";; g ) message="Primaerer Gruppenname des effektiven Benutzers (%$index) = $value";; H ) message="Heimatverzeichnis des effektiven Benutzers (%$index) = $value";; I ) message="IP Adresse des Client-Rechners (%$index) = $value";; M ) message="(Internet)Hostname des Client-Rechners (%$index) = $value";; m ) message="NETBIOS-Name des Client-Rechners (%$index) = $value";; a ) message="Betriebssystem des Client-Rechners (%$index) = $value";; esac echo "$message" >> /tmp/samba-smbinfo In smb.conf: [public] comment = public directory on vmeis path = /public public = yes create mode = 0777 directory mode = 0777 browseable = yes writable = yes oplocks = no level2 oplocks = no blocking locks = no preexec = echo "\"T %T \" \"d %d \" \"v %v \" \"h %h \" \"L %L \" \"N %N \" \"p %p \" \"R %R \" \"S %S \" \"P %P \" \"U %U \" \"G %G \" \"u %u \" \"g %g \" \"H %H \" \"I %I \" \"M %M \" \"m %m \" \"a %a \"" | xargs -n1 /usr/local/bin/samba-smbinfo;\ smbclient -U "eisfair Samba Server" -M %m </tmp/samba-smbinfo;\ rm -f /tmp/samba-smbinfo & vfs object = /usr/lib/samba/vscan-oav.so vfs options = config-file = /etc/vscan-oav.conf The echo statement till "/usr/local/bin/samba-smbinfo;\" is one line. Note that the file /tmp/samba-smbinfo holds the information and smbclient sends this to the client. In my case this file will be deleted after sending. Sorry @all for the long lines (84 chars) in my message. der tom
Thomas Bork
2003-Jul-01 17:20 UTC
[Samba] Listing samba 2.2.8a (redhat 8) verables to a text file
Hallo Peter,> Thanks I have it all working now, I have noticed some querks that you may be intersted in. > > When I have "root preexec //" in a single line upto and including the "smbclient -U %L -M %m > </tmp/samba-smbinfo;\" it works fine but when I split the line just before this comment I > get a% in the final output reading Win2K instead of WinXP(which is the correct answer) I > have tested this severial times.. strange but true.take a look at http://marc.theaimsgroup.com/?t=104947538400001&r=1&w=2 http://marc.theaimsgroup.com/?t=105073236300004&r=1&w=2 http://marc.theaimsgroup.com/?l=samba&m=105251589526927&w=2 There is a problem in 2.2.8a to correct recognizing WinXP - and also a patch for this. Maybe this is your problem.> > http://www.devone.org/eisfair/doc/ > Unfortunely I cannot read German currently, but i am very intersted in this.Try this: http://www.eisfair.org/english/eisfair.htm Sorry, but the complete documentation isn't available in english yet.> Sorry I am a DIV, i was too wrapped up in the "root preexec = echo" sfuff and promtly forgot > all about samba its self.Glad to solved the problem :) Kind Regards der tom ____________________________________________________________________________ Nur bei WEB.DE Testsieger FreeMail testen und damit 1 qm Regenwald schuetzen. Jetzt anmelden und mithelfen! http://user.web.de/Regenwald