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-b...@mindrot.org Reporter: s...@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. _______________________________________________ openssh-bugs mailing list openssh-bugs@mindrot.org https://lists.mindrot.org/mailman/listinfo/openssh-bugs