Unofficial patches to talk for RFC 931 support

Dan Bernstein brnstnd at kramden.acf.nyu.edu
Thu Feb 7 20:49:52 AEST 1991


These are unofficial patches to BSD 4.3 talk (the version on
gatekeeper.dec.com). They change the ``Connection established'' message
to ``Connection established to user at host, authenticating...'', which
rapidly changes to ``Connection established to user at host (user at host)''.
The first user at host is what you typed; the second one uses RFC 931 to
authenticate the connection, and will detect spoofs in what is otherwise
a quite insecure system. If the remote system doesn't support RFC 931,
talk will report ``unknown at host'' for the second ID.

These patches require the authuser library, part of the authd package
posted here recently.

---Dan

*** Makefile.old	Wed Sep 28 01:28:11 1988
--- Makefile	Thu Feb  7 04:14:31 1991
***************
*** 27,33 ****
  all: talk
  
  talk: ${OBJS} ${LIBC}
! 	${CC} -o $@ ${CFLAGS} ${OBJS} -lcurses -ltermlib
  
  clean:
  	rm -f ${OBJS} core talk
--- 27,33 ----
  all: talk
  
  talk: ${OBJS} ${LIBC}
! 	${CC} -o $@ ${CFLAGS} ${OBJS} -lcurses -ltermlib -lauthuser
  
  clean:
  	rm -f ${OBJS} core talk
*** io.c.old	Thu Feb  7 03:46:13 1991
--- io.c	Thu Feb  7 04:34:16 1991
***************
*** 29,34 ****
--- 29,38 ----
  #include <stdio.h>
  #include <errno.h>
  #include <sys/time.h>
+ #include <sys/types.h>
+ #include <netinet/in.h>
+ #include <arpa/inet.h>
+ extern char *auth_tcpuser();
  
  #define A_LONG_TIME 10000000
  #define STDIN_MASK (1<<fileno(stdin))	/* the bit mask for standard
***************
*** 35,40 ****
--- 39,47 ----
  					   input */
  extern int errno;
  
+ char *remname;
+ char *remhost;
+ 
  /*
   * The routine to do the actual talking
   */
***************
*** 44,51 ****
  	int read_set, nb;
  	char buf[BUFSIZ];
  	struct timeval wait;
  
! 	message("Connection established\007\007\007");
  	current_line = 0;
  	sockt_mask = (1<<sockt);
  
--- 51,85 ----
  	int read_set, nb;
  	char buf[BUFSIZ];
  	struct timeval wait;
+   unsigned long in;
+   struct in_addr sa;
+   unsigned short local;
+   unsigned short remote;
+   char *user;
+   char *host;
+   char mess[500];
  
!   sprintf(mess
! 	  ,"Connection established\007\007\007 to %.50s%s%.150s, authenticating..."
! 	  ,remname,remhost ? "@" : "",remhost ? remhost : "");
!   message(mess);
! 
!   if (auth_fd(sockt,&in,&local,&remote) == -1)
!     host = user = 0; /* XXX: so f'ing impossible it's not even funny */
!   else
!    {
!     user = auth_tcpuser(in,local,remote);
!     sa.s_addr = in;
!     host = inet_ntoa(sa);
!    }
! 
!   if (!user) user = "unknown";
!   if (!host) host = "unknown";
! 
!   sprintf(mess,"Connection established to %.50s%s%.150s (%.50s@%.50s)"
! 	  ,remname,remhost ? "@" : "",remhost ? remhost : "",user,host);
! 
!   message(mess);
  	current_line = 0;
  	sockt_mask = (1<<sockt);
  
*** get_addrs.c.old	Tue Oct 11 16:42:28 1988
--- get_addrs.c	Thu Feb  7 04:49:29 1991
***************
*** 32,39 ****
  	/* look up the address of the local host */
  	hp = gethostbyname(my_machine_name);
  	if (hp == NULL) {
! 		fprintf(stderr, "talk: %s: ", my_machine_name);
! 		herror((char *)NULL);
  		exit(-1);
  	}
  	bcopy(hp->h_addr, (char *)&my_machine_addr, hp->h_length);
--- 32,38 ----
  	/* look up the address of the local host */
  	hp = gethostbyname(my_machine_name);
  	if (hp == NULL) {
! 		fprintf(stderr, "talk: %s: unknown host\n", my_machine_name);
  		exit(-1);
  	}
  	bcopy(hp->h_addr, (char *)&my_machine_addr, hp->h_length);
***************
*** 44,51 ****
  	if (strcmp(his_machine_name, my_machine_name)) {
  		hp = gethostbyname(his_machine_name);
  		if (hp == NULL) {
! 			fprintf(stderr, "talk: %s: ", his_machine_name);
! 			herror((char *)NULL);
  			exit(-1);
  		}
  		bcopy(hp->h_addr, (char *) &his_machine_addr, hp->h_length);
--- 43,49 ----
  	if (strcmp(his_machine_name, my_machine_name)) {
  		hp = gethostbyname(his_machine_name);
  		if (hp == NULL) {
! 			fprintf(stderr, "talk: %s: unknown host\n", his_machine_name);
  			exit(-1);
  		}
  		bcopy(hp->h_addr, (char *) &his_machine_addr, hp->h_length);
*** get_names.c.old	Wed Jun 29 23:22:35 1988
--- get_names.c	Thu Feb  7 04:32:01 1991
***************
*** 29,34 ****
--- 29,37 ----
  char	*rindex();
  extern	CTL_MSG msg;
  
+ extern char *remname; /* to print after Connection established */
+ extern char *remhost;
+ 
  /*
   * Determine the local and remote user, tty, and machines
   */
***************
*** 66,82 ****
  		;
  	if (*cp == '\0') {
  		/* this is a local to local talk */
! 		his_name = argv[1];
  		his_machine_name = my_machine_name;
  	} else {
  		if (*cp++ == '@') {
  			/* user at host */
! 			his_name = argv[1];
! 			his_machine_name = cp;
  		} else {
  			/* host.user or host!user or host:user */
! 			his_name = cp;
! 			his_machine_name = argv[1];
  		}
  		*--cp = '\0';
  	}
--- 69,86 ----
  		;
  	if (*cp == '\0') {
  		/* this is a local to local talk */
! 		remname = his_name = argv[1];
  		his_machine_name = my_machine_name;
+ 		remhost = 0;
  	} else {
  		if (*cp++ == '@') {
  			/* user at host */
! 			remname = his_name = argv[1];
! 			remhost = his_machine_name = cp;
  		} else {
  			/* host.user or host!user or host:user */
! 			remname = his_name = cp;
! 			remhost = his_machine_name = argv[1];
  		}
  		*--cp = '\0';
  	}



More information about the Alt.sources mailing list