From nobody Sun Dec 01 20:30:50 2024 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 4Y1dpf5Jysz5g81W; Sun, 01 Dec 2024 20:30:50 +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 "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Y1dpf37M7z4Gp9; Sun, 1 Dec 2024 20:30:50 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1733085050; 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=DbCO9mq/wOKLvjpOf5eBkE42PKc3MIHsuy1XTxZRWWQ=; b=Z/NM0qYDqsK5FdXNlCZMqKchX2Kx24Awig2X6OnlD29FOtIYLV/k1bIGQYZ9pQfXK6jo+R J4zUoYOC7XahHeUDvggvknLySy8/hObmoN0yKaNekomKIAW5iIownLpLJ8i9vRWBP8cb5A 9+koS2IDSiuetariXBlDxRsB3H17SSU2e0u0GU6XAEeAdzHgJ0z6RYFj4wOXq7QBO/m/wv yLVk4IXuMJWC+smb10GWSKCMvdWnTfGFtz6KK/jeBHXT6/DmlZeRpkDn1kjBQBMnZdPGjp ComD2B1zafhubbgLckg2vPsvblLKtrvJdWR4U1dgYq2vdMEDaDmV1fjJDa7O8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1733085050; 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=DbCO9mq/wOKLvjpOf5eBkE42PKc3MIHsuy1XTxZRWWQ=; b=U/F+/pg7eJygF1t5IbPrqRfe0CfGm8CCTjchqXi9EpKOEKxDr8xJOENjdVtfp+4SMnEETT M5peqEvMOqxdQzbYxJwMeF8w95sAxFzGHMRG8tsGUeasdHsHMhgE8rhg2iK0lfyM21ZuSQ vw8Ag6jJgLoMwkRckw7XBFsMODIHt6kehUjuMRdtSnMfUJBgjNopJUOtd+CmHhR5CsG2yw VAJFJVRm2frvActYHk6a+EIDwanjjX+WETEFO9a7Vg7xw51NyObSZMDbOAJ5W4irb9Reks YbasKaJ4dOduFOGNk7DYn13VguuJCdRZI97R4YKYlXd6EfH8WduaywHSWb9Qpw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1733085050; a=rsa-sha256; cv=none; b=C7Uu+rSrQXf5ep9ORyPpqaigaVqFiY9gvsrVOHjoeeBBPp5FhbPcuSPSXwM4a23Z2iFbTq 2RbjXYrk2iwUMJLt6SdSVwwcIzT7l85ZVQ4CtbFJKHA8plS09UIrzj8RFzfEBy+TO7xbGI 5IojXqtBHEkCLGIYsf/l4d2zKubPIqqRa3Drs18AFAgnXH39ZE9kbAmZwNQVNtr+baq5kR hwIqQ13UeieQuW/dbCtXG8AweA5n3LRg+Jq/ieY+AzuEExSfdJIXTt1ANatuAcgnh5U4UV oESSpC/cgVOBuBzddB438bcqUv6mHu54iRxktf78YYa0pJglZNqzN0ciMQAXAQ== 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 4Y1dpf2llWz17SQ; Sun, 1 Dec 2024 20:30:50 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 4B1KUoVl045175; Sun, 1 Dec 2024 20:30:50 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4B1KUoqK045172; Sun, 1 Dec 2024 20:30:50 GMT (envelope-from git) Date: Sun, 1 Dec 2024 20:30:50 GMT Message-Id: <202412012030.4B1KUoqK045172@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: d4dd9e22c138 - main - comsat: Use initgroups and setgid not just setuid 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: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-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: d4dd9e22c13896e6b5e2a6fc78dad4f8496cc14d Auto-Submitted: auto-generated The branch main has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=d4dd9e22c13896e6b5e2a6fc78dad4f8496cc14d commit d4dd9e22c13896e6b5e2a6fc78dad4f8496cc14d Author: Ed Maste AuthorDate: 2024-11-28 16:54:48 +0000 Commit: Ed Maste CommitDate: 2024-12-01 20:29:02 +0000 comsat: Use initgroups and setgid not just setuid PR: 270404 Reviewed by: jlduran Obtained from: NetBSD Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D47828 --- libexec/comsat/comsat.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/libexec/comsat/comsat.c b/libexec/comsat/comsat.c index 76f6190bea7b..e2aea1b709b6 100644 --- a/libexec/comsat/comsat.c +++ b/libexec/comsat/comsat.c @@ -212,10 +212,11 @@ jkfprintf(FILE *tp, char user[], char file[], off_t offset) struct passwd *p; unsigned char line[BUFSIZ]; - /* Set effective uid to user in case mail drop is on nfs */ - if ((p = getpwnam(user)) == NULL) - return; - if (setuid(p->pw_uid) != 0) + /* Set uid/gid/groups to user's in case mail drop is on nfs */ + if ((p = getpwnam(user)) == NULL || + initgroups(p->pw_name, p->pw_gid) == -1 || + setgid(p->pw_gid) == -1 || + setuid(p->pw_uid) == -1) return; if ((fi = fopen(file, "r")) == NULL)