[Samba] SMB share specific log file creation

Srini v.vvsrini at gmail.com
Tue May 15 11:15:12 GMT 2007

Hi all,

We are trying to print the log messages pertaining to each share in a
different log file for auditing purposes.

We are using Samba v3.0.20b.

We are trying to modify the file
smbd/service.c::make_connection_snum() function by changing the log
file full path. The code changes that is done are as follows:

        char logfilefullpath[70];
        char sharename[256];

        safe_strcpy_fn (__FILE__, __LINE__ ,logfilefullpath,
"/log/sharenet/", sizeof ("/log/sharenet/"));
        safe_strcat_fn (__FILE__,__LINE__,logfilefullpath,".log",


        if( DEBUGLVL( IS_IPC(conn) ? 3 : 1 ) ) {
                dbgtext( "%s (%s) ", get_remote_machine_name(),
conn->client_address );
                dbgtext( "%s", srv_is_signing_active() ? "signed " : "");
                dbgtext( "connect to service %s ", lp_servicename(snum) );
                dbgtext( "initially as user %s ", user );
                dbgtext( "(uid=%d, gid=%d) ", (int)geteuid(), (int)getegid() );
                dbgtext( "(pid %d)\n", (int)sys_getpid() );

We have done a similar code snipped in the relevant portion of the
code in open_file part of Samba as well. However we find that the log
file randomly gets written to the default log file (log file= variable
in smb.conf) or sometimes to the share specific log file (that we have
attempted above). It looks like that this was a buffering problem and
so we tried to put in dbgflush() routine as well after calling
dbgtext() macro. Still with no success...

Has anyone tried to modify the source code to generate share specific
log trails - either by modifying the source code or without? If so,
can the experts guide us on this?

Thanks in advance for all your inputs and help,


More information about the samba mailing list