diff --git a/configure.ac b/configure.ac index 89f74e8ba8..398b05a5d6 100644 --- a/configure.ac +++ b/configure.ac @@ -601,6 +601,16 @@ fi AC_DEFINE_UNQUOTED(IPTABLES_PATH, "$IPTABLES_PATH", [Define to path of iptables binary]) AC_SUBST(IPTABLES_PATH) +# dnsmasq path +AC_ARG_WITH(dnsmasq, AS_HELP_STRING([--with-dnsmasq=/path/to/dnsmasq], [path to dnsmasq])) +if test "x${with_dnsmasq}" = x; then + AC_PATH_PROG(DNSMASQ_PATH, dnsmasq, [], $PATH:/sbin:/usr/sbin) +else + DNSMASQ_PATH="$with_dnsmasq" +fi +AC_DEFINE_UNQUOTED(DNSMASQ_PATH, "$DNSMASQ_PATH", [Define to path of dnsmasq binary]) +AC_SUBST(DNSMASQ_PATH) + # system CA certificates path AC_ARG_WITH(system-ca-path, AS_HELP_STRING([--with-system-ca-path=/path/to/ssl/certs], [path to system CA certificates])) if test "x${with_system_ca_path}" = x; then diff --git a/src/dns-manager/nm-dns-dnsmasq.c b/src/dns-manager/nm-dns-dnsmasq.c index 23f46e9de1..8367693da7 100644 --- a/src/dns-manager/nm-dns-dnsmasq.c +++ b/src/dns-manager/nm-dns-dnsmasq.c @@ -54,6 +54,7 @@ static inline const char * find_dnsmasq (void) { static const char *paths[] = { + DNSMASQ_PATH, "/usr/local/sbin/dnsmasq", "/usr/sbin/dnsmasq", "/sbin/dnsmasq", @@ -62,7 +63,7 @@ find_dnsmasq (void) const char **binary = paths; while (*binary != NULL) { - if (g_file_test (*binary, G_FILE_TEST_EXISTS)) + if (**binary && g_file_test (*binary, G_FILE_TEST_EXISTS)) return *binary; binary++; } diff --git a/src/dnsmasq-manager/nm-dnsmasq-manager.c b/src/dnsmasq-manager/nm-dnsmasq-manager.c index 5ad6b005d1..fb1a367c99 100644 --- a/src/dnsmasq-manager/nm-dnsmasq-manager.c +++ b/src/dnsmasq-manager/nm-dnsmasq-manager.c @@ -169,16 +169,16 @@ static inline const char * nm_find_dnsmasq (void) { static const char *dnsmasq_binary_paths[] = { + DNSMASQ_PATH, "/usr/local/sbin/dnsmasq", "/usr/sbin/dnsmasq", "/sbin/dnsmasq", NULL }; - const char **dnsmasq_binary = dnsmasq_binary_paths; while (*dnsmasq_binary != NULL) { - if (g_file_test (*dnsmasq_binary, G_FILE_TEST_EXISTS)) + if (**dnsmasq_binary && g_file_test (*dnsmasq_binary, G_FILE_TEST_EXISTS)) break; dnsmasq_binary++; }