From nobody Wed Sep 04 20:54:10 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 4WzZVB2FzYz5VMPL; Wed, 04 Sep 2024 20:54:10 +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 4WzZVB1hD9z4Pfd; Wed, 4 Sep 2024 20:54:10 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1725483250; 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=wARvEDljJE1zPyuHknOy+xon+1GoFRVCKVmS4Pm1CbU=; b=b/i2c9VTCLgufsiszWSqqGDDCazxQlTqiz9ALubjyW/4uO8V9aALiOQc/1hPi0NVe5wh8j kEkJOT8o/Zub66M/o+tcB1fhgiANT1b+Zn3yVEgROK3w6ltyK2nw4x5+NZmK9yjrpD2IMC twU6waws9PTu2q/wyORWHngrbgBrLPZazd9Z6l3vaAjOXgtiKs69VUSGh4qPJS3xzlr2cn gvYsRm1Tt1LtIj3YQlF6XujJD3y5zRraMynZotmLdqSyWna3EZlQOFWhD3zT7Ts/670NJ0 ogzpHVvExhvQ+nFDf4R4RxeS1my0J/C11XyDHNbejP5QgfrbjgLMFQQMh3wBVA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1725483250; a=rsa-sha256; cv=none; b=h8Ng/o7QLGvdfpUv3hvgy/7Y+NsejRckf2B9/RmA3Djw7fhsfbXSBDSnYFhHWSpuSLYMRZ l0pvuV3EUxuScuciiTDH3QC0pfvqqwUPz8i5WMLDBN6JbB1V01oKzimMahGiyOwe7EiU1G A5G6zql620QF8mgA71r1CvfnfBRBVKysWcpLLO+QM5cs8wo839HjqmhLhBB1ihHlCAh679 B2LjIzOdDdUYmq/LhzrzaoJQwZjq7v7M6qHNlovaqkwsj+fvEWDOqfVxHoIwC/NLPD2xHO YUC40KwpcOQWB7EreUBU+i7B2KQNBs4VEzz3GZ5VPQS2G9DnbEYqC0fwakQTRg== 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=1725483250; 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=wARvEDljJE1zPyuHknOy+xon+1GoFRVCKVmS4Pm1CbU=; b=I80eBaFfZ4h+Zwn1TVdKcdtfv+3/lTVk3hQaoeylPV0oPuzncnSdiu/n0TG7N6Sr6NTWWU LznjBDjj0boYV9Apr4//s+M2HrcqHnKEzK4FtqRqZzcTmrjHTaNs/E0aWCCXk8VfWCxZjo evU/PBNKoot/wARZxH4lOCJnTlJVJKYBsNdi4f6d/7k10ORFE4ZyGECS2+Xb47PAlwUrrw Bo+AY1JHcaqqdZtkpXGcIOPsiy2D7KY0k/ZeFLV1BHGKzR0swFDtUkt9MgYPUhkutD87kb i/4FAHy8a5lYEDGAcS+UuFq9wyoo9VkyNtXb3FWRAw8WiiB0NWM0sizx6Wa9xQ== 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 4WzZVB1HLszfvV; Wed, 4 Sep 2024 20:54:10 +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 484KsA4p033591; Wed, 4 Sep 2024 20:54:10 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 484KsAUE033588; Wed, 4 Sep 2024 20:54:10 GMT (envelope-from git) Date: Wed, 4 Sep 2024 20:54:10 GMT Message-Id: <202409042054.484KsAUE033588@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: d94dbaa516e0 - releng/14.0 - 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: emaste X-Git-Repository: src X-Git-Refname: refs/heads/releng/14.0 X-Git-Reftype: branch X-Git-Commit: d94dbaa516e0c7fb05a52f1c76020165482b7bf0 Auto-Submitted: auto-generated The branch releng/14.0 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=d94dbaa516e0c7fb05a52f1c76020165482b7bf0 commit d94dbaa516e0c7fb05a52f1c76020165482b7bf0 Author: Kyle Evans AuthorDate: 2024-08-05 18:43:56 +0000 Commit: Ed Maste CommitDate: 2024-09-04 20:31:04 +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) (cherry picked from commit 33708452aaabca205d81eceb83e0813e5882815c) Approved by: so --- 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();