Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83 (MC840302); site erix.UUCP Path: utzoo!linus!decvax!genrad!panda!talcott!harvard!seismo!mcvax!enea!erix!mike From: mike@erix.UUCP (Mike Williams) Newsgroups: net.sources Subject: Re: Lock your terminal for lunch Message-ID: <930@erix.UUCP> Date: Tue, 10-Sep-85 10:59:08 EDT Article-I.D.: erix.930 Posted: Tue Sep 10 10:59:08 1985 Date-Received: Sat, 14-Sep-85 02:19:13 EDT References: <131@pyuxv.UUCP> <679@sfmag.UUCP> Reply-To: mike@erix.UUCP (Mike Williams) Organization: L M Ericsson, Stockholm, Sweden Lines: 42 We use this one. /* Lock a terminal which is not in use. Give own password to unlock */ #include #include #include #define BELL 007 struct passwd *getpwuid(); 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()); /* signal handling */ for (t = 1; t <= 26; t++) signal(t, SIG_IGN); /* Process will die if HUP is received - good for modem lines! */ signal(SIGHUP,SIG_DFL); /* 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) exit(0); putchar(BELL); fflush(stdout); } }