[Samba] how to use root preexec on user share with %U not as root user

Rowland penny rpenny at samba.org
Thu Apr 30 21:14:34 UTC 2020

On 30/04/2020 21:40, Jelle de Jong via samba wrote:
> First logon is I use samba-tool to add the user then I go to an 
> Windows 10 Pro domain member system and logon to the machine. The 
> \\SAMBA01\users\lgaga folder will not be there.....
It will not be there, samba-tool doesn't have the code to create the 
users folder, but when created on Windows, Windows does.
> amba-tool user create lgaga passwd --login-shell /bin/bash 
> --given-name "Lady Gaga" --home-drive=H 
> --home-directory="\\\SAMBA01\users\lgaga"
> Could you or others share (sent) the /path/to/a/script you use because 
> when I try to use mine above script the user always is root, and I 
> need a smarter script that sets the setfacl correct with Windows ACL 
> instead of posix acl.

The problem is, to get it to work correctly, you need to ensure that you 
do not change the users homeDirectory attribute (this is what 
'--home-directory' sets). Also a 'root preexec' script is obviously run 
as 'root', so of course any directories will be created with root 
ownership. This means the script needs to change ownership etc.

I have a script that will give you pointers, it isn't really tested, but 
you are welcome to a copy.


More information about the samba mailing list