Re: git: 24d5194306b5 - main - build: Emit a warning for build targets run as root
- In reply to: Ed Maste : "git: 24d5194306b5 - main - build: Emit a warning for build targets run as root"
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 09 Oct 2026 18:43:57 UTC
> On Oct 9, 2026, at 8:04 AM, Ed Maste <emaste@FreeBSD.org> wrote:
>
> The branch main has been updated by emaste:
>
> URL: https://cgit.FreeBSD.org/src/commit/?id=24d5194306b573bf3396858b4c0aa5d420c37c91
>
> commit 24d5194306b573bf3396858b4c0aa5d420c37c91
> Author: Ed Maste <emaste@FreeBSD.org>
> AuthorDate: 2025-05-14 15:23:42 +0000
> Commit: Ed Maste <emaste@FreeBSD.org>
> CommitDate: 2026-10-09 15:02:30 +0000
>
> build: Emit a warning for build targets run as root
>
> Build targets should generally be run as an unprivileged user. Even
> though building as root is discouraged many users do so, so just start
> with a warning.
>
> Reviewed by: brooks
> Differential Revision: https://reviews.freebsd.org/D50352
> ---
> Makefile.inc1 | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/Makefile.inc1 b/Makefile.inc1
> index c1dd1fe836d3..6a228a29ed5d 100644
> --- a/Makefile.inc1
> +++ b/Makefile.inc1
> @@ -375,6 +375,10 @@ test-system-${_t}: .PHONY
> .elif ${MK_LLD_BOOTSTRAP} == "yes"
> .info SYSTEM_LINKER: libclang will be built for bootstrapping a cross-linker.
> .endif
> +BUILD_USER!= id -u
> +.if ${BUILD_USER} == 0
> +.warning Warning: ${.TARGETS} should not be run as root
> +.endif
> .endif
>
> # End WITH_SYSTEM_COMPILER / WITH_SYSTEM_LD
I don’t think this is the right spot to do this because a lot of targets like `_libraries` are invoked via submakes.
Please see my comments in the Differential.
-Enji