From nobody Thu Dec 21 13:43:49 2023 X-Original-To: dev-commits-src-all@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 4Sws8j73pkz54px9; Thu, 21 Dec 2023 13:43:49 +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 4Sws8j4Dq3z4NxS; Thu, 21 Dec 2023 13:43:49 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1703166229; 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=GwzrBFcrRbljMUCEwpq0s15BkVBOjodAkkPd99nm9e4=; b=qWD2TUF96/E99Z4WUfhQD9KqyihYfMY4/CkylKd0m4OrmlgzfJ4p4WWcUZEH1oT5JGMQK/ vRYAKiO/TJC+qaaaNbC18g3sphPdLgT6DGc5yoM+AoNY1bG/HCZr7FzGjuwn2NtZNHQdMG OG78ajCkJBLeeGuiknpv+6qKMzE85OPWwE7ZaAM4ydusn+dw4N6jrMnAJrHEFlumwio0+o wwGvtLclGVTYYfjZx7wBM2ozuH4dzEd9iCjLSjbUmvBOCAU2gzMiTow1qGa5fasfwEjKMb 2Gec/Fx32ONfvPDPxb3h0kBnZ797o0EBIDI8WahpB97aOl2xeCjfvVsm5VlLQQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1703166229; a=rsa-sha256; cv=none; b=rfg0dNfcyY9bnu44/KY7Ts4y7VCyjK439SrA7zgjxeeMgK6+KArU0+gsc7wq+ceLn/1APd ZFyn0vfY0fMCSiIOiA53WW7/sQ81ER0zhIgLK9rWHGFBwtUFwdmBWzFgNwrI6fHjOJOa28 VruW16Q6BRo9vvuNA4rBEDvF2uA7p5sfvxn1VJKfh+XFFNuhIYE7hnz8j8XTnU6rq5Kh11 RA2fS34xssAdJ3EaNIMSaPuv9LyOTrC4A/HOPjsDavb2I1VCbRJP9yGQ9VXcU9nfsSWmkn c00q5a9uUpixn20eW72nzCpIKndwg3EqfYV9+cxGPRbWrSfXWfvgNHwqnWvgEA== 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=1703166229; 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=GwzrBFcrRbljMUCEwpq0s15BkVBOjodAkkPd99nm9e4=; b=J5qM2uePnS2uD7AJ45jo62g6TsFZ9dvybu6dX6JcfHjk7la1HmglT7pp3Qqpl/cAKQAwG1 yL7f7h00NFsoh4s+MuSxEVDZXBwTAE/VS9qD8cDBk0Kbt1lsE1fGMRCp+7HzjLQY/Z3U+I YlLxC/RRQx+aQyPzXMdLlmPxe3OTn06x/h+9b6fPanC0rrQr8Zj1jJuSViZQHepX5sBFZR oSUA+a39UgOGd6930l8WUuV6/F3pt9UWlS1wdlVEqT6FraLoPBvb9nFRkyoLScXaNXbmMx gGvGjdSxzY4+sVIrErLgP0IBv+gsMiQmbci4jTGvjk97rwEj6bi+yQHlsbNKGg== 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 4Sws8j2qcczZRV; Thu, 21 Dec 2023 13:43:49 +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 3BLDhncF079681; Thu, 21 Dec 2023 13:43:49 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3BLDhnYl079678; Thu, 21 Dec 2023 13:43:49 GMT (envelope-from git) Date: Thu, 21 Dec 2023 13:43:49 GMT Message-Id: <202312211343.3BLDhnYl079678@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Olivier Certner Subject: git: 9fcf54d3750e - stable/13 - setusercontext(): Apply personal settings only on matching effective UID List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: olce X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 9fcf54d3750e379868e51e4aa7fbf696877ab2ed Auto-Submitted: auto-generated The branch stable/13 has been updated by olce: URL: https://cgit.FreeBSD.org/src/commit/?id=9fcf54d3750e379868e51e4aa7fbf696877ab2ed commit 9fcf54d3750e379868e51e4aa7fbf696877ab2ed Author: Olivier Certner AuthorDate: 2023-05-30 16:35:08 +0000 Commit: Olivier Certner CommitDate: 2023-12-21 13:39:03 +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 Sponsored by: Kumacom SAS Differential Revision: https://reviews.freebsd.org/D40351 (cherry picked from commit 892654fe9b5a9115815c30a423b8db47185aebbd) Approved by: markj (mentor) --- 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); }