Re: Being *Smart* with the shadow file ???
From: __jakal__ (jakal_at_jakal.com)
Date: 07/06/05
- Next message: adrian_at_satisoft.com: "Re: Zsh + GUI (was: (patch for Bash) Here-file)"
- Previous message: Stephane CHAZELAS: "Re: LC_NUMERIC not used in shells?"
- In reply to: Spook: "Being *Smart* with the shadow file ???"
- Next in thread: Spook: "Re: Being *Smart* with the shadow file ???"
- Reply: Spook: "Re: Being *Smart* with the shadow file ???"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 6 Jul 2005 13:57:46 +0530
"Spook" <spectre@xtra.co.nz> wrote in message
news:1120612823.488367.204810@g43g2000cwa.googlegroups.com...
> Hello All,
> It's late in the day and my mind is weary...
>
> I'm trying to write a script to calculate that a user's password is
> about to expire in 3 days and the script that will run daily will do a
> `passwd -f $userid` so that when s/he logs in the next day s/he will be
> forced to change password.
>
> Reason I'm doing this is that currently the users get sent directly to
> a Oracle FORMS menu dictated by their .profile when they login. They do
> not even see the $>prompt to change password.
>
> So now I see that the third entry (lastchg) in the /etc/shadow file
> pertains to when the user last changed their passwd from UNIX epoch of
> January 1, 1970.
>
> Now this is making my head spin on how I'm going to write a shell
> script to calculate the date stamp on the shadow file and the current
> date.
>
> My initial plan was to extract the userid and date from the `passwd
> -sa` and some how compare todays date and the last change + 3 months
> date.
>
> testuser PS 07/05/05 90 70
>
> Example: I would set variable $A = the last change date 07/05/05 and
> add 3 months as required... so the month of 07 to 10 .
>
> A="10/05/05"
> B=`date '+%D'`
>
> So now ...
> If [ $A == $B ]; then
> passwd -f $userid
> fi
>
> Well that's my current plan...but I still think trying to figure out
> how to calculate using UNIX epoch would be the way to go...
An easier solution is to find the difference between today and epoch which
is trivial in perl
use POSIX;
#no. of days since epoch
$today = floor(time/3600/24);
compare this with the 3rd field in shadow file and do the required
arithmatic
>
> Thanks in advance...
>
- Next message: adrian_at_satisoft.com: "Re: Zsh + GUI (was: (patch for Bash) Here-file)"
- Previous message: Stephane CHAZELAS: "Re: LC_NUMERIC not used in shells?"
- In reply to: Spook: "Being *Smart* with the shadow file ???"
- Next in thread: Spook: "Re: Being *Smart* with the shadow file ???"
- Reply: Spook: "Re: Being *Smart* with the shadow file ???"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|