summaryrefslogtreecommitdiffstats
path: root/usr.bin/getent
diff options
context:
space:
mode:
authored <ed@FreeBSD.org>2010-04-02 11:05:59 +0000
committered <ed@FreeBSD.org>2010-04-02 11:05:59 +0000
commit0e3cec01fc03abe666c04e3bfb10c74c603bc896 (patch)
tree439ada48def3b5c58a260e3f9320ac09d7868688 /usr.bin/getent
parent6095f153a8d278b211795821aea246185b86e58c (diff)
downloadFreeBSD-src-0e3cec01fc03abe666c04e3bfb10c74c603bc896.zip
FreeBSD-src-0e3cec01fc03abe666c04e3bfb10c74c603bc896.tar.gz
Change how getent utmpx works.
- Always require active, log or lastlogin to be provided. - Allow the user to provide custom filenames.
Diffstat (limited to 'usr.bin/getent')
-rw-r--r--usr.bin/getent/getent.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/usr.bin/getent/getent.c b/usr.bin/getent/getent.c
index e958665..0459cca 100644
--- a/usr.bin/getent/getent.c
+++ b/usr.bin/getent/getent.c
@@ -615,14 +615,13 @@ static int
utmpx(int argc, char *argv[])
{
const struct utmpx *ut;
- int rv = RV_OK, db;
+ const char *file = NULL;
+ int rv = RV_OK, db = 0;
assert(argc > 1);
assert(argv != NULL);
- if (argc == 2) {
- db = UTXDB_ACTIVE;
- } else if (argc == 3) {
+ if (argc == 3 || argc == 4) {
if (strcmp(argv[2], "active") == 0)
db = UTXDB_ACTIVE;
else if (strcmp(argv[2], "lastlogin") == 0)
@@ -631,15 +630,18 @@ utmpx(int argc, char *argv[])
db = UTXDB_LOG;
else
rv = RV_USAGE;
+ if (argc == 4)
+ file = argv[3];
} else {
rv = RV_USAGE;
}
if (rv == RV_USAGE) {
- fprintf(stderr, "Usage: %s utmpx [active | lastlogin | log]\n",
+ fprintf(stderr,
+ "Usage: %s utmpx active | lastlogin | log [filename]\n",
getprogname());
} else if (rv == RV_OK) {
- if (setutxdb(db, NULL) != 0)
+ if (setutxdb(db, file) != 0)
return (RV_NOTFOUND);
while ((ut = getutxent()) != NULL)
utmpxprint(ut);
OpenPOWER on IntegriCloud