summaryrefslogtreecommitdiffstats
path: root/usr.bin/finger
diff options
context:
space:
mode:
authormini <mini@FreeBSD.org>2002-07-02 08:00:20 +0000
committermini <mini@FreeBSD.org>2002-07-02 08:00:20 +0000
commit712f956e9e0dbe86568da5bc27fb0a75c38b84e1 (patch)
tree7246b8e210a907ac2095a88d0fe80e7eb1a1f7b9 /usr.bin/finger
parent3480b426f56630106d09d39b69abfba723b845df (diff)
downloadFreeBSD-src-712f956e9e0dbe86568da5bc27fb0a75c38b84e1.zip
FreeBSD-src-712f956e9e0dbe86568da5bc27fb0a75c38b84e1.tar.gz
Add -g option, which restricts printing of the gecos fields to just the user's
real name. PR: bin/39462 Submitted by: Mike Makonnen <makonnen@pacbell.net> Obtained from: NetBSD MFC after: 1 week
Diffstat (limited to 'usr.bin/finger')
-rw-r--r--usr.bin/finger/extern.h1
-rw-r--r--usr.bin/finger/finger.19
-rw-r--r--usr.bin/finger/finger.c7
-rw-r--r--usr.bin/finger/lprint.c3
-rw-r--r--usr.bin/finger/sprint.c8
5 files changed, 23 insertions, 5 deletions
diff --git a/usr.bin/finger/extern.h b/usr.bin/finger/extern.h
index 89219c6..8054ff4 100644
--- a/usr.bin/finger/extern.h
+++ b/usr.bin/finger/extern.h
@@ -38,6 +38,7 @@ extern char tbuf[1024]; /* Temp buffer for anybody. */
extern int entries; /* Number of people. */
extern DB *db; /* Database. */
extern int d_first;
+extern int gflag;
void enter_lastlog(PERSON *);
PERSON *enter_person(struct passwd *);
diff --git a/usr.bin/finger/finger.1 b/usr.bin/finger/finger.1
index ff7574d..432d762 100644
--- a/usr.bin/finger/finger.1
+++ b/usr.bin/finger/finger.1
@@ -40,7 +40,7 @@
.Nd user information lookup program
.Sh SYNOPSIS
.Nm
-.Op Fl lmpshoT
+.Op Fl glmpshoT
.Op Ar user ...\&
.Op Ar user@host ...\&
.Sh DESCRIPTION
@@ -87,6 +87,13 @@ When used in conjunction with the
option, the office location and office phone information is displayed
instead of the name of the remote host.
.Pp
+.It Fl g
+This option restricts the gecos output to only the users' real
+name. It also has the side-effect of restricting the output
+of the remote host when used in conjunction with the
+.Fl h
+option.
+.Pp
.It Fl l
Produce a multi-line format displaying all of the information
described for the
diff --git a/usr.bin/finger/finger.c b/usr.bin/finger/finger.c
index d5d38c3..0e6c176 100644
--- a/usr.bin/finger/finger.c
+++ b/usr.bin/finger/finger.c
@@ -89,7 +89,7 @@ __FBSDID("$FreeBSD$");
DB *db;
time_t now;
-int entries, lflag, mflag, pplan, sflag, oflag, Tflag;
+int entries, gflag, lflag, mflag, pplan, sflag, oflag, Tflag;
int d_first = -1;
char tbuf[1024];
@@ -107,8 +107,11 @@ option(argc, argv)
optind = 1; /* reset getopt */
- while ((ch = getopt(argc, argv, "lmpshoT")) != -1)
+ while ((ch = getopt(argc, argv, "glmpshoT")) != -1)
switch(ch) {
+ case 'g':
+ gflag = 1;
+ break;
case 'l':
lflag = 1; /* long format */
break;
diff --git a/usr.bin/finger/lprint.c b/usr.bin/finger/lprint.c
index f55b6d4..20b0306 100644
--- a/usr.bin/finger/lprint.c
+++ b/usr.bin/finger/lprint.c
@@ -127,6 +127,8 @@ lprint(pn)
pn->name, pn->realname, pn->dir);
(void)printf("\tShell: %-s\n", *pn->shell ? pn->shell : _PATH_BSHELL);
+ if (gflag)
+ goto no_gecos;
/*
* try and print office, office phone, and home phone on one line;
* if that fails, do line filling so it looks nice.
@@ -160,6 +162,7 @@ lprint(pn)
if (oddfield)
putchar('\n');
+no_gecos:
/*
* long format con't:
* if logged in
diff --git a/usr.bin/finger/sprint.c b/usr.bin/finger/sprint.c
index be7006e..b209b56 100644
--- a/usr.bin/finger/sprint.c
+++ b/usr.bin/finger/sprint.c
@@ -89,7 +89,7 @@ sflag_print()
#define MAXREALNAME 20
#define MAXHOSTNAME 17 /* in reality, hosts are never longer than 16 */
(void)printf("%-*s %-*s%s %s\n", UT_NAMESIZE, "Login", MAXREALNAME,
- "Name", " TTY Idle Login Time",
+ "Name", " TTY Idle Login Time ", (gflag) ? "" :
oflag ? "Office Phone" : "Where");
for (sflag = R_FIRST;; sflag = R_NEXT) {
@@ -143,7 +143,10 @@ sflag_print()
(void)strftime(p, sizeof(p), "%R", lc);
}
(void)printf(" %-5.5s", p);
-office: if (oflag) {
+office:
+ if (gflag)
+ goto no_gecos;
+ if (oflag) {
if (pn->office)
(void)printf(" %-7.7s", pn->office);
else if (pn->officephone)
@@ -153,6 +156,7 @@ office: if (oflag) {
prphone(pn->officephone));
} else
(void)printf(" %.*s", MAXHOSTNAME, w->host);
+no_gecos:
putchar('\n');
}
}
OpenPOWER on IntegriCloud