Bug 3438 - env var that is SetEnv'ed multiple times in the same SetEnv directive, is sent/printed several times
Summary: env var that is SetEnv'ed multiple times in the same SetEnv directive, is sen...
Status: NEW
Alias: None
Product: Portable OpenSSH
Classification: Unclassified
Component: Miscellaneous (show other bugs)
Version: 9.0p1
Hardware: Other Linux
: P5 normal
Assignee: Assigned to nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-05-22 05:11 AEST by Christoph Anton Mitterer
Modified: 2022-11-15 11:01 AEDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Christoph Anton Mitterer 2022-05-22 05:11:53 AEST
Hey.

Not sure whether this is a bug, but I guess so.

When doing e.g.
  SetEnv LC_ALL=C
  SetEnv LC_ALL=C.UTF-8

only the former will show up in e.g. -G as:
  setenv LC_ALL=C
respectively -v as:
  debug1: channel 0: setting env LC_ALL = "C"

which is, I guess, as it should be.

However, when using:
  SetEnv LC_ALL=C LC_ALL=C.UTF-8

-G will give:
setenv LC_ALL=C
setenv LC_ALL=C.UTF-8

and -v:
  debug1: channel 0: setting env LC_ALL = "C"
  debug1: channel 0: setting env LC_ALL = "C.UTF-8"

and in the remote shell, the env var is actually set to the latter ("C.UTF-8").
If actually desired, than at least this should be documented in SetEnv.

And -G should probably only print the one line that actually matters.


Thanks,
Chris.
Comment 1 Colin Watson 2022-11-14 06:27:22 AEDT
This bug is referenced in the changelog for OpenSSH 9.1/9.1p1 as being fixed in that release:

 * ssh(1), sshd(8): SetEnv directives in ssh_config and sshd_config
   are now first-match-wins to match other directives. Previously
   if an environment variable was multiply specified the last set
   value would have been used. bz3438

Should it be closed?
Comment 2 Christoph Anton Mitterer 2022-11-15 11:01:03 AEDT
I've just verified this with Colin's fresh openssh-client 1:9.1p1-1:

When set in ssh_config as:
  SetEnv LC_ALL=C
  SetEnv LC_ALL=C.UTF-8

one now gets:
  setenv LC_ALL=C
in -G and in -v:
  debug1: channel 0: setting env LC_ALL = "C"


And without the following in the config:
  SetEnv LC_ALL=C LC_ALL=C.UTF-8
one now gets:
  setenv LC_ALL=C
in -G and in -v:
  debug1: channel 0: setting env LC_ALL = "C"


So I can confirm it's been fixed.


I'll leave it open for now, cause maybe ssh upstream wants to add some documentation?


Cheers,
Chris.