Date: Wed, 6 Jun 2001 11:14:03 -0400 (EDT) From: David Miner <david@slis-two.lis.fsu.edu> To: <freebsd-security@FreeBSD.ORG> Subject: Encrypted passwords Message-ID: <Pine.BSF.4.30_heb2.09.0106061108460.49859-100000@slis-two.lis.fsu.edu>
next in thread | raw e-mail | index | archive | help
A while back there was a good discussion on using encrypted passwords to "automatically" create user accounts. I haave a need to create classroom accounts every semester and (borrowing freely from adduser) created the following perl script. But something is not right and I have to go in and manually change the passwords to what I want. The program asks for a password file name and the file contains passwords that I have approved as meeting my standards. The problem seems to be in how they get encrypted. Suggestions, please? -------------------Begin Program----------------------- #!/usr/bin/perl sub check_root { die "You are not root!\n" if $< && !$test; } sub salt { local($salt); # initialization local($i, $rand); local(@itoa64) = ( '0' .. '9', 'a' .. 'z', 'A' .. 'Z' ); # 0 .. 63 # to64 for ($i = 0; $i < 8; $i++) { srand(time + $rand + $$); $rand = rand(25*29*17 + $rand); $salt .= $itoa64[$rand & $#itoa64]; } return $salt; } sub get_pw_file { print "Enter password file name: "; chop($read = <STDIN>); open (P1, $read); @pwd1 = <P1>; print "Password file read", "\n"; close P1; } #main &get_pw_file; print "Enter path to home directories: "; chop($home=<STDIN>); # default HOME print "Enter class name: "; chop($b=<STDIN>); #class name print "Enter first number wanted: "; chop($a=<STDIN>); #first number wanted print "Enter number of users wanted: "; chop($r=<STDIN>); #number of users wanted $c=$r+$a; $s = "/bin/csh"; open (DEL,">$b\-del"); open (PWD, ">$b\-pwd"); for (;$a<($c);$a++) { $name="$b\-$a"; $fullname= "LIS".$name; $userhome="$home\/$name"; print $name," ",$pwd1[$a]," \n"; print (DEL "pw userdel -n $name \n"); print (PWD "The password for $name is $pwd1[$a] \n"); $cryptpwd = ""; $cryptpwd = crypt($pwd1[$a], &salt); system(`pw useradd -n $name -c $fullname -d $userhome -s $s -m; chpass -p $cryptpwd $name`); system(`mkdir $userhome\/public_html`); system(`chmod 755 $userhome\/public_html`); system(`chown $name:websitedev $userhome\/public_html`); } close ; -----------------End program------------------------- --------------------------------------------------------------------- David R. Miner miner@lis.fsu.edu Systems Integrator voice: 850-644-8107 School of Information Studies fax: 850-644-6253 Florida State University Tallahassee, FL 32306-2100 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-security" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.30_heb2.09.0106061108460.49859-100000>