toby@gargoyle.UChicago.UUCP (Toby Harness) (01/15/85)
# Included below is a different, perhaps improved, public domain # version of "lock". # # # Toby Harness Ogburn/Stouffer Center, University of Chicago # ...ihnp4!gargoyle!toby # # This is a shell archive. Use sh, not csh, to unbundle. echo Contents: echo '-rw-r--r-- 1 toby 1104 Jan 15 12:42 lock.c' echo '-rw-r--r-- 1 toby 445 Jan 15 13:06 lock.l' echo Extracting: sed 's/^X//' >lock.c <<'NOT_A_CUTE_SAYING-lock.c' X/* X * lock.c - lock a tty until owner returns X * X * cc lock.c -O -s -o lock X * X * Toby Harness 3/18/84 X */ X X#include <stdio.h> X#include <signal.h> X#include <pwd.h> X X#define MASTER "lock" X Xextern char *crypt(), *getpass(); Xextern struct passwd *getpwuid(), *getpwnam(); X Xmain(argc, argv) Xint argc; Xchar **argv; X{ X register int i; X char salt[3], MasterSalt[3], *in_string; X struct passwd *pw, *Masterpw; X X if((pw = getpwuid(getuid())) == NULL) { X fprintf(stderr, "%s: Who are you?\n", *argv); X exit(1); X } X if((Masterpw = getpwnam(MASTER)) == NULL) { X fprintf(stderr, "%s: can`t find passwd entry for %s\n", X *argv, MASTER); X exit(1); X } X X while(i < 19) X signal(i++, SIG_IGN); X X in_string = getpass("LOCKED\nPassword: "); X X strncpy(salt, pw->pw_passwd, 2); X strncpy(MasterSalt, Masterpw->pw_passwd, 2); X X for (;;) { X if(*in_string && X (!strcmp(pw->pw_passwd, crypt(in_string, salt)) || X !strcmp(Masterpw->pw_passwd, crypt(in_string, MasterSalt)))) X break; X in_string = getpass("Password: "); X } X} NOT_A_CUTE_SAYING-lock.c ls -l lock.c sed 's/^X//' >lock.l <<'NOT_A_CUTE_SAYING-lock.l' X.TH LOCK Local X.SH NAME Xlock \- reserve a terminal X.SH SYNOPSIS X.B lock X.SH DESCRIPTION X.I Lock Xprints "LOCKED" on Xthe screen and refuses to relinquish the terminal until Xthe user`s (login) password is entered. The user can also Xlogin elsewhere to kill the lock process. X.PP XThere exists a system master password associated with the pseudo-user X"lock" that also may be used to unlock the terminal. X.SH AUTHOR XToby Harness X.SH FILES X/etc/passwd NOT_A_CUTE_SAYING-lock.l ls -l lock.l exit 0