Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 (Tek) 9/28/84 based on 9/17/84; site teklds.UUCP Path: utzoo!watmath!clyde!bonnie!akgua!whuxlm!harpo!decvax!tektronix!teklds!dap From: dap@teklds.UUCP (Damon Permezel) Newsgroups: net.sources Subject: Lock your terminal for launch. Message-ID: <1015@teklds.UUCP> Date: Thu, 12-Sep-85 13:30:32 EDT Article-I.D.: teklds.1015 Posted: Thu Sep 12 13:30:32 1985 Date-Received: Sat, 14-Sep-85 17:09:22 EDT Distribution: net Organization: Tektronix, Beaverton OR Lines: 68 [eat me] At Waterloo, we had a nifty programme to keep turkeys from stealing ones terminal when one wasn't around (ie, gone home for the night, etc). /* * somb - intelligent 'lock' * * Author: * Damon Anton Permezel * - recreating a programme I once knew and loved */ #include #include #include #include #include #define BUFSZ 512 struct sgttyb tty, ntty; struct passwd *pwd, *getpwuid(); int somb(); main(argc, argv) char **argv; { register int t; int uid; uid = getuid(); pwd = getpwuid(uid); for (t = 1; t <= NSIG; t++) if (t != SIGHUP) signal(t, SIG_IGN); signal(SIGINT, somb); if (gtty(0, &tty)) exit(1); ntty = tty; ntty.sg_flags &= ~ECHO; stty(0, &ntty); for (;;) pause(); } somb() { char buf[BUFSZ]; signal(SIGINT, SIG_IGN); printf("Password: "); gets(buf); if (strcmp(crypt(buf, pwd->pw_passwd), pwd->pw_passwd)) { printf("\nGo away.\n"); signal(SIGINT, somb); } else { stty(0, &tty); putchar('\n'); exit(0); } }