preexec = echo $HOME > /tmp/homedir
don't work correct.
It always returns root homepath,
not user homepath.
syntax should be
preexec = echo %$(HOME) > /tmp/homedir
However, samba does not initialize the user's
logon evironment so I doubt that the $HOME variable
will work at all.
For the home directory path, you should be using
preexec = echo %H > /tmp/homedir
But than this behavior should be described in the man page.
It is documented. See the section on variables in
the smb.conf(5) man page.
I took a look at man smb.conf and found
a section VARIABLE SUBSTITUTIONS.
It describes how to use variables in config files.
But I didn't find any comment samba doesn't
set environment variables when using preexec.
Man programs will have a strange behavoir
Example: I use smbclient and preexec with the netlogon share
sending infos to users.
Although I call smbclient as user sender name will be displayed
isn't it obvious that environment variables of the samba server's environment
are meant? Anything else would be impossible.
About the HOME also see man page:
%H the home directory of the user given by %u.