Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F178109944
D29978.1795987331.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
2 KB
Referenced Files
None
Subscribers
None
D29978.1795987331.diff
View Options
Index: session.c
===================================================================
--- session.c
+++ session.c
@@ -990,6 +990,9 @@
struct passwd *pw = s->pw;
#if !defined (HAVE_LOGIN_CAP) && !defined (HAVE_CYGWIN)
char *path = NULL;
+#else
+ extern char **environ;
+ char **senv, **var, *val;
#endif
/* Initialize the environment. */
@@ -1011,6 +1014,9 @@
}
#endif
+ if (getenv("TZ"))
+ child_set_env(&env, &envsize, "TZ", getenv("TZ"));
+
#ifdef GSSAPI
/* Allow any GSSAPI methods that we've used to alter
* the child's environment as they see fit
@@ -1028,11 +1034,33 @@
child_set_env(&env, &envsize, "LOGIN", pw->pw_name);
#endif
child_set_env(&env, &envsize, "HOME", pw->pw_dir);
+ if (!options.use_pam) {
+ snprintf(buf, sizeof buf, "%.200s/%.50s",
+ _PATH_MAILDIR, pw->pw_name);
+ child_set_env(&env, &envsize, "MAIL", buf);
+ }
#ifdef HAVE_LOGIN_CAP
- if (setusercontext(lc, pw, pw->pw_uid, LOGIN_SETPATH) < 0)
- child_set_env(&env, &envsize, "PATH", _PATH_STDPATH);
- else
- child_set_env(&env, &envsize, "PATH", getenv("PATH"));
+ child_set_env(&env, &envsize, "PATH", _PATH_STDPATH);
+ child_set_env(&env, &envsize, "TERM", "su");
+ /*
+ * Temporarily swap out our real environment with an empty one,
+ * let setusercontext() apply any environment variables defined
+ * for the user's login class, copy those variables to the child,
+ * free the temporary environment, and restore the original.
+ */
+ senv = environ;
+ environ = xmalloc(sizeof(*environ));
+ *environ = NULL;
+ (void) setusercontext(lc, pw, pw->pw_uid, LOGIN_SETENV|LOGIN_SETPATH);
+ for (var = environ; *var != NULL; ++var) {
+ if ((val = strchr(*var, '=')) != NULL) {
+ *val++ = '\0';
+ child_set_env(&env, &envsize, *var, val);
+ }
+ free(*var);
+ }
+ free(environ);
+ environ = senv;
#else /* HAVE_LOGIN_CAP */
# ifndef HAVE_CYGWIN
/*
@@ -1052,17 +1080,9 @@
# endif /* HAVE_CYGWIN */
#endif /* HAVE_LOGIN_CAP */
- if (!options.use_pam) {
- snprintf(buf, sizeof buf, "%.200s/%.50s",
- _PATH_MAILDIR, pw->pw_name);
- child_set_env(&env, &envsize, "MAIL", buf);
- }
-
/* Normal systems set SHELL by default. */
child_set_env(&env, &envsize, "SHELL", shell);
- if (getenv("TZ"))
- child_set_env(&env, &envsize, "TZ", getenv("TZ"));
if (s->term)
child_set_env(&env, &envsize, "TERM", s->term);
if (s->display)
@@ -1365,7 +1385,7 @@
if (platform_privileged_uidswap()) {
#ifdef HAVE_LOGIN_CAP
if (setusercontext(lc, pw, pw->pw_uid,
- (LOGIN_SETALL & ~(LOGIN_SETPATH|LOGIN_SETUSER))) < 0) {
+ (LOGIN_SETALL & ~(LOGIN_SETENV|LOGIN_SETPATH|LOGIN_SETUSER))) < 0) {
perror("unable to set user context");
exit(1);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Nov 29, 9:22 PM (20 h, 14 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
42096695
Default Alt Text
D29978.1795987331.diff (2 KB)
Attached To
Mode
D29978: ssh: Pass setusercontext environment variables to child
Attached
Detach File
Event Timeline