#! /usr/bin/perl -w
use strict;
my $host = `uname -n`;
chomp $host;
sub send_message
{
my ( $user, $message ) = @_;
open FH, "|mail -s \"Password on $host\" $user\@mailhost"
or die "Unable to open pipe to mail\n";
print FH $message;
close FH;
}
foreach my $user ( split /[,=\n]/, `lsgroup -a users helpdesk` )
{
$user =~ /^helpdesk/ and next;
my (undef,$chtime) = split /[=\n]/, `lssec -f /etc/security/passwd -s $user -a lastupdate 2>/dev/null`;
$chtime or (print STDERR "$user has never been updated\n"), next;
$chtime = int ((time - $chtime)/( 60 * 60 * 24 ));
$chtime < 42 and next;
( $chtime = 56 - $chtime ) <= 0 and
send_message $user, "Your password on $host has expired" or
send_message $user, "Your password on $host will expire in $chtime days - please log in and reset it";
}