summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Lindstrom <mouring@eviladmin.org>2001-06-05 19:59:08 +0000
committerBen Lindstrom <mouring@eviladmin.org>2001-06-05 19:59:08 +0000
commit1bda4c835e2fb1c8a9088f9d1011ae404ab8cd85 (patch)
tree8324d761b353f64cc150e28c51e96b27c351c0ed
parentbd0e2de8e59b4588a45a27c168e70bba95db9969 (diff)
- stevesk@cvs.openbsd.org 2001/05/19 19:43:57
[misc.c misc.h servconf.c sshd.8 sshd.c] sshd command-line arguments and configuration file options that specify time may be expressed using a sequence of the form: time[qualifier], where time is a positive integer value and qualifier is one of the following: <none>,s,m,h,d,w Examples: 600 600 seconds (10 minutes) 10m 10 minutes 1h30m 1 hour 30 minutes (90 minutes) ok markus@
-rw-r--r--ChangeLog14
-rw-r--r--misc.c64
-rw-r--r--misc.h26
-rw-r--r--servconf.c21
-rw-r--r--sshd.845
-rw-r--r--sshd.c12
6 files changed, 170 insertions, 12 deletions
diff --git a/ChangeLog b/ChangeLog
index 69a9b6f0e..c0f0510c6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -27,6 +27,18 @@
27 - markus@cvs.openbsd.org 2001/05/19 16:46:19 27 - markus@cvs.openbsd.org 2001/05/19 16:46:19
28 [ssh.1 sshd.8] 28 [ssh.1 sshd.8]
29 document MACs defaults with .Dq 29 document MACs defaults with .Dq
30 - stevesk@cvs.openbsd.org 2001/05/19 19:43:57
31 [misc.c misc.h servconf.c sshd.8 sshd.c]
32 sshd command-line arguments and configuration file options that
33 specify time may be expressed using a sequence of the form:
34 time[qualifier], where time is a positive integer value and qualifier
35 is one of the following:
36 <none>,s,m,h,d,w
37 Examples:
38 600 600 seconds (10 minutes)
39 10m 10 minutes
40 1h30m 1 hour 30 minutes (90 minutes)
41 ok markus@
30 42
3120010528 4320010528
32 - (tim) [conifgure.in] add setvbuf test needed for sftp-int.c 44 - (tim) [conifgure.in] add setvbuf test needed for sftp-int.c
@@ -5457,4 +5469,4 @@
5457 - Wrote replacements for strlcpy and mkdtemp 5469 - Wrote replacements for strlcpy and mkdtemp
5458 - Released 1.0pre1 5470 - Released 1.0pre1
5459 5471
5460$Id: ChangeLog,v 1.1233 2001/06/05 19:52:52 mouring Exp $ 5472$Id: ChangeLog,v 1.1234 2001/06/05 19:59:08 mouring Exp $
diff --git a/misc.c b/misc.c
index b0fdbe03c..208819cd2 100644
--- a/misc.c
+++ b/misc.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: misc.c,v 1.8 2001/05/11 14:59:56 markus Exp $ */ 1/* $OpenBSD: misc.c,v 1.9 2001/05/19 19:43:57 stevesk Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2000 Markus Friedl. All rights reserved. 4 * Copyright (c) 2000 Markus Friedl. All rights reserved.
@@ -25,7 +25,7 @@
25 */ 25 */
26 26
27#include "includes.h" 27#include "includes.h"
28RCSID("$OpenBSD: misc.c,v 1.8 2001/05/11 14:59:56 markus Exp $"); 28RCSID("$OpenBSD: misc.c,v 1.9 2001/05/19 19:43:57 stevesk Exp $");
29 29
30#include "misc.h" 30#include "misc.h"
31#include "log.h" 31#include "log.h"
@@ -154,6 +154,66 @@ int a2port(const char *s)
154 return port; 154 return port;
155} 155}
156 156
157#define SECONDS 1
158#define MINUTES (SECONDS * 60)
159#define HOURS (MINUTES * 60)
160#define DAYS (HOURS * 24)
161#define WEEKS (DAYS * 7)
162
163long convtime(const char *s)
164{
165 long total, secs;
166 const char *p;
167 char *endp;
168
169 errno = 0;
170 total = 0;
171 p = s;
172
173 if (p == NULL || *p == '\0')
174 return -1;
175
176 while (*p) {
177 secs = strtol(p, &endp, 10);
178 if (p == endp ||
179 (errno == ERANGE && (secs == LONG_MIN || secs == LONG_MAX)) ||
180 secs < 0)
181 return -1;
182
183 switch (*endp++) {
184 case '\0':
185 endp--;
186 case 's':
187 case 'S':
188 break;
189 case 'm':
190 case 'M':
191 secs *= MINUTES;
192 break;
193 case 'h':
194 case 'H':
195 secs *= HOURS;
196 break;
197 case 'd':
198 case 'D':
199 secs *= DAYS;
200 break;
201 case 'w':
202 case 'W':
203 secs *= WEEKS;
204 break;
205 default:
206 return -1;
207 }
208 total += secs;
209 if (total < 0)
210 return -1;
211 p = endp;
212 }
213
214 return total;
215}
216
157char * 217char *
158cleanhostname(char *host) 218cleanhostname(char *host)
159{ 219{
diff --git a/misc.h b/misc.h
index 01a736c03..086f98e0f 100644
--- a/misc.h
+++ b/misc.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: misc.h,v 1.7 2001/05/11 14:59:56 markus Exp $ */ 1/* $OpenBSD: misc.h,v 1.8 2001/05/19 19:43:57 stevesk Exp $ */
2 2
3/* 3/*
4 * Author: Tatu Ylonen <ylo@cs.hut.fi> 4 * Author: Tatu Ylonen <ylo@cs.hut.fi>
@@ -34,6 +34,30 @@ int a2port(const char *s);
34char *cleanhostname(char *host); 34char *cleanhostname(char *host);
35char *colon(char *cp); 35char *colon(char *cp);
36 36
37/*
38 * Convert a time string into seconds; format is
39 * a sequence of:
40 * time[qualifier]
41 *
42 * Valid time qualifiers are:
43 * <none> seconds
44 * s|S seconds
45 * m|M minutes
46 * h|H hours
47 * d|D days
48 * w|W weeks
49 *
50 * Examples:
51 * 90m 90 minutes
52 * 1h30m 90 minutes
53 * 2d 2 days
54 * 1w 1 week
55 *
56 * Return -1 if time string is invalid.
57 */
58
59long convtime(const char *s);
60
37/* function to assist building execv() arguments */ 61/* function to assist building execv() arguments */
38typedef struct arglist arglist; 62typedef struct arglist arglist;
39struct arglist { 63struct arglist {
diff --git a/servconf.c b/servconf.c
index 02d06bdad..2d10963c4 100644
--- a/servconf.c
+++ b/servconf.c
@@ -10,7 +10,7 @@
10 */ 10 */
11 11
12#include "includes.h" 12#include "includes.h"
13RCSID("$OpenBSD: servconf.c,v 1.80 2001/05/18 14:13:29 markus Exp $"); 13RCSID("$OpenBSD: servconf.c,v 1.81 2001/05/19 19:43:57 stevesk Exp $");
14 14
15#ifdef KRB4 15#ifdef KRB4
16#include <krb.h> 16#include <krb.h>
@@ -429,11 +429,21 @@ parse_int:
429 429
430 case sLoginGraceTime: 430 case sLoginGraceTime:
431 intptr = &options->login_grace_time; 431 intptr = &options->login_grace_time;
432 goto parse_int; 432parse_time:
433 arg = strdelim(&cp);
434 if (!arg || *arg == '\0')
435 fatal("%s line %d: missing time value.",
436 filename, linenum);
437 if ((value = convtime(arg)) == -1)
438 fatal("%s line %d: invalid time value.",
439 filename, linenum);
440 if (*intptr == -1)
441 *intptr = value;
442 break;
433 443
434 case sKeyRegenerationTime: 444 case sKeyRegenerationTime:
435 intptr = &options->key_regeneration_time; 445 intptr = &options->key_regeneration_time;
436 goto parse_int; 446 goto parse_time;
437 447
438 case sListenAddress: 448 case sListenAddress:
439 arg = strdelim(&cp); 449 arg = strdelim(&cp);
@@ -792,12 +802,15 @@ parse_flag:
792 case sBanner: 802 case sBanner:
793 charptr = &options->banner; 803 charptr = &options->banner;
794 goto parse_filename; 804 goto parse_filename;
805
795 case sClientAliveInterval: 806 case sClientAliveInterval:
796 intptr = &options->client_alive_interval; 807 intptr = &options->client_alive_interval;
797 goto parse_int; 808 goto parse_time;
809
798 case sClientAliveCountMax: 810 case sClientAliveCountMax:
799 intptr = &options->client_alive_count_max; 811 intptr = &options->client_alive_count_max;
800 goto parse_int; 812 goto parse_int;
813
801 case sPAMAuthenticationViaKbdInt: 814 case sPAMAuthenticationViaKbdInt:
802 intptr = &options->pam_authentication_via_kbd_int; 815 intptr = &options->pam_authentication_via_kbd_int;
803 goto parse_flag; 816 goto parse_flag;
diff --git a/sshd.8 b/sshd.8
index 26201528c..02960b70b 100644
--- a/sshd.8
+++ b/sshd.8
@@ -34,7 +34,7 @@
34.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 34.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
35.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36.\" 36.\"
37.\" $OpenBSD: sshd.8,v 1.123 2001/05/19 16:46:19 markus Exp $ 37.\" $OpenBSD: sshd.8,v 1.124 2001/05/19 19:43:57 stevesk Exp $
38.Dd September 25, 1999 38.Dd September 25, 1999
39.Dt SSHD 8 39.Dt SSHD 8
40.Os 40.Os
@@ -794,6 +794,49 @@ program.
794The default is 794The default is
795.Pa /usr/X11R6/bin/xauth . 795.Pa /usr/X11R6/bin/xauth .
796.El 796.El
797.Ss Time Formats
798.Pp
799.Nm
800command-line arguments and configuration file options that specify time
801may be expressed using a sequence of the form:
802.Sm off
803.Ar time Oo Ar qualifier Oc ,
804.Sm on
805where
806.Ar time
807is a positive integer value and
808.Ar qualifier
809is one of the following:
810.Pp
811.Bl -tag -width Ds -compact -offset indent
812.It Cm <none>
813seconds
814.It Cm s | Cm S
815seconds
816.It Cm m | Cm M
817minutes
818.It Cm h | Cm H
819hours
820.It Cm d | Cm D
821days
822.It Cm w | Cm W
823weeks
824.El
825.Pp
826Each member of the sequence is added together to calculate
827the total time value.
828.Pp
829Time format examples:
830.Pp
831.Bl -tag -width Ds -compact -offset indent
832.It 600
833600 seconds (10 minutes)
834.It 10m
83510 minutes
836.It 1h30m
8371 hour 30 minutes (90 minutes)
838.El
839
797.Sh LOGIN PROCESS 840.Sh LOGIN PROCESS
798When a user successfully logs in, 841When a user successfully logs in,
799.Nm 842.Nm
diff --git a/sshd.c b/sshd.c
index a20b81cca..135c08bb0 100644
--- a/sshd.c
+++ b/sshd.c
@@ -40,7 +40,7 @@
40 */ 40 */
41 41
42#include "includes.h" 42#include "includes.h"
43RCSID("$OpenBSD: sshd.c,v 1.196 2001/05/18 14:13:29 markus Exp $"); 43RCSID("$OpenBSD: sshd.c,v 1.197 2001/05/19 19:43:57 stevesk Exp $");
44 44
45#include <openssl/dh.h> 45#include <openssl/dh.h>
46#include <openssl/bn.h> 46#include <openssl/bn.h>
@@ -618,10 +618,16 @@ main(int ac, char **av)
618 } 618 }
619 break; 619 break;
620 case 'g': 620 case 'g':
621 options.login_grace_time = atoi(optarg); 621 if ((options.login_grace_time = convtime(optarg)) == -1) {
622 fprintf(stderr, "Invalid login grace time.\n");
623 exit(1);
624 }
622 break; 625 break;
623 case 'k': 626 case 'k':
624 options.key_regeneration_time = atoi(optarg); 627 if ((options.key_regeneration_time = convtime(optarg)) == -1) {
628 fprintf(stderr, "Invalid key regeneration interval.\n");
629 exit(1);
630 }
625 break; 631 break;
626 case 'h': 632 case 'h':
627 if (options.num_host_key_files >= MAX_HOSTKEYS) { 633 if (options.num_host_key_files >= MAX_HOSTKEYS) {