Skip to content

Commit 742e09a

Browse files
committed
fix(postcheck): #11 filters boot-order false positives from tmpfiles dry-run
Build was failing at postcheck #11 with: /usr/lib/tmpfiles.d/mios-infra.conf:5: Failed to resolve group 'cockpit': Unknown group /usr/lib/tmpfiles.d/mios-infra.conf:6: Failed to resolve group 'cockpit': Unknown group cockpit is declared by upstream cockpit-bridge's sysusers.d entry. At runtime the boot order is sysusers -> tmpfiles, so tmpfiles resolves the group fine. At BUILD time inside the OCI image, sysusers has not run, so a tmpfiles --dry-run reports a false positive. Fix: harvest every user + group declared by ANY sysusers.d file (both /etc/sysusers.d and /usr/lib/sysusers.d, awk first-field of u/g lines) and filter out only the 'Failed to resolve (user|group) X: Unknown (user|group)' warnings whose X is in that declared set. Genuine tmpfiles errors -- bad path syntax, unknown line type, missing required field, /var/run/lock paths (caught by #9), etc. -- still fail the build. Tested all three scenarios: - cockpit (declared in sysusers.d) -> warning dropped - unknown_grp (NOT declared) -> warning kept (would fail) - 'Unknown line type XXXX' (real error) -> kept (would fail) awk uses match($0, regex, array) which is gawk-only -- the Fedora bootc base image ships gawk as /usr/bin/awk so this is safe.
1 parent fecf03f commit 742e09a

1 file changed

Lines changed: 37 additions & 2 deletions

File tree

automation/99-postcheck.sh

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,22 +300,57 @@ fi
300300
# Catches: bad path syntax, unsupported types, missing required fields. The
301301
# legacy /var/run / /var/lock case is already covered by #9; this catches
302302
# every other tmpfiles syntax error.
303+
#
304+
# Boot-order caveat: at runtime systemd-sysusers runs before
305+
# systemd-tmpfiles, so groups/users declared in sysusers.d are present
306+
# in /etc/{passwd,group} by the time tmpfiles resolves them. At build
307+
# time inside the OCI image, sysusers has not run, so dry-running
308+
# tmpfiles reports false-positive "Failed to resolve user/group X:
309+
# Unknown user/group" warnings for entities declared in sysusers.d.
310+
# We harvest the declared name set and filter those warnings out --
311+
# every other tmpfiles error still fails the build.
303312
log "Validating MiOS tmpfiles.d syntax..."
304313
if command -v systemd-tmpfiles >/dev/null 2>&1; then
314+
# Build the union of users + groups declared by sysusers.d (any file).
315+
_sysusers_declared=$(
316+
for d in /etc/sysusers.d /usr/lib/sysusers.d; do
317+
[[ -d "$d" ]] || continue
318+
for f in "$d"/*.conf; do
319+
[[ -f "$f" ]] || continue
320+
awk '/^[ug][[:space:]]+/ { print $2 }' "$f"
321+
done
322+
done | sort -u
323+
)
305324
_bad_tmpfiles=$(
306325
for f in /usr/lib/tmpfiles.d/mios-*.conf; do
307326
[[ -f "$f" ]] || continue
308327
# --dry-run alone reports parse errors; combine with --create
309328
# (also dry-run) so it exercises the full directive interpreter.
310329
out=$(systemd-tmpfiles --dry-run --create "$f" 2>&1 || true)
311-
echo "$out" | grep -E "^${f}:" || true
330+
# Keep only lines that name THIS file (filename prefix).
331+
echo "$out" | awk -v f="$f" -v decl="$_sysusers_declared" '
332+
BEGIN {
333+
n = split(decl, a, "\n")
334+
for (i = 1; i <= n; i++) if (a[i] != "") known[a[i]] = 1
335+
}
336+
# Only this-file lines are real findings.
337+
$0 !~ "^" f ":" { next }
338+
{
339+
# If the warning is the boot-order false positive,
340+
# extract the missing entity name and drop the line
341+
# if it is declared in sysusers.d.
342+
if (match($0, /Failed to resolve (user|group) [\x27"]([^\x27"]+)[\x27"]/, m)) {
343+
if (m[2] in known) next
344+
}
345+
print
346+
}'
312347
done
313348
)
314349
if [[ -n "$_bad_tmpfiles" ]]; then
315350
printf '%s\n' "$_bad_tmpfiles" >&2
316351
die "systemd-tmpfiles reported errors in MiOS tmpfiles.d config(s)"
317352
fi
318-
log " MiOS tmpfiles.d configs parse clean"
353+
log " MiOS tmpfiles.d configs parse clean (sysusers-declared names accepted)"
319354
else
320355
log " systemd-tmpfiles unavailable -- skipping tmpfiles verification"
321356
fi

0 commit comments

Comments
 (0)