From 7b31a8311b0d2d4546217e9f3ce4f80604c88957 Mon Sep 17 00:00:00 2001 From: Kevin Steves Date: Mon, 10 Jun 2002 17:36:24 +0000 Subject: use convtime() to parse and validate key lifetime. can now use '-t 2h' etc. ok markus@ provos@ --- usr.bin/ssh/ssh-add.1 | 6 ++++-- usr.bin/ssh/ssh-add.c | 11 ++++++++--- 2 files changed, 12 insertions(+), 5 deletions(-) (limited to 'usr.bin') diff --git a/usr.bin/ssh/ssh-add.1 b/usr.bin/ssh/ssh-add.1 index 350d1031dcd..bbf34203dc5 100644 --- a/usr.bin/ssh/ssh-add.1 +++ b/usr.bin/ssh/ssh-add.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: ssh-add.1,v 1.33 2002/06/05 21:55:44 markus Exp $ +.\" $OpenBSD: ssh-add.1,v 1.34 2002/06/10 17:36:22 stevesk Exp $ .\" .\" -*- nroff -*- .\" @@ -90,7 +90,9 @@ Lock the agent with a password. Unlock the agent. .It Fl t Ar life Set a maximum lifetime when adding identities to an agent. -The lifetime is specified in seconds. +The lifetime may be specified in seconds or in a time format +specified in +.Xr sshd 8 . .It Fl s Ar reader Add key in smartcard .Ar reader . diff --git a/usr.bin/ssh/ssh-add.c b/usr.bin/ssh/ssh-add.c index bb1942b7536..716f6f66bc7 100644 --- a/usr.bin/ssh/ssh-add.c +++ b/usr.bin/ssh/ssh-add.c @@ -35,7 +35,7 @@ */ #include "includes.h" -RCSID("$OpenBSD: ssh-add.c,v 1.56 2002/06/05 21:55:44 markus Exp $"); +RCSID("$OpenBSD: ssh-add.c,v 1.57 2002/06/10 17:36:23 stevesk Exp $"); #include @@ -48,6 +48,7 @@ RCSID("$OpenBSD: ssh-add.c,v 1.56 2002/06/05 21:55:44 markus Exp $"); #include "authfile.h" #include "pathnames.h" #include "readpass.h" +#include "misc.h" /* argv0 */ extern char *__progname; @@ -61,7 +62,7 @@ static char *default_files[] = { }; /* Default lifetime (0 == forever) */ -static u_int lifetime = 0; +static int lifetime = 0; /* we keep a cache of one passphrases */ static char *pass = NULL; @@ -342,7 +343,11 @@ main(int argc, char **argv) sc_reader_id = optarg; break; case 't': - lifetime = atoi(optarg); + if ((lifetime = convtime(optarg)) == -1) { + fprintf(stderr, "Invalid lifetime\n"); + ret = 1; + goto done; + } break; default: usage(); -- cgit v1.2.3