summaryrefslogtreecommitdiff
path: root/ssh-agent.c
diff options
context:
space:
mode:
authorBen Lindstrom <mouring@eviladmin.org>2002-06-06 21:46:08 +0000
committerBen Lindstrom <mouring@eviladmin.org>2002-06-06 21:46:08 +0000
commitb7788f3ebee920d6b14b37034f7f769788b6dff6 (patch)
treed58829d766cbf8e547d8c7400d80879a84284502 /ssh-agent.c
parent22fa01cdea7d8fa159113a9148d523a3b8a46278 (diff)
- 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 'ssh-agent.c')
-rw-r--r--ssh-agent.c31
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 @@
35 35
36#include "includes.h" 36#include "includes.h"
37#include "openbsd-compat/fake-queue.h" 37#include "openbsd-compat/fake-queue.h"
38RCSID("$OpenBSD: ssh-agent.c,v 1.85 2002/04/02 11:49:39 markus Exp $"); 38RCSID("$OpenBSD: ssh-agent.c,v 1.86 2002/06/05 16:08:07 markus Exp $");
39 39
40#include <openssl/evp.h> 40#include <openssl/evp.h>
41#include <openssl/md5.h> 41#include <openssl/md5.h>
@@ -803,6 +803,7 @@ usage(void)
803 fprintf(stderr, " -s Generate Bourne shell commands on stdout.\n"); 803 fprintf(stderr, " -s Generate Bourne shell commands on stdout.\n");
804 fprintf(stderr, " -k Kill the current agent.\n"); 804 fprintf(stderr, " -k Kill the current agent.\n");
805 fprintf(stderr, " -d Debug mode.\n"); 805 fprintf(stderr, " -d Debug mode.\n");
806 fprintf(stderr, " -a socket Bind agent socket to given name.\n");
806 exit(1); 807 exit(1);
807} 808}
808 809
@@ -819,6 +820,7 @@ main(int ac, char **av)
819#endif 820#endif
820 pid_t pid; 821 pid_t pid;
821 char *shell, *format, *pidstr, pidstrbuf[1 + 3 * sizeof pid]; 822 char *shell, *format, *pidstr, pidstrbuf[1 + 3 * sizeof pid];
823 char *agentsocket = NULL;
822 extern int optind; 824 extern int optind;
823 fd_set *readsetp = NULL, *writesetp = NULL; 825 fd_set *readsetp = NULL, *writesetp = NULL;
824 826
@@ -829,9 +831,9 @@ main(int ac, char **av)
829 seed_rng(); 831 seed_rng();
830 832
831#ifdef __GNU_LIBRARY__ 833#ifdef __GNU_LIBRARY__
832 while ((ch = getopt(ac, av, "+cdks")) != -1) { 834 while ((ch = getopt(ac, av, "+cdksa:")) != -1) {
833#else /* __GNU_LIBRARY__ */ 835#else /* __GNU_LIBRARY__ */
834 while ((ch = getopt(ac, av, "cdks")) != -1) { 836 while ((ch = getopt(ac, av, "cdksa:")) != -1) {
835#endif /* __GNU_LIBRARY__ */ 837#endif /* __GNU_LIBRARY__ */
836 switch (ch) { 838 switch (ch) {
837 case 'c': 839 case 'c':
@@ -852,6 +854,9 @@ main(int ac, char **av)
852 usage(); 854 usage();
853 d_flag++; 855 d_flag++;
854 break; 856 break;
857 case 'a':
858 agentsocket = optarg;
859 break;
855 default: 860 default:
856 usage(); 861 usage();
857 } 862 }
@@ -892,14 +897,20 @@ main(int ac, char **av)
892 } 897 }
893 parent_pid = getpid(); 898 parent_pid = getpid();
894 899
895 /* Create private directory for agent socket */ 900 if (agentsocket == NULL) {
896 strlcpy(socket_dir, "/tmp/ssh-XXXXXXXX", sizeof socket_dir); 901 /* Create private directory for agent socket */
897 if (mkdtemp(socket_dir) == NULL) { 902 strlcpy(socket_dir, "/tmp/ssh-XXXXXXXX", sizeof socket_dir);
898 perror("mkdtemp: private socket dir"); 903 if (mkdtemp(socket_dir) == NULL) {
899 exit(1); 904 perror("mkdtemp: private socket dir");
905 exit(1);
906 }
907 snprintf(socket_name, sizeof socket_name, "%s/agent.%d", socket_dir,
908 parent_pid);
909 } else {
910 /* Try to use specified agent socket */
911 socket_dir[0] = '\0';
912 strlcpy(socket_name, agentsocket, sizeof socket_name);
900 } 913 }
901 snprintf(socket_name, sizeof socket_name, "%s/agent.%d", socket_dir,
902 parent_pid);
903 914
904 /* 915 /*
905 * Create socket early so it will exist before command gets run from 916 * Create socket early so it will exist before command gets run from