From owner-cvs-all Thu Jun 27 22:54: 2 2002 Delivered-To: cvs-all@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 57F0037B401; Thu, 27 Jun 2002 22:53:57 -0700 (PDT) Received: from nagual.pp.ru (pobrecita.freebsd.ru [194.87.13.42]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2432A43E06; Thu, 27 Jun 2002 22:53:56 -0700 (PDT) (envelope-from ache@pobrecita.freebsd.ru) Received: from pobrecita.freebsd.ru (ache@localhost [127.0.0.1]) by nagual.pp.ru (8.12.4/8.12.3) with ESMTP id g5S5rnYB018283; Fri, 28 Jun 2002 09:53:53 +0400 (MSD) (envelope-from ache@pobrecita.freebsd.ru) Received: (from ache@localhost) by pobrecita.freebsd.ru (8.12.4/8.12.3/Submit) id g5S5rmA2018282; Fri, 28 Jun 2002 09:53:48 +0400 (MSD) (envelope-from ache) Date: Fri, 28 Jun 2002 09:53:47 +0400 From: "Andrey A. Chernov" To: Dag-Erling Smorgrav Cc: cvs-committers@FreeBSD.org, cvs-all@FreeBSD.org Subject: Re: cvs commit: src/crypto/openssh-portable session.c Message-ID: <20020628055347.GA18229@nagual.pp.ru> References: <200206261417.g5QEHTjR074759@freefall.freebsd.org> <20020626152357.GA30110@nagual.pp.ru> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.1i Sender: owner-cvs-all@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Wed, Jun 26, 2002 at 23:59:09 +0200, Dag-Erling Smorgrav wrote: > Yes, that's a good point. The original code also assumes > setusercontext(3) will succeed, and copies the parent's PATH to the > child - but if setusercontext(3) failed, PATH might be anything (what > if sshd was started manually from a shell?) It should use a > compiled-in fallback instead. Here is modified variant of my patch. Problems addressed: fallback PATH, fallback TERM, both like in login. Problems not addressed: method you use produce memory leak, memory mallocked for each new environment variable in setusercontext() but later you free only main environment pointer and not walk through all env. variables list, freeing them. Such code must be added before xfree(environ). --- session.c.bak Wed Jun 26 18:17:28 2002 +++ session.c Fri Jun 28 09:44:21 2002 @@ -962,11 +962,15 @@ _PATH_MAILDIR, pw->pw_name); child_set_env(&env, &envsize, "MAIL", buf); #ifdef HAVE_LOGIN_CAP + child_set_env(&env, &envsize, "PATH", + (pw->pw_uid == 0) ? + _PATH_STDPATH : _PATH_DEFPATH); senv = environ; environ = xmalloc(sizeof(char *)); *environ = NULL; (void) setusercontext(lc, pw, pw->pw_uid, LOGIN_SETENV|LOGIN_SETPATH); + (void) setenv("TERM", "su", 0); copy_environment(environ, &env, &envsize); xfree(environ); environ = senv; -- Andrey A. Chernov http://ache.pp.ru/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe cvs-all" in the body of the message