#!/bin/sh
#
# source:
#   $Source: /var/cvs/projects/debian/cracklib/debian/dpkg.src/cracklib-runtime.cron.daily.in,v $
#
# revision:
#   @(#) $Id: cracklib-runtime.cron.daily.in,v 1.2 1998/04/25 04:23:01 jplejacq Exp $
#
# copyright:
#   Copyright (C) 1998 Jean Pierre LeJacq <jplejacq@quoininc.com>
#
#   Distributed under the GNU GENERAL PUBLIC LICENSE.
#
# synopsis:
#   /etc/cron.daily/cracklib
#
# description:
#   Host configuration of cron.daily program for cracklib.
#
#   Regenerate the cracklib database from source word files.  The
#   files are created with mode 0640 to prevent access to other than
#   root.


# main:
  set -e

  umask 0026


  if [ ! -x "/usr/bin/logger" ]
  then
    exit 1
  fi


  if [ ! -x "/usr/sbin/crack_mkdict" ]
  then
    /usr/bin/logger\
      -p "auth.err"\
      -t "cracklib"\
      "/usr/sbin/crack_mkdict unexecutable"
    exit 1
  fi


  if [ ! -x "/usr/sbin/crack_packer" ]
  then
    /usr/bin/logger\
      -p "auth.err"\
      -t "cracklib"\
      "/usr/sbin/crack_packer unexecutable"
    exit 1
  fi


  if [ -r "/etc/cracklib/cracklib.conf" ]
  then
    . /etc/cracklib/cracklib.conf
  else
    /usr/bin/logger\
      -p "auth.err"\
      -t "cracklib"\
      "/etc/cracklib/cracklib.conf unreadable"
    exit 1
  fi


  if [ -n "${cracklib_dictpath_src}"  -a  -n "${cracklib_dictpath}" ]
  then
    /usr/sbin/crack_mkdict ${cracklib_dictpath_src} |\
      /usr/sbin/crack_packer ${cracklib_dictpath}
  fi


  exit 0
