summaryrefslogtreecommitdiffstats
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 4801f4a7..247b8397 100644
--- a/clientloop.c
+++ b/clientloop.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: clientloop.c,v 1.312 2018/04/10 00:10:49 djm Exp $ */
+/* $OpenBSD: clientloop.c,v 1.313 2018/06/09 03:01:12 djm Exp $ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -2158,7 +2158,8 @@ void
client_session2_setup(struct ssh *ssh, int id, int want_tty, int want_subsystem,
const char *term, struct termios *tiop, int in_fd, Buffer *cmd, char **env)
{
- int len;
+ int i, j, matched, len;
+ char *name, *val;
Channel *c = NULL;
debug2("%s: id %d", __func__, id);
@@ -2193,9 +2194,6 @@ client_session2_setup(struct ssh *ssh, int id, int want_tty, int want_subsystem,
/* Transfer any environment variables from client to server */
if (options.num_send_env != 0 && env != NULL) {
- int i, j, matched;
- char *name, *val;
-
debug("Sending environment.");
for (i = 0; env[i] != NULL; i++) {
/* Split */
@@ -2227,6 +2225,22 @@ client_session2_setup(struct ssh *ssh, int id, int want_tty, int want_subsystem,
free(name);
}
}
+ for (i = 0; i < options.num_setenv; i++) {
+ /* Split */
+ name = xstrdup(options.setenv[i]);
+ if ((val = strchr(name, '=')) == NULL) {
+ free(name);
+ continue;
+ }
+ *val++ = '\0';
+
+ debug("Setting env %s = %s", name, val);
+ channel_request_start(ssh, id, "env", 0);
+ packet_put_cstring(name);
+ packet_put_cstring(val);
+ packet_send();
+ free(name);
+ }
len = buffer_len(cmd);
if (len > 0) {