=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/lock/lock.c,v retrieving revision 1.5 retrieving revision 1.6 diff -c -r1.5 -r1.6 *** src/usr.bin/lock/lock.c 1996/08/06 18:10:23 1.5 --- src/usr.bin/lock/lock.c 1996/09/06 01:57:15 1.6 *************** *** 1,4 **** ! /* $OpenBSD: lock.c,v 1.5 1996/08/06 18:10:23 deraadt Exp $ */ /* $NetBSD: lock.c,v 1.8 1996/05/07 18:32:31 jtc Exp $ */ /* --- 1,4 ---- ! /* $OpenBSD: lock.c,v 1.6 1996/09/06 01:57:15 downsj Exp $ */ /* $NetBSD: lock.c,v 1.8 1996/05/07 18:32:31 jtc Exp $ */ /* *************** *** 47,53 **** #if 0 static char sccsid[] = "@(#)lock.c 8.1 (Berkeley) 6/6/93"; #endif ! static char rcsid[] = "$OpenBSD: lock.c,v 1.5 1996/08/06 18:10:23 deraadt Exp $"; #endif /* not lint */ /* --- 47,53 ---- #if 0 static char sccsid[] = "@(#)lock.c 8.1 (Berkeley) 6/6/93"; #endif ! static char rcsid[] = "$OpenBSD: lock.c,v 1.6 1996/09/06 01:57:15 downsj Exp $"; #endif /* not lint */ /* *************** *** 80,85 **** --- 80,86 ---- struct timeval zerotime; struct termios tty, ntty; long nexttime; /* keep the timeout time */ + int no_timeout; /* lock terminal forever */ /*ARGSUSED*/ main(argc, argv) *************** *** 100,110 **** sectimeout = TIMEOUT; mypw = NULL; usemine = 0; if (!(pw = getpwuid(getuid()))) errx(1, "unknown uid %d.", getuid()); ! while ((ch = getopt(argc, argv, "pt:")) != EOF) switch((char)ch) { case 't': if ((sectimeout = atoi(optarg)) <= 0) --- 101,112 ---- sectimeout = TIMEOUT; mypw = NULL; usemine = 0; + no_timeout = 0; if (!(pw = getpwuid(getuid()))) errx(1, "unknown uid %d.", getuid()); ! while ((ch = getopt(argc, argv, "npt:")) != EOF) switch((char)ch) { case 't': if ((sectimeout = atoi(optarg)) <= 0) *************** *** 114,122 **** usemine = 1; mypw = strdup(pw->pw_passwd); break; case '?': default: ! fprintf(stderr, "usage: lock [-p] [-t timeout]\n"); exit(1); } timeout.tv_sec = sectimeout * 60; --- 116,127 ---- usemine = 1; mypw = strdup(pw->pw_passwd); break; + case 'n': + no_timeout = 1; + break; case '?': default: ! fprintf(stderr, "usage: lock [-n] [-p] [-t timeout]\n"); exit(1); } timeout.tv_sec = sectimeout * 60; *************** *** 170,180 **** ntimer.it_interval = zerotime; ntimer.it_value = timeout; ! setitimer(ITIMER_REAL, &ntimer, &otimer); /* header info */ ! printf("lock: %s on %s. timeout in %d minutes\ntime now is %.20s%s%s", ! ttynam, hostname, sectimeout, ap, tzn, ap + 19); for (;;) { printf("Key: "); --- 175,191 ---- ntimer.it_interval = zerotime; ntimer.it_value = timeout; ! if (!no_timeout) ! setitimer(ITIMER_REAL, &ntimer, &otimer); /* header info */ ! if (no_timeout) { ! printf("lock: %s on %s. no timeout\ntime now is %.20s%s%s", ! ttynam, hostname, ap, tzn, ap + 19); ! } else { ! printf("lock: %s on %s. timeout in %d minutes\ntime now is %.20s%s%s", ! ttynam, hostname, sectimeout, ap, tzn, ap + 19); ! } for (;;) { printf("Key: "); *************** *** 236,244 **** { struct timeval timval; ! if (!gettimeofday(&timval, (struct timezone *)NULL)) ! printf("lock: type in the unlock key. timeout in %ld:%ld minutes\n", ! (nexttime - timval.tv_sec) / 60, (nexttime - timval.tv_sec) % 60); } void --- 247,262 ---- { struct timeval timval; ! if (!gettimeofday(&timval, (struct timezone *)NULL)) { ! (void)printf("lock: type in the unlock key. "); ! if (no_timeout) { ! putchar('\n'); ! } else { ! printf("timeout in %ld:%ld minutes\n", ! (nexttime - timval.tv_sec) / 60, ! (nexttime - timval.tv_sec) % 60); ! } ! } } void *************** *** 252,258 **** void bye() { ! (void)tcsetattr(0, TCSADRAIN, &tty); ! printf("lock: timeout\n"); ! exit(1); } --- 270,278 ---- void bye() { ! if (!no_timeout) { ! (void)tcsetattr(0, TCSADRAIN, &tty); ! printf("lock: timeout\n"); ! exit(1); ! } }