John J. Trammell wrote:
> Hey all:
> 
> After struggling with the newer inn2/nnrpd auth features (in
> particular with the lack of documentation for the ckpasswd
> util), I Used the Source and was able to come up with this
> test/driver script.  I hope someone finds it useful some day.
> Questions and constructive comments are welcome.
> 
> #!/usr/bin/perl -w
> use strict;
> 
> # test script for ckpasswd, Debian/woody inn2 install
> 
> my $ckpasswd = "/usr/lib/news/bin/auth/passwd/ckpasswd";
> 
> sub mycrypt
> {
>     my $pass = shift;
>     my @a = (0..9, 'A'..'Z', 'a'..'z');
>     my $salt = $a[rand(@a)] . $a[rand(@a)];
>     return crypt($pass, $salt);
> }


if you want to support md5passwords, which perl does if the system 
library does you want to change your salt generation and crypt to 
something more like this (the code snippet below also does a quick check 
to see if the system supports md5passwords or not).

sub salt_gen {
         my $item = "";
         my $let = 
"abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ.";
         for(my $i=0; $i < 8; $i++) {
                 $item .= substr($let, rand(length($let)), 1);
         }
         return $item;
}

# check for md5 crypt support
$random_thing = salt_gen();
$var = '$1$'.$random_thing.'$';
$check = crypt("bob", $var);
if ($check eq "\$1Ai/bpypBusU") { # crypt doesn't support md5
         $var = $random_thing;
}
$crypt = crypt($ARGV[1], $var);



Eric

> 



_______________________________________________
Twin Cities Linux Users Group Mailing List - Minneapolis/St. Paul, Minnesota
http://www.mn-linux.org tclug-list at mn-linux.org
https://mailman.real-time.com/mailman/listinfo/tclug-list