alan@drivax.UUCP (Alan Fargusson) (09/17/85)
Here is a modified version of one of the 'lock terminal' programs which I changed to work with System V. It disables signal processing and layer switching with an ioctl to prevent any escaping from the lock. ------------------------- cut here ------------------------- /* Lock a terminal which is not in use. Give own password to unlock */ #include <signal.h> #include <stdio.h> #include <pwd.h> #include <termio.h> #define BELL 007 struct passwd *getpwuid(); struct termio old, new; main() { int t; char *pass; char pwbuf[10]; char *getpass(); char *strcpy(); char *crypt(); char *pw; register struct passwd *pwd; /* get password entry */ pwd = getpwuid(getuid()); /* save old termio, and disable signals (and layer switching) */ ioctl( 0, TCGETA, &old ); new = old; new.c_lflag &= ~ISIG; ioctl( 0, TCSETAW, &new ); /* loop here to wait for correct password */ while (1) { strcpy(pwbuf, getpass("Password:")); pw = crypt(pwbuf, pwd->pw_passwd); if(strcmp(pw, pwd->pw_passwd) == 0) break; putchar(BELL); fflush(stdout); } /* restore termio modes */ ioctl( 0, TCSETAW, &old ); } ------------------------- cut here ------------------------- -- Alan Fargusson. { ihnp4, amdahl, mot }!drivax!alan