From nobody Tue Oct 10 01:57:53 2023 X-Original-To: dev-commits-src-main@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 4S4JvQ2BFvz4wtsW; Tue, 10 Oct 2023 01:57:54 +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 4S4JvQ1JvPz4MXT; Tue, 10 Oct 2023 01:57:54 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1696903074; 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=3iClp7elWpo8LFiaCV0+pwPJ4yLCkIynx+riocuvUw4=; b=O5jfVktv3HZdGrZqHOJM+psmWhj/falzI2xCxbklwVAOPkWxmJLvZKlFMne1vafSbyieSX bEQU+7RGSwbdFdJROTmosgmUZqiexa3RiHFu4p/gTsQe7hjUOJh3DxmKQAsSux8X+eeyOV XFtLeWt9ITfJgKeOEsEmMjaIoJFdE3/kBxlQpxxatwWvKdPdpd5R/rGbnuTDEoNP+D6uCq o28A++tO12YlHB0fIzQq5TLhW3UTa37f07xzeGsccaHl0eu2H81PUIpAi6ozpFpN+a479s SxcX7gq+SyJWmrkRIeW/wWklv4zjfsyB/TpNax22bLAwD7U9rBXi3JF+q4k/xQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1696903074; a=rsa-sha256; cv=none; b=uzBGjTsApNoEN4WB8tOhBVkm6nlfJcS4MmNXnp+B22qbVJ+ADGPdNzsZ9euZejnsiV4EU9 d9qPRJjtc+2P6L6r/xHI5WXBGGLk4RpAV0PmBhlM3S5XbdLS7KvZdX1BVrCAuugtyfTCxr o6004fdeY/Y+C1LcdAxPG0UPVFimEwA9GvYVjOVmGhUonPc8V7BIbRChKetXcpLXl1084q l3Z8vnnLDTAswW2i/rOe3HTNXGLqjZ1TpYItQXoo2xxw9RL222os2Y6Zyvptnt6SGO+7TW +MQhk0fWRHz5vctRi20xM9nM0TvEBgnCbgColiBIigBN9uZb6MBlRzkKxA+NxQ== 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=1696903074; 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=3iClp7elWpo8LFiaCV0+pwPJ4yLCkIynx+riocuvUw4=; b=Vb50EpHuNCc1jn8K6DVcGEOo/Hzt6vT+PSgesHTIiZU1D3Gc76bUVWMx+nm0n4nVHFN6tL SVm3UH7pofjG/2n0RJoZGMD9zZGCERuPbQr89D6emI/N06amEYXqcD4tn9FQ61bOhpiFRQ T2MNRTyy0CHpxpBk+k3xTr70K3WnM6+PqMss4ujec2OO1NC3BvS4OBOnEhb4FP4+I5HrzI zVB7QsHNH37HSW71ieWBuAOFqVslrncLSPrsF0sZjtcL+X2XH+y1u5w+bcqqcsAXYoeOSn sjuHIwD3R5nzPYX9Fc6InLYqSk0CB8s6FaIzD7WyKUYC5qwJk0IwH1bBo++CcA== 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 4S4JvQ0KLSz4Jf; Tue, 10 Oct 2023 01:57:54 +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 39A1vrcQ036850; Tue, 10 Oct 2023 01:57:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 39A1vrwb036847; Tue, 10 Oct 2023 01:57:53 GMT (envelope-from git) Date: Tue, 10 Oct 2023 01:57:53 GMT Message-Id: <202310100157.39A1vrwb036847@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ed Maste Subject: git: 892654fe9b5a - main - setusercontext(): Apply personal settings only on matching effective UID List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: 892654fe9b5a9115815c30a423b8db47185aebbd Auto-Submitted: auto-generated The branch main has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=892654fe9b5a9115815c30a423b8db47185aebbd commit 892654fe9b5a9115815c30a423b8db47185aebbd Author: Olivier Certner AuthorDate: 2023-05-30 16:35:08 +0000 Commit: Ed Maste CommitDate: 2023-10-10 01:47:10 +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 --- 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); }