summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarel Zak2014-05-29 13:21:57 +0200
committerKarel Zak2014-05-29 13:21:57 +0200
commitea24eacc6bbbd3c8477df5c499be26846bf56547 (patch)
treeae422e858717a85cf34a9dd2ae307c17c822b006
parentlslogins: clean up password hash check (diff)
downloadkernel-qcow2-util-linux-ea24eacc6bbbd3c8477df5c499be26846bf56547.tar.gz
kernel-qcow2-util-linux-ea24eacc6bbbd3c8477df5c499be26846bf56547.tar.xz
kernel-qcow2-util-linux-ea24eacc6bbbd3c8477df5c499be26846bf56547.zip
lslogins: cleanup time formats
Signed-off-by: Karel Zak <kzak@redhat.com>
-rw-r--r--login-utils/lslogins.13
-rw-r--r--login-utils/lslogins.c54
2 files changed, 25 insertions, 32 deletions
diff --git a/login-utils/lslogins.1 b/login-utils/lslogins.1
index 249a2406e..06415eb94 100644
--- a/login-utils/lslogins.1
+++ b/login-utils/lslogins.1
@@ -66,7 +66,8 @@ treshold can also be specified explicitly (necessary for some distributions that
starting from 100, 500 - or an entirely different value - rather than 1000).
.TP
\fB\-\-time-format\fR \fItype\fP
-Display dates in short, full or iso format.
+Display dates in short, full or iso format. The default is short, this time
+format is designed to be space efficient and human readable.
.TP
\fB\-u\fR, \fB\-\-user\-accs\fR
Show user accounts. These are by the default all accounts with UID above 1000 (inclusive), with the exception of either nobody or nfsnobody (UID 65534). The UID
diff --git a/login-utils/lslogins.c b/login-utils/lslogins.c
index aa94e77db..6c5639f99 100644
--- a/login-utils/lslogins.c
+++ b/login-utils/lslogins.c
@@ -140,7 +140,6 @@ struct lslogins_user {
* */
enum {
TIME_INVALID = 0,
- TIME_SHORT_RELATIVE,
TIME_SHORT,
TIME_FULL,
TIME_ISO,
@@ -215,31 +214,31 @@ static const char *const pretty_status[] = {
static struct lslogins_coldesc coldescs[] =
{
- [COL_USER] = { "USER", N_("user name"), N_("Username"), 0.2, SCOLS_FL_NOEXTREMES },
- [COL_UID] = { "UID", N_("user ID"), "UID", 0.05, SCOLS_FL_RIGHT},
+ [COL_USER] = { "USER", N_("user name"), N_("Username"), 0.1, SCOLS_FL_NOEXTREMES },
+ [COL_UID] = { "UID", N_("user ID"), "UID", 1, SCOLS_FL_RIGHT},
[COL_PWDEMPTY] = { "PWD-EMPTY", N_("password not requiured"), N_("Password no required"), 1, SCOLS_FL_RIGHT },
[COL_PWDDENY] = { "PWD-DENY", N_("login by password disabled"), N_("Login by password disabled"), 1, SCOLS_FL_RIGHT },
[COL_PWDLOCK] = { "PWD-LOCK", N_("password defined, but locked"), N_("Password is locked"), 1, SCOLS_FL_RIGHT },
[COL_NOLOGIN] = { "NOLOGIN", N_("log in disabled by nologin(8) or pam_nologin(8)"), N_("No login"), 1, SCOLS_FL_RIGHT },
- [COL_PGRP] = { "GROUP", N_("primary group name"), N_("Primary group"), 0.2 },
- [COL_PGID] = { "GID", N_("primary group ID"), "GID", 0.05, SCOLS_FL_RIGHT },
+ [COL_PGRP] = { "GROUP", N_("primary group name"), N_("Primary group"), 0.1 },
+ [COL_PGID] = { "GID", N_("primary group ID"), "GID", 1, SCOLS_FL_RIGHT },
[COL_SGRPS] = { "SUPP-GROUPS", N_("supplementary group names"), N_("Supplementary groups"), 0.1 },
[COL_SGIDS] = { "SUPP-GIDS", N_("supplementary group IDs"), N_("Supplementary group IDs"), 0.1 },
- [COL_HOME] = { "HOMEDIR", N_("home directory"), N_("Home directory"), 0.3 },
+ [COL_HOME] = { "HOMEDIR", N_("home directory"), N_("Home directory"), 0.1 },
[COL_SHELL] = { "SHELL", N_("login shell"), N_("Shell"), 0.1 },
- [COL_GECOS] = { "GECOS", N_("full user name"), N_("Gecos field"), 0.3, SCOLS_FL_TRUNC },
- [COL_LAST_LOGIN] = { "LAST-LOGIN", N_("date of last login"), N_("Last login"), 24 },
+ [COL_GECOS] = { "GECOS", N_("full user name"), N_("Gecos field"), 0.1, SCOLS_FL_TRUNC },
+ [COL_LAST_LOGIN] = { "LAST-LOGIN", N_("date of last login"), N_("Last login"), 0.1, SCOLS_FL_RIGHT },
[COL_LAST_TTY] = { "LAST-TTY", N_("last tty used"), N_("Last terminal"), 0.05 },
- [COL_LAST_HOSTNAME] = { "LAST-HOSTNAME",N_("hostname during the last session"), N_("Last hostname"), 0.2},
- [COL_FAILED_LOGIN] = { "FAILED-LOGIN", N_("date of last failed login"), N_("Failed login"), 24 },
+ [COL_LAST_HOSTNAME] = { "LAST-HOSTNAME",N_("hostname during the last session"), N_("Last hostname"), 0.1},
+ [COL_FAILED_LOGIN] = { "FAILED-LOGIN", N_("date of last failed login"), N_("Failed login"), 0.1 },
[COL_FAILED_TTY] = { "FAILED-TTY", N_("where did the login fail?"), N_("Failed login terminal"), 0.05 },
[COL_HUSH_STATUS] = { "HUSHED", N_("User's hush settings"), N_("Hushed"), 1, SCOLS_FL_RIGHT },
- [COL_PWD_WARN] = { "PWD-WARN", N_("password warn interval"), N_("Days to passwd warning"), 24 },
- [COL_PWD_EXPIR] = { "PWD-EXPIR", N_("password expiration date"), N_("Password expiration"), 24 },
- [COL_PWD_CTIME] = { "PWD-CHANGE", N_("date of last password change"), N_("Password changed"), 24 },
- [COL_PWD_CTIME_MIN] = { "PWD-MIN", N_("number of days required between changes"), N_("Minimal change time"), 24 },
- [COL_PWD_CTIME_MAX] = { "PWD-MAX", N_("max number of days a password may remain unchanged"), N_("Maximal change time"), 24 },
- [COL_SELINUX] = { "CONTEXT", N_("the user's security context"), N_("Selinux context"), 0.4 },
+ [COL_PWD_WARN] = { "PWD-WARN", N_("password warn interval"), N_("Days to passwd warning"), 0.1 },
+ [COL_PWD_EXPIR] = { "PWD-EXPIR", N_("password expiration date"), N_("Password expiration"), 0.1 },
+ [COL_PWD_CTIME] = { "PWD-CHANGE", N_("date of last password change"), N_("Password changed"), 0.1 },
+ [COL_PWD_CTIME_MIN] = { "PWD-MIN", N_("number of days required between changes"), N_("Minimal change time"), 0.1 },
+ [COL_PWD_CTIME_MAX] = { "PWD-MAX", N_("max number of days a password may remain unchanged"), N_("Maximal change time"), 0.1 },
+ [COL_SELINUX] = { "CONTEXT", N_("the user's security context"), N_("Selinux context"), 0.1 },
[COL_NPROCS] = { "PROC", N_("Number of processes run by the user"), N_("Process count"), 1, SCOLS_FL_RIGHT },
};
@@ -298,7 +297,7 @@ static char *make_time(int mode, time_t time)
{
char *s;
struct tm tm;
- char buf[32] = {0};
+ char buf[64] = {0};
localtime_r(&time, &tm);
@@ -308,15 +307,14 @@ static char *make_time(int mode, time_t time)
if (*(s = buf + strlen(buf) - 1) == '\n')
*s = '\0';
break;
- case TIME_SHORT_RELATIVE:
- if (date_is_today(time))
- strftime(buf, 32, "%H:%M:%S", &tm);
- else /*fallthrough*/
case TIME_SHORT:
- strftime(buf, 32, "%a %b %d %Y", &tm);
+ if (date_is_today(time))
+ strftime(buf, sizeof(buf), "%H:%M:%S", &tm);
+ else
+ strftime(buf, sizeof(buf), "%b%d/%H:%M", &tm);
break;
case TIME_ISO:
- strftime(buf, 32, "%Y-%m-%dT%H:%M:%S%z", &tm);
+ strftime(buf, sizeof(buf), "%Y-%m-%dT%H:%M:%S%z", &tm);
break;
default:
errx(EXIT_FAILURE, _("unssupported time type"));
@@ -1119,7 +1117,7 @@ struct lslogins_timefmt {
};
static struct lslogins_timefmt timefmts[] = {
- { "short", TIME_SHORT_RELATIVE },
+ { "short", TIME_SHORT },
{ "full", TIME_FULL },
{ "iso", TIME_ISO },
};
@@ -1181,7 +1179,6 @@ int main(int argc, char *argv[])
OPT_WTMP,
OPT_BTMP,
OPT_NOTRUNC,
- OPT_FULLT,
OPT_TIME_FMT,
};
@@ -1190,7 +1187,6 @@ int main(int argc, char *argv[])
{ "colon-separate", no_argument, 0, 'c' },
{ "export", no_argument, 0, 'e' },
{ "failed", no_argument, 0, 'f' },
- { "fulltimes", no_argument, 0, OPT_FULLT },
{ "groups", required_argument, 0, 'g' },
{ "help", no_argument, 0, 'h' },
{ "logins", required_argument, 0, 'l' },
@@ -1219,7 +1215,6 @@ int main(int argc, char *argv[])
static const ul_excl_t excl[] = { /* rows and cols in ASCII order */
{ 'c','e','n','r','z' },
- { 'i', OPT_FULLT, OPT_TIME_FMT },
{ 0 }
};
int excl_st[ARRAY_SIZE(excl)] = UL_EXCL_STATUS_INIT;
@@ -1229,7 +1224,7 @@ int main(int argc, char *argv[])
textdomain(PACKAGE);
atexit(close_stdout);
- ctl->time_mode = TIME_SHORT_RELATIVE;
+ ctl->time_mode = TIME_SHORT;
while ((c = getopt_long(argc, argv, "acefg:hl:mno:rsuxzZ",
longopts, NULL)) != -1) {
@@ -1310,9 +1305,6 @@ int main(int argc, char *argv[])
case OPT_NOTRUNC:
coldescs[COL_GECOS].flag = 0;
break;
- case OPT_FULLT:
- ctl->time_mode = TIME_FULL;
- break;
case OPT_TIME_FMT:
{
size_t i;