summaryrefslogtreecommitdiff
path: root/sshconnect.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2002-09-19 12:05:02 +1000
committerDamien Miller <djm@mindrot.org>2002-09-19 12:05:02 +1000
commit8c4e18a6ec22a09b9082ff74b668685c30a028e7 (patch)
tree29f64f89bc87bd3fc2dd87310fd7cb77e7a9f9ea /sshconnect.c
parent9b037b837aea146ab331edea68f39eb377cee3e5 (diff)
- djm@cvs.openbsd.org 2002/09/19 01:58:18
[ssh.c sshconnect.c] bugzilla.mindrot.org #223 - ProxyCommands don't exit. Patch from dtucker@zip.com.au; ok markus@
Diffstat (limited to 'sshconnect.c')
-rw-r--r--sshconnect.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/sshconnect.c b/sshconnect.c
index 0cb824852..776d72065 100644
--- a/sshconnect.c
+++ b/sshconnect.c
@@ -13,7 +13,7 @@
13 */ 13 */
14 14
15#include "includes.h" 15#include "includes.h"
16RCSID("$OpenBSD: sshconnect.c,v 1.134 2002/09/13 19:23:09 stevesk Exp $"); 16RCSID("$OpenBSD: sshconnect.c,v 1.135 2002/09/19 01:58:18 djm Exp $");
17 17
18#include <openssl/bn.h> 18#include <openssl/bn.h>
19 19
@@ -41,6 +41,7 @@ extern Options options;
41extern char *__progname; 41extern char *__progname;
42extern uid_t original_real_uid; 42extern uid_t original_real_uid;
43extern uid_t original_effective_uid; 43extern uid_t original_effective_uid;
44extern pid_t proxy_command_pid;
44 45
45#ifndef INET6_ADDRSTRLEN /* for non IPv6 machines */ 46#ifndef INET6_ADDRSTRLEN /* for non IPv6 machines */
46#define INET6_ADDRSTRLEN 46 47#define INET6_ADDRSTRLEN 46
@@ -64,9 +65,16 @@ ssh_proxy_connect(const char *host, u_short port, const char *proxy_command)
64 /* Convert the port number into a string. */ 65 /* Convert the port number into a string. */
65 snprintf(strport, sizeof strport, "%hu", port); 66 snprintf(strport, sizeof strport, "%hu", port);
66 67
67 /* Build the final command string in the buffer by making the 68 /*
68 appropriate substitutions to the given proxy command. */ 69 * Build the final command string in the buffer by making the
70 * appropriate substitutions to the given proxy command.
71 *
72 * Use "exec" to avoid "sh -c" processes on some platforms
73 * (e.g. Solaris)
74 */
69 buffer_init(&command); 75 buffer_init(&command);
76 buffer_append(&command, "exec ", 5);
77
70 for (cp = proxy_command; *cp; cp++) { 78 for (cp = proxy_command; *cp; cp++) {
71 if (cp[0] == '%' && cp[1] == '%') { 79 if (cp[0] == '%' && cp[1] == '%') {
72 buffer_append(&command, "%", 1); 80 buffer_append(&command, "%", 1);
@@ -134,6 +142,8 @@ ssh_proxy_connect(const char *host, u_short port, const char *proxy_command)
134 /* Parent. */ 142 /* Parent. */
135 if (pid < 0) 143 if (pid < 0)
136 fatal("fork failed: %.100s", strerror(errno)); 144 fatal("fork failed: %.100s", strerror(errno));
145 else
146 proxy_command_pid = pid; /* save pid to clean up later */
137 147
138 /* Close child side of the descriptors. */ 148 /* Close child side of the descriptors. */
139 close(pin[0]); 149 close(pin[0]);