bugzilla-daemon at mindrot.org
2021-Jul-26 10:26 UTC
[Bug 3332] New: Multiple SetEnv commands in the config are ignored (only the first one works)
https://bugzilla.mindrot.org/show_bug.cgi?id=3332
Bug ID: 3332
Summary: Multiple SetEnv commands in the config are ignored
(only the first one works)
Product: Portable OpenSSH
Version: 8.2p1
Hardware: All
OS: Linux
Status: NEW
Severity: minor
Priority: P5
Component: ssh
Assignee: unassigned-bugs at mindrot.org
Reporter: sven at openssh.berkvens.net
Hi,
I tried placing something like this in my configuration:
Host dev6
# Development LXC 6: Test 6
Hostname 10.101.110.6
SetEnv LC_MONETARY=en_US.UTF-8
SetEnv LC_TELEPHONE=en_US.UTF-8
SetEnv LC_MEASUREMENT=en_US.UTF-8
SetEnv LC_NAME=en_US.UTF-8
SetEnv LC_PAPER=en_US.UTF-8
SetEnv LC_ADDRESS=en_US.UTF-8
SetEnv LC_IDENTIFICATION=en_US.UTF-8
SetEnv LC_NUMERIC=en_US.UTF-8
SetEnv LC_TIME=en_US.UTF-8
SetEnv LANG=en_US.UTF-8
This does not work properly. The SetEnv commands are all accepted while
reading the configuration file, but only the first one is actually
remembered and sent. If I run "ssh -G dev6" to get the configuration,
it says:
....
userknownhostsfile ~/.ssh/known_hosts ~/.ssh/known_hosts2
sendenv LANG
sendenv LC_*
setenv LC_MONETARY=en_US.UTF-8
forwardagent yes
....
I think the culprit is a line in readconf.c that I don't understand the
purpose of:
case oSetEnv:
*** value = options->num_setenv;
while ((arg = strdelimw(&s)) != NULL && *arg !=
'\0') {
if (strchr(arg, '=') == NULL)
fatal("%s line %d: Invalid SetEnv.",
filename, linenum);
*** if (!*activep || value != 0)
continue;
/* Adding a setenv var */
if (options->num_setenv >= INT_MAX)
fatal("%s line %d: too many SetEnv.",
filename, linenum);
options->setenv = xrecallocarray(
options->setenv, options->num_setenv,
options->num_setenv + 1,
sizeof(*options->setenv));
options->setenv[options->num_setenv++]
xstrdup(arg);
}
break;
The two lines I prefixed with *** look strange to me. The number of
already remembered SetEnv items is remembered at the start. Later, in
the loop, if there were already entries present at the start of the
loop, then every entry that is found in the loop is not stored.
Of course, there is a simple solution for my use case: simply use a
single SetEnv command with all the environment variables and their
values as arguments. But I think the way I tried to write is should be
accepted too. Or, as an alternative, the configuration file reader
should warn me about incorrect usage.
Thanks for reading,
Sven
--
You are receiving this mail because:
You are watching the assignee of the bug.
bugzilla-daemon at mindrot.org
2021-Jul-26 10:26 UTC
[Bug 3332] Multiple SetEnv commands in the config are ignored (only the first one works)
https://bugzilla.mindrot.org/show_bug.cgi?id=3332
Sven Berkvens-Matthijsse <sven at openssh.berkvens.net> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |sven at openssh.berkvens.net
--
You are receiving this mail because:
You are watching the assignee of the bug.
bugzilla-daemon at mindrot.org
2021-Jul-26 10:27 UTC
[Bug 3332] Multiple SetEnv commands in the config are ignored (only the first one works)
https://bugzilla.mindrot.org/show_bug.cgi?id=3332
Sven Berkvens-Matthijsse <sven at openssh.berkvens.net> changed:
What |Removed |Added
----------------------------------------------------------------------------
OS|Linux |All
--
You are receiving this mail because:
You are watching the assignee of the bug.
bugzilla-daemon at mindrot.org
2021-Jul-26 21:29 UTC
[Bug 3332] Multiple SetEnv commands in the config are ignored (only the first one works)
https://bugzilla.mindrot.org/show_bug.cgi?id=3332
Damien Miller <djm at mindrot.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
CC| |djm at mindrot.org
Resolution|--- |WONTFIX
--- Comment #1 from Damien Miller <djm at mindrot.org> ---
This is intentional - SetEnv behaves like almost all other ssh_config
directives (first-match-wins).
Unfortunately, this is inconsistent with SendEnv, because I mistakenly
implemented that allowing multiple directives, which leads to other
problems (e.g. bug #3247).
You may enter multiple environment variables on a single SetEnv line.
--
You are receiving this mail because:
You are watching someone on the CC list of the bug.
You are watching the assignee of the bug.
bugzilla-daemon at mindrot.org
2022-Feb-25 02:57 UTC
[Bug 3332] Multiple SetEnv commands in the config are ignored (only the first one works)
https://bugzilla.mindrot.org/show_bug.cgi?id=3332
Damien Miller <djm at mindrot.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |CLOSED
--- Comment #2 from Damien Miller <djm at mindrot.org> ---
closing bugs resolved before openssh-8.9
--
You are receiving this mail because:
You are watching the assignee of the bug.
You are watching someone on the CC list of the bug.