From owner-freebsd-current Tue Jun 25 14:18:24 2002 Delivered-To: freebsd-current@freebsd.org Received: from nagual.pp.ru (pobrecita.freebsd.ru [194.87.13.42]) by hub.freebsd.org (Postfix) with ESMTP id 32A5837B403; Tue, 25 Jun 2002 14:18:15 -0700 (PDT) Received: from pobrecita.freebsd.ru (ache@localhost [127.0.0.1]) by nagual.pp.ru (8.12.4/8.12.3) with ESMTP id g5PLHvcW021300; Wed, 26 Jun 2002 01:18:06 +0400 (MSD) (envelope-from ache@pobrecita.freebsd.ru) Received: (from ache@localhost) by pobrecita.freebsd.ru (8.12.4/8.12.3/Submit) id g5PLHseH021299; Wed, 26 Jun 2002 01:17:55 +0400 (MSD) (envelope-from ache) Date: Wed, 26 Jun 2002 01:17:52 +0400 From: "Andrey A. Chernov" To: des@freebsd.org Cc: current@freebsd.org Subject: openssh-portable fix for setusercontext env. Message-ID: <20020625211749.GA21219@nagual.pp.ru> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.1i Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Current variant not set all needed env. vars correctly. Please note that TZ, PATH, MAIL and TERM variables may be (or may be not) modified by setusercontext() so they must be set _before_ setusercontext() call. And now I keep silence about the place from where I take this code. --- session.c.bak Tue Jun 25 22:33:58 2002 +++ session.c Wed Jun 26 01:09:03 2002 @@ -957,6 +957,17 @@ child_set_env(&env, &envsize, "LOGNAME", pw->pw_name); child_set_env(&env, &envsize, "HOME", pw->pw_dir); #ifdef HAVE_LOGIN_CAP + if (getenv("TZ")) + child_set_env(&env, &envsize, "TZ", getenv("TZ")); + child_set_env(&env, &envsize, "PATH", + (pw->pw_uid == 0) ? + _PATH_STDPATH : _PATH_DEFPATH); + snprintf(buf, sizeof buf, "%.200s/%.50s", + _PATH_MAILDIR, pw->pw_name); + child_set_env(&env, &envsize, "MAIL", buf); + if (s->term) + child_set_env(&env, &envsize, "TERM", s->term); + senv = environ; environ = xmalloc(sizeof(char *)); *environ = NULL; @@ -965,7 +976,6 @@ copy_environment(environ, &env, &envsize); xfree(environ); environ = senv; - child_set_env(&env, &envsize, "PATH", getenv("PATH")); #else /* HAVE_LOGIN_CAP */ # ifndef HAVE_CYGWIN /* @@ -981,16 +991,19 @@ child_set_env(&env, &envsize, "PATH", _PATH_STDPATH); # endif /* SUPERUSER_PATH */ # endif /* HAVE_CYGWIN */ -#endif /* HAVE_LOGIN_CAP */ snprintf(buf, sizeof buf, "%.200s/%.50s", _PATH_MAILDIR, pw->pw_name); child_set_env(&env, &envsize, "MAIL", buf); +#endif /* HAVE_LOGIN_CAP */ /* Normal systems set SHELL by default. */ child_set_env(&env, &envsize, "SHELL", shell); } if (getenv("TZ")) +#ifdef HAVE_LOGIN_CAP + if (options.use_login) +#endif /* HAVE_LOGIN_CAP */ child_set_env(&env, &envsize, "TZ", getenv("TZ")); /* Set custom environment options from RSA authentication. */ @@ -1018,6 +1031,9 @@ if (s->ttyfd != -1) child_set_env(&env, &envsize, "SSH_TTY", s->tty); if (s->term) +#ifdef HAVE_LOGIN_CAP + if (options.use_login) +#endif /* HAVE_LOGIN_CAP */ child_set_env(&env, &envsize, "TERM", s->term); if (s->display) child_set_env(&env, &envsize, "DISPLAY", s->display); -- Andrey A. Chernov http://ache.pp.ru/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message