Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site codas.UUCP Path: utzoo!watmath!clyde!bonnie!akgua!akguc!codas!mikel From: mikel@codas.UUCP (Mikel Manitius) Newsgroups: net.sources Subject: Termnial Locking Programs Message-ID: <146@codas.UUCP> Date: Sat, 5-Oct-85 17:36:43 EDT Article-I.D.: codas.146 Posted: Sat Oct 5 17:36:43 1985 Date-Received: Mon, 7-Oct-85 03:58:55 EDT Distribution: net Organization: AT&T Information Systems (SDSS) - Orlando Lines: 79 Since everyone seems to want a terminal locking program, I have decided to post one I threw together a while ago, Note that it has a five minute timeout, at which point it will log out out, if invoked from the login shell, or just leave your terminal unprotected if invoked from a process stack. Note that one could add a few lines of kode to make it stty the input/output speed to 0, which would cause the line to drop, unless you have a DH controller. The five minute timeout is good enough to let you run to the candy machine, get a print out, or some releif in a busy computer center. ----------begin lock.c---------- char *sccsid = "@(#)lock.c Mikel Manitius 1.0 85-10-05"; #include #include #include #define TIMEOUT 5*60 /* * lock - lock terminal until knowlegable joe returns. * * Mikel Manitius - 85-10-05 - AT&T Information Systems. * * UUCP: ...{ihnp4!akguc}!codas!mikel * ...attmail!mmanitius */ char *getpass(); timeout() { int now; struct tm *tm; struct tm *localtime(); time(&now); tm = localtime(&now); printf("\7* Lock has timed out at %d:%02d:%02d\n", tm->tm_hour, tm->tm_min, tm->tm_sec); kill(getppid(), SIGKILL); exit(1); } main() { int n; char pass[14]; char *try; alarm(TIMEOUT); alarm(TIMEOUT); signal(SIGALRM, timeout); strcpy(pass, getpass("Key:")); printf("* Terminal locked until knowlegable joe returns.\n"); signal(SIGTERM, SIG_IGN); signal(SIGQUIT, SIG_IGN); signal(SIGINT, SIG_IGN); signal(SIGHUP, SIG_IGN); for(n=0;;n++) { try = getpass("Key:"); if(!strcmp(try, pass)) break; else printf("No dice pal.\n"); } if(n > 0) printf("attempts: %d\n", n); } -----------end lock.c----------- Enjoy. -- ======= Mikel Manitius ==----===== AT&T (305) 869-2462 RNX: 755 ==------===== Information Systems ...{akguc|ihnp4}!codas!mikel ===----====== SDSS Regional Support ...attmail!mmanitius =========== Altamonte Springs, FL My opinions are my own. =======