summaryrefslogtreecommitdiff
path: root/readconf.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 /readconf.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 'readconf.c')
-rw-r--r--readconf.c34
1 files changed, 31 insertions, 3 deletions
diff --git a/readconf.c b/readconf.c
index 733b67f76..8ff23c05c 100644
--- a/readconf.c
+++ b/readconf.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: readconf.c,v 1.289 2018/06/06 18:29:18 markus Exp $ */ 1/* $OpenBSD: readconf.c,v 1.290 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
@@ -161,7 +161,7 @@ typedef enum {
161 oEnableSSHKeysign, oRekeyLimit, oVerifyHostKeyDNS, oConnectTimeout, 161 oEnableSSHKeysign, oRekeyLimit, oVerifyHostKeyDNS, oConnectTimeout,
162 oAddressFamily, oGssAuthentication, oGssDelegateCreds, 162 oAddressFamily, oGssAuthentication, oGssDelegateCreds,
163 oServerAliveInterval, oServerAliveCountMax, oIdentitiesOnly, 163 oServerAliveInterval, oServerAliveCountMax, oIdentitiesOnly,
164 oSendEnv, oControlPath, oControlMaster, oControlPersist, 164 oSendEnv, oSetEnv, oControlPath, oControlMaster, oControlPersist,
165 oHashKnownHosts, 165 oHashKnownHosts,
166 oTunnel, oTunnelDevice, 166 oTunnel, oTunnelDevice,
167 oLocalCommand, oPermitLocalCommand, oRemoteCommand, 167 oLocalCommand, oPermitLocalCommand, oRemoteCommand,
@@ -277,6 +277,7 @@ static struct {
277 { "serveraliveinterval", oServerAliveInterval }, 277 { "serveraliveinterval", oServerAliveInterval },
278 { "serveralivecountmax", oServerAliveCountMax }, 278 { "serveralivecountmax", oServerAliveCountMax },
279 { "sendenv", oSendEnv }, 279 { "sendenv", oSendEnv },
280 { "setenv", oSetEnv },
280 { "controlpath", oControlPath }, 281 { "controlpath", oControlPath },
281 { "controlmaster", oControlMaster }, 282 { "controlmaster", oControlMaster },
282 { "controlpersist", oControlPersist }, 283 { "controlpersist", oControlPersist },
@@ -1398,15 +1399,38 @@ parse_keytypes:
1398 continue; 1399 continue;
1399 } else { 1400 } else {
1400 /* Adding an env var */ 1401 /* Adding an env var */
1401 if (options->num_send_env >= MAX_SEND_ENV) 1402 if (options->num_send_env >= INT_MAX)
1402 fatal("%s line %d: too many send env.", 1403 fatal("%s line %d: too many send env.",
1403 filename, linenum); 1404 filename, linenum);
1405 options->send_env = xrecallocarray(
1406 options->send_env, options->num_send_env,
1407 options->num_send_env,
1408 sizeof(*options->send_env));
1404 options->send_env[options->num_send_env++] = 1409 options->send_env[options->num_send_env++] =
1405 xstrdup(arg); 1410 xstrdup(arg);
1406 } 1411 }
1407 } 1412 }
1408 break; 1413 break;
1409 1414
1415 case oSetEnv:
1416 value = options->num_setenv;
1417 while ((arg = strdelimw(&s)) != NULL && *arg != '\0') {
1418 if (strchr(arg, '=') == NULL)
1419 fatal("%s line %d: Invalid SetEnv.",
1420 filename, linenum);
1421 if (!*activep || value != 0)
1422 continue;
1423 /* Adding a setenv var */
1424 if (options->num_setenv >= INT_MAX)
1425 fatal("%s line %d: too many SetEnv.",
1426 filename, linenum);
1427 options->setenv = xrecallocarray(
1428 options->setenv, options->num_setenv,
1429 options->num_setenv + 1, sizeof(*options->setenv));
1430 options->setenv[options->num_setenv++] = xstrdup(arg);
1431 }
1432 break;
1433
1410 case oControlPath: 1434 case oControlPath:
1411 charptr = &options->control_path; 1435 charptr = &options->control_path;
1412 goto parse_string; 1436 goto parse_string;
@@ -1855,7 +1879,10 @@ initialize_options(Options * options)
1855 options->verify_host_key_dns = -1; 1879 options->verify_host_key_dns = -1;
1856 options->server_alive_interval = -1; 1880 options->server_alive_interval = -1;
1857 options->server_alive_count_max = -1; 1881 options->server_alive_count_max = -1;
1882 options->send_env = NULL;
1858 options->num_send_env = 0; 1883 options->num_send_env = 0;
1884 options->setenv = NULL;
1885 options->num_setenv = 0;
1859 options->control_path = NULL; 1886 options->control_path = NULL;
1860 options->control_master = -1; 1887 options->control_master = -1;
1861 options->control_persist = -1; 1888 options->control_persist = -1;
@@ -2606,6 +2633,7 @@ dump_client_config(Options *o, const char *host)
2606 dump_cfg_strarray_oneline(oGlobalKnownHostsFile, o->num_system_hostfiles, o->system_hostfiles); 2633 dump_cfg_strarray_oneline(oGlobalKnownHostsFile, o->num_system_hostfiles, o->system_hostfiles);
2607 dump_cfg_strarray_oneline(oUserKnownHostsFile, o->num_user_hostfiles, o->user_hostfiles); 2634 dump_cfg_strarray_oneline(oUserKnownHostsFile, o->num_user_hostfiles, o->user_hostfiles);
2608 dump_cfg_strarray(oSendEnv, o->num_send_env, o->send_env); 2635 dump_cfg_strarray(oSendEnv, o->num_send_env, o->send_env);
2636 dump_cfg_strarray(oSetEnv, o->num_setenv, o->setenv);
2609 2637
2610 /* Special cases */ 2638 /* Special cases */
2611 2639