#!/usr/bin/perl -T

use strict;
use warnings;
use esmith::ConfigDB;
use Crypt::Cracklib;
use CGI::FormMagick::Validator::Network;

our $db = esmith::ConfigDB->open or
    die "Couldn't open configuration database (permissions problems?)";

my $strength = $db->get_prop('passwordstrength', 'Users');
my $pass = <>;
chomp $pass;

exit 0 if ($strength eq "none");

my $reason = ($strength eq 'strong') ?
    fascist_check($pass, '/usr/lib/cracklib_dict') :
    CGI::FormMagick::Validator::password(undef, $pass);

exit 0 if (lc($reason) eq "ok");
exit 1;
