Finger logging program

Christopher R Volpe volpe at camelback.crd.ge.com
Fri Apr 12 06:52:56 AEST 1991


In article <1991Apr10.001954.27707 at agate.berkeley.edu>,
c60b-1eq at e260-3e.berkeley.edu (Noam Mendelson) writes:
|>If anyone knows of a more generic type program which logs finger attempts,
|>please post it or refer readers of this newsgroup to the appropriate
|>FTP site or article #.
|>
|>+==========================================================================+
|>| Noam Mendelson   ..!agate!ucbvax!web!c60b-1eq | "I haven't lost my mind, |
|>| c60b-1eq at web.Berkeley.EDU                     |  it's backed up on tape  |
|>| University of California at Berkeley          |  somewhere."             |

I hacked one up a while back. It runs on SunOS 4.x. It's a pretty ugly
hack, but it seems to do the job. (It requires that you set up your
.plan file to be a FIFO. (Type "man mknod" to see how.)
======================================================================
#include <sys/types.h>
#include <sys/file.h>
#include <sys/uio.h>
#include <stdio.h>

main()
{ int fd;
  fd_set writefds;
  int i=1;


  while (1) {
  fd=open(".plan",O_WRONLY);
  if (fd!=1) if (dup2(fd,1)== (-1)) fprintf(stderr,"Error on dup\n");

    printf("\nHello! You are the %dth person to finger me on ",i);
    fflush(stdout);
    system("hostname");
    printf("The current date is ");
    fflush(stdout);
    system("date");
    printf("\nHere's some nice trivia for you:\n");
    fflush(stdout);
    system("/usr/games/fortune");
    fflush(stdout);

/* Send me mail indicating the request */
    system("(echo \"You have been fingered on\" `hostname` at `date`; \
             echo \"Relevant process information follows:\"; \
             ((ps -agxu; netstat) | grep finger) ) | mail -s \"Finger
notification\" \
             volpe at stp");

    printf("\nPlease finger me again sometime!\n");
    printf("*****************************************************\n");
    fflush(stdout);
    i++;
  close(fd);close(1);sleep(3);
  }
    
}
              
==================
Chris Volpe
G.E. Corporate R&D
volpecr at crd.ge.com



More information about the Comp.unix.questions mailing list