thank you for your help, but still no dice. I am wondering what's going on here.
I installed Crypt-PasswdMD5-1.2 perl module to make this work.
my script is as follows (I know showing the salt isn't suposed to be done
but before I put it to use I plan to randomly generate it)

#!/usr/bin/perl
print "Enter your preferd username.\n";
$username = <STDIN>;
chomp($username);
print "enter your prefered password\n";
$passwd = <STDIN>;
$salt="\$1\$blahblahblah\$";
use Crypt::PasswdMD5;
$pwd = unix_md5_crypt($passwd,$salt);
chomp($pwd);
print `/usr/sbin/useradd $username -p $pwd`;
print "the password is $pwd\n";

all is done corect till it puts the passwd in /etc/shadow

here is the shadow entry

kim2:/ozTmBDXkQ3jmXzv1:12029:0:99999:7:::

on the last line it prints the password to the screen and I get

the password is $1$blahblah$hWn8A/ozTmBDXkQ3jmXzv1

it looks to me like it choped the passwd at the /

grrr,

On Sun, 08 Dec 2002 13:14:23 +0000
Chris Ball <[EMAIL PROTECTED]> wrote:

> >> On 8 Dec 2002 07:22:39, Jerry M. Howell II <[EMAIL PROTECTED]> said:
> 
>    > I used the useradd -p and it doesn't insert the passwd like it
>    > should I should see something like $1$blahhblahhblahh but it
>    > doesn't do this, if I manualy insert it it works fine but it looks
>    > like print `/usr/sbin/useradd "$username" -p "$pwd"`; screws it up
> 
> You've been using the wrong hashing algorithm, I'm afraid.  crypt()
> isn't used in modern UNIX password files, md5 is.  I think your code
> will start working if you use:
> 
>    use Crypt::PasswdMD5; 
>    $pass = unix_md5_crypt($input_pass,$salt);
> 
> Also, your double-quotes in the useradd command look redundant.  Try
> removing them, if it still doesn't work.  They may been being processed
> as part of the username/password.
> 
> Hope this helps,
> 
> - Chris.
> -- 
> $a="printf.net";  Chris Ball | chris@void.$a | www.$a | finger: chris@$a
> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 


-- 
Jerry M. Howell II

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to