From nobody Thu Aug 8 20:07:07 2024 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 4WfykN0Pt6z5S94q; Thu, 08 Aug 2024 20:07:08 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4WfykM5R3nz4pKw; Thu, 8 Aug 2024 20:07:07 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1723147627; 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=xdHX+/fohZbBg2uOie0mmaGi+1eY0YhCSdDT7zW4bcc=; b=pcTmoAQPaxhkQBOH0beWCFHL8bHdvOnT/hGEbt8GEwy0kaQWszcCAt3LCgo440GZRyjt59 MsGTSsAjllFKfwIF8mqz6iGyEuGjoEpUlZrpAKU3u2XcI3afXK0pkTHWVZG/724CIazUpl XSLsiE98lQSdcRvcuRoRH+q698Oa3rSqpqfasmzrNr3dppWnTtYCgUviaqbeAlazkcTMrw nQBzCzQLYI5rzSUalhhOWHpmASd2QZepurFSHqzSYYYv35L3f7pAGWD7rH7I+3euYQ0gtD lV0HrXsQVB/mCnVL9IHc/+lQ6VvzZYtx2i4NeUJ7rjBMLd4aDn6YEKwbuvAnUA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1723147627; a=rsa-sha256; cv=none; b=pDnkalbeCfX/UIo+4A/sPJVAVcBCn5qpNEO1UsBUUrBErvOVpCF8wgXIh0nxNWF4ODdxZb w7fXbtLkmOAHqQHop8jou9gNyfeQ9bZwJjcHW+XcqXLJ5SO3iv7ydIUvgHminQvc+BAy2c Iien+FoaQQkKxS/KOgUtz83rKGFMNPTl4vrwjKh/vkJrIbr+ERoGE5K7XZoq/Hd2Wzio4n kAy3rbct2ougfK9KxUx1usNWWd2XAtVTAQTGkZI+dCnrpqMwl7O9g8a9WaBD2v5WhFm2l5 o8VowjOCN/rq63QQKERaSBQC+Bjc0efEOjlldqElzOZvkmTPtCeafeTTV5Zx1g== 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=1723147627; 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=xdHX+/fohZbBg2uOie0mmaGi+1eY0YhCSdDT7zW4bcc=; b=gDn1K9JS7jBYoDiW452m/SKoOO2RAECHai4KwN7RgZcIpMgJpQcaEjntYKtq3fTEhQ9Cau Yaq9WMBQ0EsF8qsjxZ7sVlMDWR4DNEJ3OIQ0oQLri6Le73wvr7/iZo+KeQeDW+OvBuPB1r toABHu4LSGxwmG0mcM/9i7C4mVWpv9hf986zrArB+nUWFbc3j/rvcaoDtnmdf3YBeLXZzW 4ujQJZ9UVb0CZArhvRiQoZ9mVI660ppYm6BksXb8sjlXdzzjFDEIvGNslHyYsYZLT0W50Y 6w/0MACrxO/+xoH4hO7n1LKb28uGMIERKgmmLnSKN1BMeav9yTs/CRwPaGsQvQ== 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 4WfykM50NZzn7W; Thu, 8 Aug 2024 20:07:07 +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 478K77uL017369; Thu, 8 Aug 2024 20:07:07 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 478K77ls017366; Thu, 8 Aug 2024 20:07:07 GMT (envelope-from git) Date: Thu, 8 Aug 2024 20:07:07 GMT Message-Id: <202408082007.478K77ls017366@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kyle Evans Subject: git: 3a9010c98b3d - stable/13 - calendar: don't setlogin(2) in the -a user handlers 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: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kevans X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 3a9010c98b3d9676307fac20d42cdd3cfd4bc46d Auto-Submitted: auto-generated The branch stable/13 has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=3a9010c98b3d9676307fac20d42cdd3cfd4bc46d commit 3a9010c98b3d9676307fac20d42cdd3cfd4bc46d Author: Kyle Evans AuthorDate: 2024-08-05 18:43:56 +0000 Commit: Kyle Evans CommitDate: 2024-08-08 20:00:40 +0000 calendar: don't setlogin(2) in the -a user handlers As of e67975d331 ("Fix 'calendar -a' in several ways."), `calendar -a` will now fork off a new process for each user and do all of its own processing in the user's own context. As a side-effect, calendar(1) started calling setlogin(2) in each of the forked processes and inadvertently hijacked the login name for the session it was running under, which was typically not a fresh session but rather that of whatever cron/periodic run spawned it. Thus, daily and security e-mails started coming from completely arbitrary user. We could create a new session, but it appears that nothing calendar(1) does really needs the login name to be clobbered; opt to just avoid the setlogin(2) call entirely rather than incur the overhead of a new session for each process. PR: 280418 Reviewed by: des, olce Fixes: e67975d331 ("Fix 'calendar -a' in several ways.") (cherry picked from commit 6cb8b61efe8899ee9194563108d0ae90c1eb89e3) --- usr.bin/calendar/calendar.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr.bin/calendar/calendar.c b/usr.bin/calendar/calendar.c index 476c0495d218..2e3baee7d57f 100644 --- a/usr.bin/calendar/calendar.c +++ b/usr.bin/calendar/calendar.c @@ -224,7 +224,7 @@ main(int argc, char *argv[]) lc = login_getpwclass(pw); if (setusercontext(lc, pw, pw->pw_uid, - LOGIN_SETALL) != 0) + LOGIN_SETALL & ~LOGIN_SETLOGIN) != 0) errx(1, "setusercontext"); setenv("HOME", pw->pw_dir, 1); cal();