git: 9496457f230f - main - bsd.init.mk: always define _gid when MK_INSTALL_AS_USER is set

From: Robert Clausecker <fuz_at_FreeBSD.org>
Date: Mon, 24 Aug 2026 23:01:22 UTC
The branch main has been updated by fuz:

URL: https://cgit.FreeBSD.org/src/commit/?id=9496457f230f933afa78b0a60295d59828bff08c

commit 9496457f230f933afa78b0a60295d59828bff08c
Author:     Robert Clausecker <fuz@FreeBSD.org>
AuthorDate: 2026-08-24 18:13:02 +0000
Commit:     Robert Clausecker <fuz@FreeBSD.org>
CommitDate: 2026-08-24 23:01:01 +0000

    bsd.init.mk: always define _gid when MK_INSTALL_AS_USER is set
    
    A recent commit started to use _uid and _gid in <bsd.dirs.mk> to
    mangle the user and group for newly installed directories when
    MK_INSTALL_AS_USER is set.  However, _gid was previously only set
    when _uid was not 0, causing the group to be set to the empty
    string.
    
    Set _uid and _gid together to avoid this problem.
    
    Fixes:          541e6e2d516b6c9d3681b24464e9ef53c1f2579a
    PR:             297841
    Reviewed by:    emaste, imp
    Reported by:    Ralph Zitz <ralph@zitz.dk>
    Differential Revision: https://reviews.freebsd.org/D59150
---
 share/mk/bsd.init.mk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/share/mk/bsd.init.mk b/share/mk/bsd.init.mk
index 4d3acc3a1148..dc6d104e484f 100644
--- a/share/mk/bsd.init.mk
+++ b/share/mk/bsd.init.mk
@@ -32,11 +32,11 @@ OBJS_SRCS_FILTER+= R
 _uid!=	id -u
 .export _uid
 .endif
-.if ${_uid} != 0
 .if !defined(_gid)
 _gid!=	id -g
 .export _gid
 .endif
+.if ${_uid} != 0
 .for x in BIN CONF DOC DTB INFO KMOD LIB MAN NLS SHARE
 $xOWN=	${_uid}
 $xGRP=	${_gid}