summaryrefslogtreecommitdiff
path: root/clientloop.c
diff options
context:
space:
mode:
authordjm@openbsd.org <djm@openbsd.org>2018-06-09 03:01:12 +0000
committerDamien Miller <djm@mindrot.org>2018-06-09 13:11:00 +1000
commit7082bb58a2eb878d23ec674587c742e5e9673c36 (patch)
treeca7c8ddb616358d96279fdbfd5986328f48a1821 /clientloop.c
parent3b9798bda15bd3f598f5ef07595d64e23504da91 (diff)
upstream: add a SetEnv directive to ssh_config that allows setting
environment variables for the remote session (subject to the server accepting them) refactor SendEnv to remove the arbitrary limit of variable names. ok markus@ OpenBSD-Commit-ID: cfbb00d9b0e10c1ffff1d83424351fd961d1f2be
Diffstat (limited to 'clientloop.c')
-rw-r--r--clientloop.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/clientloop.c b/clientloop.c
index 4801f4a77..247b83979 100644
--- a/clientloop.c
+++ b/clientloop.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: clientloop.c,v 1.312 2018/04/10 00:10:49 djm Exp $ */ 1/* $OpenBSD: clientloop.c,v 1.313 2018/06/09 03:01:12 djm Exp $ */
2/* 2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -2158,7 +2158,8 @@ void
2158client_session2_setup(struct ssh *ssh, int id, int want_tty, int want_subsystem, 2158client_session2_setup(struct ssh *ssh, int id, int want_tty, int want_subsystem,
2159 const char *term, struct termios *tiop, int in_fd, Buffer *cmd, char **env) 2159 const char *term, struct termios *tiop, int in_fd, Buffer *cmd, char **env)
2160{ 2160{
2161 int len; 2161 int i, j, matched, len;
2162 char *name, *val;
2162 Channel *c = NULL; 2163 Channel *c = NULL;
2163 2164
2164 debug2("%s: id %d", __func__, id); 2165 debug2("%s: id %d", __func__, id);
@@ -2193,9 +2194,6 @@ client_session2_setup(struct ssh *ssh, int id, int want_tty, int want_subsystem,
2193 2194
2194 /* Transfer any environment variables from client to server */ 2195 /* Transfer any environment variables from client to server */
2195 if (options.num_send_env != 0 && env != NULL) { 2196 if (options.num_send_env != 0 && env != NULL) {
2196 int i, j, matched;
2197 char *name, *val;
2198
2199 debug("Sending environment."); 2197 debug("Sending environment.");
2200 for (i = 0; env[i] != NULL; i++) { 2198 for (i = 0; env[i] != NULL; i++) {
2201 /* Split */ 2199 /* Split */
@@ -2227,6 +2225,22 @@ client_session2_setup(struct ssh *ssh, int id, int want_tty, int want_subsystem,
2227 free(name); 2225 free(name);
2228 } 2226 }
2229 } 2227 }
2228 for (i = 0; i < options.num_setenv; i++) {
2229 /* Split */
2230 name = xstrdup(options.setenv[i]);
2231 if ((val = strchr(name, '=')) == NULL) {
2232 free(name);
2233 continue;
2234 }
2235 *val++ = '\0';
2236
2237 debug("Setting env %s = %s", name, val);
2238 channel_request_start(ssh, id, "env", 0);
2239 packet_put_cstring(name);
2240 packet_put_cstring(val);
2241 packet_send();
2242 free(name);
2243 }
2230 2244
2231 len = buffer_len(cmd); 2245 len = buffer_len(cmd);
2232 if (len > 0) { 2246 if (len > 0) {