From nobody Tue Oct 24 00:57:30 2023 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4SDtvG2xHdz4xDhj; Tue, 24 Oct 2023 00:57:30 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4SDtvG2N2Zz4RJP; Tue, 24 Oct 2023 00:57:30 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1698109050; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=SnzngUaWsRaP7iUOvqUSo1L/CJCP3hPfXSrM3Sl3fUc=; b=EEWTgDmjlb4bOq29SSz6pDZo7U+C+/KnMWpHpBNFl5y4pNhbCV6QgUIK2esRoDK5jn9bfE gdZFVXKPMaZy0iVNuKRO0mUSJAdLQTsTtKsei3M+geOI7fKHMtheCbrlgzdC/kbg7oCrw7 yXMalKnJ/nAHJNcbcv0bpA6QY/dX3DIJWhKgfkJg2JjYZjIQEcLP9P+1tCLcQlZXapZCjk eRx5Grm6ZLawq+oCfsIj8f4Z0U3UcWy59sK6eJQCviPxA/uZRWTAJkKq3SlHbdzcylopLY 0jCofqnD8kCgxTsv1tCk653TcsL5+lAy+S6HiHN3Xw3+DvaF1oFTfXtmBsbosA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1698109050; a=rsa-sha256; cv=none; b=N5MnRv73oXZz/aBQMNRTuV6AXGpKg1ZlrV+s52noGmnRnwl3J5oO5it+seSnHfrNCjo7PG +JwAh2UCHNckoJAdNNKRtl8n8OFXMSjAF52/B2DaGssnciPct87dpRI0RQRUOv6ZexbJNH al9bjtFiF+5HSg9Ca4TTtrKfWMoBuL9x6PGyfjcS0Dtb7JSwnBab+lva6NVS6NFvC0i92T ZeUvQ6NMJTNKch/ULw6pTNhRiWS27oBMEYY/gVUg36n82uGCYUWlOeRbjizmN3wgdMAkMA YKDEWfc+vPL0/WrkT/tRSv5QOtIzQl7doS+VLGyswzpECYPApiFPgLfccz+ViQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1698109050; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=SnzngUaWsRaP7iUOvqUSo1L/CJCP3hPfXSrM3Sl3fUc=; b=mYaI1LjvvZERJiEXZ+cb8qJlODSioyy5nqIG/MsZdfvxAB1e9zP/DiCyLS2QVvGlhpFnNT 43nNCrryHT+0yEV4Prw20O/UjUzSbfr/RiNvGF/RmPxxtLhCA6hftsDALzWsY53NINwcg5 YHtAXagcrIDvp3Zn5YVDCao22nVOf/uRo0lpwAb1RCDwcHgXfBX3qTbi3josY+U0anHH8F J1e2RDXXB9N1J5WcVJZIOkGQUOZBh9PXhq20D0efQuN3sn0UEsl6W61boUj9V+aPjwjzNV a8g+gca5Ocyyhgt3en748KAbFz2pW423e12qvg5sSSmarB3sN9/lpVAZ8whafw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4SDtvG1NQ9z12ZC; Tue, 24 Oct 2023 00:57:30 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 39O0vUBL021635; Tue, 24 Oct 2023 00:57:30 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 39O0vUbR021632; Tue, 24 Oct 2023 00:57:30 GMT (envelope-from git) Date: Tue, 24 Oct 2023 00:57:30 GMT Message-Id: <202310240057.39O0vUbR021632@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Ed Maste Subject: git: ede6fd06726c - stable/14 - setusercontext(): Apply personal settings only on matching effective UID List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: emaste X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: ede6fd06726c02e9d2a5c47ac8cf80d8aaec5a70 Auto-Submitted: auto-generated The branch stable/14 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=ede6fd06726c02e9d2a5c47ac8cf80d8aaec5a70 commit ede6fd06726c02e9d2a5c47ac8cf80d8aaec5a70 Author: Olivier Certner AuthorDate: 2023-05-30 16:35:08 +0000 Commit: Ed Maste CommitDate: 2023-10-24 00:57:11 +0000 setusercontext(): Apply personal settings only on matching effective UID Commit 35305a8dc114 (r211393) added a check on whether 'uid' was equal to getuid() before calling setlogincontext(). Doing so still allows a setuid program to apply resource limits and priorities specified in a user-controlled configuration file ('~/.login_conf') where a non-setuid program could not. Plug the hole by checking instead that the process' effective UID is the target one (which is likely what was meant in the initial commit). PR: 271750 Reviewed by: kib, des MFC after: 2 weeks Sponsored by: Kumacom SAS Differential Revision: https://reviews.freebsd.org/D40351 (cherry picked from commit 892654fe9b5a9115815c30a423b8db47185aebbd) --- lib/libutil/login_class.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/libutil/login_class.c b/lib/libutil/login_class.c index 90a3ec5d106a..1036e9f9208c 100644 --- a/lib/libutil/login_class.c +++ b/lib/libutil/login_class.c @@ -546,7 +546,7 @@ setusercontext(login_cap_t *lc, const struct passwd *pwd, uid_t uid, unsigned in /* * Now, we repeat some of the above for the user's private entries */ - if (getuid() == uid && (lc = login_getuserclass(pwd)) != NULL) { + if (geteuid() == uid && (lc = login_getuserclass(pwd)) != NULL) { mymask = setlogincontext(lc, pwd, mymask, flags); login_close(lc); }