hwdb: strip the root from filenames when generating hwdb.bin
The modern hwdb.bin format contains the filenames of the input data that makes up the database. This is useful but in offline builds where --root is used, the filenames are the full build paths including the specified root. This introduces build paths and thus information leakage and non-reproducible data. Solve this by stripping the root prefix off the original path when passing to import_file. Add TEST-17-UDEV.hwdb.sh to verify that hwdb.bin files contain the path inside the root, but not the path of the root.
This commit is contained in:
Executable
+35
@@ -0,0 +1,35 @@
|
||||
#!/usr/bin/env bash
|
||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
set -eux
|
||||
set -o pipefail
|
||||
|
||||
if ! command -v systemd-hwdb >/dev/null; then
|
||||
echo "systemd-hwdb not found, skipping."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# shellcheck source=test/units/util.sh
|
||||
. "$(dirname "$0")"/util.sh
|
||||
|
||||
at_exit() (
|
||||
set +e
|
||||
|
||||
[[ -d "$ROOTFS" ]] && rm -rf "$ROOTFS"
|
||||
)
|
||||
trap at_exit EXIT
|
||||
|
||||
ROOTFS="$(mktemp -d -t test-17-udev-hwdb.XXXX)"
|
||||
HWDB=$ROOTFS/usr/lib/udev/hwdb.d
|
||||
|
||||
mkdir -p "$HWDB"
|
||||
cat >"$HWDB/99-test.hwdb" <<EOF
|
||||
scsi:*
|
||||
ID_TEST=test
|
||||
EOF
|
||||
|
||||
systemd-hwdb update --root "$ROOTFS" --usr
|
||||
|
||||
# check the rootfs path does not appear in hwdb.bin
|
||||
run_and_grep -n "$ROOTFS" strings "$ROOTFS/usr/lib/udev/hwdb.bin"
|
||||
# check the path in the rootfs does appear in hwdb.bin
|
||||
run_and_grep 99-test.hwdb strings "$ROOTFS/usr/lib/udev/hwdb.bin"
|
||||
Reference in New Issue
Block a user