Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/libexec/fingerd dual-stack fingerd. Run it from inetd like:



details:   https://anonhg.NetBSD.org/src/rev/c85df623a8c3
branches:  trunk
changeset: 474242:c85df623a8c3
user:      itojun <itojun%NetBSD.org@localhost>
date:      Fri Jul 02 06:00:06 1999 +0000

description:
dual-stack fingerd.  Run it from inetd like:
>>finger  stream tcp6 nowait nobody /usr/libexec/fingerd fingerd

Single daemon on tcp6 socket will be able to serve both IPv4 and
IPv6 connections, while you can run both if you wish.

diffstat:

 libexec/fingerd/Makefile  |   4 +++-
 libexec/fingerd/fingerd.c |  20 +++++++++-----------
 2 files changed, 12 insertions(+), 12 deletions(-)

diffs (66 lines):

diff -r acac771f92a9 -r c85df623a8c3 libexec/fingerd/Makefile
--- a/libexec/fingerd/Makefile  Fri Jul 02 05:54:21 1999 +0000
+++ b/libexec/fingerd/Makefile  Fri Jul 02 06:00:06 1999 +0000
@@ -1,7 +1,9 @@
-#      $NetBSD: Makefile,v 1.7 1997/10/08 09:13:33 mrg Exp $
+#      $NetBSD: Makefile,v 1.8 1999/07/02 06:00:06 itojun Exp $
 #      from: @(#)Makefile      8.1 (Berkeley) 6/4/93
 
 PROG=  fingerd
 MAN=   fingerd.8
 
+CPPFLAGS+=-DINET6
+
 .include <bsd.prog.mk>
diff -r acac771f92a9 -r c85df623a8c3 libexec/fingerd/fingerd.c
--- a/libexec/fingerd/fingerd.c Fri Jul 02 05:54:21 1999 +0000
+++ b/libexec/fingerd/fingerd.c Fri Jul 02 06:00:06 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fingerd.c,v 1.10 1999/01/31 08:51:53 mrg Exp $ */
+/*     $NetBSD: fingerd.c,v 1.11 1999/07/02 06:00:06 itojun Exp $      */
 
 /*
  * Copyright (c) 1983, 1993
@@ -43,7 +43,7 @@
 #if 0
 static char sccsid[] = "from: @(#)fingerd.c    8.1 (Berkeley) 6/4/93";
 #else
-static char const rcsid[] = "$NetBSD: fingerd.c,v 1.10 1999/01/31 08:51:53 mrg Exp $";
+static char const rcsid[] = "$NetBSD: fingerd.c,v 1.11 1999/07/02 06:00:06 itojun Exp $";
 #endif
 #endif /* not lint */
 
@@ -72,11 +72,11 @@
        register FILE *fp;
        register int ch, ac = 2;
        register char *lp = NULL /* XXX gcc */;
-       struct hostent *hp;
-       struct sockaddr_in sin;
+       struct sockaddr_storage ss;
        int p[2], logging, no_forward, user_required, short_list, sval;
 #define        ENTRIES 50
        char **ap, *av[ENTRIES + 1], **comp, line[1024], *prog, *s;
+       char hostbuf[MAXHOSTNAMELEN];
 
        prog = _PATH_FINGER;
        logging = no_forward = user_required = short_list = 0;
@@ -119,14 +119,12 @@
 
 
        if (logging) {
-               sval = sizeof(sin);
-               if (getpeername(0, (struct sockaddr *)&sin, &sval) < 0)
+               sval = sizeof(ss);
+               if (getpeername(0, (struct sockaddr *)&ss, &sval) < 0)
                        err("getpeername: %s", strerror(errno));
-               if ((hp = gethostbyaddr((char *)&sin.sin_addr.s_addr,
-                   sizeof(sin.sin_addr.s_addr), AF_INET)))
-                       lp = hp->h_name;
-               else
-                       lp = inet_ntoa(sin.sin_addr);
+               (void)getnameinfo((struct sockaddr *)&ss, ss.__ss_len,
+                               hostbuf, sizeof(hostbuf), NULL, 0, 0);
+               lp = hostbuf;
        }
        
        if (!fgets(line, sizeof(line), stdin)) {



Home | Main Index | Thread Index | Old Index