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
This commit is contained in:
parent
8b768fc82b
commit
0830bd135e
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=99249
@ -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 *);
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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');
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user