summaryrefslogtreecommitdiffstats
path: root/login-utils/lslogins.c
diff options
context:
space:
mode:
authorKarel Zak2014-07-16 11:19:09 +0200
committerKarel Zak2014-07-16 11:19:20 +0200
commit4b6ae07123ce4ad3fbcf381db7961195f47f577c (patch)
tree049bc7ce6f0f6af7449054dcb8b4dbf4d0e29238 /login-utils/lslogins.c
parentlslogins: use bit-array, cleanup SELinux code (diff)
downloadkernel-qcow2-util-linux-4b6ae07123ce4ad3fbcf381db7961195f47f577c.tar.gz
kernel-qcow2-util-linux-4b6ae07123ce4ad3fbcf381db7961195f47f577c.tar.xz
kernel-qcow2-util-linux-4b6ae07123ce4ad3fbcf381db7961195f47f577c.zip
lslogins: add --noheadings
That's fatal mistake that this option which is required for script is missing. Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'login-utils/lslogins.c')
-rw-r--r--login-utils/lslogins.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/login-utils/lslogins.c b/login-utils/lslogins.c
index 7651f091e..96f0c70c2 100644
--- a/login-utils/lslogins.c
+++ b/login-utils/lslogins.c
@@ -265,7 +265,8 @@ struct lslogins_control {
const char *journal_path;
- unsigned int selinux_enabled : 1;
+ unsigned int selinux_enabled : 1,
+ noheadings : 1;
};
/* these have to remain global since there's no other reasonable way to pass
@@ -856,12 +857,15 @@ static int create_usertree(struct lslogins_control *ctl)
return 0;
}
-static struct libscols_table *setup_table(void)
+static struct libscols_table *setup_table(struct lslogins_control *ctl)
{
struct libscols_table *tb = scols_new_table();
int n = 0;
+
if (!tb)
- return NULL;
+ errx(EXIT_FAILURE, _("failed to initialize output table"));
+ if (ctl->noheadings)
+ scols_table_enable_noheadings(tb, 1);
switch(outmode) {
case OUT_COLON:
@@ -1094,7 +1098,7 @@ static int print_pretty(struct libscols_table *tb)
static int print_user_table(struct lslogins_control *ctl)
{
- tb = setup_table();
+ tb = setup_table(ctl);
if (!tb)
return -1;
@@ -1165,6 +1169,7 @@ static void __attribute__((__noreturn__)) usage(FILE *out)
fputs(_(" -l, --logins=<logins> display only users from <logins>\n"), out);
fputs(_(" -m, --supp-groups display supplementary groups as well\n"), out);
fputs(_(" -n, --newline display each piece of information on a new line\n"), out);
+ fputs(_(" --noheadings don't print headings\n"), out);
fputs(_(" --notruncate don't truncate output\n"), out);
fputs(_(" -o, --output[=<list>] define the columns to output\n"), out);
fputs(_(" -p, --pwd display information related to login by password.\n"), out);
@@ -1204,6 +1209,7 @@ int main(int argc, char *argv[])
OPT_WTMP,
OPT_BTMP,
OPT_NOTRUNC,
+ OPT_NOHEAD,
OPT_TIME_FMT,
};
@@ -1218,6 +1224,7 @@ int main(int argc, char *argv[])
{ "supp-groups", no_argument, 0, 'G' },
{ "newline", no_argument, 0, 'n' },
{ "notruncate", no_argument, 0, OPT_NOTRUNC },
+ { "noheadings", no_argument, 0, OPT_NOHEAD },
{ "output", required_argument, 0, 'o' },
{ "last", no_argument, 0, 'L', },
{ "raw", no_argument, 0, 'r' },
@@ -1347,6 +1354,9 @@ int main(int argc, char *argv[])
case OPT_NOTRUNC:
coldescs[COL_GECOS].flag = 0;
break;
+ case OPT_NOHEAD:
+ ctl->noheadings = 1;
+ break;
case OPT_TIME_FMT:
{
size_t i;