]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
udevadm-hwdb: honor root when querying
authordongshengyuan <545258830@qq.com>
Fri, 10 Jul 2026 08:05:07 +0000 (16:05 +0800)
committerdongshengyuan <545258830@qq.com>
Fri, 10 Jul 2026 08:05:07 +0000 (16:05 +0800)
The deprecated udevadm hwdb command parsed --root for both update and
test modes, but the test path always queried the host database.

Pass the configured root to hwdb_query() so --root affects --test in
the same way as systemd-hwdb query.

Reproducer:

$ tmp=$(mktemp -d)
$ mkdir -p "$tmp/etc/udev/hwdb.d"
$ printf 'test:codex-root-test\n ID_TEST_CODEX=from-root\n' > "$tmp/etc/udev/hwdb.d/99-codex.hwdb"
$ systemd-hwdb --root="$tmp" update
$ systemd-hwdb --root="$tmp" query test:codex-root-test
ID_TEST_CODEX=from-root
$ udevadm hwdb --root="$tmp" --test=test:codex-root-test
udevadm hwdb is deprecated. Use systemd-hwdb instead.

The last command was expected to print ID_TEST_CODEX=from-root, but
queried the host database instead.

src/udev/udevadm-hwdb.c

index bb6f03d5408901e4e5239cf2133fe82224d22ab7..0a38e6ee06841fd013850efbdd4f3450cf41b917 100644 (file)
@@ -99,7 +99,7 @@ int verb_hwdb_main(int argc, char *argv[], uintptr_t _data, void *userdata) {
         }
 
         if (arg_test)
-                return hwdb_query(arg_test, NULL);
+                return hwdb_query(arg_test, arg_root);
 
         return 0;
 }