[alt.sources] The Worlds Smallest T-lock

noel@uokmax.UUCP (Bamf) (07/01/89)

/* Always one for minimalistic code, and to break up all the chatting 
   thats been going on in this froup...

   I present to you, the worlds smallest T-Lock.   

   (For those of you in non-academic envrionments, T-Lock 
    means terminal lock.  We don't all get our own.)

   Thats right, 4, count'em 4, lines of code.  7 if you count funny.         */


    /* No muss, no fuss, no trust.  No backdoors, no alarms, and no LINT.  */
   /* It uses YOUR login password, and laughs at julian fries.            */
  /*  Works for me, (On a Encore Muiltimax and SUN3 (4.2BSD)), YMMV.     */
 /*  Oh, and yes, I know that gotos are a sin, but thats the kind of    */
/*  world we live in.  Use it in good health.  Bamf-Ware In-C, (c)1989 */

#include <pwd.h>
main() {
	char *crypt(),*getpass(),*xpass=getpwuid(getuid())->pw_passwd;

	(void)sigsetmask(-1);
A:	(void)printf("\nTerminal locked by %s\n",getpwuid(getuid())->pw_name);

	if (strcmp(crypt(getpass("Login password:"),xpass),xpass)) goto A;
}

-- 
/*       "Can you do something out of this world?" -- Supertramp
----You want it should sing too?------|  noel@uokmax | csm9a!bgphp1!ngorelic
<Dis-Claimer, Dat-Claimer, to look at |    ...texsun!uokmax!tavern!anyone
 'em, you'd never know the diff...>   | "Beam me up Scotty, we're outta beer" */