From a3550f285812f652c7cd8ace74e72d09fa9a9393 Mon Sep 17 00:00:00 2001 From: ume Date: Mon, 22 Jul 2002 17:19:54 +0000 Subject: add -4 and -6 option to be able to specify an address family. Requested by: matusita MFC after: 1 week --- usr.bin/finger/finger.1 | 10 +++++++++- usr.bin/finger/finger.c | 13 +++++++++++-- usr.bin/finger/net.c | 3 ++- 3 files changed, 22 insertions(+), 4 deletions(-) (limited to 'usr.bin') diff --git a/usr.bin/finger/finger.1 b/usr.bin/finger/finger.1 index 432d762..4c00c54 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 glmpshoT +.Op Fl 46glmpshoT .Op Ar user ...\& .Op Ar user@host ...\& .Sh DESCRIPTION @@ -50,6 +50,14 @@ utility displays information about the system users. .Pp Options are: .Bl -tag -width flag +.It Fl 4 +Forces +.Nm +to use IPv4 addresses only. +.It Fl 6 +Forces +.Nm +to use IPv6 addresses only. .It Fl s Display the user's login name, real name, terminal name and write status (as a ``*'' before the terminal name if write permission is diff --git a/usr.bin/finger/finger.c b/usr.bin/finger/finger.c index 0e6c176..a695672 100644 --- a/usr.bin/finger/finger.c +++ b/usr.bin/finger/finger.c @@ -73,6 +73,8 @@ __FBSDID("$FreeBSD$"); * well as home directory, shell, mail info, and .plan/.project files. */ +#include +#include #include #include #include @@ -90,6 +92,7 @@ __FBSDID("$FreeBSD$"); DB *db; time_t now; int entries, gflag, lflag, mflag, pplan, sflag, oflag, Tflag; +sa_family_t family = PF_UNSPEC; int d_first = -1; char tbuf[1024]; @@ -107,8 +110,14 @@ option(argc, argv) optind = 1; /* reset getopt */ - while ((ch = getopt(argc, argv, "glmpshoT")) != -1) + while ((ch = getopt(argc, argv, "46glmpshoT")) != -1) switch(ch) { + case '4': + family = AF_INET; + break; + case '6': + family = AF_INET6; + break; case 'g': gflag = 1; break; @@ -144,7 +153,7 @@ option(argc, argv) static void usage() { - (void)fprintf(stderr, "usage: finger [-lmpshoT] [login ...]\n"); + (void)fprintf(stderr, "usage: finger [-46lmpshoT] [login ...]\n"); exit(1); } diff --git a/usr.bin/finger/net.c b/usr.bin/finger/net.c index 67a7087..b4df124 100644 --- a/usr.bin/finger/net.c +++ b/usr.bin/finger/net.c @@ -60,6 +60,7 @@ __FBSDID("$FreeBSD$"); extern int lflag; /* XXX finger.h? */ extern int Tflag; /* XXX finger.h? */ +extern sa_family_t family; static void cleanup(int sig);; static int do_protocol(const char *name, const struct addrinfo *ai); @@ -82,7 +83,7 @@ netfinger(name) alarm(TIME_LIMIT); hint.ai_flags = AI_CANONNAME; - hint.ai_family = PF_UNSPEC; + hint.ai_family = family; hint.ai_socktype = SOCK_STREAM; error = getaddrinfo(host, "finger", &hint, &ai0); -- cgit v1.1