Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 (Tek) 9/28/84 based on 9/17/84; site tekig5.UUCP Path: utzoo!watmath!clyde!burl!ulysses!mhuxr!mhuxt!houxm!vax135!cornell!uw-beaver!tektronix!tekig3!tekig5!attila From: attila@tekig5.UUCP (Wayne Knapp) Newsgroups: net.sources Subject: anti-idle Message-ID: <254@tekig5.UUCP> Date: Fri, 27-Sep-85 17:21:26 EDT Article-I.D.: tekig5.254 Posted: Fri Sep 27 17:21:26 1985 Date-Received: Sun, 29-Sep-85 08:25:21 EDT Distribution: net Organization: Tektronix, Beaverton OR Lines: 124 [] Here is a c program which shows some interesting uses of system calls and has little other value :-). It is a totally benign program doing no damage to anyone (except perhaps some overly eager system administrators who may suffer some mental damage). This program should be run from your .login file (.profile if you run --heaven forbid-- b-shell). It makes it look like your terminal has been idle for random times ranging from 0 to 99:59 hours to anyone who does w after your terminal has been idle for a short time. ----------------------------------------------------------------------- #include #include #include #include #include #include #include #define MICKEY 60 /* sleep loop */ #define MOUSE ;; char *pn; extern char *getlogin(); /* #################### main (argc, argv) #################### */ main () /* beaver dam building program for national guard */ { register char **p, *q; char *tty, *ttyname(); int i=0; signal(SIGTTOU, SIG_IGN); /* allow writting to control terminals */ signal(SIGHUP,SIG_DFL); if ( (tty = ttyname(fileno(stderr))) == NULL ) /* the name of the tty */ error("Unable to find the terminal name.\n"); if (fork()) /* exit from the parent */ exit(0); /* CHILD */ for(MOUSE) /* set idle time and then sleep */ { chkidle(tty); sleep(MICKEY); } } /* #################### chkidle(tty) #################### */ chkidle(tty) /* check to see if the terminal is idle */ char *tty; { struct stat stbuf; long clock; int seed; char *name; time_t timep[2]; /* terminal hungup, time to go */ if ( (name =getlogin()) == (char *)NULL || *name == NULL) exit(0); if ( stat(tty, &stbuf) < 0 ) error("Unable to stat the tty (%s)\n", tty); else { time(&clock); seed = clock & 255; timep[0] = clock - (random(seed) % 359940); timep[1] = clock - (random(seed) % 359940); utime(tty,timep); } } /* #################### error(fmt, args) #################### */ error(fmt, args) /* print an error message and exit */ char *fmt; { extern char *pn; char namefmt[200]; sprintf(namefmt, "%s: %s", pn, fmt); _doprnt(namefmt, &args, stderr); exit(1); } Brought to you by Super Global Mega Corp .com