From: Sami Kerola Date: Fri, 12 Dec 2014 22:46:04 +0000 (+0000) Subject: lslogins: allow changing password changed and expiration time formats X-Git-Tag: v2.26-rc1~112^2~17 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=aa45b344d374e4cb20747061b1648aead2543080;p=thirdparty%2Futil-linux.git lslogins: allow changing password changed and expiration time formats The password change and expiry has are marked with resolution of a day, so add a new short iso-8601 format. With this system admins can easily find users has not updated their password lately $ lslogins --time-format=iso --user --output=pwd-change,user | sort -n Signed-off-by: Sami Kerola --- diff --git a/login-utils/lslogins.c b/login-utils/lslogins.c index 9929b14750..f050595ea5 100644 --- a/login-utils/lslogins.c +++ b/login-utils/lslogins.c @@ -143,6 +143,7 @@ enum { TIME_SHORT, TIME_FULL, TIME_ISO, + TIME_ISO_SHORT, }; /* @@ -349,6 +350,9 @@ static char *make_time(int mode, time_t time) case TIME_ISO: strftime(buf, sizeof(buf), "%Y-%m-%dT%H:%M:%S%z", &tm); break; + case TIME_ISO_SHORT: + strftime(buf, sizeof(buf), "%Y-%m-%d", &tm); + break; default: errx(EXIT_FAILURE, _("unsupported time type")); } @@ -693,7 +697,8 @@ static struct lslogins_user *get_user_info(struct lslogins_control *ctl, const c break; case COL_PWD_EXPIR: if (shadow && shadow->sp_expire >= 0) - user->pwd_expire = make_time(TIME_SHORT, + user->pwd_expire = make_time(ctl->time_mode == TIME_ISO ? + TIME_ISO_SHORT : ctl->time_mode, shadow->sp_expire * 86400); break; case COL_PWD_CTIME: @@ -701,7 +706,8 @@ static struct lslogins_user *get_user_info(struct lslogins_control *ctl, const c * (especially in non-GMT timezones) would only serve * to confuse */ if (shadow) - user->pwd_ctime = make_time(TIME_SHORT, + user->pwd_ctime = make_time(ctl->time_mode == TIME_ISO ? + TIME_ISO_SHORT : ctl->time_mode, shadow->sp_lstchg * 86400); break; case COL_PWD_CTIME_MIN: