From nobody Thu Aug 8 20:07:04 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 4WfykJ3CS2z5S8tY; Thu, 08 Aug 2024 20:07:04 +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 4WfykJ1Mmrz4pT0; Thu, 8 Aug 2024 20:07:04 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1723147624; 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=BZxqIXBvETdipGyd0k+oOl8CfWBuT3l5Zv0uhzKXRb8=; b=trGXni4OFCZcffZeWNhkvjrQJr+GjmH/1FlzUWRt5YsA5PONzeKjnRIec14TLFSAnyeVH9 53SIoDcTlHzXF+W9aAWQBISLfaGQd9HcAuwpb6KWUxLSFmi950iet1ZFtA4m6+B5HCXBei X7AC+3IO2GoGfu8q06HpUwuf17fyIL0oOCuUO1Wbv/8f3Ci/corlm9sR+wUcBAtAJ+MWdn E8zH6u3OsSRZCkFGsGtTKGsA/IByBHW/0j6Vh6qkF5m6/tu/1Hy8Kq1j4XIaCUHgmcXE+r S+2TZd+aNuQcVED0plPNS5SiiDBzAl6N4ShUIbdT9ip3swo18HELkTz1h1rARQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1723147624; a=rsa-sha256; cv=none; b=iN27ga/MzPSS+XTs+GJRuhGPJjm/6vBWB0cct4D16CtoDCvjVyd2Dm77dWYpoXAoX17i0R ZP+cfht6TTltvIEwTHtcd62Zd5ncIUDMppxMsG8AYcMhryhRhxJSEKO573firw0GZHCVko wAEBTrdLP3ZC3ox7xH9Q8K/2HGTGLyfdkvoy0qd46Ud+HzlEtepS48fU22O2RsqkDcRijj 3Mm4wpYWOKJ+5l2+pZPmbPc2/GGt3pHJIZ5RFGI+kT/hgYLCsGxF6d3ysJdCRMpotjiNtD r7OHg9n8gJPhI1NFGVDqEvrIkm/fzKDACNYNL9GeaOL8I1LVaajwDFkBcfyMKQ== 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=1723147624; 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=BZxqIXBvETdipGyd0k+oOl8CfWBuT3l5Zv0uhzKXRb8=; b=GdfQYR1LjC/NfPKh9O7DMJQmDiNHPw2Sy2W+frZhJU14ALTW1A6wtXUPgLiziDqDCU8G/W 3uKGdMcvCKCuhICZF8rcn4uNxwRfkP/vme4hFmMVBwzSVXoY52syJyXLacdf8MHHt4rQZY QlEVxKFnmfA93goCsdDGc6/WhGJK2gVUywFaj5SwbZxlFB1KOby6yWYC7y/kNclNVHb6ac 2sm6c183TrLuLm3QlmFIPxjq6yYzp+LB5wueJSZw38ciUPfnj3/mq/49Cy5/j0rZrUp/KP v2EHzGsKMoGoy3pSK827sowBSJHoEL3RYjAdtQdpT/sPGy5E3SgkbhDos1ko4A== 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 4WfykJ0zyTzmyC; Thu, 8 Aug 2024 20:07:04 +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 478K74pt017161; Thu, 8 Aug 2024 20:07:04 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 478K74jW017158; Thu, 8 Aug 2024 20:07:04 GMT (envelope-from git) Date: Thu, 8 Aug 2024 20:07:04 GMT Message-Id: <202408082007.478K74jW017158@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: 33708452aaab - stable/14 - 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/14 X-Git-Reftype: branch X-Git-Commit: 33708452aaabca205d81eceb83e0813e5882815c Auto-Submitted: auto-generated The branch stable/14 has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=33708452aaabca205d81eceb83e0813e5882815c commit 33708452aaabca205d81eceb83e0813e5882815c Author: Kyle Evans AuthorDate: 2024-08-05 18:43:56 +0000 Commit: Kyle Evans CommitDate: 2024-08-08 19:59:21 +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();