diff options
author | Markus Friedl <markus@cvs.openbsd.org> | 2002-06-05 16:08:08 +0000 |
---|---|---|
committer | Markus Friedl <markus@cvs.openbsd.org> | 2002-06-05 16:08:08 +0000 |
commit | f7a3988cc804a04caf1ca135c8eab792edb05667 (patch) | |
tree | 0e209b0aa6f20cbc0fc2e81d6213e9972ca565e5 /usr.bin/ssh | |
parent | e0baa21aed63316fff785fe18e5e881453ba85be (diff) |
'-a bind_address' binds the agent to user-specified unix-domain
socket instead of /tmp/ssh-XXXXXXXX/agent.<pid>; ok djm@ (some time ago).
Diffstat (limited to 'usr.bin/ssh')
-rw-r--r-- | usr.bin/ssh/ssh-agent.1 | 9 | ||||
-rw-r--r-- | usr.bin/ssh/ssh-agent.c | 29 |
2 files changed, 27 insertions, 11 deletions
diff --git a/usr.bin/ssh/ssh-agent.1 b/usr.bin/ssh/ssh-agent.1 index 9909ef59022..5f498b7e3a4 100644 --- a/usr.bin/ssh/ssh-agent.1 +++ b/usr.bin/ssh/ssh-agent.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: ssh-agent.1,v 1.31 2002/02/04 20:41:16 stevesk Exp $ +.\" $OpenBSD: ssh-agent.1,v 1.32 2002/06/05 16:08:07 markus Exp $ .\" .\" Author: Tatu Ylonen <ylo@cs.hut.fi> .\" Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland @@ -42,6 +42,7 @@ .Nd authentication agent .Sh SYNOPSIS .Nm ssh-agent +.Op Fl a Ar bind_address .Op Fl c Li | Fl s .Op Fl d .Op Ar command Op Ar args ... @@ -64,6 +65,11 @@ machines using .Pp The options are as follows: .Bl -tag -width Ds +.It Fl a Ar bind_address +Bind the agent to the unix-domain socket +.Ar bind_address . +The default is +.Pa /tmp/ssh-XXXXXXXX/agent.<pid> . .It Fl c Generate C-shell commands on .Dv stdout . @@ -135,7 +141,6 @@ by the agent, and the result will be returned to the requester. This way, private keys are not exposed to clients using the agent. .Pp A unix-domain socket is created -.Pq Pa /tmp/ssh-XXXXXXXX/agent.<pid> , and the name of this socket is stored in the .Ev SSH_AUTH_SOCK environment diff --git a/usr.bin/ssh/ssh-agent.c b/usr.bin/ssh/ssh-agent.c index f6ce4a53042..d38fa3cf34b 100644 --- a/usr.bin/ssh/ssh-agent.c +++ b/usr.bin/ssh/ssh-agent.c @@ -35,7 +35,7 @@ #include "includes.h" #include <sys/queue.h> -RCSID("$OpenBSD: ssh-agent.c,v 1.85 2002/04/02 11:49:39 markus Exp $"); +RCSID("$OpenBSD: ssh-agent.c,v 1.86 2002/06/05 16:08:07 markus Exp $"); #include <openssl/evp.h> #include <openssl/md5.h> @@ -799,6 +799,7 @@ usage(void) fprintf(stderr, " -s Generate Bourne shell commands on stdout.\n"); fprintf(stderr, " -k Kill the current agent.\n"); fprintf(stderr, " -d Debug mode.\n"); + fprintf(stderr, " -a socket Bind agent socket to given name.\n"); exit(1); } @@ -810,12 +811,13 @@ main(int ac, char **av) struct rlimit rlim; pid_t pid; char *shell, *format, *pidstr, pidstrbuf[1 + 3 * sizeof pid]; + char *agentsocket = NULL; extern int optind; fd_set *readsetp = NULL, *writesetp = NULL; SSLeay_add_all_algorithms(); - while ((ch = getopt(ac, av, "cdks")) != -1) { + while ((ch = getopt(ac, av, "cdksa:")) != -1) { switch (ch) { case 'c': if (s_flag) @@ -835,6 +837,9 @@ main(int ac, char **av) usage(); d_flag++; break; + case 'a': + agentsocket = optarg; + break; default: usage(); } @@ -875,14 +880,20 @@ main(int ac, char **av) } parent_pid = getpid(); - /* Create private directory for agent socket */ - strlcpy(socket_dir, "/tmp/ssh-XXXXXXXX", sizeof socket_dir); - if (mkdtemp(socket_dir) == NULL) { - perror("mkdtemp: private socket dir"); - exit(1); + if (agentsocket == NULL) { + /* Create private directory for agent socket */ + strlcpy(socket_dir, "/tmp/ssh-XXXXXXXX", sizeof socket_dir); + if (mkdtemp(socket_dir) == NULL) { + perror("mkdtemp: private socket dir"); + exit(1); + } + snprintf(socket_name, sizeof socket_name, "%s/agent.%d", socket_dir, + parent_pid); + } else { + /* Try to use specified agent socket */ + socket_dir[0] = '\0'; + strlcpy(socket_name, agentsocket, sizeof socket_name); } - snprintf(socket_name, sizeof socket_name, "%s/agent.%d", socket_dir, - parent_pid); /* * Create socket early so it will exist before command gets run from |