home *** CD-ROM | disk | FTP | other *** search
- Return-path: <armstron@cs.arizona.edu>
- Received: from optima.cs.arizona.edu by vaxb.acs.unt.edu with PMDF#10363; Thu,
- 11 Apr 1991 16:10 CST
- Received: from caslon.cs.arizona.edu by optima.cs.arizona.edu (4.1/15) id
- AA23217; Thu, 11 Apr 91 14:09:13 MST
- Received: by caslon.cs.arizona.edu; Thu, 11 Apr 91 14:09:11 -0700
- Date: Thu, 11 Apr 91 14:09:10 MST
- From: Jim Armstrong <armstron@cs.arizona.edu>
- Subject: RE: fingeree ...
- In-reply-to: <9482C88780002EE8@vaxb.acs.unt.edu>; from "christopher williams"
- at Apr 11, 91 2:46 pm
- To: CGW@vaxb.acs.unt.edu (christopher williams)
- Message-id: <9104112109.AA29387@caslon.cs.arizona.edu>
- X-Envelope-to: CGW
- X-Mailer: ELM [version 2.3 PL8]
-
- > >About a month ago there was a sample program posted to this newsgroup that
- > >set up a FIFO named pipe as your .plan file. I modified the code to set up
- > >a simple (perhaps naive) finger monitor for users on my machine. The process
- > do you still have the source for it? would you send it to me?
-
- Here is the article which appeared in comp.unix.questions a while back. It
- contains generic code that will run any program you want whenever a certain
- file is accessed (i.e. the .plan file in this case). All you have to do is
- compile it (it creates an executable called 'plan') and then to get it
- running say 'plan a.out &' where a.out is some program you have written.
- I don't have my program any more, but basically what I did was a ps au
- within that program. It used egrep to search for someone currently fingering
- me and appended the output to a file. To get really fancy you could then
- read from that file to find out exactly who it is (all in the same program)
- and print out a nice personal message to whoever is fingering you as part
- of what looks to be your .plan file. A couple of things to watch out for:
- If the finger is remote, the ps au won't find anything. Also, if two people
- finger you at the same time you may run into trouble, but I didn't try
- experimenting with this too much. I also found it helpful to timestamp a
- date to the file, too (I used localtime() for efficiency). This makes it
- easier to look back later at the file and see who's been fingering you and
- when while you were not logged on. It also helpful in debugging your program.
-
- So set up this code and experiment with different programs. Just be creative
- and see what else you can do with it. One idea I used for a while is making
- it print a different quote each time. The possibilites are endless. Enjoy.
-
- Jim
-
-
- Article 31270 of comp.unix.questions:
- Path: arizona!arizona.edu!cerritos.edu!usc!sdd.hp.com!wuarchive!uunet!unisoft!rembo
- From: rembo@unisoft.UUCP (Tony Rems)
- Newsgroups: comp.unix.questions
- Subject: Re: Finger
- Message-ID: <3391@unisoft.UUCP>
- Date: 22 Feb 91 02:44:17 GMT
- References: <37675@netnews.upenn.edu>
- Reply-To: rembo@unisoft.UUCP (Tony Rems)
- Organization: UniSoft Corporation -- UNIX R Us.
- Lines: 254
-
- In article <37675@netnews.upenn.edu> minzhi@eniac.seas.upenn.edu (Min-Zhi Shao) writes:
- >
- > When I fingered our system administrator, I got the following result:
- >
- >_________________________________________________________________________
- >Login name: gardella In real life: Ed Gardella [CETS]
- >Directory: /home/cets/gardella Shell: /usr/local/bin/bash
- >On since Feb 15 19:49:04 on ttyp1 from TSTEST.SEAS.UPEN
- >14 minutes Idle Time
- >No unread mail
- >Project: System Administrator eniac.seas.upenn.edu
- >Plan:
- > Meander about until something interesting comes along.
- >
- >Office: 154 Moore Building Work Phone: 898-2491
- > Home Phone: 387-4104
- >
- >I have been fingered 3 times today
- >_________________________________________________________________________
- >
- >the .plan file in his home directory looks like:
- >
- >prw-r--r-- 1 gardella 0 Feb 15 23:48 /home/cets/gardella/.plan
- >^
-
- As you have found out by now, I'm sure, the p means that this is
- a named pipe aka a FIFO. If you'd like to do this yourself, here
- is a little program I wrote to do it (see the comments at the
- the beginning of the plan.c file for usage info):
-
- Here's the shar of my plan program, just cut up until it says
- "cut here", and then type 'sh filename' using whatever filename
- you save it as. If you use 'plan' it will get overwritten.
-
- The code here should compile w/o any problems on any BSD machine,
- I have tried it on a Sun, Vax 750, and Pyramid 90x. It should
- also work properly on any SVR4.0 machine.
-
- The code is pretty heavily commented so it should be self
- explanatory.
-
- Note that you should put a -DFILENAME="your_home_dir/.plan"
- to get it to put your path in, or you can just edit the
- source and change the value of FILENAME permanently.
-
- If you have any problems getting it compiled, just send me mail.
-
- Enjoy.
-
- -Tony
-
- -------------------------cut-here------------------------------------
- #! /bin/sh
- # This is a shell archive. Remove anything before this line, then unpack
- # it by saving it into a file and typing "sh file". To overwrite existing
- # files, type "sh file -c". You can also feed this as standard input via
- # unshar, or by typing "sh <file", e.g.. If this archive is complete, you
- # will see the following message at the end:
- # "End of shell archive."
- # Contents: Makefile plan.c
- # Wrapped by rembo@unisoft on Mon Oct 8 10:22:34 1990
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- if test -f 'Makefile' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'Makefile'\"
- else
- echo shar: Extracting \"'Makefile'\" \(1408 characters\)
- sed "s/^X//" >'Makefile' <<'END_OF_FILE'
- DEST = /users/eng/rembo/.unisoftbin
- X
- XEXTHDRS = /usr/include/fcntl.h \
- X /usr/include/signal.h \
- X /usr/include/stdio.h \
- X /usr/include/sys/fcntl.h \
- X /usr/include/sys/file.h \
- X /usr/include/sys/stat.h \
- X /usr/include/sys/sysmacros.h \
- X /usr/include/sys/sysmacros.h \
- X /usr/include/sys/types.h \
- X /usr/include/sys/types.h
- X
- HDRS =
- X
- LDFLAGS =
- X
- LIBS =
- X
- LINKER = cc
- X
- MAKEFILE = Makefile
- X
- OBJS = plan.o
- X
- PRINT = pr
- X
- PROGRAM = plan
- X
- SRCS = plan.c
- X
- all: $(PROGRAM)
- X
- X$(PROGRAM): $(OBJS) $(LIBS)
- X @echo -n "Loading $(PROGRAM) ... "
- X @$(LINKER) $(LDFLAGS) $(OBJS) $(LIBS) -o $(PROGRAM)
- X @echo "done"
- X
- clean:; @rm -f $(OBJS)
- X
- depend:; @mkmf -f $(MAKEFILE) PROGRAM=$(PROGRAM) DEST=$(DEST)
- X
- index:; @ctags -wx $(HDRS) $(SRCS)
- X
- install: $(PROGRAM)
- X @echo Installing $(PROGRAM) in $(DEST)
- X @install -s $(PROGRAM) $(DEST)
- X
- print:; @$(PRINT) $(HDRS) $(SRCS)
- X
- program: $(PROGRAM)
- X
- tags: $(HDRS) $(SRCS); @ctags $(HDRS) $(SRCS)
- X
- update: $(DEST)/$(PROGRAM)
- X
- X$(DEST)/$(PROGRAM): $(SRCS) $(LIBS) $(HDRS) $(EXTHDRS)
- X @make -f $(MAKEFILE) DEST=$(DEST) install
- X###
- plan.o: /usr/include/sys/types.h /usr/include/sys/sysmacros.h \
- X /usr/include/sys/sysmacros.h /usr/include/sys/file.h \
- X /usr/include/sys/fcntl.h /usr/include/sys/types.h \
- X /usr/include/fcntl.h /usr/include/stdio.h /usr/include/sys/stat.h \
- X /usr/include/signal.h
- END_OF_FILE
- if test 1408 -ne `wc -c <'Makefile'`; then
- echo shar: \"'Makefile'\" unpacked with wrong size!
- fi
- # end of 'Makefile'
- fi
- if test -f 'plan.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'plan.c'\"
- else
- echo shar: Extracting \"'plan.c'\" \(2197 characters\)
- sed "s/^X//" >'plan.c' <<'END_OF_FILE'
- X
- X/* THIS IS THE UNPUBLISHED SOURCE CODE OF REMBO */
- X/* The copyright notice above does not evidence any */
- X/* actual or intended publication of such source code. */
- X/* So, use it if you like, but give me credit. */
- X
- X
- X/* Usage: plan program_name */
- X
- X
- X/* Description: */
- X
- X/* This program takes the full pathname of an */
- X/* executable and runs it on a fifo in the */
- X/* user's home directory named .plan. This */
- X/* way, when finger is executed, the output */
- X/* of the program goes to the fifo. */
- X
- X/* Written by: Tony Rems */
- X
- X/* Send bugs and flames to /dev/null or */
- X/* rembo@unisoft.com */
- X
- X#include <sys/types.h>
- X#include <sys/file.h>
- X#include <stdio.h>
- X#include <fcntl.h>
- X#include <sys/stat.h>
- X#include <signal.h>
- X
- X/* Defines */
- X#define FILENAME "/users/eng/rembo/.plan"
- X#define PERMS 0666
- X#define USAGE "%s program_name\n"
- X
- X/* Function prototypes */
- void sig_handler();
- X
- main (argc, argv)
- int argc;
- char *argv[];
- X{
- X int fd;
- X int pid;
- X int status;
- X
- X if ( argc !=2 ) {
- X fprintf (stderr, USAGE, argv[0]);
- X exit(1);
- X } /* if */
- X
- X/* Catch interrupts for cleanup */
- X signal(SIGTERM, sig_handler);
- X signal(SIGINT, sig_handler);
- X signal(SIGHUP, sig_handler);
- X
- X unlink (FILENAME);
- X
- X/* Make the fifo */
- X if ((mknod(FILENAME, S_IFIFO | PERMS, 0)) < 0 ) {
- X perror("mknod");
- X exit(2);
- X } /* if */
- X
- X while (1) {
- X if ((fd = open(FILENAME, O_WRONLY)) < 0 ) {
- X perror("open");
- X exit(3);
- X } /* if */
- X
- X/* Once our open completes we know that someone else has
- X * opened the FIFO for reading, so we can know run our
- X * program on it. So, we fork, exec our program and
- X * wait for the child to complete.
- X */
- X switch (pid = fork()) {
- X case -1:
- X perror("fork");
- X exit(4);
- X break;
- X case 0:
- X/* If we're in the child, we copy our fifo to stdout */
- X/* and exec the program given */
- X dup2(fd, 1);
- X execlp(argv[1],argv[1],(void *)NULL);
- X perror("child returned");
- X exit(5);
- X break;
- X default:
- X/* If we're in the parent, we close the pipe and wait */
- X close(fd);
- X while (wait(&status) != pid)
- X ;
- X break;
- X } /* switch */
- X sleep(2);
- X close(fd);
- X } /* while */
- X} /* main */
- X
- void sig_handler() /* cleanup */
- X{
- X unlink(FILENAME);
- X exit(0);
- X}
- END_OF_FILE
- if test 2197 -ne `wc -c <'plan.c'`; then
- echo shar: \"'plan.c'\" unpacked with wrong size!
- fi
- # end of 'plan.c'
- fi
- echo shar: End of shell archive.
- exit 0
-
-
-
-