[Samba] home directories ask user for password

Hoogstraten, Ton Ton.Hoogstraten at ingram.nl
Mon Nov 23 06:01:19 MST 2009


Massimo,

Perhaps removing the 'valid users' solves your problem. In theory it can
only display the homedir of the user connecting. The 'homes' share is
translated to the user name. Below if my current config that is working
for me. The preexec that I have is creating the homedir if it does not
exist (Perhaps that may be another possible cause of your error?).
Script is included. Make sure you change $path to your homedir location.
For quota uncomment and change the quota function for a given device.

Regards,

Ton


[homes]
        comment = Home Directories
        read only = No
        browseable = No
        root preexec = /etc/samba/homedir.pl %U
        create mask = 0664
        directory mask = 0775


homedir.pl:

#!/usr/bin/perl -w
use strict;

my $user = shift;
my $path = "<path to your homedir locations>";
my $logfile = "/var/log/samba/homedir.log";

if (! -d "$path/$user" && $user) {
                
        if (my $uid = getpwnam($user)) {

                if ((mkdir "$path/$user",0750) && (chown $uid, -1,
"$path/$user")) { 
                        
                        open(LOG, ">>$logfile");
                        my $time = localtime;

                        print LOG "$time: Homedir $path/$user for
uid:$uid created.\n";
                        
                        #Set default quota for mount points:
				#quota($user,15000,"</dev/sda>");
                        
                        close(LOG);
                }
        }
}



sub quota {
my $user = shift;
my $quota = shift;
my $mount = shift;

        if (system("/usr/sbin/setquota -u $user 0 $quota 0 0 $mount") ==
0)
        {
        my $time = localtime;
        print LOG "$time: Updated quota settings for user $user on
$mount\n";
        }

}



More information about the samba mailing list