~ubuntu-branches/ubuntu/intrepid/shadow/intrepid-updates

« back to all changes in this revision

Viewing changes to debian/passwd.expire.cron

  • Committer: Bazaar Package Importer
  • Author(s): Colin Watson
  • Date: 2004-09-14 01:01:32 UTC
  • Revision ID: james.westby@ubuntu.com-20040914010132-caqdvzrhku8od2qk
Tags: 1:4.0.3-28.5ubuntu6
Update German translation of passwd/user-fullname.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
 
35
open(SH, "< /etc/shadow");
 
36
while (<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;
 
48
Your account will expire in $daysleft $days. Please change your password before
 
49
then or your account will expire
 
50
EOF
 
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
}