]> git.ipfire.org Git - thirdparty/libvirt.git/commit
virdnsmasq: Lookup DNSMASQ in PATH
authorMichal Privoznik <mprivozn@redhat.com>
Mon, 10 Jan 2022 15:19:31 +0000 (16:19 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 18 Jan 2022 14:19:47 +0000 (15:19 +0100)
commit5c98d1cee0be741a3205bb08be8bca4165259154
tree7167cba5f9c33c5882e0bad1ccb36246a69ed142
parent96308ebae9b2f4dae4051764944acbb05aae89c9
virdnsmasq: Lookup DNSMASQ in PATH

While it's true that our virCommand subsystem is happy with
non-absolute paths, the dnsmasq capability code is not. It stores
the path to dnsmasq within and makes it accessible via
dnsmasqCapsGetBinaryPath(). While strictly speaking no caller
necessarily needs canonicalized path, let's find dnsmasq once and
cache the result.

Therefore, when constructing the capabilities structure look up
the binary path. If DNSMASQ already contains an absolute path
then virFindFileInPath() will simply return a copy.

With this code in place, the virFileIsExecutable() check can be
removed from dnsmasqCapsRefreshInternal() because
virFindFileInPath() already made sure the binary is executable.

But introducing virFindFileInPath() means we have to mock it in
test suite because dnsmasqCaps are created in
networkxml2conftest.

Moreover, we don't need to check for dnsmasq in configure.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
meson.build
src/util/virdnsmasq.c
tests/meson.build
tests/networkxml2conftest.c
tests/virdnsmasqmock.c [new file with mode: 0644]