Some password policy enforcement information questions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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




[Index of Archives]     [Fedora User Discussion]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [Fedora News]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Maintainers]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Legacy]     [Fedora Desktop]     [Fedora Fonts]     [ATA RAID]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Centos]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora QA]     [Fedora Triage]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Tux]     [Yosemite News]     [Yosemite Photos]     [Linux Apps]     [Maemo Users]     [Gnome Users]     [KDE Users]     [Fedora Tools]     [Fedora Art]     [Fedora Docs]     [Maemo Users]     [Asterisk PBX]     [Fedora Sparc]     [Fedora Universal Network Connector]     [Fedora ARM]

  Powered by Linux