[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: useradd -p



On Mon, 2002-04-01 at 16:51, Charles Menzes wrote:
> 
> the man page for useradd shows that the '-p' flag  is used to specify an 
> already encrypted password string as as returned by crypt(3).

Just a side note: is there a reason you don't use setpwent?

> in my (very) simple perl script, i have:
> 
>     ## generate random characters
>     my $random = new String::Random;
> 
>     ## salt the passwd
>     my $salt = $random->randpattern("ss");
> 
>     ## encrypt the password
>     my $crypt = crypt($first_pass, $salt);
> 
>     ## return encrypted password to root routine
>     return ($crypt);
> 
> this just passes teh value of $crypt to a system call to 'useradd' that 
> uses /-p "$crypt"/.

Some thoughts:

 - is the string encoded correctly?  What do you get if you enter the
password the normal way to useradd?  As I recall, you need to run the
result of crypt() through a base64 translation.

 - did you make sure you tacked on the salt?  I don't think that's
automatic.  The salt should appear at the start of the encoded password
string.


-
To unsubscribe, send email to majordomo@luci.org with
"unsubscribe luci-discuss" in the body.