This is my port of Keith Gabryelski's `finger' to linux.

The source in this archive is untouched; the patches you need to apply
are later in this README...

This is _not_ a network-aware version; try GNU finger for that (and
good luck getting that sucker to work!).

-- `Grave' Dave Gymer
dpg@cs.nott.ac.uk

NOTES:

The `ttylocs' file is in the form `ttyname:location', eg.
--------------------------
tty1:Console (vt1) [bedroom]
tty1:Console (vt2) [bedroom]
ttys1:Dialup line
--------------------------

ttyloc(1) doesn't allow you to set a terminal name.  Dunno why.

I haven't bothered to write any `what' field stuff; the Sun version
I'm used to doesn't do this, so I just conditionalized all that stuff
out.

PATCHES:

You need to apply these patches before compiling the package...

diff -cr s5finger-orig/Makefile s5finger/Makefile
*** s5finger-orig/Makefile	Tue Dec  8 22:02:35 1992
--- s5finger/Makefile	Tue Dec  8 23:03:13 1992
***************
*** 6,17 ****
  #
  
  SHELL=/bin/sh
! BINDIR=/u/local/bin
! MANDIR=/usr/man/man.LOCAL
! LIBDIR=/usr/lib/finger
! DBASEDIR=/usr/lib/finger/dbase
! NOVICEDIR=/usr/lib/finger/watson
! CFLAGS= -g
  
  all: finger ttyloc inquire bwiz
  
--- 6,17 ----
  #
  
  SHELL=/bin/sh
! BINDIR=/usr/local/bin
! MANDIR=/usr/man/man1
! LIBDIR=/usr/local/lib/finger
! DBASEDIR=/usr/local/lib/finger/dbase
! NOVICEDIR=/usr/local/lib/finger/watson
! CFLAGS= -O2 -fomit-frame-pointer -s -N
  
  all: finger ttyloc inquire bwiz
  
***************
*** 50,59 ****
  	chmod 777 $(DBASEDIR)
  	cp finger ttyloc bwiz inquire $(BINDIR)
  	cp birthday_card $(LIBDIR)
! 	chown root $(BINDIR)/finger
! 	chown bin $(BINDIR)/ttyloc
! 	chmod 4711 $(BINDIR)/finger $(BINDIR)/ttyloc
! 	-ln $(BINDIR)/finger $(BINDIR)/whois
  	-mkdir $(NOVICEDIR)
  	cp novice/* $(NOVICEDIR)
  	chmod 755 $(NOVICEDIR)
--- 50,57 ----
  	chmod 777 $(DBASEDIR)
  	cp finger ttyloc bwiz inquire $(BINDIR)
  	cp birthday_card $(LIBDIR)
! 	chmod 4755 $(BINDIR)/finger $(BINDIR)/ttyloc
! 	ln -s -f $(BINDIR)/finger $(BINDIR)/whois
  	-mkdir $(NOVICEDIR)
  	cp novice/* $(NOVICEDIR)
  	chmod 755 $(NOVICEDIR)
diff -cr s5finger-orig/bwiz.c s5finger/bwiz.c
*** s5finger-orig/bwiz.c	Tue Dec  8 22:02:35 1992
--- s5finger/bwiz.c	Tue Dec  8 22:17:19 1992
***************
*** 53,59 ****
  	fprintf(stderr,	"%s: Couldn't find database directory %s (%s).\n",
  		progname, whois_dbase_dir, puterr(errno));
      else
! 	while (read(fd, &dir, sizeof(struct direct)) == sizeof(struct direct))
  	    if (strcmp(dir.d_name, ".") && strcmp(dir.d_name, "..") &&
  		is_birthday(dir.d_name, timestr))
  		send_birthday_card(dir.d_name);
--- 53,60 ----
  	fprintf(stderr,	"%s: Couldn't find database directory %s (%s).\n",
  		progname, whois_dbase_dir, puterr(errno));
      else
! 	while (read(fd, (char *) &dir, sizeof(struct direct))
! 	       == sizeof(struct direct))
  	    if (strcmp(dir.d_name, ".") && strcmp(dir.d_name, "..") &&
  		is_birthday(dir.d_name, timestr))
  		send_birthday_card(dir.d_name);
diff -cr s5finger-orig/defs.h s5finger/defs.h
*** s5finger-orig/defs.h	Tue Dec  8 22:02:36 1992
--- s5finger/defs.h	Wed Dec  9 19:18:49 1992
***************
*** 11,17 ****
  ** finger.h
  */
  
! #define SCO_XENIX_386		/* SCO Xenix 386 machines. */
  /*#define SCO_XENIX_286		/* SCO Xenix 286 machines - NOT TESTED. */
  /*#define UNIX_PC		/* The 3B1 and 7300 machines. */
  /*#define SYSV_3B5		/* The 3B5 machine - NOT TESTED. */
--- 11,17 ----
  ** finger.h
  */
  
! /*#define SCO_XENIX_386		/* SCO Xenix 386 machines. */
  /*#define SCO_XENIX_286		/* SCO Xenix 286 machines - NOT TESTED. */
  /*#define UNIX_PC		/* The 3B1 and 7300 machines. */
  /*#define SYSV_3B5		/* The 3B5 machine - NOT TESTED. */
***************
*** 21,27 ****
--- 21,29 ----
  ** the kernel every time.
  */
  
+ #ifndef linux
  #define	NLIST_FILE	"/usr/lib/finger/nlist"
+ #endif
  
  /*
  ** WHOIS_DBASE_DIR -
***************
*** 28,42 ****
--- 30,53 ----
  ** A directory for keeping data base files on individual users.  
  */
  
+ #ifndef linux
  #define	WHOIS_DBASE_DIR	"/usr/lib/finger/dbase"
+ #else
+ #define	WHOIS_DBASE_DIR	"/usr/local/lib/finger/dbase"
+ #endif
  
  /*
+ 
  ** BIRTHDAY_CARD -
  ** The birthday that the birthday wizard will send to users at the
  ** appropriate time.
  **/
  
+ #ifndef linux
  #define BIRTHDAY_CARD	"/usr/lib/finger/birthday_card"
+ #else
+ #define BIRTHDAY_CARD	"/usr/local/lib/finger/birthday_card"
+ #endif
  
  /*
  ** PLAN_FILE -
***************
*** 66,72 ****
--- 77,87 ----
  ** How do we mail things?
  */
  
+ #ifndef linux
  #define MAILER		"/usr/bin/smail"
+ #else
+ #define MAILER		"/usr/bin/mail"
+ #endif
  
  /*
  ** Below here are things you probably do not want to change.
Only in s5finger: etc
diff -cr s5finger-orig/finger.c s5finger/finger.c
*** s5finger-orig/finger.c	Tue Dec  8 22:02:35 1992
--- s5finger/finger.c	Tue Dec  8 22:27:08 1992
***************
*** 25,37 ****
  #include <sys/dir.h>
  #include <sys/signal.h>
  #include <sys/param.h>
  #include <sys/proc.h>
  #include <sys/user.h>
  #include <sys/var.h>
  
! #ifdef NEED_NLIST.H
  #include <nlist.h>
! #endif /* NEED_NLIST.H */
  
  #include <fcntl.h>
  #include <utmp.h>
--- 25,39 ----
  #include <sys/dir.h>
  #include <sys/signal.h>
  #include <sys/param.h>
+ #ifndef linux
  #include <sys/proc.h>
  #include <sys/user.h>
  #include <sys/var.h>
+ #endif
  
! #ifdef NEED_NLIST_H
  #include <nlist.h>
! #endif /* NEED_NLIST_H */
  
  #include <fcntl.h>
  #include <utmp.h>
***************
*** 40,45 ****
--- 42,51 ----
  #include <errno.h>
  #include "finger.h"
  
+ #ifdef linux
+ #include <unistd.h>
+ #endif
+ 
  extern void setutent(), utmpname();
  
  extern char
***************
*** 65,75 ****
--- 71,83 ----
  
  char
      *progname,				/* Our name. */
+ #ifndef linux
      *kernel_file = KERNEL_FILE,		/* The kernal file. */
      *kmem_file = KMEM_FILE,		/* Kernals memory file. */
      *mem_file = MEM_FILE,		/* Physical memory file. */
      *swap_file = SWAP_FILE,		/* Swappin' file. */
      *nlist_file = NLIST_FILE,		/* Our nlist file. */
+ #endif
      *whois_dbase_dir = WHOIS_DBASE_DIR;	/* Whois data base stuff. */
  
  int
***************
*** 78,84 ****
--- 86,94 ----
      uname_length = sizeof("-Name-") - 1,   /* Current max username length. */
      gname_length = sizeof("-Group-") - 1,  /* Current max group name length. */
      flname_length = sizeof("--Full Name--") - 1, /* Current max flname len. */
+ #ifndef linux
      what_length = sizeof("-What-") - 1,	   /* Current max What length. */
+ #endif
      idle_length = sizeof("Idle") - 1,	   /* Current max idle time length. */
      ttyname_length = sizeof("-TTY-") - 1;  /* Current max TTY length. */
  
***************
*** 95,111 ****
  	fd,				/* All purpose file descriptor. */
  	options,			/* Are we processing options? */
  	status,				/* all purpose status holder. */
  	kmem,				/* File dscrptr for kernel memory. */
  	mem,				/* File dscrptr for physical memory. */
  	swap,				/* File dscrptr for swapped memory. */
  	NPROC,				/* Number of processes. */
! 	specified = FALSE,		/* User specified people to finger. */
! 	noswap = TRUE;			/* Is swap a bogus file descriptor?*/
  
      struct stat stbuf[2];		/* Couple of stat buffs to work in. */
      struct proc *proc;			/* The process table. */
      struct user *u;			/* Used to get args. */
      struct var v;			/* The var struct holds NPROC. */
      struct utmp *ut;			/* For looking up logged in users. */
      struct finger *f;			/* Pointer to list. */
  
--- 105,125 ----
  	fd,				/* All purpose file descriptor. */
  	options,			/* Are we processing options? */
  	status,				/* all purpose status holder. */
+ #ifndef linux
  	kmem,				/* File dscrptr for kernel memory. */
  	mem,				/* File dscrptr for physical memory. */
  	swap,				/* File dscrptr for swapped memory. */
  	NPROC,				/* Number of processes. */
! 	noswap = TRUE,			/* Is swap a bogus file descriptor?*/
! #endif
! 	specified = FALSE;		/* User specified people to finger. */
  
      struct stat stbuf[2];		/* Couple of stat buffs to work in. */
+ #ifndef linux
      struct proc *proc;			/* The process table. */
      struct user *u;			/* Used to get args. */
      struct var v;			/* The var struct holds NPROC. */
+ #endif
      struct utmp *ut;			/* For looking up logged in users. */
      struct finger *f;			/* Pointer to list. */
  
***************
*** 262,268 ****
  			"%s: Couldn't find database directory %s (%s).\n",
  			progname, whois_dbase_dir, puterr(errno));
  	    else
! 		while (read(fd, &dir, sizeof(struct direct)) ==
  		       sizeof(struct direct))
  		    if (strcmp(dir.d_name, ".") && strcmp(dir.d_name, ".."))
  			add_user(dir.d_name, TRUE);
--- 276,282 ----
  			"%s: Couldn't find database directory %s (%s).\n",
  			progname, whois_dbase_dir, puterr(errno));
  	    else
! 		while (read(fd, (char *) &dir, sizeof(struct direct)) ==
  		       sizeof(struct direct))
  		    if (strcmp(dir.d_name, ".") && strcmp(dir.d_name, ".."))
  			add_user(dir.d_name, TRUE);
***************
*** 336,341 ****
--- 350,356 ----
  ** If not, nlist /xenix and update it for future use.
  */
  
+ #ifndef linux
      if (stat(kernel_file, &stbuf[0]) < 0)
      {
  	fprintf(stderr, "%s: Couldn't stat kernel file %s (%s).\n", progname,
***************
*** 495,500 ****
--- 510,516 ----
  
  	f = f->next;
      }
+ #endif /* !linux */
  
  /*
  ** Ok, so we have a big table of people.  Print this pup with info
***************
*** 528,535 ****
--- 544,553 ----
  	    flname_length)
  	    flname_length = l;
  
+ #ifndef linux
  	if ((l = strnlen(f->next->what, sizeof(f->next->what))) > what_length)
  	    what_length = l;
+ #endif
  
  	if ((l = strnlen(f->next->ttyname, sizeof(f->next->ttyname))) >
  	    ttyname_length)
***************
*** 568,573 ****
--- 586,592 ----
  ** Copy bytes from kernel address space to this process.
  */
  
+ #ifndef linux
  void
  mem_copy(fd, name, caddr, kaddr, nbytes)
  char *caddr, *name;
***************
*** 583,588 ****
--- 602,608 ----
  	exit(1);
      }
  }
+ #endif
  
  /*
  ** add_user - Add a user to the linked of fingered users.  name is
***************
*** 867,872 ****
--- 887,893 ----
  ** nlist kernel for _v and write it out to nlist_file for future reference.
  */
  
+ #ifndef linux
  nlist_kernel()
  {
      int
***************
*** 944,954 ****
--- 965,977 ----
  	}
      }
  }
+ #endif
  
  /*
  ** get_what() - returns the name of program PID is currently running.
  */
  
+ #ifndef linux
  char *
  get_what(proc, NPROC, u, pid)
  int NPROC, pid;
***************
*** 973,978 ****
--- 996,1002 ----
      else
  	return u[entry].u_comm;
  }
+ #endif
  
  /*
  ** find_recent() - Find the most recently execed child process of PPID.
***************
*** 981,986 ****
--- 1005,1011 ----
  ** (proc.p_wchan != &proc);
  */
  
+ #ifndef linux
  long
  find_recent(ppid, proc, NPROC, u)
  int NPROC;
***************
*** 1013,1018 ****
--- 1038,1044 ----
      
      return ours;
  }
+ #endif
  
  /*
  ** group_name() - return a the name of the group whose group id is GID
***************
*** 1140,1146 ****
--- 1166,1176 ----
  	       uname_length, "-Name-",
  	       gname_length, "-Group-",
  	       flname_length, "--Full Name--",
+ #ifndef linux
  	       what_length, "-What-",
+ #else
+ 	       0, "",
+ #endif
  	       idle_length, "Idle",
  	       ttyname_length, "-TTY-",
  	       "-Console Location-");
***************
*** 1161,1167 ****
--- 1191,1201 ----
  	       hidename ? "" : f->next->gname,
  	       flname_length, sizeof(f->next->flname),
  	       hidename ? "" : f->next->flname,
+ #ifndef linux
  	       what_length, sizeof(f->next->what), f->next->what,
+ #else
+ 	       0, 0, "",
+ #endif
  	       idle_length, sizeof(f->next->idle), f->next->idle,
  	       f->next->messy ? ' ' : '*',
  	       ttyname_length, sizeof(f->next->ttyname), f->next->ttyname,
diff -cr s5finger-orig/finger.h s5finger/finger.h
*** s5finger-orig/finger.h	Tue Dec  8 22:02:35 1992
--- s5finger/finger.h	Tue Dec  8 22:07:04 1992
***************
*** 10,18 ****
--- 10,20 ----
  #include "ttyloc.h"
  #include "dbase.h"
  
+ #ifndef linux
  #define KMEM_FILE	"/dev/kmem"
  #define MEM_FILE	"/dev/mem"
  #define SWAP_FILE	"/dev/swap"
+ #endif
  
  #define DEFAULT_IDLE_TIME (30 * 60)
  
***************
*** 43,50 ****
--- 45,54 ----
  /*
  ** Some defines for easy access to nlist struct.
  */
+ #ifndef linux
  #define	v_addr		nl[0].n_value
  #define	proc_addr	nl[1].n_value
+ #endif
  
  /*
  ** Below are machine dependent macros and definitions.  On XENIX
***************
*** 150,155 ****
--- 154,160 ----
  ** nlist structure.
  */
  
+ #ifndef linux
  #ifdef NO_PREFIX_UNDERLINES_IN_SYMBOLS
  struct nlist nl[] =
  {
***************
*** 165,167 ****
--- 170,173 ----
      { "", },
  };
  #endif /* NO_PREFIX_UNDERLINES_IN_SYMBOLS */
+ #endif
diff -cr s5finger-orig/rots.c s5finger/rots.c
*** s5finger-orig/rots.c	Tue Dec  8 22:02:35 1992
--- s5finger/rots.c	Tue Dec  8 22:14:50 1992
***************
*** 11,18 ****
--- 11,20 ----
  #include <stdio.h>
  #include <errno.h>
  
+ #ifndef linux
  extern int errno, sys_nerr;
  extern char *sys_errlist[];
+ #endif
  extern char *malloc(), *realloc();
  
  extern *progname;
***************
*** 77,81 ****
  
      (void) sprintf(qwerty, "Unknown error %d", error);
  
!     return ((unsigned)error >= sys_nerr) ? qwerty : sys_errlist[error];
  }
--- 79,84 ----
  
      (void) sprintf(qwerty, "Unknown error %d", error);
  
!     return (((unsigned)error >= sys_nerr)
! 	    ? qwerty : (char *) sys_errlist[error]);
  }
diff -cr s5finger-orig/ttyloc.h s5finger/ttyloc.h
*** s5finger-orig/ttyloc.h	Tue Dec  8 22:02:35 1992
--- s5finger/ttyloc.h	Tue Dec  8 22:29:55 1992
***************
*** 6,13 ****
--- 6,18 ----
  ** Please keep this header.
  */
  
+ #ifndef linux
  #define TTYLOCS		"/etc/ttylocs"
  #define LTMP		"/etc/ltmp"
+ #else
+ #define TTYLOCS		"/usr/local/etc/ttylocs"
+ #define LTMP		"/usr/local/etc/ltmp"
+ #endif
  
  #define	DEFAULT_TTYLOC_FILE	".ttylocs"
  #define	TTYLOC_LENGTH		50
diff -cr s5finger-orig/ttyrots.c s5finger/ttyrots.c
*** s5finger-orig/ttyrots.c	Tue Dec  8 22:02:35 1992
--- s5finger/ttyrots.c	Wed Dec  9 18:14:31 1992
***************
*** 108,113 ****
--- 108,114 ----
      static struct ltmp lt;
      static struct utmp utbuf, *ut;
  
+ #define DEBUG
      strncpy(utbuf.ut_line, ttyname, sizeof(utbuf.ut_line));
  
      if ((ut = getutline(&utbuf)) == (struct utmp *)NULL)
***************
*** 116,122 ****
      if ((fd = open(LTMP, O_CREAT|O_RDWR, 0622)) < 0)
  	return FAIL;
  
!     while (read(fd, &lt, sizeof(struct ltmp)) == sizeof(struct ltmp))
  	if (!strcmp(lt.lt_line, ut->ut_line))
  	{
  	    lseek(fd, (long)-sizeof(struct ltmp), 1);
--- 117,124 ----
      if ((fd = open(LTMP, O_CREAT|O_RDWR, 0622)) < 0)
  	return FAIL;
  
!     while (read(fd, (char *) &lt, sizeof(struct ltmp))
! 	   == sizeof(struct ltmp))
  	if (!strcmp(lt.lt_line, ut->ut_line))
  	{
  	    lseek(fd, (long)-sizeof(struct ltmp), 1);
***************
*** 171,177 ****
  #endif /* DEBUG */
  	}
  
!     write(fd, &lt, sizeof(struct ltmp));
      close(fd);
      return OK;
  }
--- 173,179 ----
  #endif /* DEBUG */
  	}
  
!     write(fd, (char *) &lt, sizeof(struct ltmp));
      close(fd);
      return OK;
  }
***************
*** 186,192 ****
      if ((fd = open(LTMP, O_RDONLY)) < 0)
  	return (struct ltmp *)NULL;
  
!     while (read(fd, &lt, sizeof(struct ltmp)) == sizeof(struct ltmp))
  	if (!strcmp(lt.lt_line, line))
  	{
  	    close(fd);
--- 188,195 ----
      if ((fd = open(LTMP, O_RDONLY)) < 0)
  	return (struct ltmp *)NULL;
  
!     while (read(fd, (char *) &lt, sizeof(struct ltmp))
! 	   == sizeof(struct ltmp))
  	if (!strcmp(lt.lt_line, line))
  	{
  	    close(fd);
diff -cr s5finger-orig/watson s5finger/watson
*** s5finger-orig/watson	Tue Dec  8 22:02:36 1992
--- s5finger/watson	Wed Dec  9 18:29:51 1992
***************
*** 1,4 ****
! :
  #
  # watson - for the finger distribution.
  # Written by Keith Gabryelski
--- 1,4 ----
! #!/bin/sh
  #
  # watson - for the finger distribution.
  # Written by Keith Gabryelski
***************
*** 8,14 ****
  # This is an interactive data base handler for the whois database.
  #
  
! novice_directory=/usr/lib/finger/watson
  
  #
  # getyorn() - SOP, get `y' or `n' and return some status relating to them.
--- 8,14 ----
  # This is an interactive data base handler for the whois database.
  #
  
! novice_directory=/usr/local/lib/finger/watson
  
  #
  # getyorn() - SOP, get `y' or `n' and return some status relating to them.
***************
*** 380,386 ****
  birthday_novice_file="$novice_directory/birthday"
  remark_novice_file="$novice_directory/remark"
  
! quit=`stty -a | sed -n -e "s/.*quit = \([^; ]*\).*/\1/p"`
  
  trap quiter "2"
  
--- 380,386 ----
  birthday_novice_file="$novice_directory/birthday"
  remark_novice_file="$novice_directory/remark"
  
! quit=^\\
  
  trap quiter "2"
  
