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);
}

my %pass = (
    foo => "bar", # user => passwd
    baz => "quux",
    gandalf => "friend",
);

#
# generate a password file for testing
#

open(TMP,">passwd.tmp") or die "can't open passwd.tmp: $!";
for (keys %pass) { printf TMP "$_:%s\n", mycrypt($pass{$_}) }
close TMP;
END { unlink "passwd.tmp"; }

#
# test each generated user/pass pair with ckpasswd
#

for (keys %pass)
{   
    warn "testing password for user '$_'\n";
    open(CK,"|$ckpasswd -f passwd.tmp")
        or die "unable to open pipe to ckpasswd: $!";
    print CK "ClientAuthname: $_\n";
    print CK "ClientPassword: $pass{$_}\n";
    if (close(CK))
    {   
        warn "...OK\n";
    }
    else
    {   
        warn "$!" if $!;
        print_exit_status($?);
        die "error testing userid '$_'";
    }
}

sub print_exit_status
{   
    my $s = shift;
    my $exit   = $s >> 8;
    my $signal = $s & 127;
    my $core   = $s & 128;

    print <<EOF;
 exit value:    $exit
 signal number: $signal
 dumped core:   $core
EOF
}

-- 
trammell at el-swifto.com  9EC7 BC6D E688 A184 9F58  FD4C 2C12 CC14 8ABA 36F5
Twin Cities Linux Users Group (TCLUG)      Minneapolis/St. Paul, Minnesota
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 240 bytes
Desc: not available
Url : http://shadowknight.real-time.com/pipermail/tclug-list/attachments/20030307/000c4267/attachment.pgp