Termnial Locking Programs
Mikel Manitius
mikel at codas.UUCP
Sun Oct 6 07:36:43 AEST 1985
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 <stdio.h>
#include <signal.h>
#include <time.h>
#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. =======
More information about the Comp.sources.unix
mailing list