diff options
author | Ben Lindstrom <mouring@eviladmin.org> | 2002-06-06 23:46:08 +0200 |
---|---|---|
committer | Ben Lindstrom <mouring@eviladmin.org> | 2002-06-06 23:46:08 +0200 |
commit | b7788f3ebee920d6b14b37034f7f769788b6dff6 (patch) | |
tree | d58829d766cbf8e547d8c7400d80879a84284502 /ssh-agent.c | |
parent | - markus@cvs.openbsd.org 2002/06/05 16:08:07 (diff) | |
download | openssh-b7788f3ebee920d6b14b37034f7f769788b6dff6.tar.xz openssh-b7788f3ebee920d6b14b37034f7f769788b6dff6.zip |
- markus@cvs.openbsd.org 2002/06/05 16:08:07
[ssh-agent.1 ssh-agent.c]
'-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 '')
-rw-r--r-- | ssh-agent.c | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/ssh-agent.c b/ssh-agent.c index 33596c47a..d3321478b 100644 --- a/ssh-agent.c +++ b/ssh-agent.c @@ -35,7 +35,7 @@ #include "includes.h" #include "openbsd-compat/fake-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> @@ -803,6 +803,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); } @@ -819,6 +820,7 @@ main(int ac, char **av) #endif pid_t pid; char *shell, *format, *pidstr, pidstrbuf[1 + 3 * sizeof pid]; + char *agentsocket = NULL; extern int optind; fd_set *readsetp = NULL, *writesetp = NULL; @@ -829,9 +831,9 @@ main(int ac, char **av) seed_rng(); #ifdef __GNU_LIBRARY__ - while ((ch = getopt(ac, av, "+cdks")) != -1) { + while ((ch = getopt(ac, av, "+cdksa:")) != -1) { #else /* __GNU_LIBRARY__ */ - while ((ch = getopt(ac, av, "cdks")) != -1) { + while ((ch = getopt(ac, av, "cdksa:")) != -1) { #endif /* __GNU_LIBRARY__ */ switch (ch) { case 'c': @@ -852,6 +854,9 @@ main(int ac, char **av) usage(); d_flag++; break; + case 'a': + agentsocket = optarg; + break; default: usage(); } @@ -892,14 +897,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 |