summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorschwarze <schwarze@openbsd.org>2019-07-24 20:23:09 +0000
committerschwarze <schwarze@openbsd.org>2019-07-24 20:23:09 +0000
commitf6462fb5afa7997dc3ec8c412166460be4dfaaf2 (patch)
tree2ead35f38a2d7f7a9e17695b08221d93c23902e6
parentTwo problems: (diff)
downloadwireguard-openbsd-f6462fb5afa7997dc3ec8c412166460be4dfaaf2.tar.xz
wireguard-openbsd-f6462fb5afa7997dc3ec8c412166460be4dfaaf2.zip
Make sure that -n overrides -t even when -n precedes -t, like it
does in FreeBSD and in NetBSD, and fully document that behaviour. Input, feedback, and OK jca@.
-rw-r--r--usr.bin/lock/lock.119
-rw-r--r--usr.bin/lock/lock.c12
2 files changed, 22 insertions, 9 deletions
diff --git a/usr.bin/lock/lock.1 b/usr.bin/lock/lock.1
index 46e3c431b9b..62530d08c59 100644
--- a/usr.bin/lock/lock.1
+++ b/usr.bin/lock/lock.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: lock.1,v 1.19 2019/07/19 18:32:19 cheloha Exp $
+.\" $OpenBSD: lock.1,v 1.20 2019/07/24 20:23:09 schwarze Exp $
.\"
.\" Copyright (c) 1987, 1990, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -29,7 +29,7 @@
.\"
.\" @(#)lock.1 8.1 (Berkeley) 6/6/93
.\"
-.Dd $Mdocdate: July 19 2019 $
+.Dd $Mdocdate: July 24 2019 $
.Dt LOCK 1
.Os
.Sh NAME
@@ -37,7 +37,7 @@
.Nd reserve a terminal
.Sh SYNOPSIS
.Nm lock
-.Op Fl p
+.Op Fl np
.Op Fl a Ar style
.Op Fl t Ar timeout
.Sh DESCRIPTION
@@ -63,6 +63,15 @@ user may enter the name of the
.Ar style
to get the standard prompt for that
.Ar style .
+.It Fl n
+Lock the terminal forever.
+This overrides
+.Fl t
+and is the default on
+.Ox
+unless
+.Fl t
+is specified.
.It Fl p
A password is not requested, instead the user's current login password
is used.
@@ -78,7 +87,9 @@ password.
.It Fl t Ar timeout
Unlock the terminal after
.Ar timeout
-minutes.
+minutes unless
+.Fl n
+is also specified.
When used in this manner
.Nm
should be invoked so that the user is safely logged out
diff --git a/usr.bin/lock/lock.c b/usr.bin/lock/lock.c
index 0e27d637a4e..e5307fcf928 100644
--- a/usr.bin/lock/lock.c
+++ b/usr.bin/lock/lock.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lock.c,v 1.45 2019/07/21 22:44:44 jca Exp $ */
+/* $OpenBSD: lock.c,v 1.46 2019/07/24 20:23:09 schwarze Exp $ */
/* $NetBSD: lock.c,v 1.8 1996/05/07 18:32:31 jtc Exp $ */
/*
@@ -60,7 +60,7 @@ void bye(int);
void hi(int);
void usage(void);
-int no_timeout = 1; /* lock terminal forever */
+int no_timeout = 0; /* lock terminal forever */
int
main(int argc, char *argv[])
@@ -77,6 +77,7 @@ main(int argc, char *argv[])
time_t curtime;
login_cap_t *lc;
+ sectimeout = 0;
style = NULL;
usemine = 0;
memset(&timeout, 0, sizeof(timeout));
@@ -113,18 +114,19 @@ main(int argc, char *argv[])
sectimeout = strtonum(optarg, 1, INT_MAX, &errstr);
if (errstr)
errx(1, "timeout %s: %s", errstr, optarg);
- no_timeout = 0;
break;
case 'p':
usemine = 1;
break;
case 'n':
- /* backward compatibility, -n meant "lock forever" */
+ no_timeout = 1;
break;
default:
usage();
}
}
+ if (sectimeout == 0)
+ no_timeout = 1;
gethostname(hostname, sizeof(hostname));
if (usemine && lc == NULL)
@@ -249,7 +251,7 @@ bye(int signo)
void
usage(void)
{
- fprintf(stderr, "usage: %s [-p] [-a style] [-t timeout]\n",
+ fprintf(stderr, "usage: %s [-np] [-a style] [-t timeout]\n",
getprogname());
exit(1);
}