home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 2 / 2687 < prev    next >
Internet Message Format  |  1991-02-07  |  5KB

  1. From: brnstnd@kramden.acf.nyu.edu (Dan Bernstein)
  2. Newsgroups: alt.sources
  3. Subject: Unofficial patches to talk for RFC 931 support
  4. Message-ID: <19568:Feb709:49:5291@kramden.acf.nyu.edu>
  5. Date: 7 Feb 91 09:49:52 GMT
  6.  
  7. These are unofficial patches to BSD 4.3 talk (the version on
  8. gatekeeper.dec.com). They change the ``Connection established'' message
  9. to ``Connection established to user@host, authenticating...'', which
  10. rapidly changes to ``Connection established to user@host (user@host)''.
  11. The first user@host is what you typed; the second one uses RFC 931 to
  12. authenticate the connection, and will detect spoofs in what is otherwise
  13. a quite insecure system. If the remote system doesn't support RFC 931,
  14. talk will report ``unknown@host'' for the second ID.
  15.  
  16. These patches require the authuser library, part of the authd package
  17. posted here recently.
  18.  
  19. ---Dan
  20.  
  21. *** Makefile.old    Wed Sep 28 01:28:11 1988
  22. --- Makefile    Thu Feb  7 04:14:31 1991
  23. ***************
  24. *** 27,33 ****
  25.   all: talk
  26.   
  27.   talk: ${OBJS} ${LIBC}
  28. !     ${CC} -o $@ ${CFLAGS} ${OBJS} -lcurses -ltermlib
  29.   
  30.   clean:
  31.       rm -f ${OBJS} core talk
  32. --- 27,33 ----
  33.   all: talk
  34.   
  35.   talk: ${OBJS} ${LIBC}
  36. !     ${CC} -o $@ ${CFLAGS} ${OBJS} -lcurses -ltermlib -lauthuser
  37.   
  38.   clean:
  39.       rm -f ${OBJS} core talk
  40. *** io.c.old    Thu Feb  7 03:46:13 1991
  41. --- io.c    Thu Feb  7 04:34:16 1991
  42. ***************
  43. *** 29,34 ****
  44. --- 29,38 ----
  45.   #include <stdio.h>
  46.   #include <errno.h>
  47.   #include <sys/time.h>
  48. + #include <sys/types.h>
  49. + #include <netinet/in.h>
  50. + #include <arpa/inet.h>
  51. + extern char *auth_tcpuser();
  52.   
  53.   #define A_LONG_TIME 10000000
  54.   #define STDIN_MASK (1<<fileno(stdin))    /* the bit mask for standard
  55. ***************
  56. *** 35,40 ****
  57. --- 39,47 ----
  58.                          input */
  59.   extern int errno;
  60.   
  61. + char *remname;
  62. + char *remhost;
  63.   /*
  64.    * The routine to do the actual talking
  65.    */
  66. ***************
  67. *** 44,51 ****
  68.       int read_set, nb;
  69.       char buf[BUFSIZ];
  70.       struct timeval wait;
  71.   
  72. !     message("Connection established\007\007\007");
  73.       current_line = 0;
  74.       sockt_mask = (1<<sockt);
  75.   
  76. --- 51,85 ----
  77.       int read_set, nb;
  78.       char buf[BUFSIZ];
  79.       struct timeval wait;
  80. +   unsigned long in;
  81. +   struct in_addr sa;
  82. +   unsigned short local;
  83. +   unsigned short remote;
  84. +   char *user;
  85. +   char *host;
  86. +   char mess[500];
  87.   
  88. !   sprintf(mess
  89. !       ,"Connection established\007\007\007 to %.50s%s%.150s, authenticating..."
  90. !       ,remname,remhost ? "@" : "",remhost ? remhost : "");
  91. !   message(mess);
  92. !   if (auth_fd(sockt,&in,&local,&remote) == -1)
  93. !     host = user = 0; /* XXX: so f'ing impossible it's not even funny */
  94. !   else
  95. !    {
  96. !     user = auth_tcpuser(in,local,remote);
  97. !     sa.s_addr = in;
  98. !     host = inet_ntoa(sa);
  99. !    }
  100. !   if (!user) user = "unknown";
  101. !   if (!host) host = "unknown";
  102. !   sprintf(mess,"Connection established to %.50s%s%.150s (%.50s@%.50s)"
  103. !       ,remname,remhost ? "@" : "",remhost ? remhost : "",user,host);
  104. !   message(mess);
  105.       current_line = 0;
  106.       sockt_mask = (1<<sockt);
  107.   
  108. *** get_addrs.c.old    Tue Oct 11 16:42:28 1988
  109. --- get_addrs.c    Thu Feb  7 04:49:29 1991
  110. ***************
  111. *** 32,39 ****
  112.       /* look up the address of the local host */
  113.       hp = gethostbyname(my_machine_name);
  114.       if (hp == NULL) {
  115. !         fprintf(stderr, "talk: %s: ", my_machine_name);
  116. !         herror((char *)NULL);
  117.           exit(-1);
  118.       }
  119.       bcopy(hp->h_addr, (char *)&my_machine_addr, hp->h_length);
  120. --- 32,38 ----
  121.       /* look up the address of the local host */
  122.       hp = gethostbyname(my_machine_name);
  123.       if (hp == NULL) {
  124. !         fprintf(stderr, "talk: %s: unknown host\n", my_machine_name);
  125.           exit(-1);
  126.       }
  127.       bcopy(hp->h_addr, (char *)&my_machine_addr, hp->h_length);
  128. ***************
  129. *** 44,51 ****
  130.       if (strcmp(his_machine_name, my_machine_name)) {
  131.           hp = gethostbyname(his_machine_name);
  132.           if (hp == NULL) {
  133. !             fprintf(stderr, "talk: %s: ", his_machine_name);
  134. !             herror((char *)NULL);
  135.               exit(-1);
  136.           }
  137.           bcopy(hp->h_addr, (char *) &his_machine_addr, hp->h_length);
  138. --- 43,49 ----
  139.       if (strcmp(his_machine_name, my_machine_name)) {
  140.           hp = gethostbyname(his_machine_name);
  141.           if (hp == NULL) {
  142. !             fprintf(stderr, "talk: %s: unknown host\n", his_machine_name);
  143.               exit(-1);
  144.           }
  145.           bcopy(hp->h_addr, (char *) &his_machine_addr, hp->h_length);
  146. *** get_names.c.old    Wed Jun 29 23:22:35 1988
  147. --- get_names.c    Thu Feb  7 04:32:01 1991
  148. ***************
  149. *** 29,34 ****
  150. --- 29,37 ----
  151.   char    *rindex();
  152.   extern    CTL_MSG msg;
  153.   
  154. + extern char *remname; /* to print after Connection established */
  155. + extern char *remhost;
  156.   /*
  157.    * Determine the local and remote user, tty, and machines
  158.    */
  159. ***************
  160. *** 66,82 ****
  161.           ;
  162.       if (*cp == '\0') {
  163.           /* this is a local to local talk */
  164. !         his_name = argv[1];
  165.           his_machine_name = my_machine_name;
  166.       } else {
  167.           if (*cp++ == '@') {
  168.               /* user@host */
  169. !             his_name = argv[1];
  170. !             his_machine_name = cp;
  171.           } else {
  172.               /* host.user or host!user or host:user */
  173. !             his_name = cp;
  174. !             his_machine_name = argv[1];
  175.           }
  176.           *--cp = '\0';
  177.       }
  178. --- 69,86 ----
  179.           ;
  180.       if (*cp == '\0') {
  181.           /* this is a local to local talk */
  182. !         remname = his_name = argv[1];
  183.           his_machine_name = my_machine_name;
  184. +         remhost = 0;
  185.       } else {
  186.           if (*cp++ == '@') {
  187.               /* user@host */
  188. !             remname = his_name = argv[1];
  189. !             remhost = his_machine_name = cp;
  190.           } else {
  191.               /* host.user or host!user or host:user */
  192. !             remname = his_name = cp;
  193. !             remhost = his_machine_name = argv[1];
  194.           }
  195.           *--cp = '\0';
  196.       }
  197.