*BSD News Article 85651


Return to BSD News archive

Path: euryale.cc.adfa.oz.au!newshost.carno.net.au!harbinger.cc.monash.edu.au!news.cs.su.oz.au!metro!metro!munnari.OZ.AU!news.ecn.uoknor.edu!news.wildstar.net!news.sdsmt.edu!news.mid.net!mr.net!www.nntp.primenet.com!nntp.primenet.com!enews.sgi.com!news.sgi.com!news.msfc.nasa.gov!in1.nntp.cais.net!news2.cais.com!hhui
From: hhui@stardot.com (Hui-Hui Hu)
Newsgroups: comp.unix.bsd.freebsd.misc
Subject: GNU fingerd patch
Date: 24 Dec 1996 19:44:26 GMT
Organization: Arc Four
Lines: 65
Message-ID: <59pbqq$csf@news2.cais.com>
NNTP-Posting-Host: 207.176.50.17
Bcc: bson@gnu.ai.mit.edu, hhui, bug-gnu-utils@gnu.ai.mit.edu
Originator: hhui@disperse.arcfour.com
Xref: euryale.cc.adfa.oz.au comp.unix.bsd.freebsd.misc:33119

I finally installed GNU fingerd and besides free()ing nonexistent memory, 
fingers look like

User     Real Name          What    Idle  TTY  Host      Console Location
hhui     Hui-Hui Hu                       *p1 disperse  (198.26.55.74)
                                                           ^ bah.

This is because if a user logs in from an address that doesn't fit
in the utmp (16 chars) freeBSD will store it as an IP, and the
program (w, for instance) is supposed to reverse look it up. Of course,
cfingerd doesn't.

The patch is trivial, but I screw everything up, so caveats.. is GNU
fingerd still being maintained? Here's a cdiff.

*** finger-1.37-lame/lib/os.c	Tue Dec 24 14:15:35 1996
--- finger-1.37/lib/os.c	Tue Dec 24 14:14:56 1996
***************
*** 26,31 ****
--- 26,33 ----
  #include <sys/acct.h>
  #include <time.h>
  #include <packet.h>
+ #include <sys/socket.h>
+ #include <netdb.h>
  
  #ifdef HAVE_UTMPX_H
  #include <utmpx.h>
***************
*** 485,490 ****
--- 486,492 ----
  
    UTMP **result;
    int result_size = 0;
+   struct hostent *hp; u_long l;
  
  #ifndef HAVE_GETUTENT
    file = open (UTMP_FILE, O_RDONLY);
***************
*** 529,534 ****
--- 531,549 ----
  	continue;
  #endif /* sun */
  
+ #ifdef __FreeBSD__
+ if (UT(entry,ut_host)[0]) {
+  if (isdigit(UT(entry,ut_host)[0]) && 
+     (long)(l=inet_addr(UT(entry,ut_host))) != -1 &&
+     (hp=gethostbyaddr((char *)&l,sizeof(l),AF_INET))) {
+  if (hp->h_name) {
+       strncpy(UT(entry,ut_host), hp->h_name,UT_HOSTSIZE);
+       UT(entry,ut_host)[UT_HOSTSIZE-1]='\0';
+     } /* valid hostname */
+   }  /* IP addr */
+ } /* UTMP */
+ #endif
+ 
        for (i = 0; result[i]; i++)
  	{
  	  /* If the same person is logged in more than once, we are

------ cut here -----

-- 
Tung-Hui Hu / Arc Four / hhui@arcfour.com