tomcat-11: fix mediator version and license
[oi-userland.git] / components / network / hpn-ssh / patches / 0029-Accept-LANG-and-LC_-environment-variables-from-clien.patch
blob8d2afb6f17d6978ddd0254e329a3130407d59b0d
1 This preserves most of the old SunSSH locale negotiation
2 behaviour (at least the parts that are most commonly used).
4 --- hpn-ssh-hpn-18.4.2/servconf.c.orig
5 +++ hpn-ssh-hpn-18.4.2/servconf.c
6 @@ -174,7 +174,7 @@
7 options->client_alive_interval = -1;
8 options->client_alive_count_max = -1;
9 options->num_authkeys_files = 0;
10 - options->num_accept_env = 0;
11 + options->num_accept_env = -1;
12 options->num_setenv = 0;
13 options->permit_tun = -1;
14 options->permitted_opens = NULL;
15 @@ -493,6 +493,33 @@
16 options->max_sessions = DEFAULT_SESSIONS_MAX;
17 if (options->use_dns == -1)
18 options->use_dns = 0;
19 + if (options->num_accept_env == -1) {
20 + options->num_accept_env = 0;
21 + opt_array_append("[default]", 0, "AcceptEnv",
22 + &options->accept_env, &options->num_accept_env,
23 + "LANG");
24 + opt_array_append("[default]", 0, "AcceptEnv",
25 + &options->accept_env, &options->num_accept_env,
26 + "LC_ALL");
27 + opt_array_append("[default]", 0, "AcceptEnv",
28 + &options->accept_env, &options->num_accept_env,
29 + "LC_CTYPE");
30 + opt_array_append("[default]", 0, "AcceptEnv",
31 + &options->accept_env, &options->num_accept_env,
32 + "LC_COLLATE");
33 + opt_array_append("[default]", 0, "AcceptEnv",
34 + &options->accept_env, &options->num_accept_env,
35 + "LC_TIME");
36 + opt_array_append("[default]", 0, "AcceptEnv",
37 + &options->accept_env, &options->num_accept_env,
38 + "LC_NUMERIC");
39 + opt_array_append("[default]", 0, "AcceptEnv",
40 + &options->accept_env, &options->num_accept_env,
41 + "LC_MONETARY");
42 + opt_array_append("[default]", 0, "AcceptEnv",
43 + &options->accept_env, &options->num_accept_env,
44 + "LC_MESSAGES");
45 + }
46 if (options->client_alive_interval == -1)
47 options->client_alive_interval = 0;
48 if (options->client_alive_count_max == -1)
49 @@ -2252,8 +2279,12 @@
50 fatal("%s line %d: Invalid environment name.",
51 filename, linenum);
52 found = 1;
53 + if (options->num_accept_env == -1)
54 + options->num_accept_env = 0;
55 if (!*activep)
56 continue;
57 + if (strcmp(arg, "none") == 0)
58 + continue;
59 opt_array_append(filename, linenum, keyword,
60 &options->accept_env, &options->num_accept_env,
61 arg);
62 @@ -3016,7 +3047,7 @@
63 } while(0)
64 #define M_CP_STRARRAYOPT(s, num_s) do {\
65 u_int i; \
66 - if (src->num_s != 0) { \
67 + if (src->num_s != 0 && src->num_s != -1) { \
68 for (i = 0; i < dst->num_s; i++) \
69 free(dst->s[i]); \
70 free(dst->s); \
71 --- hpn-ssh-hpn-18.4.2/session.c.orig
72 +++ hpn-ssh-hpn-18.4.2/session.c
73 @@ -848,6 +848,18 @@
77 + * If the given environment variable is set in the daemon's environment,
78 + * push it into the new child as well. If it is unset, do nothing.
79 + */
80 +static void
81 +child_inherit_env(char ***envp, u_int *envsizep, const char *name)
83 + char *value;
84 + if ((value = getenv(name)) != NULL)
85 + child_set_env(envp, envsizep, name, value);
88 +/*
89 * Reads environment variables from the given file and adds/overrides them
90 * into the environment. If the file does not exist, this does nothing.
91 * Otherwise, it must consist of empty lines, comments (line starts with '#')
92 @@ -1031,6 +1043,16 @@
93 ssh_gssapi_do_child(&env, &envsize);
94 #endif
96 + /* Default to the system-wide locale/language settings. */
97 + child_inherit_env(&env, &envsize, "LANG");
98 + child_inherit_env(&env, &envsize, "LC_ALL");
99 + child_inherit_env(&env, &envsize, "LC_CTYPE");
100 + child_inherit_env(&env, &envsize, "LC_COLLATE");
101 + child_inherit_env(&env, &envsize, "LC_TIME");
102 + child_inherit_env(&env, &envsize, "LC_NUMERIC");
103 + child_inherit_env(&env, &envsize, "LC_MONETARY");
104 + child_inherit_env(&env, &envsize, "LC_MESSAGES");
106 /* Set basic environment. */
107 for (i = 0; i < s->num_env; i++)
108 child_set_env(&env, &envsize, s->env[i].name, s->env[i].val);
109 @@ -1074,8 +1096,7 @@
110 /* Normal systems set SHELL by default. */
111 child_set_env(&env, &envsize, "SHELL", shell);
113 - if (getenv("TZ"))
114 - child_set_env(&env, &envsize, "TZ", getenv("TZ"));
115 + child_inherit_env(&env, &envsize, "TZ");
116 if (s->term)
117 child_set_env(&env, &envsize, "TERM", s->term);
118 if (s->display)
119 --- hpn-ssh-hpn-18.4.2/sshd_config.orig
120 +++ hpn-ssh-hpn-18.4.2/sshd_config
121 @@ -26,6 +26,10 @@
122 #SyslogFacility AUTH
123 #LogLevel INFO
125 +# Use the client's locale/language settings
126 +#AcceptEnv LANG LC_ALL LC_CTYPE LC_COLLATE LC_TIME LC_NUMERIC
127 +#AcceptEnv LC_MONETARY LC_MESSAGES
129 # Authentication:
131 #LoginGraceTime 2m
132 --- hpn-ssh-hpn-18.4.2/hpnsshd_config.5.orig
133 +++ hpn-ssh-hpn-18.4.2/hpnsshd_config.5
134 @@ -96,7 +96,20 @@
135 Be warned that some environment variables could be used to bypass restricted
136 user environments.
137 For this reason, care should be taken in the use of this directive.
138 -The default is not to accept any environment variables.
139 +The default is to accept only
140 +.Ev LANG
141 +and the
142 +.Ev LC_*
143 +family of environment variables. If any
144 +.Cm AcceptEnv
145 +directives are present in your config file, they will replace this default
146 +.Po
147 +ie, only the variables you list will be passed into the session's
148 +.Xr environ 7
149 +.Pc .
150 +You can also use an argument of
151 +.Dq none
152 +to specify that no environment variables should be passed.
153 .It Cm AddressFamily
154 Specifies which address family should be used by
155 .Xr sshd 8 .