source: pkg/security/vinnie/main/shadow/trunk/debian/passwd.expire.cron @ 7410

Revision 7410, 1.8 KB checked in by alanbach-guest, 3 years ago (diff)
  • Added shadow to Vinnie security
Line 
1#!/usr/bin/perl
2#
3# passwd.expire.cron: sample expiry notification script for use as a cronjob
4#
5# Copyright 1999 by Ben Collins <bcollins@debian.org>, complete rights granted
6# for use, distribution, modification, etc.
7#
8# Usage:
9#       edit the listed options, including the actual email, then rename to
10#       /etc/cron.daily/passwd
11#
12#       If your users don't have a valid login shell (ie. they are ftp or mail
13#       users only), they will need some other way to change their password
14#       (telnet will work since login will handle password aging, or a poppasswd
15#       program, if they are mail users).
16
17# <CONFIG> #
18
19# should be same as /etc/adduser.conf
20$LOW_UID=1000;
21$HIGH_UID=29999;
22
23# this let's the MTA handle the domain,
24# set it manually if you want. Make sure
25# you also add the @ like "\@domain.com"
26$MAIL_DOM="";
27
28# </CONFIG> #
29
30# Set the current day reference
31$curdays = int(time() / (60 * 60 * 24));
32
33# Now go through the list
34
35open(SH, "< /etc/shadow");
36while (<SH>) {
37    @shent = split(':', $_);
38    @userent = getpwnam($shent[0]);
39    if ($userent[2] >= $LOW_UID && $userent[2] <= $HIGH_UID) {
40        if ($curdays > $shent[2] + $shent[4] - $shent[5] &&
41                $shent[4] != -1 && $shent[4] != 0 &&
42                $shent[5] != -1 && $shent[5] != 0) {
43            $daysleft = ($shent[2] + $shent[4]) - $curdays;
44            if ($daysleft == 1) { $days = "day"; } else {$days = "days"; }
45            if ($daysleft < 0) { next; }
46            open (MAIL, "| mail -s '[WARNING] account will expire in $daysleft $days' $shent[0]${MAIL_DOM}");
47            print MAIL <<EOF;
48Your account will expire in $daysleft $days. Please change your password before
49then or your account will expire
50EOF
51            close (MAIL);
52            # This makes sure we also get a list of almost expired users
53            print "$shent[0]'s account will expire in $daysleft days\n";
54        }
55    }
56    @userent = getpwent();
57}
Note: See TracBrowser for help on using the repository browser.