#!/bin/sh
#
# source:
#   /var/cvs/projects/debian/cracklib/debian/dpkg.src/cracklib-runtime.cron.daily.in,v
#
# revision:
#   @(#) cracklib-runtime.cron.daily.in,v 1.3 1999/03/29 15:29:27 jplejacq Exp
#
# copyright:
#   Copyright (C) 1998, 1999 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/sbin/crack_mkdict" ]
  then
    exit 0
  fi


  if [ ! -x "/usr/sbin/crack_packer" ]
  then
    exit 0
  fi


  if [ -r "/etc/cracklib/cracklib.conf" ]
  then
    . /etc/cracklib/cracklib.conf
  else
    exit 0
  fi


  if [ -n "${cracklib_dictpath_src}"  -a  -n "${cracklib_dictpath}" ]
  then
    readonly status="$(\
      /usr/sbin/crack_mkdict ${cracklib_dictpath_src}\
      |\
      /usr/sbin/crack_packer ${cracklib_dictpath}\
    )"

    /usr/bin/logger\
      -p "auth.notice"\
      -t "cracklib"\
      "updating dictionary ${status} words."
  fi


  exit 0
