summaryrefslogtreecommitdiffstats
path: root/login-utils/lslogins.c
diff options
context:
space:
mode:
authorSami Kerola2014-12-12 23:46:04 +0100
committerSami Kerola2014-12-19 10:11:02 +0100
commitaa45b344d374e4cb20747061b1648aead2543080 (patch)
tree224e0662d51e9c08336a0bf0e193b43731d847d0 /login-utils/lslogins.c
parentsfdisk: in the usage text show -v for --version instead of -V (diff)
downloadkernel-qcow2-util-linux-aa45b344d374e4cb20747061b1648aead2543080.tar.gz
kernel-qcow2-util-linux-aa45b344d374e4cb20747061b1648aead2543080.tar.xz
kernel-qcow2-util-linux-aa45b344d374e4cb20747061b1648aead2543080.zip
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 <kerolasa@iki.fi>
Diffstat (limited to 'login-utils/lslogins.c')
-rw-r--r--login-utils/lslogins.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/login-utils/lslogins.c b/login-utils/lslogins.c
index 9929b1475..f050595ea 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: