freebsd-dev/crypto/heimdal/lib/kadm5/check-cracklib.pl
Stanislav Sedov ae77177087 - Update FreeBSD Heimdal distribution to version 1.5.1. This also brings
several new kerberos related libraries and applications to FreeBSD:
  o kgetcred(1) allows one to manually get a ticket for a particular service.
  o kf(1) securily forwards ticket to another host through an authenticated
    and encrypted stream.
  o kcc(1) is an umbrella program around klist(1), kswitch(1), kgetcred(1)
    and other user kerberos operations. klist and kswitch are just symlinks
    to kcc(1) now.
  o kswitch(1) allows you to easily switch between kerberos credentials if
    you're running KCM.
  o hxtool(1) is a certificate management tool to use with PKINIT.
  o string2key(1) maps a password into key.
  o kdigest(8) is a userland tool to access the KDC's digest interface.
  o kimpersonate(8) creates a "fake" ticket for a service.

  We also now install manpages for some lirbaries that were not installed
  before, libheimntlm and libhx509.

- The new HEIMDAL version no longer supports Kerberos 4.  All users are
  recommended to switch to Kerberos 5.

- Weak ciphers are now disabled by default.  To enable DES support (used
  by telnet(8)), use "allow_weak_crypto" option in krb5.conf.

- libtelnet, pam_ksu and pam_krb5 are now compiled with error on warnings
  disabled due to the function they use (krb5_get_err_text(3)) being
  deprecated.  I plan to work on this next.

- Heimdal's KDC now require sqlite to operate.  We use the bundled version
  and install it as libheimsqlite.  If some other FreeBSD components will
  require it in the future we can rename it to libbsdsqlite and use for these
  components as well.

- This is not a latest Heimdal version, the new one was released while I was
  working on the update.  I will update it to 1.5.2 soon, as it fixes some
  important bugs and security issues.
2012-03-22 08:48:42 +00:00

113 lines
2.8 KiB
Perl
Executable File

#!/usr/pkg/bin/perl
#
# Sample password verifier for Heimdals external password
# verifier, see the chapter "Password changing" in the the info
# documentation for more information about the protocol used.
#
# Three checks
# 1. Check that password is not the principal name
# 2. Check that the password passes cracklib
# 3. Check that password isn't repeated for this principal
#
# The repeat check must be last because some clients ask
# twice when getting "no" back and thus the error message
# would be wrong.
#
# Prereqs (example versions):
#
# * perl (5.8.5) http://www.perl.org/
# * cracklib (2.8.5) http://sourceforge.net/projects/cracklib
# * Crypt-Cracklib perlmodule (0.01) http://search.cpan.org/~daniel/
#
# Sample dictionaries:
# cracklib-words (1.1) http://sourceforge.net/projects/cracklib
# miscfiles (1.4.2) http://directory.fsf.org/miscfiles.html
#
# Configuration for krb5.conf or kdc.conf
#
# [password_quality]
# policies = builtin:external-check
# external_program = <your-path>/check-cracklib.pl
#
# $Id$
use strict;
use Crypt::Cracklib;
use Digest::MD5;
# NEED TO CHANGE THESE TO MATCH YOUR SYSTEM
my $database = '/usr/lib/cracklib_dict';
my $historydb = '/var/heimdal/historydb';
# NEED TO CHANGE THESE TO MATCH YOUR SYSTEM
# seconds password reuse allowed (to catch retries from clients)
my $reusetime = 60;
my %params;
sub check_basic
{
my $principal = shift;
my $passwd = shift;
if ($principal eq $passwd) {
return "Principal name as password is not allowed";
}
return "ok";
}
sub check_repeat
{
my $principal = shift;
my $passwd = shift;
my $result = 'Do not reuse passwords';
my %DB;
my $md5context = new Digest::MD5;
my $timenow = scalar(time());
$md5context->reset();
$md5context->add($principal, ":", $passwd);
my $key=$md5context->hexdigest();
dbmopen(%DB,$historydb,0600) or die "Internal: Could not open $historydb";
if (!$DB{$key} || ($timenow - $DB{$key} < $reusetime)) {
$result = "ok";
$DB{$key}=$timenow;
}
dbmclose(%DB) or die "Internal: Could not close $historydb";
return $result;
}
sub badpassword
{
my $reason = shift;
print "$reason\n";
exit 0
}
while (<STDIN>) {
last if /^end$/;
if (!/^([^:]+): (.+)$/) {
die "key value pair not correct: $_";
}
$params{$1} = $2;
}
die "missing principal" if (!defined $params{'principal'});
die "missing password" if (!defined $params{'new-password'});
my $reason;
$reason = check_basic($params{'principal'}, $params{'new-password'});
badpassword($reason) if ($reason ne "ok");
$reason = fascist_check($params{'new-password'}, $database);
badpassword($reason) if ($reason ne "ok");
$reason = check_repeat($params{'principal'}, $params{'new-password'});
badpassword($reason) if ($reason ne "ok");
print "APPROVED\n";
exit 0