Lines 10-28
Link Here
|
10 |
Sponsored by: DARPA, NAI Labs |
10 |
Sponsored by: DARPA, NAI Labs |
11 |
|
11 |
|
12 |
|
12 |
|
13 |
--- session.c 2013-03-14 19:22:37 UTC |
13 |
--- session.c.orig 2017-10-02 19:34:26 UTC |
14 |
+++ session.c |
14 |
+++ session.c |
15 |
@@ -985,6 +985,9 @@ do_setup_env(Session *s, const char *she |
15 |
@@ -966,6 +966,9 @@ do_setup_env(struct ssh *ssh, Session *s |
16 |
struct passwd *pw = s->pw; |
16 |
struct passwd *pw = s->pw; |
17 |
#if !defined (HAVE_LOGIN_CAP) && !defined (HAVE_CYGWIN) |
17 |
#if !defined (HAVE_LOGIN_CAP) && !defined (HAVE_CYGWIN) |
18 |
char *path = NULL; |
18 |
char *path = NULL; |
19 |
+#else |
19 |
+#else |
20 |
+ extern char **environ; |
20 |
+ extern char **environ; |
21 |
+ char **senv, **var; |
21 |
+ char **senv, **var, *val; |
22 |
#endif |
22 |
#endif |
23 |
|
23 |
|
24 |
/* Initialize the environment. */ |
24 |
/* Initialize the environment. */ |
25 |
@@ -1006,6 +1009,9 @@ do_setup_env(Session *s, const char *she |
25 |
@@ -987,6 +990,9 @@ do_setup_env(struct ssh *ssh, Session *s |
26 |
} |
26 |
} |
27 |
#endif |
27 |
#endif |
28 |
|
28 |
|
Lines 32-38
Link Here
|
32 |
#ifdef GSSAPI |
32 |
#ifdef GSSAPI |
33 |
/* Allow any GSSAPI methods that we've used to alter |
33 |
/* Allow any GSSAPI methods that we've used to alter |
34 |
* the childs environment as they see fit |
34 |
* the childs environment as they see fit |
35 |
@@ -1023,11 +1029,21 @@ do_setup_env(Session *s, const char *she |
35 |
@@ -1004,11 +1010,30 @@ do_setup_env(struct ssh *ssh, Session *s |
36 |
child_set_env(&env, &envsize, "LOGIN", pw->pw_name); |
36 |
child_set_env(&env, &envsize, "LOGIN", pw->pw_name); |
37 |
#endif |
37 |
#endif |
38 |
child_set_env(&env, &envsize, "HOME", pw->pw_dir); |
38 |
child_set_env(&env, &envsize, "HOME", pw->pw_dir); |
Lines 45-64
Link Here
|
45 |
- child_set_env(&env, &envsize, "PATH", getenv("PATH")); |
45 |
- child_set_env(&env, &envsize, "PATH", getenv("PATH")); |
46 |
+ child_set_env(&env, &envsize, "PATH", _PATH_STDPATH); |
46 |
+ child_set_env(&env, &envsize, "PATH", _PATH_STDPATH); |
47 |
+ child_set_env(&env, &envsize, "TERM", "su"); |
47 |
+ child_set_env(&env, &envsize, "TERM", "su"); |
|
|
48 |
+ /* |
49 |
+ * Temporarily swap out our real environment with an empty one, |
50 |
+ * let setusercontext() apply any environment variables defined |
51 |
+ * for the user's login class, copy those variables to the child, |
52 |
+ * free the temporary environment, and restore the original. |
53 |
+ */ |
48 |
+ senv = environ; |
54 |
+ senv = environ; |
49 |
+ environ = xmalloc(sizeof(char *)); |
55 |
+ environ = xmalloc(sizeof(*environ)); |
50 |
+ *environ = NULL; |
56 |
+ *environ = NULL; |
51 |
+ (void) setusercontext(lc, pw, pw->pw_uid, |
57 |
+ (void)setusercontext(lc, pw, pw->pw_uid, LOGIN_SETENV|LOGIN_SETPATH); |
52 |
+ LOGIN_SETENV|LOGIN_SETPATH); |
58 |
+ for (var = environ; *var != NULL; ++var) { |
53 |
+ copy_environment(environ, &env, &envsize); |
59 |
+ if ((val = strchr(*var, '=')) != NULL) { |
54 |
+ for (var = environ; *var != NULL; ++var) |
60 |
+ *val++ = '\0'; |
|
|
61 |
+ child_set_env(&env, &envsize, *var, val); |
62 |
+ } |
55 |
+ free(*var); |
63 |
+ free(*var); |
|
|
64 |
+ } |
56 |
+ free(environ); |
65 |
+ free(environ); |
57 |
+ environ = senv; |
66 |
+ environ = senv; |
58 |
#else /* HAVE_LOGIN_CAP */ |
67 |
#else /* HAVE_LOGIN_CAP */ |
59 |
# ifndef HAVE_CYGWIN |
68 |
# ifndef HAVE_CYGWIN |
60 |
/* |
69 |
/* |
61 |
@@ -1047,15 +1063,9 @@ do_setup_env(Session *s, const char *she |
70 |
@@ -1028,15 +1053,9 @@ do_setup_env(struct ssh *ssh, Session *s |
62 |
# endif /* HAVE_CYGWIN */ |
71 |
# endif /* HAVE_CYGWIN */ |
63 |
#endif /* HAVE_LOGIN_CAP */ |
72 |
#endif /* HAVE_LOGIN_CAP */ |
64 |
|
73 |
|
Lines 74-80
Link Here
|
74 |
/* Set custom environment options from RSA authentication. */ |
83 |
/* Set custom environment options from RSA authentication. */ |
75 |
while (custom_environment) { |
84 |
while (custom_environment) { |
76 |
struct envstring *ce = custom_environment; |
85 |
struct envstring *ce = custom_environment; |
77 |
@@ -1334,7 +1344,7 @@ do_setusercontext(struct passwd *pw) |
86 |
@@ -1321,7 +1340,7 @@ do_setusercontext(struct passwd *pw) |
78 |
if (platform_privileged_uidswap()) { |
87 |
if (platform_privileged_uidswap()) { |
79 |
#ifdef HAVE_LOGIN_CAP |
88 |
#ifdef HAVE_LOGIN_CAP |
80 |
if (setusercontext(lc, pw, pw->pw_uid, |
89 |
if (setusercontext(lc, pw, pw->pw_uid, |