summaryrefslogtreecommitdiff
path: root/ssh-agent.c
diff options
context:
space:
mode:
Diffstat (limited to 'ssh-agent.c')
-rw-r--r--ssh-agent.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/ssh-agent.c b/ssh-agent.c
index cca720ee2..554f8942a 100644
--- a/ssh-agent.c
+++ b/ssh-agent.c
@@ -35,7 +35,7 @@
35 35
36#include "includes.h" 36#include "includes.h"
37#include "openbsd-compat/sys-queue.h" 37#include "openbsd-compat/sys-queue.h"
38RCSID("$OpenBSD: ssh-agent.c,v 1.105 2002/10/01 20:34:12 markus Exp $"); 38RCSID("$OpenBSD: ssh-agent.c,v 1.106 2003/01/21 18:14:36 marc Exp $");
39 39
40#include <openssl/evp.h> 40#include <openssl/evp.h>
41#include <openssl/md5.h> 41#include <openssl/md5.h>
@@ -106,6 +106,9 @@ extern char *__progname;
106char *__progname; 106char *__progname;
107#endif 107#endif
108 108
109/* Default lifetime (0 == forever) */
110static int lifetime = 0;
111
109static void 112static void
110close_socket(SocketEntry *e) 113close_socket(SocketEntry *e)
111{ 114{
@@ -468,6 +471,8 @@ process_add_identity(SocketEntry *e, int version)
468 break; 471 break;
469 } 472 }
470 } 473 }
474 if (lifetime && !death)
475 death = time(NULL) + lifetime;
471 if (lookup_identity(k, version) == NULL) { 476 if (lookup_identity(k, version) == NULL) {
472 Identity *id = xmalloc(sizeof(Identity)); 477 Identity *id = xmalloc(sizeof(Identity));
473 id->key = k; 478 id->key = k;
@@ -930,6 +935,7 @@ usage(void)
930 fprintf(stderr, " -k Kill the current agent.\n"); 935 fprintf(stderr, " -k Kill the current agent.\n");
931 fprintf(stderr, " -d Debug mode.\n"); 936 fprintf(stderr, " -d Debug mode.\n");
932 fprintf(stderr, " -a socket Bind agent socket to given name.\n"); 937 fprintf(stderr, " -a socket Bind agent socket to given name.\n");
938 fprintf(stderr, " -t life Default identity lifetime (seconds).\n");
933 exit(1); 939 exit(1);
934} 940}
935 941
@@ -961,7 +967,7 @@ main(int ac, char **av)
961 init_rng(); 967 init_rng();
962 seed_rng(); 968 seed_rng();
963 969
964 while ((ch = getopt(ac, av, "cdksa:")) != -1) { 970 while ((ch = getopt(ac, av, "cdksa:t:")) != -1) {
965 switch (ch) { 971 switch (ch) {
966 case 'c': 972 case 'c':
967 if (s_flag) 973 if (s_flag)
@@ -984,6 +990,12 @@ main(int ac, char **av)
984 case 'a': 990 case 'a':
985 agentsocket = optarg; 991 agentsocket = optarg;
986 break; 992 break;
993 case 't':
994 if ((lifetime = convtime(optarg)) == -1) {
995 fprintf(stderr, "Invalid lifetime\n");
996 usage();
997 }
998 break;
987 default: 999 default:
988 usage(); 1000 usage();
989 } 1001 }