Date: Tue, 18 Jun 2002 03:53:38 -0700 (PDT) From: Mike Makonnen <makonnen@pacbell.net> To: FreeBSD-gnats-submit@FreeBSD.org Subject: bin/39462: [PATCH] add -g option to finger Message-ID: <200206181053.g5IArciX007835@kokeb.ambesa.net>
next in thread | raw e-mail | index | archive | help
>Number: 39462
>Category: bin
>Synopsis: [PATCH] add -g option to finger
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: change-request
>Submitter-Id: current-users
>Arrival-Date: Tue Jun 18 03:50:02 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator: Mike Makonnen
>Release: FreeBSD 5.0-CURRENT i386
>Organization:
>Environment:
FreeBSD kokeb.ambesa.net 5.0-CURRENT FreeBSD 5.0-CURRENT #0: Mon Jun 17 04:15:41 PDT 2002
mikem@kokeb.ambesa.net:/FreeBSD/builds/current/obj/FreeBSD/builds/current/src.orig/sys/GENERIC i386
>Description:
The following patch adds the -g option to finger. I found it in NetBSD.
This option restricts the printing of the gecos field to just the
Full Name (and not Office, Phone, etc).
>How-To-Repeat:
>Fix:
--- finger.patch begins here ---
Index: usr.bin/finger/extern.h
===================================================================
RCS file: /home/ncvs/src/usr.bin/finger/extern.h,v
retrieving revision 1.6
diff -u -r1.6 extern.h
--- usr.bin/finger/extern.h 22 Mar 2002 01:22:31 -0000 1.6
+++ usr.bin/finger/extern.h 18 Jun 2002 10:14:34 -0000
@@ -38,6 +38,7 @@
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 *);
Index: usr.bin/finger/finger.1
===================================================================
RCS file: /home/ncvs/src/usr.bin/finger/finger.1,v
retrieving revision 1.23
diff -u -r1.23 finger.1
--- usr.bin/finger/finger.1 19 Apr 2002 23:38:13 -0000 1.23
+++ usr.bin/finger/finger.1 18 Jun 2002 10:45:17 -0000
@@ -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
@@ -86,6 +86,13 @@
.Fl s
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
Index: usr.bin/finger/finger.c
===================================================================
RCS file: /home/ncvs/src/usr.bin/finger/finger.c,v
retrieving revision 1.27
diff -u -r1.27 finger.c
--- usr.bin/finger/finger.c 22 Mar 2002 01:22:31 -0000 1.27
+++ usr.bin/finger/finger.c 18 Jun 2002 10:13:27 -0000
@@ -89,7 +89,7 @@
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 @@
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;
Index: usr.bin/finger/lprint.c
===================================================================
RCS file: /home/ncvs/src/usr.bin/finger/lprint.c,v
retrieving revision 1.21
diff -u -r1.21 lprint.c
--- usr.bin/finger/lprint.c 22 Mar 2002 01:22:34 -0000 1.21
+++ usr.bin/finger/lprint.c 18 Jun 2002 10:11:39 -0000
@@ -127,6 +127,8 @@
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 @@
if (oddfield)
putchar('\n');
+no_gecos:
/*
* long format con't:
* if logged in
Index: usr.bin/finger/sprint.c
===================================================================
RCS file: /home/ncvs/src/usr.bin/finger/sprint.c,v
retrieving revision 1.19
diff -u -r1.19 sprint.c
--- usr.bin/finger/sprint.c 22 Mar 2002 01:22:34 -0000 1.19
+++ usr.bin/finger/sprint.c 18 Jun 2002 10:20:32 -0000
@@ -89,7 +89,7 @@
#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 @@
(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 @@
prphone(pn->officephone));
} else
(void)printf(" %.*s", MAXHOSTNAME, w->host);
+no_gecos:
putchar('\n');
}
}
--- finger.patch ends here ---
>Release-Note:
>Audit-Trail:
>Unformatted:
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200206181053.g5IArciX007835>
