Re: smb.conf preexec syntax

Rowland Penny via samba <[email protected]> Fri, 29 May 2026 14:49:12 +0100
Newsgroups gmane.network.samba.general
Message-ID <[email protected]>
On Thu, 28 May 2026 13:16:43 +0200
Matthias Leopold via samba <[email protected]> wrote:

> Hi,
> 
> I was debugging why a very old "root preexec" stanza in my smb.conf 
> (Sernet Version 4.21 on RHEL 8) doesn't work (and leaves no trace of 
> failure in Samba log). The stanza uses exact manpage syntax:
> 
> preexec = echo \"%u connected to %S from %m (%I)\" >> /tmp/log
> 
> To my experience this doesn't work. This works:
> 
> preexec = /bin/sh -c 'echo "%u connected to %S from %m (%I)" >>
> /tmp/log'
> 
> Can somebody confirm this?
> 

I finally got chance to check this out and can confirm that only the
second version works, but not fully. If I add the line to a 'homes'
share on a Unix domain member and then connect from another machine
using smbclient:

smbclient //lm22b/rowland
Password for [[email protected]]:
Try "help" to get a list of possible commands.
smb: \>

I find this in /tmp/log :

SAMDOM
owland connected to rowland from devstation (192.168.1.49)

If I change the '%u' in the preexec line to '%U', I get this:

rowland_samdom.example.com connected to rowland from devstation
(192.168.1.49)

To just get the username at the start I have to specify it in the
command:

smbclient //lm22b/rowland -Urowland
Password for [SAMDOM\rowland]:	# <-- Notice this change
Try "help" to get a list of possible commands.
smb: \>

It results in this in the log:

rowland connected to rowland from 192.168.1.49 (192.168.1.49)

I get the user, but lose the hostname and get an IP instead.

Why is nothing ever simple in Samba ?

Rowland

-- 
To unsubscribe from this list go to the following URL and read the
instructions:  https://lists.samba.org/mailman/options/samba