I'd like to thank everyone on and off list for thier help even the ones that chewed me out for even thinking of writeing a perl mod that executes as root. I don't plan on this type of code going on a prodution server for some time but finaly got it working like it should. One bump down, many to come. The final code looks like such.
#!/usr/local/bin/perl -w use strict; print "Enter your preferd username.\n"; chomp(my $username = <STDIN>); print "enter your prefered password\n"; chomp(my $passwd = <STDIN>); my $salt="\$1\$blahblahblah\$"; chomp(my $pwd = crypt($passwd,"$salt")); print `/usr/sbin/useradd '$username' -p '$pwd'`; it apears without the '' around the passwd it was passing it like a string after all $1$ in a shell is a string the same as in perl or most programming languages and scripts. If others are having similar problems hope this helps. And if someone sees other ways for me to do my code, clean it, make it more secure I'm always with an open mind On Sun, 8 Dec 2002 08:54:28 -0500 Jerry M. Howell II <[EMAIL PROTECTED]> wrote: > 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] > > > -- Jerry M. Howell II -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]