[4210] in Athena Bugs

home help back first fref pref prev next nref lref last post

fingerd changes

daemon@ATHENA.MIT.EDU (John Carr)
Tue Feb 13 06:53:50 1990

To: bugs@ATHENA.MIT.EDU
Date: Tue, 13 Feb 90 06:53:34 EST
From: John Carr <jfc@ATHENA.MIT.EDU>

These are patches to fingerd that I use on the dialup servers (to report
load and optionally log connections).  If the first argument to fingerd is
"-v" it will report machine type and load before listing users.

Please let me know if and when these patches go into a release so I can take
this program off the list of changes for dialup servers.

*** fingerd.c	Fri Nov  4 15:08:58 1988
--- /src/dialup/fingerd.c	Wed Nov 29 19:28:29 1989
***************
*** 32,37 ****
--- 32,40 ----
  #include <netinet/in.h>
  #include <stdio.h>
  #include <ctype.h>
+ #if defined(DEBUG)
+ #include <syslog.h>
+ #endif
  
  main(argc, argv)
  	int argc;
***************
*** 44,54 ****
  	FILE *fp;
  	char *av[4];
  
  	i = sizeof (sin);
  	if (getpeername(0, &sin, &i) < 0)
  		fatal(argv[0], "getpeername");
! 	if (fgets(line, sizeof(line), stdin) == NULL)
  		exit(1);
  	sp = line;
  	av[0] = "finger";
  	for (i = 1;;) {
--- 47,66 ----
  	FILE *fp;
  	char *av[4];
  
+ #ifdef DEBUG
+ 	openlog("fingerd", LOG_NOWAIT, LOG_LOCAL2);
+ 	line[0] = '\0';
+ #endif
+ 
  	i = sizeof (sin);
  	if (getpeername(0, &sin, &i) < 0)
  		fatal(argv[0], "getpeername");
! 	if (fgets(line, sizeof(line), stdin) == NULL) {
! #ifdef DEBUG
! 		syslog(LOG_NOTICE, "connection closed prematurely");
! #endif
  		exit(1);
+ 	}
  	sp = line;
  	av[0] = "finger";
  	for (i = 1;;) {
***************
*** 68,73 ****
--- 80,100 ----
  		}
  	}
  	av[i] = 0;
+ #ifdef DEBUG
+ 	sin.sin_addr.s_addr = htonl(sin.sin_addr.s_addr);
+ 	{
+ 	  char buf[64];
+ 	  sprintf(buf,"%d.%d.%d.%d(%d)",
+ 		  (sin.sin_addr.s_addr&(0xff<<24))>>24,
+ 		  (sin.sin_addr.s_addr&(0xff<<16))>>16,
+ 		  (sin.sin_addr.s_addr&(0xff<<8))>>8,
+ 		  sin.sin_addr.s_addr&0xff,htons(sin.sin_port));
+ 	  if(line[0] == '\n' || line[0] == '\r')
+ 	    syslog (LOG_INFO, "Finger connection from %s",buf);
+ 	  else
+ 	    syslog (LOG_INFO, "Finger connection from %s: \"%s\"",buf,line);
+ 	}
+ #endif
  	if (pipe(p) < 0)
  		fatal(argv[0], "pipe");
  	if ((pid = fork()) == 0) {
***************
*** 76,81 ****
--- 103,126 ----
  			dup2(p[1], 1);
  			close(p[1]);
  		}
+ 		if(argc > 1 && (line[0] == '\n' || line[0] == '\r') && 
+ 		   argv[1][0] == '-' && argv[1][1] == 'v')
+ 		  {
+ #ifdef ibm032
+ 			write(1, "Machine type is IBM RT/PC\n", 26);
+ #else
+ #ifdef vax
+ 			write(1, "Machine type is VAX\n", 20);
+ #else
+ #if defined(mips) && defined(ultrix)
+ 			write(1, "Machine type is DECstation\n", 27);
+ #endif	/* mips */
+ #endif	/* vax */
+ #endif	/* rt */
+ 			write(1, "Load information:\n", 18);
+ 			system("/usr/ucb/uptime");
+ 			write(1, "\n", 1);
+ 		}
  		execv("/usr/ucb/finger", av);
  		_exit(1);
  	}
***************
*** 98,103 ****
--- 143,151 ----
  fatal(prog, s)
  	char *prog, *s;
  {
+ #ifdef DEBUG
+ 	syslog(LOG_ERR, "%s: %m", s);
+ #endif
  	fprintf(stderr, "%s: ", prog);
  	perror(s);
  	exit(1);


home help back first fref pref prev next nref lref last post