summaryrefslogtreecommitdiff
path: root/ssh.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2004-06-18 01:17:29 +1000
committerDamien Miller <djm@mindrot.org>2004-06-18 01:17:29 +1000
commit3756dcee244f47c20a6590129d99e625169836c6 (patch)
tree4ac3b83e6a1bdc7a543e92bf1b66def8444af739 /ssh.c
parenta9972e19e941f9f711103b50dd57f6bc0c1aad53 (diff)
- (djm) OpenBSD CVS Sync
- djm@cvs.openbsd.org 2004/06/17 14:52:48 [clientloop.c clientloop.h ssh.c] support environment passing over shared connections; ok markus@
Diffstat (limited to 'ssh.c')
-rw-r--r--ssh.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/ssh.c b/ssh.c
index 4badd2961..9b434b93e 100644
--- a/ssh.c
+++ b/ssh.c
@@ -40,7 +40,7 @@
40 */ 40 */
41 41
42#include "includes.h" 42#include "includes.h"
43RCSID("$OpenBSD: ssh.c,v 1.214 2004/06/13 15:03:02 djm Exp $"); 43RCSID("$OpenBSD: ssh.c,v 1.215 2004/06/17 14:52:48 djm Exp $");
44 44
45#include <openssl/evp.h> 45#include <openssl/evp.h>
46#include <openssl/err.h> 46#include <openssl/err.h>
@@ -1080,6 +1080,8 @@ ssh_control_listener(void)
1080static void 1080static void
1081ssh_session2_setup(int id, void *arg) 1081ssh_session2_setup(int id, void *arg)
1082{ 1082{
1083 extern char **environ;
1084
1083 int interactive = tty_flag; 1085 int interactive = tty_flag;
1084 if (options.forward_x11 && getenv("DISPLAY") != NULL) { 1086 if (options.forward_x11 && getenv("DISPLAY") != NULL) {
1085 char *proto, *data; 1087 char *proto, *data;
@@ -1100,7 +1102,7 @@ ssh_session2_setup(int id, void *arg)
1100 } 1102 }
1101 1103
1102 client_session2_setup(id, tty_flag, subsystem_flag, getenv("TERM"), 1104 client_session2_setup(id, tty_flag, subsystem_flag, getenv("TERM"),
1103 NULL, fileno(stdin), &command, &ssh_subsystem_reply); 1105 NULL, fileno(stdin), &command, environ, &ssh_subsystem_reply);
1104 1106
1105 packet_set_interactive(interactive); 1107 packet_set_interactive(interactive);
1106} 1108}
@@ -1230,9 +1232,10 @@ static void
1230control_client(const char *path) 1232control_client(const char *path)
1231{ 1233{
1232 struct sockaddr_un addr; 1234 struct sockaddr_un addr;
1233 int r, sock, exitval, addr_len; 1235 int i, r, sock, exitval, addr_len;
1234 Buffer m; 1236 Buffer m;
1235 char *cp; 1237 char *cp;
1238 extern char **environ;
1236 1239
1237 memset(&addr, '\0', sizeof(addr)); 1240 memset(&addr, '\0', sizeof(addr));
1238 addr.sun_family = AF_UNIX; 1241 addr.sun_family = AF_UNIX;
@@ -1265,8 +1268,6 @@ control_client(const char *path)
1265 fatal("%s: wrong version", __func__); 1268 fatal("%s: wrong version", __func__);
1266 control_server_pid = buffer_get_int(&m); 1269 control_server_pid = buffer_get_int(&m);
1267 1270
1268 /* XXX: env passing */
1269
1270 buffer_clear(&m); 1271 buffer_clear(&m);
1271 buffer_put_int(&m, tty_flag); 1272 buffer_put_int(&m, tty_flag);
1272 buffer_put_int(&m, subsystem_flag); 1273 buffer_put_int(&m, subsystem_flag);
@@ -1275,6 +1276,13 @@ control_client(const char *path)
1275 buffer_append(&command, "\0", 1); 1276 buffer_append(&command, "\0", 1);
1276 buffer_put_cstring(&m, buffer_ptr(&command)); 1277 buffer_put_cstring(&m, buffer_ptr(&command));
1277 1278
1279 /* Pass environment */
1280 for (i = 0; environ != NULL && environ[i] != NULL; i++)
1281 ;
1282 buffer_put_int(&m, i);
1283 for (i = 0; environ != NULL && environ[i] != NULL; i++)
1284 buffer_put_cstring(&m, environ[i]);
1285
1278 if (ssh_msg_send(sock, /* version */0, &m) == -1) 1286 if (ssh_msg_send(sock, /* version */0, &m) == -1)
1279 fatal("%s: msg_send", __func__); 1287 fatal("%s: msg_send", __func__);
1280 1288