1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-24 11:29:10 +00:00

add -4 and -6 option to be able to specify an address family.

Requested by:	matusita
MFC after:	1 week
This commit is contained in:
Hajimu UMEMOTO 2002-07-22 17:19:54 +00:00
parent 9b44a25f1f
commit 3daa847108
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=100521
3 changed files with 22 additions and 4 deletions

View File

@ -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

View File

@ -73,6 +73,8 @@ __FBSDID("$FreeBSD$");
* well as home directory, shell, mail info, and .plan/.project files.
*/
#include <sys/types.h>
#include <sys/socket.h>
#include <db.h>
#include <err.h>
#include <pwd.h>
@ -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);
}

View File

@ -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);