Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 07 Apr 2026 21:49:14 +0000
From:      bugzilla-noreply@freebsd.org
To:        ports-bugs@FreeBSD.org
Subject:   [Bug 294020] security/ossec-hids-agent-config: Invalid character " " in variable name "/usr/bin/id -un"
Message-ID:  <bug-294020-7788-Fu5Rp6cIAl@https.bugs.freebsd.org/bugzilla/>
In-Reply-To: <bug-294020-7788@https.bugs.freebsd.org/bugzilla/>

index | next in thread | previous in thread | raw e-mail

https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=294020

--- Comment #5 from Juhani Krekelä <juhani@krekela.fi> ---
The problem appears to stem from this piece of code on lines 96 to 98 of
security/ossec-hids-local-config/Makefile:

.if empty(USER)
USER=$$(${ID} -un)
.endif

If you were running the build from a normal login session, USER would be set,
but I presume Poudriere doesn't do so. The USER variable is then used a bit
further down in the definition of the SUB_PLIST variable on line 110:

SUB_LIST+=      PORTNAME=${PORTNAME} \
                OSSEC_TYPE=${OSSEC_TYPE} \
                OSSEC_HOME=${OSSEC_HOME} \
                VERSION=${PORTVERSION} \
                USER=${USER} \
                OSSEC_USER=${OSSEC_USER} \
                OSSEC_GROUP=${OSSEC_GROUP} \
                OSSEC_RC=${OSSEC_RC} \
                FW_DROP=${FW_DROP}

The lines it issues a warning on in bsd.options.mk are part of a loop that gets
run once for each option for the port (starts on line 477). The relevant bit
here is that the loop adds SUB_LIST entries for all options (lines 489 to 495):

.      if ! ${SUB_LIST:M${opt}=*}
.        if ${PORT_OPTIONS:M${opt}}
SUB_LIST:=  ${SUB_LIST} ${opt}="" NO_${opt}="@comment "
.        else
SUB_LIST:=  ${SUB_LIST} ${opt}="@comment " NO_${opt}=""
.        endif
.      endif

The usage of := here interacts badly with the way USER was defined. It runs
variable expansion on the contents of SUB_LIST, which (because make variable
expansion is lazy by default) then recursively runs the expansion on USER, (if
I understand this correctly) replacing the "USER=${USER}" bit of the definition
of SUB_LIST with "USER=$(/usr/bin/id -un)". This is then assigned back to the
SUB_LIST variable.

The next time the value of SUB_LIST is used, in a way that causes expansion,
e.g. the next time we go around this loop, it then tries to expand
"USER=$(/usr/bin/id -un)". Since $() is also a possible make variable expansion
syntax, it ends up trying to expand a variable named "/usr/bin/id -un".

A similar problem seems to have been fixed with other variables by changing
$$(…) to `…` in security/ossec-hids* last summer:
https://cgit.freebsd.org/ports/commit/?id=6764a97f12fadadd0d4803aa205c47161ae50ae4

My guess is that the problem with USER was missed back then because it's
usually set from the environment.

-- 
You are receiving this mail because:
You are the assignee for the bug.

home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-294020-7788-Fu5Rp6cIAl>