From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <96079038515858.tru64-unix-managers.marc@archive.invalid> From: Chris Los Date: Sun, 21 Mar 1999 14:48:04 +0000 To: tru64-unix-managers Subject: SUMMARY: Displaying time/date of last password change for a user - X-MARC-Message: https://marc.info/?l=tru64-unix-managers&m=96079038515858 Thanks to all who responded on this. Here's my original question: > > Hello, > > Is there anyway under DU 4.0B (C2 enabled) that I can display the time > & date that a user last changed their password. I've tried looking for > this under "dxaccounts" but can't find anything. I know its probably > buried somewhere down in "/tcb/files/auth" in seconds, but was > wondering if there is a friendlier way to display this information via > dxaccounts as it seems like it should be able to do this sort of thing. > > TIA, > clos@nhb.com > The short answer to this question is that dxaccounts currently does not have a way to display the time/date of a last password change. Most respondents suggested that this info can be extracted using the following command: try /usr/tcb/bin/edauth -g See the man page for edauth, and prpasswd to understand the fields in the database. The fields of interest in the prpasswd database are u_succchg and u_unsucchg. These fields are in seconds and can converted to day/month/year hours:minutes:secs (or some other format) via your own custom written script or program. Here are 2 example programs I received. Start-of-Example-1~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ From: Matt Moore I'm not sure if you can do it from dxaccounts but I like to do things from the shell because it is a LOT faster, especially if you have a lot of accounts (we have about 10,000). You can view or change anything you want if have some good scripts to do the job. Here is a perl script to display the date of the last password change: ------------------------< Cut Here >--------------------------------- #!/usr/bin/perl # File: pwchange # Usage: pwchange username # You must be root to run this program $LINE = `edauth -g $ARGV[0] | grep u_succhg`; @FIELDS = split(/:/,$LINE); foreach (@FIELDS) { if ( $_ =~ /u_succhg/ ) { ($junk,$TIME) = split(/#/);} } ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($TIME); $mon++; print "Password Changed: $mon/$mday/$year $hour:$min:$sec \n"; ------------------------< Cut Here >--------------------------------- BTW - everything you need to decode the values in the authdb is in the man pages for prpasswd. End-of-Example-1~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Here is an example of a C program received. From: John Ferlan The program I sent you would do what you want if you had the time already available... in order to "read" the time you should take as input a username, then call getespwnam() on the user (see the man page) - and then pass to the time printing routine the prpwd->ufld->fd_schange if it's available (prpwd->uflg->fg_schange)... Yes you'll have to do a little bit of coding from what I sent you, but it shouldn't be too hard... My code takes as input an integer value and converts it... Start-of-Example-2~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /* passchg.c * * Just a little program to show how you can * print the last successful/unsuccessful password * change for the account you have logged into */ #include #include #include #include #include #include #include #include #include void print_time (time_t timbuf) { char *loc; /* the current locale */ char *dt_format; /* strftime format */ struct tm *tvp; /* Pointer to localtime return */ char timestr[128]; loc = setlocale(LC_TIME, NULL); if (!strcmp(loc, "POSIX") || !strcmp(loc, "C")) dt_format = "%a %b %e %H:%M:%S %Z %Y"; else dt_format = "%c"; /* Leave it up to libc */ tvp = localtime(&timbuf); (void)strftime(timestr, sizeof timestr, dt_format, tvp); printf ("Time is: %s\n", timestr); } /*============================MAIN PROGRAM==============================*/ main(int argc, char *argv[]) { time_t read_time; int retval = 0; if (argc == 2) { read_time = (time_t)atoi(argv[1]); print_time(read_time); } else { printf ("Bad format - usage - prtime \n"); retval = 1; } return retval; } End-of-Example-2~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~