[Samba] Automaticaly create User-Home directories for NFS

Johan Hendriks joh.hendriks at gmail.com
Wed May 28 05:53:56 MDT 2014


op 28-05-14 13:23, Daniel Thielking schreef:
> Yes I use the rsat but,
>
> I don't want a windows home share.
>
> I need a share what is conform with normal Unix file rights because of 
> NFS.
> If I would use the 'rsat tool' than i have special ACL on my 
> filesystem and NFS is not working with this.
>
> What I think what I need is an automation that, if I create an new 
> User with rsat and add him to a nisdomain than the homedir would 
> create automatically.
> Like the behavior of smbldap-useradd with the parameter -m.
>
>
> _____________________________________________________
>
> Auszubildender Fachinformatiker für Systemintegration
> RWTH Aachen
> Lehrstuhl für Integrierte Analogschaltungen
> Raum 24C 313
> Walter-Schottky-Haus
> Sommerfeldstr. 24
> D-52074 Aachen
>
> www.ias.rwth-aachen.de
>
> Email: Daniel.Thielking at ias.rwth-aachen.de
> Phone: +49-(0)241-80-27771
>   FAX: +49-(0)241-80-627771
> _____________________________________________________
>
> Am 28.05.2014 12:58, schrieb Daniel Müller:
>> Do you use rsat from windows to create the users?
>> Smb.conf:
>> [home]
>> path=/your/home/path
>> read only= no
>>
>> In rsat create the new user/password then klick on properties choose
>> profile, choose connect with, fill in \\youradc\home\%username%
>>
>>
>> EDV Daniel Müller
>>
>> Leitung EDV
>> Tropenklinik Paul-Lechler-Krankenhaus
>> Paul-Lechler-Str. 24
>> 72076 Tübingen
>> Tel.: 07071/206-463, Fax: 07071/206-499
>> eMail: mueller at tropenklinik.de
>> Internet: www.tropenklinik.de
>>
>>
>>
>>
>>
>> -----Ursprüngliche Nachricht-----
>> Von: samba-bounces at lists.samba.org 
>> [mailto:samba-bounces at lists.samba.org] Im
>> Auftrag von Daniel Thielking
>> Gesendet: Mittwoch, 28. Mai 2014 12:23
>> An: samba at lists.samba.org
>> Betreff: [Samba] Automaticaly create User-Home directories for NFS
>>
>> Hello, I have a problem with my Samba4 AD-Controller and NFS. We want to
>> distribute a NFS-Share for our home directory. The problem is that the
>> client is trying to create it on the fly for the first user login but 
>> you
>> get 'Permission denied' because of the root_spuash option of the 
>> NFS-Server.
>> My question: Is there any posibillity that the normal home directory is
>> created after adding a new user to the ActiveDirectory?
>>
>> -- 
>> _____________________________________________________
>>
>> Auszubildender Fachinformatiker für Systemintegration RWTH Aachen 
>> Lehrstuhl
>> für Integrierte Analogschaltungen Raum 24C 313 Walter-Schottky-Haus
>> Sommerfeldstr. 24
>> D-52074 Aachen
>>
>> www.ias.rwth-aachen.de
>>
>> Email: Daniel.Thielking at ias.rwth-aachen.de
>> Phone: +49-(0)241-80-27771
>>     FAX: +49-(0)241-80-627771
>> _____________________________________________________
>>
>> -- 
>> To unsubscribe from this list go to the following URL and read the
>> instructions:  https://lists.samba.org/mailman/options/samba
>>
>
I use the root *exec setting for that, and with that I call a script 
that creates the home dir as soon as the user touches the home share. I 
use FreeBSD with ZFS datasets, so my script use zfs commands to create 
zfs datasets, but you can change them with mkdir /usr/home/$1 and so on.
You can test the script by adding a username to it.  like so
# /usr/local/etc/samba/scripts/mkhomedir testuser

You can do all kinds of nifty things with these scripts. In my case 
using ZFS i can create a snapshot as soon as the user logs in or out, 
clone the profile dir, so if they log back in the dataset rolls back 
creating a sort of mandantory profile.


In my smb.conf i set the following.
[homes]
         comment = Home Directories
         path = /storage/sambashare/home/%U
         root preexec = /usr/local/etc/samba/scripts/mkhomedir.sh %U


This is my mkhomedir.sh  script



-------------------- start script -----------------

#!/usr/local/bin/bash

# check if we are a machine!
if [[ "$1" == *_ ]]; then
exit 0
fi

if [ ! -e /sambashare/home/$1 ]; then
   zfs create zroot/sambashare/home/$1
   chown $1:wheel /sambashare/home/$1
   chmod 770 /sambashare/home/$1
   setfacl -m user:$1:rwxpDdaARWcCos:fd----:allow /sambashare/home/$1
   zfs set quota=15G zroot/sambashare/home/$1
   zfs set compression=on zroot/sambashare/home/$1
fi

exit 0

--------------------- end of script -----------------


gr
Johan Hendriks



More information about the samba mailing list