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

password generator




For those of you who would like to change the password Jason chose for you
you can use this perl script to generate the password.  Works for SunOS
and Linux.  Just take the output string after the colon and paste that in
the password field in the Users table in the linuxkb database for your
userid using phpmyadmin on the admin server.


--
Aaron Turner, Core Developer       http://vodka.linuxkb.org/~aturner/
Linux Knowledge Base Organization  http://linuxkb.org/
Because world domination requires quality open documentation.
aka: aturner@vicinity.com, aturner@pobox.com, ion_beam_head@ashtech.net
The difference between `Unstable' and `Usable' is only two characters: NT

-------8<-------------8<-------------8<-------------8<-------------8<------


#!/usr/bin/perl

use strict;
my $uname = `uname`;

# Seed rand()
if ($uname =~ /^SunOS/) {
  srand ( time ^ $$ ^ unpack "%L*", `ps -efa | compress`);
} elsif ($uname =~ /^Linux/) {
  srand ( time ^ $$ ^ unpack "%L*", `ps axww | gzip`);
} 

sub randarray { $_[0]->[ rand @{ $_[0] } ] }
my @salt = qw( 0 1 2 3 4 5 6 7 8 9 a b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z . / );

my $salt = randarray ( \@salt) . randarray ( \@salt);

print STDERR "Please enter username: ";
chop (my $uname = <STDIN>);
NEWPASS:
print STDERR "Please enter password: "; 
system "stty -echo"; # turn of echo
chop (my $pass1 = <STDIN>);
system "stty echo"; # turn back on echo
print STDERR "\n";
print STDERR "Please enter password again: ";
system "stty -echo"; # turn of echo
chop (my $pass2 = <STDIN>);
system "stty echo"; # turn back on echo
print STDERR "\n";
if ($pass1 eq $pass2) {
  $pass1 = crypt ($pass2, $salt);
  print $uname . ":" . $pass1 . "\n";
} else {
  print STDERR "Password missmatch for $uname.\n";
  goto NEWPASS;
}

-------8<-------------8<-------------8<-------------8<-------------8<------