From owner-svn-ports-all@freebsd.org Mon Mar 23 23:15:10 2020 Return-Path: Delivered-To: svn-ports-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id BBE62272E3F; Mon, 23 Mar 2020 23:15:10 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 48mVbL4Lz0z4bLN; Mon, 23 Mar 2020 23:15:10 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 879B91DFEB; Mon, 23 Mar 2020 23:15:10 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 02NNFAnt020552; Mon, 23 Mar 2020 23:15:10 GMT (envelope-from bdrewery@FreeBSD.org) Received: (from bdrewery@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 02NNFAHr020550; Mon, 23 Mar 2020 23:15:10 GMT (envelope-from bdrewery@FreeBSD.org) Message-Id: <202003232315.02NNFAHr020550@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bdrewery set sender to bdrewery@FreeBSD.org using -f From: Bryan Drewery Date: Mon, 23 Mar 2020 23:15:10 +0000 (UTC) To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org Subject: svn commit: r529015 - in head/security/openssh-portable: . files X-SVN-Group: ports-head X-SVN-Commit-Author: bdrewery X-SVN-Commit-Paths: in head/security/openssh-portable: . files X-SVN-Commit-Revision: 529015 X-SVN-Commit-Repository: ports MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-ports-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the ports tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Mar 2020 23:15:10 -0000 Author: bdrewery Date: Mon Mar 23 23:15:09 2020 New Revision: 529015 URL: https://svnweb.freebsd.org/changeset/ports/529015 Log: - Simplify and refactor login.conf environment handling. Modified: head/security/openssh-portable/Makefile head/security/openssh-portable/files/patch-session.c Modified: head/security/openssh-portable/Makefile ============================================================================== --- head/security/openssh-portable/Makefile Mon Mar 23 22:08:48 2020 (r529014) +++ head/security/openssh-portable/Makefile Mon Mar 23 23:15:09 2020 (r529015) @@ -3,7 +3,7 @@ PORTNAME= openssh DISTVERSION= 8.2p1 -PORTREVISION= 0 +PORTREVISION= 1 PORTEPOCH= 1 CATEGORIES= security MASTER_SITES= OPENBSD/OpenSSH/portable Modified: head/security/openssh-portable/files/patch-session.c ============================================================================== --- head/security/openssh-portable/files/patch-session.c Mon Mar 23 22:08:48 2020 (r529014) +++ head/security/openssh-portable/files/patch-session.c Mon Mar 23 23:15:09 2020 (r529015) @@ -1,3 +1,7 @@ +bdrewery: + - Refactor and simplify original commit. + - Stop setting TERM=su without a term. + ------------------------------------------------------------------------ r99055 | des | 2002-06-29 04:21:58 -0700 (Sat, 29 Jun 2002) | 6 lines Changed paths: @@ -10,7 +14,7 @@ Reviewed by: ache Sponsored by: DARPA, NAI Labs --- session.c.orig 2020-02-13 16:40:54.000000000 -0800 -+++ session.c 2020-03-23 14:50:01.165781000 -0700 ++++ session.c 2020-03-23 16:01:07.583958000 -0700 @@ -946,7 +946,7 @@ read_etc_default_login(char ***env, u_int *envsize, ui } #endif /* HAVE_ETC_DEFAULT_LOGIN */ @@ -20,71 +24,41 @@ Sponsored by: DARPA, NAI Labs static void copy_environment_blacklist(char **source, char ***env, u_int *envsize, const char *blacklist) -@@ -994,6 +994,9 @@ do_setup_env(struct ssh *ssh, Session *s, const char * - struct passwd *pw = s->pw; - #if !defined (HAVE_LOGIN_CAP) && !defined (HAVE_CYGWIN) - char *path = NULL; -+#else -+ extern char **environ; -+ char **senv, **var; - #endif - - /* Initialize the environment. */ -@@ -1015,6 +1018,9 @@ do_setup_env(struct ssh *ssh, Session *s, const char * - } - #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 childs environment as they see fit -@@ -1032,11 +1038,21 @@ do_setup_env(struct ssh *ssh, Session *s, const char * - child_set_env(&env, &envsize, "LOGIN", pw->pw_name); - #endif - child_set_env(&env, &envsize, "HOME", pw->pw_dir); -+ 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"); -+ senv = environ; -+ environ = xmalloc(sizeof(char *)); -+ *environ = NULL; -+ (void) setusercontext(lc, pw, pw->pw_uid, -+ LOGIN_SETENV|LOGIN_SETPATH); -+ copy_environment_blacklist(environ, &env, &envsize, NULL); -+ for (var = environ; *var != NULL; ++var) -+ free(*var); -+ free(environ); -+ environ = senv; - #else /* HAVE_LOGIN_CAP */ - # ifndef HAVE_CYGWIN - /* -@@ -1056,17 +1072,9 @@ do_setup_env(struct ssh *ssh, Session *s, const char * +@@ -1056,7 +1056,8 @@ do_setup_env(struct ssh *ssh, Session *s, const char * # 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); ++ /* FreeBSD PAM doesn't set default "MAIL" */ ++ if (1 || !options.use_pam) { + snprintf(buf, sizeof buf, "%.200s/%.50s", + _PATH_MAILDIR, pw->pw_name); + child_set_env(&env, &envsize, "MAIL", buf); +@@ -1067,6 +1068,23 @@ do_setup_env(struct ssh *ssh, Session *s, const char * -- if (getenv("TZ")) -- child_set_env(&env, &envsize, "TZ", getenv("TZ")); + if (getenv("TZ")) + child_set_env(&env, &envsize, "TZ", getenv("TZ")); ++#ifdef HAVE_LOGIN_CAP ++ /* Load environment from /etc/login.conf setenv directives. */ ++ { ++ extern char **environ; ++ char **senv, **var; ++ ++ senv = environ; ++ environ = xmalloc(sizeof(char *)); ++ *environ = NULL; ++ (void) setusercontext(lc, pw, pw->pw_uid, LOGIN_SETENV); ++ copy_environment_blacklist(environ, &env, &envsize, NULL); ++ for (var = environ; *var != NULL; ++var) ++ free(*var); ++ free(environ); ++ environ = senv; ++ } ++#endif if (s->term) child_set_env(&env, &envsize, "TERM", s->term); if (s->display) -@@ -1369,7 +1377,7 @@ do_setusercontext(struct passwd *pw) +@@ -1369,7 +1387,7 @@ do_setusercontext(struct passwd *pw) if (platform_privileged_uidswap()) { #ifdef HAVE_LOGIN_CAP if (setusercontext(lc, pw, pw->pw_uid,