From nobody Wed Sep 04 20:29:38 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 4WzYxt3K9Gz5VKQp; Wed, 04 Sep 2024 20:29:38 +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 4WzYxt2Ltnz4JDk; Wed, 4 Sep 2024 20:29:38 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1725481778; 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=uMqRvsh9gO1gD8TXjAz8HWSLaKfkRhcDJpPriYpQBQA=; b=fch8LT6JaR3PtexVPk/HoxJW15uQVzZpPri5PPQ9wSm/1YuKIu4tyOwvefqbhMOijhcd8W ml2t1eNCPi17Z6+dNssyQZzpekvg/qy2OjDKSvI39aBqbxhYsJig3CJqAyp/yjrzdwMfYC MHVn0wu/Ivp9jtlRVwZ9zB6EqZtoxeMHcfrSzTnTLyuxP6vli77H0TUmWnNpcKdLvuyOly HH6v+ZzBo+V1xPwV0bxNZZgDUb9BZgn3CdnEh8ZOE/sIiXU8tVmUhg/ROtXjQ2OjaJEUqQ wUYvGzJ6aCnc3nAT3Sl8lFiz9V4GZuOuwaXXvV39BIvSnUh2qTS1wcKGKLk96w== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1725481778; a=rsa-sha256; cv=none; b=QFG/jiauZH+ThLPbR7Ow3RnLozlh8PAzCW+UZ5yB8s8A2CRA1FIZAjhqkzuuW4ekyBRNnD kY3O6ICDFFTH0W3qPnyHfIvASYPMezp8tdJn/IXUNdjHBn6/Y79l8uCKzQNdthCB+KlcO4 7bsXIcuoDS8lu43npLm24bd0wSDOBRC/+U157CAXeDSL7D/tu1IzMmtfGRYMNzhzgrAQHz qBLTtPJbkuDuw64Fh+6vNDbk5vCRA3cGXuUtVypUgd9uQDOv3hAutUfiPBqDOsUAsyjMCE IiKz7ud4zmuzpL+wJPEzRKINlFcGEAOMMpdm1zcSfL0ym+ry8RD1GDAdA/MtzQ== 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=1725481778; 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=uMqRvsh9gO1gD8TXjAz8HWSLaKfkRhcDJpPriYpQBQA=; b=pAhVthcK7VudvkA7ZvSIfl8Y8LP8ueM0V8Hkw4NbNfHmN7NZSWcY6y6P0M9mnPiX9vu3Nf BzyxzXheljv9d8eapsBnlYmraVKM+c9N+e2ndPIuh/uS7OpDA+se90TQiMTZOxze8e0P0M dcoH0aMm3N26s0PHzK3Ut5SA8sGArIECATdZUMaOUxaaux0g8EN9FITo2Kg23kJTLkXh+y aEMNiMPas9U8Cfmn9n0KUnzEHBxObseRQxo9cw0I6/7u1em7e/TrPAGu6wELQxrJ9wuRY5 mol/cgztt+gsZqwru1FHwdTI8/btgZI3btpVwnVKJDvnygCwwcsxiP9YB3/cGw== 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 4WzYxt1xxSzfkN; Wed, 4 Sep 2024 20:29:38 +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 484KTcdR082400; Wed, 4 Sep 2024 20:29:38 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 484KTcHs082397; Wed, 4 Sep 2024 20:29:38 GMT (envelope-from git) Date: Wed, 4 Sep 2024 20:29:38 GMT Message-Id: <202409042029.484KTcHs082397@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: eab94c0fbb78 - releng/13.3 - 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/13.3 X-Git-Reftype: branch X-Git-Commit: eab94c0fbb782f1d849981d0dde2106ec9bc8df3 Auto-Submitted: auto-generated The branch releng/13.3 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=eab94c0fbb782f1d849981d0dde2106ec9bc8df3 commit eab94c0fbb782f1d849981d0dde2106ec9bc8df3 Author: Kyle Evans AuthorDate: 2024-08-05 18:43:56 +0000 Commit: Ed Maste CommitDate: 2024-09-04 20:28:41 +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 3a9010c98b3d9676307fac20d42cdd3cfd4bc46d) 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();