1 $DragonFly: src/secure/usr.sbin/sshd/Attic/session.c.patch,v 1.1 2004/07/31 20:05:00 geekgod Exp $
2 --- session.c.orig 2004-07-23 14:26:51.000000000 +0200
3 +++ session.c 2004-07-23 14:20:00.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) {
32 char **env, *laddr, *path = NULL;
33 +#ifdef HAVE_LOGIN_CAP
34 + extern char **environ;
37 struct passwd *pw = s->pw;
39 /* Initialize the environment. */
41 copy_environment(environ, &env, &envsize);
45 + child_set_env(&env, &envsize, "TZ", getenv("TZ"));
48 /* Allow any GSSAPI methods that we've used to alter
49 * the childs environment as they see fit
50 @@ -1002,11 +1027,22 @@
51 child_set_env(&env, &envsize, "LOGIN", pw->pw_name);
53 child_set_env(&env, &envsize, "HOME", pw->pw_dir);
54 + snprintf(buf, sizeof buf, "%.200s/%.50s",
55 + _PATH_MAILDIR, pw->pw_name);
56 + child_set_env(&env, &envsize, "MAIL", buf);
58 - if (setusercontext(lc, pw, pw->pw_uid, LOGIN_SETPATH) < 0)
59 - child_set_env(&env, &envsize, "PATH", _PATH_STDPATH);
61 - child_set_env(&env, &envsize, "PATH", getenv("PATH"));
62 + child_set_env(&env, &envsize, "PATH", _PATH_STDPATH);
63 + child_set_env(&env, &envsize, "TERM", "su");
65 + environ = xmalloc(sizeof(char *));
67 + (void) setusercontext(lc, pw, pw->pw_uid,
68 + LOGIN_SETENV|LOGIN_SETPATH);
69 + copy_environment(environ, &env, &envsize);
70 + for (var = environ; *var != NULL; ++var)
74 #else /* HAVE_LOGIN_CAP */
77 @@ -1027,15 +1063,9 @@
78 # endif /* HAVE_CYGWIN */
79 #endif /* HAVE_LOGIN_CAP */
81 - snprintf(buf, sizeof buf, "%.200s/%.50s",
82 - _PATH_MAILDIR, pw->pw_name);
83 - child_set_env(&env, &envsize, "MAIL", buf);
85 /* Normal systems set SHELL by default. */
86 child_set_env(&env, &envsize, "SHELL", shell);
89 - child_set_env(&env, &envsize, "TZ", getenv("TZ"));
91 /* Set custom environment options from RSA authentication. */
92 if (!options.use_login) {
96 if (setusercontext(lc, pw, pw->pw_uid,
97 - (LOGIN_SETALL & ~LOGIN_SETPATH)) < 0) {
98 + (LOGIN_SETALL & ~(LOGIN_SETENV|LOGIN_SETPATH))) < 0) {
99 perror("unable to set user context");
102 @@ -1391,6 +1421,9 @@
104 const char *shell, *shell0, *hostname = NULL;
105 struct passwd *pw = s->pw;
106 +#ifdef HAVE_LOGIN_CAP
107 + int lc_requirehome;
110 /* remove hostkey from the child's memory */
111 destroy_sensitive_data();
112 @@ -1461,6 +1494,10 @@
116 +#ifdef HAVE_LOGIN_CAP
117 + lc_requirehome = login_getcapbool(lc, "requirehome", 0);
120 #if defined(KRB5) && defined(USE_AFS)
122 * At this point, we check to see if AFS is active and if we have
123 @@ -1492,7 +1529,7 @@
124 fprintf(stderr, "Could not chdir to home directory %s: %s\n",
125 pw->pw_dir, strerror(errno));
126 #ifdef HAVE_LOGIN_CAP
127 - if (login_getcapbool(lc, "requirehome", 0))
128 + if (lc_requirehome)