summaryrefslogtreecommitdiff
path: root/usr.bin/ssh/ssh.c
diff options
context:
space:
mode:
authorDamien Miller <djm@cvs.openbsd.org>2004-06-17 14:52:49 +0000
committerDamien Miller <djm@cvs.openbsd.org>2004-06-17 14:52:49 +0000
commit9549b87bfd5c610614fd577c47478687fd11e10c (patch)
treee74c70d57c2fa49f60ab650aa1a106cddcdc1dab /usr.bin/ssh/ssh.c
parent822e0910aad8c0f29044e60212354d5cbcf7ae1d (diff)
support environment passing over shared connections; ok markus@
Diffstat (limited to 'usr.bin/ssh/ssh.c')
-rw-r--r--usr.bin/ssh/ssh.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/usr.bin/ssh/ssh.c b/usr.bin/ssh/ssh.c
index 44d1ad1a6a0..7a1376bf425 100644
--- a/usr.bin/ssh/ssh.c
+++ b/usr.bin/ssh/ssh.c
@@ -40,7 +40,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: ssh.c,v 1.214 2004/06/13 15:03:02 djm Exp $");
+RCSID("$OpenBSD: ssh.c,v 1.215 2004/06/17 14:52:48 djm Exp $");
#include <openssl/evp.h>
#include <openssl/err.h>
@@ -1064,6 +1064,8 @@ ssh_control_listener(void)
static void
ssh_session2_setup(int id, void *arg)
{
+ extern char **environ;
+
int interactive = tty_flag;
if (options.forward_x11 && getenv("DISPLAY") != NULL) {
char *proto, *data;
@@ -1084,7 +1086,7 @@ ssh_session2_setup(int id, void *arg)
}
client_session2_setup(id, tty_flag, subsystem_flag, getenv("TERM"),
- NULL, fileno(stdin), &command, &ssh_subsystem_reply);
+ NULL, fileno(stdin), &command, environ, &ssh_subsystem_reply);
packet_set_interactive(interactive);
}
@@ -1214,9 +1216,10 @@ static void
control_client(const char *path)
{
struct sockaddr_un addr;
- int r, sock, exitval;
+ int i, r, sock, exitval;
Buffer m;
char *cp;
+ extern char **environ;
memset(&addr, '\0', sizeof(addr));
addr.sun_family = AF_UNIX;
@@ -1249,8 +1252,6 @@ control_client(const char *path)
fatal("%s: wrong version", __func__);
control_server_pid = buffer_get_int(&m);
- /* XXX: env passing */
-
buffer_clear(&m);
buffer_put_int(&m, tty_flag);
buffer_put_int(&m, subsystem_flag);
@@ -1259,6 +1260,13 @@ control_client(const char *path)
buffer_append(&command, "\0", 1);
buffer_put_cstring(&m, buffer_ptr(&command));
+ /* Pass environment */
+ for (i = 0; environ != NULL && environ[i] != NULL; i++)
+ ;
+ buffer_put_int(&m, i);
+ for (i = 0; environ != NULL && environ[i] != NULL; i++)
+ buffer_put_cstring(&m, environ[i]);
+
if (ssh_msg_send(sock, /* version */0, &m) == -1)
fatal("%s: msg_send", __func__);