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

Peter Atkin peter at computer-facilities.com
Mon Jun 30 10:38:18 GMT 2003


Hi Thomas

Thanks for the update, I had to do a little modification to your very good one liner.. I had problems getting consistent 
results, I found out running the "preexec" as "root" seemed to solve that. 

I am very new to Linux and have major difficulty with user and directory rights, so i just did a work around.

[smbdiags]
        comment = temp diag directory
        path = /etc/samba/scripts/
        browseable = yes
        root 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 /etc/samba/scripts/samba-smbinfo; smbclient -U %L -M %U </etc/samba/scripts/smbinfo; rm -f /etc/samba/scripts/smbinfo &

This works very well so far, under both 2000 and XP, the "root preexec" is all on one line. their are still some querks 
like when this gets run via Terminal Services it does not display. but when a simple e.g.:

[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
        preexec = smbclient -U %L -M %m </etc/samba/messages/source.txt

Works well even under Terminal Services.


The "/etc/samba/scripts/smbinfo" has been modified to the output looks a little organized.

#! /bin/sh
#-----------------------------------------------------------------------------
# /etc/samba/scripts/samba-smbinfo - write info to /etc/samba/scripts/smbinfo 
#
# Copyright (c) 2001-2003 Thomas Bork <tom at 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="Current time and date		(%$index) = $value";;
d)  message="Process ID of server		(%$index) = $value";;
v)  message="Samba-Version			(%$index) = $value";;
h)  message="DNS hostname of server		(%$index) = $value";;
L)  message="Netbios name of server		(%$index) = $value";;
N)  message="NIS home directory			(%$index) = $value";;
p)  message="Path of services home from NIS	(%$index) = $value";;
R)  message="Protocal level			(%$index) = $value";;
S)  message="Name of service			(%$index) = $value";;
P)  message="Root directory of service		(%$index) = $value";;
U)  message="Session user name			(%$index) = $value";;
G)  message="Primary group name			(%$index) = $value";;
u)  message="User name of service		(%$index) = $value";;
g)  message="Primary group name of share	(%$index) = $value";;
H)  message="Home directory			(%$index) = $value";;
I)  message="Client IP				(%$index) = $value";;
M)  message="Internet DNS of client		(%$index) = $value";;
m)  message="client machine NetBios		(%$index) = $value";;
a)  message="Architecture			(%$index) = $value";;
esac
echo "$message" >> /etc/samba/scripts/smbinfo
cp -f /etc/samba/scripts/smbinfo /mnt/nas/users/peter

**** I have one question how can i direct the output of samba-smbinfo to say a home account of a user. 
e.g "/mnt/nas/users/%U" it seems when i do its i get "%U" as a file name.

Sorry for the long e-mail, and again thanks.


-----Original Message-----
From: "Thomas Bork" <tombork at web.de>
To: <peter at computer-facilities.com>
Cc: <samba at lists.samba.org>
Date: Sat, 28 Jun 2003 23:18:40 +0200
Subject: Re: [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 at 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




More information about the samba mailing list