1*5748Sroot static char *sccsid = "@(#)lock.c 4.2 (Berkeley) 02/11/82"; 21041Sbill #include <stdio.h> 31041Sbill #include <sys/types.h> 4*5748Sroot #include <sys/stat.h> 51041Sbill #include <signal.h> 61041Sbill #include <sgtty.h> 71041Sbill 81041Sbill /* 91041Sbill * Lock a terminal up until the knowledgeable Joe returns. 101041Sbill */ 111041Sbill char masterp[] = "hasta la vista\n"; 121041Sbill struct sgttyb tty, ntty; 131041Sbill char s[BUFSIZ], s1[BUFSIZ]; 141041Sbill 151041Sbill main(argc, argv) 161041Sbill char **argv; 171041Sbill { 181041Sbill register int t; 191041Sbill struct stat statb; 201041Sbill 21*5748Sroot 22*5748Sroot /* 23*5748Sroot * Ignore signals generated from tty keyboard. These signals 24*5748Sroot * are for xBSD only. This program should be compiled with 25*5748Sroot * the jobs library (cc ... -ljobs). 26*5748Sroot */ 27*5748Sroot sigset( SIGINT, SIG_IGN ); 28*5748Sroot sigset( SIGQUIT, SIG_IGN ); 29*5748Sroot sigset( SIGTSTP, SIG_IGN ); 30*5748Sroot 311041Sbill if (argc > 0) 321041Sbill argv[0] = 0; 331041Sbill if (gtty(0, &tty)) 341041Sbill exit(1); 351041Sbill ntty = tty; ntty.sg_flags &= ~ECHO; 361041Sbill stty(0, &ntty); 371041Sbill printf("Key: "); 381041Sbill fgets(s, sizeof s, stdin); 391041Sbill printf("\nAgain: "); 401041Sbill fgets(s1, sizeof s1, stdin); 411041Sbill putchar('\n'); 421041Sbill if (strcmp(s1, s)) { 431041Sbill putchar(07); 441041Sbill stty(0, &tty); 451041Sbill exit(1); 461041Sbill } 471041Sbill s[0] = 0; 481041Sbill for (;;) { 491041Sbill fgets(s, sizeof s, stdin); 501041Sbill if (strcmp(s1, s) == 0) 511041Sbill break; 521041Sbill if (strcmp(s, masterp) == 0) 531041Sbill break; 541041Sbill putchar(07); 551041Sbill if (gtty(0, &ntty)) 561041Sbill exit(1); 571041Sbill } 581041Sbill stty(0, &tty); 591041Sbill } 60