summaryrefslogtreecommitdiff
path: root/ssh-add.c
diff options
context:
space:
mode:
authorBen Lindstrom <mouring@eviladmin.org>2002-06-06 21:54:57 +0000
committerBen Lindstrom <mouring@eviladmin.org>2002-06-06 21:54:57 +0000
commit61d328acf9d0adcb10a254d072dafa84fb14b78f (patch)
tree974cd00f825192cda0f43acf3f82579d431eab5a /ssh-add.c
parent163f3b8f6be475e4fc28358846d0bed7bf0587e4 (diff)
- markus@cvs.openbsd.org 2002/06/05 21:55:44
[authfd.c authfd.h ssh-add.1 ssh-add.c ssh-agent.c] ssh-add -t life, Set lifetime (in seconds) when adding identities; ok provos@
Diffstat (limited to 'ssh-add.c')
-rw-r--r--ssh-add.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/ssh-add.c b/ssh-add.c
index 315d94018..e4aa8a522 100644
--- a/ssh-add.c
+++ b/ssh-add.c
@@ -35,7 +35,7 @@
35 */ 35 */
36 36
37#include "includes.h" 37#include "includes.h"
38RCSID("$OpenBSD: ssh-add.c,v 1.55 2002/06/05 20:56:39 markus Exp $"); 38RCSID("$OpenBSD: ssh-add.c,v 1.56 2002/06/05 21:55:44 markus Exp $");
39 39
40#include <openssl/evp.h> 40#include <openssl/evp.h>
41 41
@@ -66,6 +66,8 @@ static char *default_files[] = {
66 NULL 66 NULL
67}; 67};
68 68
69/* Default lifetime (0 == forever) */
70static u_int lifetime = 0;
69 71
70/* we keep a cache of one passphrases */ 72/* we keep a cache of one passphrases */
71static char *pass = NULL; 73static char *pass = NULL;
@@ -167,6 +169,18 @@ add_file(AuthenticationConnection *ac, const char *filename)
167 } else 169 } else
168 fprintf(stderr, "Could not add identity: %s\n", filename); 170 fprintf(stderr, "Could not add identity: %s\n", filename);
169 171
172 if (ret == 0 && lifetime != 0) {
173 if (ssh_lifetime_identity(ac, private, lifetime)) {
174 fprintf(stderr,
175 "Lifetime set to %d seconds for: %s (%s)\n",
176 lifetime, filename, comment);
177 } else {
178 fprintf(stderr,
179 "Could not set lifetime for identity: %s\n",
180 filename);
181 }
182 }
183
170 xfree(comment); 184 xfree(comment);
171 key_free(private); 185 key_free(private);
172 186
@@ -280,6 +294,7 @@ usage(void)
280 fprintf(stderr, " -D Delete all identities.\n"); 294 fprintf(stderr, " -D Delete all identities.\n");
281 fprintf(stderr, " -x Lock agent.\n"); 295 fprintf(stderr, " -x Lock agent.\n");
282 fprintf(stderr, " -x Unlock agent.\n"); 296 fprintf(stderr, " -x Unlock agent.\n");
297 fprintf(stderr, " -t life Set lifetime (in seconds) when adding identities.\n");
283#ifdef SMARTCARD 298#ifdef SMARTCARD
284 fprintf(stderr, " -s reader Add key in smartcard reader.\n"); 299 fprintf(stderr, " -s reader Add key in smartcard reader.\n");
285 fprintf(stderr, " -e reader Remove key in smartcard reader.\n"); 300 fprintf(stderr, " -e reader Remove key in smartcard reader.\n");
@@ -307,7 +322,7 @@ main(int argc, char **argv)
307 fprintf(stderr, "Could not open a connection to your authentication agent.\n"); 322 fprintf(stderr, "Could not open a connection to your authentication agent.\n");
308 exit(2); 323 exit(2);
309 } 324 }
310 while ((ch = getopt(argc, argv, "lLdDxXe:s:")) != -1) { 325 while ((ch = getopt(argc, argv, "lLdDxXe:s:t:")) != -1) {
311 switch (ch) { 326 switch (ch) {
312 case 'l': 327 case 'l':
313 case 'L': 328 case 'L':
@@ -336,6 +351,9 @@ main(int argc, char **argv)
336 deleting = 1; 351 deleting = 1;
337 sc_reader_id = optarg; 352 sc_reader_id = optarg;
338 break; 353 break;
354 case 't':
355 lifetime = atoi(optarg);
356 break;
339 default: 357 default:
340 usage(); 358 usage();
341 ret = 1; 359 ret = 1;