1 $DragonFly: src/secure/usr.sbin/sshd/Attic/session.c.patch,v 1.2 2006/09/28 18:42:50 corecode Exp $
2 --- session.c 2006-09-01 07:38:37.000000000 +0200
3 +++ session.c 2006-09-28 20:03:43.000000000 +0200
12 +#ifdef HAVE_LOGIN_CAP
13 + fname = login_getcapstr(lc, "copyright", NULL, NULL);
14 + if (fname != NULL && (f = fopen(fname, "r")) != NULL) {
15 + while (fgets(buf, sizeof(buf), f) != NULL)
19 +#endif /* HAVE_LOGIN_CAP */
20 + (void)printf("%s\n\t%s %s\n",
21 + "Copyright (c) 1980, 1983, 1986, 1988, 1990, 1991, 1993, 1994",
22 + "The Regents of the University of California. ",
23 + "All rights reserved.");
27 if (options.print_motd) {
30 struct passwd *pw = s->pw;
31 #ifndef HAVE_LOGIN_CAP
34 + extern char **environ;
38 /* Initialize the environment. */
44 + child_set_env(&env, &envsize, "TZ", getenv("TZ"));
47 /* Allow any GSSAPI methods that we've used to alter
48 * the childs environment as they see fit
49 @@ -1044,11 +1068,22 @@
50 child_set_env(&env, &envsize, "LOGIN", pw->pw_name);
52 child_set_env(&env, &envsize, "HOME", pw->pw_dir);
53 + snprintf(buf, sizeof buf, "%.200s/%.50s",
54 + _PATH_MAILDIR, pw->pw_name);
55 + child_set_env(&env, &envsize, "MAIL", buf);
57 - if (setusercontext(lc, pw, pw->pw_uid, LOGIN_SETPATH) < 0)
58 - child_set_env(&env, &envsize, "PATH", _PATH_STDPATH);
60 - child_set_env(&env, &envsize, "PATH", getenv("PATH"));
61 + child_set_env(&env, &envsize, "PATH", _PATH_STDPATH);
62 + child_set_env(&env, &envsize, "TERM", "su");
64 + environ = xmalloc(sizeof(char *));
66 + (void) setusercontext(lc, pw, pw->pw_uid,
67 + LOGIN_SETENV|LOGIN_SETPATH);
68 + copy_environment(environ, &env, &envsize);
69 + for (var = environ; *var != NULL; ++var)
73 #else /* HAVE_LOGIN_CAP */
76 @@ -1069,15 +1104,9 @@
77 # endif /* HAVE_CYGWIN */
78 #endif /* HAVE_LOGIN_CAP */
80 - snprintf(buf, sizeof buf, "%.200s/%.50s",
81 - _PATH_MAILDIR, pw->pw_name);
82 - child_set_env(&env, &envsize, "MAIL", buf);
84 /* Normal systems set SHELL by default. */
85 child_set_env(&env, &envsize, "SHELL", shell);
88 - child_set_env(&env, &envsize, "TZ", getenv("TZ"));
90 /* Set custom environment options from RSA authentication. */
91 if (!options.use_login) {
95 if (setusercontext(lc, pw, pw->pw_uid,
96 - (LOGIN_SETALL & ~LOGIN_SETPATH)) < 0) {
97 + (LOGIN_SETALL & ~(LOGIN_SETENV|LOGIN_SETPATH))) < 0) {
98 perror("unable to set user context");
101 @@ -1472,6 +1501,9 @@
103 const char *shell, *shell0, *hostname = NULL;
104 struct passwd *pw = s->pw;
105 +#ifdef HAVE_LOGIN_CAP
106 + int lc_requirehome;
109 /* remove hostkey from the child's memory */
110 destroy_sensitive_data();
111 @@ -1559,6 +1591,10 @@
115 +#ifdef HAVE_LOGIN_CAP
116 + lc_requirehome = login_getcapbool(lc, "requirehome", 0);
119 #if defined(KRB5) && defined(USE_AFS)
121 * At this point, we check to see if AFS is active and if we have
122 @@ -1590,7 +1626,7 @@
123 fprintf(stderr, "Could not chdir to home directory %s: %s\n",
124 pw->pw_dir, strerror(errno));
125 #ifdef HAVE_LOGIN_CAP
126 - if (login_getcapbool(lc, "requirehome", 0))
127 + if (lc_requirehome)