[Samba] Using more than one passwd program

Gémes Géza geza at kzsdabas.sulinet.hu
Fri Jun 24 06:47:18 GMT 2005


lx írta:

> Gémes Géza schrieb:
>
>> lx wrote:
>>
>>> Hello Everybody,
>>>
>>> i try to use more than the common:
>>>
>>> passwd program = /usr/bin/passwd %u
>>>
>>> what i try to do is a
>>>
>>> passwd program = /usr/bin/passwd %u && /usr/bin/htpasswd 
>>> /location/of/file %u
>>>
>>> it works perfect with /usr/bin/passwd...
>>>
>>> but i just can´t get it to make an entry to /usr/bin/htpasswd
>>>
>>> can someone please help me
>>>
>>> best regards
>>> Alex
>>
>>
>>
>> In that case you might want to write an expect script which would 
>> invoke /usr/bin/passwd and /usr/bin/htpaswd, and tell your samba, 
>> that your password program is that script.
>>
>> Good Luck!
>>
>> Geza
>
>
> Hi Geza,
>
> thanks for the reply, how could such a script look like?
>
> i still dont understand the linux way of transfering variables...
>
> could you give me a hint?
>
> i got some thin like this
>
> <>
>
> #!/bin/sh
>
> /usr/bin/passwd $1
> /usr/bin/htpasswd /location/of/file $1
>
> <>
>
> is this right?
>
> Best regards,
>
> L
> x

You could try something like that:
#!/usr/bin/expect

spawn /usr/bin/passwd [lindex $argv 0]

set password [lindex $argv 1]

expect "New UNIX password:"
send "$password\r"
expect "Retype new UNIX password:"
send "$password\r"
expect "passwd: all authentication tokens updated successfully."
send "\r"

spawn /usr/sbin/htpasswd -c passwdfile [lindex $argv 0]

expect "password:"
send "$password\r"
expect "password:"
send "$password\r"

expect eof

Please try it on the command line first, as I'm not an expect expert ;-(

Cheers

Geza


More information about the samba mailing list