Users whose passwords are about to expire
"Chris de Vidal" <[email protected]>
| Newsgroups | gmane.linux.pld.shadow.general |
|---|---|
| Message-ID | <[email protected]> |
Hello shadow suite users!
I've been using chage to expire passwords and it's working great. I'm
very pleased with the whole shadow suite.
When I use chage -W I am warned when I log in via SSH or locally when my
password is about to expire. This is GOOD.
However, I'd like to use chage -W for users on a file server who never log
in via SSH or locally. I'd like a list of users who would see the
password expiration warning message if they were to log in.
I noticed that chage has the -l flag which I can use like so:
for user in `cut -d: -f1 /etc/passwd`
do
echo -n $user
chage -l $user | grep "Password Expires:" | awk -F: '{ print $2; }'
done
Which gives me this output:
user1 Nov 23, 2003
user2 Jul 15, 2004
This is good, but to send mail to the users who are about to expire (who
would be warned if they were to log in), I'll need to script something
with perl or bash or possibly even C. I'll need to get the current date,
and for each user add the number of days set with chage -W, and see if the
expiration date is within that range. If so, I'll need to echo that
username and move on to the next username.
But before I reinvent the wheel, is there a program that will do this?
The password expiration login warning message ALMOST does this, but it is
triggered only at login, it sends the warning right to the user's TTY and
it doesn't give the root user a chance to list them all for scripting.
Perhaps I need to roll up my sleeves and edit the source of that warning
message? I'm not very good at writing C code :-/
If I had a list of usernames who were about to expire, I could write a
cron script that could send them mail and direct them to a web form where
they could change their password.
Hope you can help,
/dev/idal