[Samba] Slackware 12.1 + Samba 3.0.28a + a lot of users
Robert
robert at spotswood-computer.net
Tue Jul 8 11:34:13 GMT 2008
On Tuesday 08 July 2008, Helmut Hullen wrote:
> Hallo, Krzysztof,
>
> Du (krzys18) meintest am 08.07.08:
> > Now, I'm trying to convince Samba to let Win XP users to connect to
> > their home directories for example /raid/Users/user000001,
> > /raid/Users/user000002 etc. I have a lot of users (Slackware Unix
> > users in /etc/passwd and /etc/shadow) so defining them with
> > "smbpasswd -a userNNNNNN" is impossible. Well, maybe it is possible
> > but... considering the number of users it would take too much time.
>
> If you don't want LDAP you have to use the "smbpasswd" way.
>
> (and LDAP leads to other problems ...)
<snip>
To help make things easier for me when I had to do it the "smbpasswd way"
recently, I wrote an expect script. I had to add the users to passwd and
create the directories, so there may be some extra stuff in here you don't
need, but it should get you started. Comment out what you don't need. This
requires expect and takes two arguments on the command line: the username and
the password. Improvements are welcome.
For example, if I need to add user frank with password secret, call the script
like this (as root):
<path to script>/<script name> frank secret
With the right shell script loop, this could be highly automated.
========Begin script=============
#!/usr/bin/expect -f
set password [lindex $argv 1]
set username [lindex $argv 0]
spawn useradd $username
sleep 1
spawn mkdir /home/$username
sleep 1
spawn chown -R $username:$username /home/$username
sleep 5
spawn chmod 0770 -R /home/$username
sleep 5
spawn passwd [lindex $argv 0]
expect {
-re "password:" {sleep 1; send "$password\r"; exp_continue}
-re "password:" {sleep 1; send "$password\r";}
}
spawn mkdir /home/profiles/$username
sleep 1
spawn chown $username:$username /home/profiles/$username
sleep 1
spawn chown -R $username:$username /home/$username
sleep 1
spawn chmod 0770 -R /home/$username
sleep 5
spawn smbpasswd -a $username
expect {
-re "password:" {sleep 1; send "$password\r"; exp_continue}
-re "password:" {sleep 1; send "$password\r";}
}
========End script=============
--
Fail to learn history-repeat it.
Fail to learn rights-lose them.
Learn both-get screwed by previous two groups.
More information about the samba
mailing list