TMason
2013-Mar-15  20:59 UTC
[Samba] Samba (3.6.12) - Different Home Directories for Different Users
Hello, I am using Samba (3.6.12) with Gentoo Linux (Kernel Version 3.7.10) and I have a system integrated with Active Directory (the Microsoft Windows servers are running 2008 Enterprise Edition, Release 2). All is well on that front (I can log in, directories are created, etc.) What I would like to do now is have different /etc/skel directories for different groups. So, for example, if someone from the Finance department logs in one set of default settings are copied for that person but if someone from sales logs in another set of default settings are copied over for that user. How can I do this with Samba/Linux? Thank you for your time.
Chris Smith
2013-Mar-16  22:02 UTC
[Samba] Samba (3.6.12) - Different Home Directories for Different Users
On Fri, Mar 15, 2013 at 4:59 PM, TMason <c.koeber at live.com> wrote:> What I would like to do now is have different /etc/skel directories for > different groups. So, for example, if someone from the Finance department > logs in one set of default settings are copied for that person but if > someone from sales logs in another set of default settings are copied over > for that user. > > How can I do this with Samba/Linux?Maybe you can use the group variable %G in the add user script as part of the skel name: -k /etc/skel%G and make sure you have a corresponding skeleton directory for each group.
Jim Potter
2013-Mar-17  20:23 UTC
[Samba] Samba (3.6.12) - Different Home Directories for Different Users
Hi,
I have a similar setup (complex home directory setup) and I use the root 
preexec option to do it. See the 'id $1  | grep staff' bit below to 
check group membership.
I found that 'id auser' works much better than 'groups auser'.
don't
know why, but groups sometimes takes a few moments to run, and the share 
is not accessible until the script has finished.
Hope that helps,
Jim
 From smb.conf:
[homes]
         comment = windows home directory
         path = /srv/nas/BEC/%U/home
         root preexec = /bin/bash /srv/scripts/home.sh %U /srv/nas/BEC
         read only = no
         browseable = no
         csc policy = documents
         hide files = /desktop.ini/$RECYCLE.BIN/recycled/
         veto files = /*.bat/
         vfs objects = recycle
/srv/scripts/home.sh:
#!/bin/bash
if [ -z "$2" ]
then
         echo "no repository specified"
         exit 0
fi
if [ ! -d $2/$1 ]
then
         mkdir -p $2/$1/home/AutoBackup
         mkdir -p $2/$1/myDocs/Desktop
         mkdir $2/$1/myDocs/Downloads
         mkdir $2/$1/myDocs/My\ Music
         mkdir $2/$1/myDocs/My\ Pictures
         mkdir $2/$1/myDocs/My\ Videos
         mkdir $2/$1/myDocs/OpenOffice\ backups
         mkdir $2/$1/myDocs/OpenOffice\ templates
         mkdir -p /srv/recycled/$1
         ln -ns $2/$1/myDocs $2/$1/home/myDocs
         ln -ns /srv/recycled/$1 /srv/users/$1/home/recycled
         if (id $1 | grep "staff") >> /dev/null;
         then
                 mkdir -p $2/$1/archive
                 ln -ns /srv/recycled/$1 $2/$1/archive/recycled
                 ln -s msdfs:personalTest\\archive $2/$1/archive
         fi
         chown -R $1:"Domain admins" $2/$1 /srv/recycled/$1
         chmod -R 770 $2/$1 /srv/recycled/$1
         chmod 570 $2/$1/home
fi
On 15/03/2013 20:59, TMason wrote:> Hello,
>
> I am using Samba (3.6.12) with Gentoo Linux (Kernel Version 3.7.10) 
> and I have a system integrated with Active Directory (the Microsoft 
> Windows servers are running 2008 Enterprise Edition, Release 2). All 
> is well on that front (I can log in, directories are created, etc.)
>
> What I would like to do now is have different /etc/skel directories 
> for different groups. So, for example, if someone from the Finance 
> department logs in one set of default settings are copied for that 
> person but if someone from sales logs in another set of default 
> settings are copied over for that user.
>
> How can I do this with Samba/Linux? Thank you for your time.
>