Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/lock Add new option "-n" to disable lock timeout. Pa...
details: https://anonhg.NetBSD.org/src/rev/ac4b559a6765
branches: trunk
changeset: 474058:ac4b559a6765
user: tron <tron%NetBSD.org@localhost>
date: Sun Jun 27 10:00:36 1999 +0000
description:
Add new option "-n" to disable lock timeout. Patch supplied by "The Man"
in PR bin/7816.
diffstat:
usr.bin/lock/lock.1 | 7 +++++--
usr.bin/lock/lock.c | 33 ++++++++++++++++++++++++---------
2 files changed, 29 insertions(+), 11 deletions(-)
diffs (112 lines):
diff -r 73e151a5a4da -r ac4b559a6765 usr.bin/lock/lock.1
--- a/usr.bin/lock/lock.1 Sun Jun 27 06:18:33 1999 +0000
+++ b/usr.bin/lock/lock.1 Sun Jun 27 10:00:36 1999 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: lock.1,v 1.5 1997/10/19 04:15:39 lukem Exp $
+.\" $NetBSD: lock.1,v 1.6 1999/06/27 10:00:36 tron Exp $
.\"
.\" Copyright (c) 1987, 1990, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -41,7 +41,7 @@
.Nd reserve a terminal
.Sh SYNOPSIS
.Nm
-.Op Fl p
+.Op Fl np
.Op Fl t Ar timeout
.Sh DESCRIPTION
.Nm
@@ -55,6 +55,9 @@
Options:
.Pp
.Bl -tag -width Fl
+.It Fl n
+No timeout is used. The terminal will be locked indefinitely or until
+current challenge is met.
.It Fl p
A password is not requested, instead the user's current login password
is used.
diff -r 73e151a5a4da -r ac4b559a6765 usr.bin/lock/lock.c
--- a/usr.bin/lock/lock.c Sun Jun 27 06:18:33 1999 +0000
+++ b/usr.bin/lock/lock.c Sun Jun 27 10:00:36 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lock.c,v 1.16 1998/12/19 19:30:57 christos Exp $ */
+/* $NetBSD: lock.c,v 1.17 1999/06/27 10:00:36 tron Exp $ */
/*
* Copyright (c) 1980, 1987, 1993
@@ -46,7 +46,7 @@
#if 0
static char sccsid[] = "@(#)lock.c 8.1 (Berkeley) 6/6/93";
#endif
-__RCSID("$NetBSD: lock.c,v 1.16 1998/12/19 19:30:57 christos Exp $");
+__RCSID("$NetBSD: lock.c,v 1.17 1999/06/27 10:00:36 tron Exp $");
#endif /* not lint */
/*
@@ -88,6 +88,7 @@
struct timeval timeout;
struct timeval zerotime;
struct termios tty, ntty;
+int notimeout; /* no timeout at all */
long nexttime; /* keep the timeout time */
int
@@ -111,12 +112,16 @@
setuid(getuid()); /* discard privs */
+ notimeout = 0;
sectimeout = TIMEOUT;
mypw = NULL;
usemine = 0;
- while ((ch = getopt(argc, argv, "pt:")) != -1)
+ while ((ch = getopt(argc, argv, "npt:")) != -1)
switch ((char)ch) {
+ case 'n':
+ notimeout = 1;
+ break;
case 't':
if ((sectimeout = atoi(optarg)) <= 0)
errx(1, "illegal timeout value: %s", optarg);
@@ -181,15 +186,23 @@
(void)signal(SIGINT, hi);
(void)signal(SIGQUIT, hi);
(void)signal(SIGTSTP, hi);
- (void)signal(SIGALRM, bye);
- ntimer.it_interval = zerotime;
- ntimer.it_value = timeout;
- setitimer(ITIMER_REAL, &ntimer, &otimer);
+ if (notimeout) {
+ (void)signal(SIGALRM, hi);
+ (void)printf("lock: %s on %s. no timeout.\ntime now is %.20s%s%s",
+ ttynam, hostname, ap, tzn, ap + 19);
+ }
+ else {
+ (void)signal(SIGALRM, bye);
- /* header info */
+ ntimer.it_interval = zerotime;
+ ntimer.it_value = timeout;
+ setitimer(ITIMER_REAL, &ntimer, &otimer);
+
+ /* header info */
(void)printf("lock: %s on %s. timeout in %d minutes\ntime now is %.20s%s%s",
ttynam, hostname, sectimeout, ap, tzn, ap + 19);
+ }
for (;;) {
(void)printf("Key: ");
@@ -254,7 +267,9 @@
{
struct timeval timval;
- if (!gettimeofday(&timval, (struct timezone *)NULL))
+ if (notimeout)
+ (void)printf("lock: type in the unlock key.\n");
+ else if (!gettimeofday(&timval, (struct timezone *)NULL))
(void)printf("lock: type in the unlock key. timeout in %ld:%ld minutes\n",
(nexttime - timval.tv_sec) / 60, (nexttime - timval.tv_sec) % 60);
}
Home |
Main Index |
Thread Index |
Old Index