From nobody Tue Jan 20 04:09:39 2026 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 4dwDNz68P2z6Nw2J for ; Tue, 20 Jan 2026 04:09:39 +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 "R13" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4dwDNz3lVtz3VtP for ; Tue, 20 Jan 2026 04:09:39 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1768882179; 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=b93pFQKvRl5RequZFmVW0eV9n1l7mxes2cNp0gYkD1E=; b=vcPL528/z2cfIOw88oj2gsAvX3CMMnzAo5d+zxB7ivlTgA4hbNlEC5ma9yuESPwbxTckPh BEttBNRV4X8J7aS+seJKbtb9d8o9k2r4QWhGUc02Ttsp1G9ELN9KPP76XjIQRkJ6E3LivL l+2dQXx1p5JI3+1NQIh+k2re56QlORW4Twb62Wqt/qCEMqz1FdfumZBFPXYTTiyO+xXsWg fO+c8Dgrq8h3xWN7f7QvgKfxPeiUPy+3Pnc/ppK8xFWYbir7/YzNFu1R1Foe0etaoWqNcv mR7X/AWt3fDWZvaWY0y4GJvTCIkqAPwEvHFJS3DlS5YTeerNZkJEtoGF+oS6ug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1768882179; 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=b93pFQKvRl5RequZFmVW0eV9n1l7mxes2cNp0gYkD1E=; b=f6DKCIp0XzJgV+i3LHhkwKuZkaLu1e1nCqt2N6ur7LFiIuX6JTx8a+rtqCmwdCBiG1WKFj +4Y7XF+UJ/DuiQv89SL0eRFkWAPDZ+rnZbDqCMrFEdHQKjA/EllaNeZfdnv6n5PHQ8xsUA TFx944UL+sslzIaFzk+79sJ/YUNs3y//i56a4xl+JEaOyIqEO46Fy3QOMeWB8m9qJxSddZ 6DgDWXI6DuhRo80x2+4YdzuGLY8C3RBM+v2uJwYRslF2tNzY6EotzJu4fVaWTH9esQVCzA G4HRw2ia/WwUTQEI2/ApmS8mEth74ABjfs8uruGR+gnccY2y0jWuWDt+9H9Apg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1768882179; a=rsa-sha256; cv=none; b=qt0rkHe5duvPbv/wKCM2RMwLyKOO6tIsJd9ZZ5SLl0Q01SOFQXY29O4Y60gzLpuPaCpq3x 1/0Pb+UY+pmKbvPEADt2+dSv0ZE+TXbsIyY80Qg+lTd3eI8tTb2Oj6GLGqwiyRiyDX3pN6 G59ScGhM6ZwsAX01bcajjlYMiXh6bByCCdJQhh/n7AACivi0nuuJAeiaA8nfs1yZUirj4O nGIYERLAO8GItOmA0NW7bvO6asTVIDB9YV7iiBLdSq4iR1DmJHYkQiHcCM0LlzuMb0/XQ7 h/mJ298GgOgHjWSmSJOOAB2TKqvuvV+TWOKQUxMpoPpYbSiJAeKdTMEX11lZmQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4dwDNz2z5Yz11pT for ; Tue, 20 Jan 2026 04:09:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 27cef by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Tue, 20 Jan 2026 04:09:39 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kyle Evans Subject: git: 57b08d98db0a - stable/14 - libutil: defer setting the MAC label until after the login class 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: 57b08d98db0a5bc16a6f0b47ade5b25021564d14 Auto-Submitted: auto-generated Date: Tue, 20 Jan 2026 04:09:39 +0000 Message-Id: <696f0003.27cef.7b254ad8@gitrepo.freebsd.org> The branch stable/14 has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=57b08d98db0a5bc16a6f0b47ade5b25021564d14 commit 57b08d98db0a5bc16a6f0b47ade5b25021564d14 Author: Kyle Evans AuthorDate: 2025-10-29 02:37:21 +0000 Commit: Kyle Evans CommitDate: 2026-01-20 04:05:44 +0000 libutil: defer setting the MAC label until after the login class MAC policies, like mac_biba(4), may forbid changing the login class once a label has been applied. For setting up the initial login context, this isn't really expected and in-fact may break some class-based configuration. Defer setting the MAC label until after the login class is set, and remove the requirement that we have a pwd entry since the label is pulled from the login class -- we only use pwd for syslog in this path. Patch is largely by Kevin Barry, with some modifications and this commit message by kevans@. PR: 177698 Reviewed by: des, olce Co-authored-by: Kevin Barry (cherry picked from commit 98edcbcce0a4650084bd86e704cfa38bf590250c) --- lib/libutil/login_class.c | 55 ++++++++++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 25 deletions(-) diff --git a/lib/libutil/login_class.c b/lib/libutil/login_class.c index 172da78aaf17..db0218f94371 100644 --- a/lib/libutil/login_class.c +++ b/lib/libutil/login_class.c @@ -544,7 +544,7 @@ setusercontext(login_cap_t *lc, const struct passwd *pwd, uid_t uid, unsigned in /* we need a passwd entry to set these */ if (pwd == NULL) - flags &= ~(LOGIN_SETGROUP | LOGIN_SETLOGIN | LOGIN_SETMAC); + flags &= ~(LOGIN_SETGROUP | LOGIN_SETLOGIN); /* Set the process priority */ if (flags & LOGIN_SETPRIORITY) @@ -565,6 +565,27 @@ setusercontext(login_cap_t *lc, const struct passwd *pwd, uid_t uid, unsigned in } } + /* Set the sessions login */ + if ((flags & LOGIN_SETLOGIN) && setlogin(pwd->pw_name) != 0) { + syslog(LOG_ERR, "setlogin(%s): %m", pwd->pw_name); + login_close(llc); + return (-1); + } + + /* Inform the kernel about current login class */ + if (lc != NULL && lc->lc_class != NULL && (flags & LOGIN_SETLOGINCLASS)) { + error = setloginclass(lc->lc_class); + if (error != 0) { + syslog(LOG_ERR, "setloginclass(%s): %m", lc->lc_class); +#ifdef notyet + login_close(llc); + return (-1); +#endif + } + } + + setlogincontext(lc, pwd, flags); + /* Set up the user's MAC label. */ if ((flags & LOGIN_SETMAC) && mac_is_present(NULL) == 1) { const char *label_string; @@ -573,8 +594,10 @@ setusercontext(login_cap_t *lc, const struct passwd *pwd, uid_t uid, unsigned in label_string = login_getcapstr(lc, "label", NULL, NULL); if (label_string != NULL) { if (mac_from_text(&label, label_string) == -1) { - syslog(LOG_ERR, "mac_from_text('%s') for %s: %m", - pwd->pw_name, label_string); + syslog(LOG_ERR, "mac_from_text('%s') for %s %s: %m", + label_string, pwd != NULL ? "user" : "class", + pwd != NULL ? pwd->pw_name : lc->lc_class); + login_close(llc); return (-1); } if (mac_set_proc(label) == -1) @@ -583,33 +606,15 @@ setusercontext(login_cap_t *lc, const struct passwd *pwd, uid_t uid, unsigned in error = 0; mac_free(label); if (error != 0) { - syslog(LOG_ERR, "mac_set_proc('%s') for %s: %s", - label_string, pwd->pw_name, strerror(error)); + syslog(LOG_ERR, "mac_set_proc('%s') for %s %s: %s", + label_string, pwd != NULL ? "user" : "class", + pwd != NULL ? pwd->pw_name : lc->lc_class, strerror(error)); + login_close(llc); return (-1); } } } - /* Set the sessions login */ - if ((flags & LOGIN_SETLOGIN) && setlogin(pwd->pw_name) != 0) { - syslog(LOG_ERR, "setlogin(%s): %m", pwd->pw_name); - login_close(llc); - return (-1); - } - - /* Inform the kernel about current login class */ - if (lc != NULL && lc->lc_class != NULL && (flags & LOGIN_SETLOGINCLASS)) { - error = setloginclass(lc->lc_class); - if (error != 0) { - syslog(LOG_ERR, "setloginclass(%s): %m", lc->lc_class); -#ifdef notyet - login_close(llc); - return (-1); -#endif - } - } - - setlogincontext(lc, pwd, flags); login_close(llc); /* This needs to be done after anything that needs root privs */