mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-29 20:11:16 +00:00
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>
20 lines
371 B
C
20 lines
371 B
C
/*
|
|
* Copyright (C) 2022 Red Hat, Inc.
|
|
* SPDX-License-Identifier: LGPL-2.1-or-later
|
|
*/
|
|
|
|
#include <config.h>
|
|
|
|
#include "internal.h"
|
|
#include "virfile.h"
|
|
|
|
char *
|
|
virFindFileInPath(const char *file)
|
|
{
|
|
if (STREQ_NULLABLE(file, "dnsmasq"))
|
|
return g_strdup("/usr/sbin/dnsmasq");
|
|
|
|
/* We should not need any other binaries so return NULL. */
|
|
return NULL;
|
|
}
|