#include #include #include #include #include #include sigjmp_buf start; void handler(sig, code, scp, addr) int sig, code; struct sigcontext *scp; char *addr; { close(1); longjmp(start, 0); } main() { int fd; fd_set writefds; setjmp(start); signal(SIGHUP.handler); signal(SIGINT, handler); signal(SIGQUIT, handler); signal(SIGPIPE, handler); while (1) { fd = open(".plan", O_WRONLY); if (fd != 1) if (dup2(fd, 1) == (-1)) fprintf(stderr, "Error on dup\n"); system("cat .plan.bak"); fflush(stdout); /* Send me mail indicating the request */ system ("(echo \"You have been fingered on `hostname` at `date`; echo Relevant process information follows:; `netstat -an | grep -i finger`\" | mail -s Finger-Alert username@machine"); fflush(stdout); close(fd); close(1); sleep(3); } }