Finger
Tony Rems
rembo at unisoft.UUCP
Fri Feb 22 13:44:17 AEST 1991
In article <37675 at netnews.upenn.edu> minzhi at 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 at 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 at 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 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
More information about the Comp.unix.questions
mailing list