home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / unix / sysv386 / 12485 < prev    next >
Encoding:
Text File  |  1992-07-27  |  3.3 KB  |  133 lines

  1. Xref: sparky comp.unix.sysv386:12485 biz.sco.general:2710
  2. Newsgroups: comp.unix.sysv386,biz.sco.general
  3. Path: sparky!uunet!kithrup!sef
  4. From: sef@kithrup.COM (Sean Eric Fagan)
  5. Subject: diffs to net/2 fingerd for SCO 3.2v2
  6. Organization: Kithrup Enterprises, Ltd.
  7. Date: Mon, 27 Jul 1992 11:08:55 GMT
  8. Message-ID: <1992Jul27.110855.1458@kithrup.COM>
  9. Sender: sef@kithrup.COM (Sean Eric Fagan)
  10. Lines: 121
  11.  
  12. Here are some diffs to make the Net/2 fingerd compile and run under SCOnix,
  13. with logging via syslog.  (That was about the major extent of the changes,
  14. actually.)  Use at your own risk; I have tested somewhat, but not
  15. extensively.  If you find any bugs, please let me know, but don't expect me
  16. to rush to fix them 8-).
  17.  
  18. Diffs for the net/2 finger in the next posting.
  19.  
  20. -- snip snip --
  21. *** fingerd/Makefile.~1~    Sun Jul 26 13:54:08 1992
  22. --- fingerd/Makefile    Sun Jul 26 14:00:01 1992
  23. ***************
  24. *** 4,10 ****
  25.   MAN8=    fingerd.0
  26.   OBJS=    fingerd.o
  27.   CC=    gcc
  28. ! CFLAGS=    -g
  29.   
  30.   fingerd:    $(OBJS)
  31.       $(CC) $(CFLAGS) -o fingerd $(OBJS) $(LIBS)
  32. --- 4,11 ----
  33.   MAN8=    fingerd.0
  34.   OBJS=    fingerd.o
  35.   CC=    gcc
  36. ! CFLAGS=    -g -DLOGGING
  37. ! LIBS=    -lsocket
  38.   
  39.   fingerd:    $(OBJS)
  40.       $(CC) $(CFLAGS) -o fingerd $(OBJS) $(LIBS)
  41. *** fingerd/fingerd.c.~1~    Sun Jul 26 13:10:04 1992
  42. --- fingerd/fingerd.c    Sun Jul 26 19:55:30 1992
  43. ***************
  44. *** 43,49 ****
  45. --- 43,84 ----
  46.   
  47.   #include <stdio.h>
  48.   #include "pathnames.h"
  49. + #ifdef LOGGING
  50. + # include <syslog.h>
  51. + # include <sys/types.h>
  52. + # include <netinet/in.h>
  53. + # include <sys/socket.h>
  54. + # include <netdb.h>
  55. + #endif    /* LOGGING */
  56.   
  57. + static char *
  58. + remote_hostname (struct sockaddr_in laddr) {
  59. +   union {
  60. +     unsigned long ul;
  61. +     struct {
  62. +       unsigned char uc[4];
  63. +     } s;
  64. +   } ip_addr;
  65. +   static char ip_name[50];
  66. +   char *name;
  67. +   struct hostent *hp;
  68. + /*  ip_addr.ul = ntohl(laddr.sin_addr.s_addr); */
  69. +   ip_addr.ul = laddr.sin_addr.s_addr;
  70. +   if ((hp = gethostbyaddr ((char *)&laddr.sin_addr,
  71. +                sizeof (laddr.sin_addr),
  72. +                AF_INET)) == 0) {
  73. +     sprintf (ip_name, "[%d.%d.%d.%d]",
  74. +          ip_addr.s.uc[3],
  75. +          ip_addr.s.uc[2],
  76. +          ip_addr.s.uc[1],
  77. +          ip_addr.s.uc[0]);
  78. +     name = ip_name;
  79. +   } else
  80. +     name = hp->h_name;
  81. +   return name;
  82. + }
  83.   main()
  84.   {
  85.       register FILE *fp;
  86. ***************
  87. *** 54,60 ****
  88.       char **ap, *av[ENTRIES + 1], line[1024], *strtok();
  89.   
  90.   #ifdef LOGGING                    /* unused for now */
  91. ! #include <netinet/in.h>
  92.       struct sockaddr_in sin;
  93.       int sval;
  94.   
  95. --- 89,95 ----
  96.       char **ap, *av[ENTRIES + 1], line[1024], *strtok();
  97.   
  98.   #ifdef LOGGING                    /* unused for now */
  99. !     char *tline, *cp, *tcp;
  100.       struct sockaddr_in sin;
  101.       int sval;
  102.   
  103. ***************
  104. *** 65,70 ****
  105. --- 100,119 ----
  106.   
  107.       if (!fgets(line, sizeof(line), stdin))
  108.           exit(1);
  109. + #ifdef LOGGING
  110. +     openlog ("fingerd", LOG_PID, LOG_DAEMON);
  111. +     setlogmask (LOG_UPTO (LOG_DEBUG));
  112. +     tline = alloca (strlen (line) + 1);
  113. +     strcpy (tline, line);
  114. +     for (cp = tline; *cp; cp++) {
  115. +       if (*cp == '\n' || *cp == '\r')
  116. +         *cp = ' ';
  117. +     }
  118. +     syslog (LOG_INFO, "%s:  `%s'", remote_hostname(sin), tline);
  119. +     closelog ();
  120. + #endif    /* LOGGING */
  121.   
  122.       av[0] = "finger";
  123.       for (lp = line, ap = &av[1];;) {
  124. -- 
  125. Sean Eric Fagan  | "My psychiatrist says I have a messiah
  126. sef@kithrup.COM  |  complex.  But I forgive him."
  127. -----------------+              -- Jim Carrey
  128. Any opinions expressed are my own, and generally unpopular with others.
  129.