[Fedora-directory-users] Some password policy enforcement information questions

Mike Jackson mj at sci.fi
Sat Feb 25 09:58:53 UTC 2006


Bliss, Aaron wrote:
>
> /etc/profile should work just fine.  I thought this might be helpful to
> other users (perl script was tough for me, as I've never really scripted
> in perl but couldn't figure out a way to do in bash), so here you go:

As it turns out, perl hacking is my hobby :-) Here is your script, 
improved a bit, and with command line option parsing included.


#!/usr/bin/perl -w

use strict;
use Getopt::Long;
use Time::Local;

my %o;
GetOptions(
     \%o,
     'year=i',
     'month=i',
     'day=i',
);

my $year    = $o{year};     # exp year
my $month   = $o{month};    # exp month
my $day     = $o{day};      # exp day

if (!($year && $month && $day))
{
     die "Usage: $0 --year YYYY --month MM --day DD\n";
}

my $maxyear = 2038;         # highest year for 32-bit systems
my $warning = 14;           # warning window in days

if ($year >= $maxyear) { die "Max year is $maxyear\n" }

$month     -= 1;
my $ep_exp  = timelocal(0,0,0,$day,$month,$year);
my $ep_cur  = timelocal(0,0,0, (localtime(time)) [3,4,5]);

# calculate the difference and send a warning if necessary
my $days    = ($ep_exp - $ep_cur) / 86400;
if ($days <= $warning)
{
   print "Warning: Your LDAP password expires in $days days\n";
}



--
mike




More information about the Fedora-directory-users mailing list