summaryrefslogtreecommitdiff
path: root/src/dns-manager
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2014-07-31 14:02:22 -0500
committerDan Williams <dcbw@redhat.com>2014-09-11 12:11:56 -0500
commit544fc82aa722ef2a510969394c82fe88710162cd (patch)
treef5ae373b2926436a92c842613614bdd9627ae5cb /src/dns-manager
parent053c8fa5df1b2df552d83d90ac75a3bfff3fa869 (diff)
downloadNetworkManager-544fc82aa722ef2a510969394c82fe88710162cd.tar.gz
core: consolidate helper progam searching (bgo #734131)
Instead of having basically the same code in a bunch of different place to find helper programs, just have one place do it. Yes, this does mean that the same sequence of paths is searched for all helpers (so for example, dnsmasq will no longer be found first in /usr/local) but I think consistency is the better option here. https://bugzilla.gnome.org/show_bug.cgi?id=734131
Diffstat (limited to 'src/dns-manager')
-rw-r--r--src/dns-manager/nm-dns-dnsmasq.c30
1 files changed, 9 insertions, 21 deletions
diff --git a/src/dns-manager/nm-dns-dnsmasq.c b/src/dns-manager/nm-dns-dnsmasq.c
index 8367693da7..416cfe3b01 100644
--- a/src/dns-manager/nm-dns-dnsmasq.c
+++ b/src/dns-manager/nm-dns-dnsmasq.c
@@ -35,6 +35,7 @@
#include "nm-ip4-config.h"
#include "nm-ip6-config.h"
#include "nm-dns-utils.h"
+#include "NetworkManagerUtils.h"
G_DEFINE_TYPE (NMDnsDnsmasq, nm_dns_dnsmasq, NM_TYPE_DNS_PLUGIN)
@@ -50,26 +51,6 @@ typedef struct {
/*******************************************/
-static inline const char *
-find_dnsmasq (void)
-{
- static const char *paths[] = {
- DNSMASQ_PATH,
- "/usr/local/sbin/dnsmasq",
- "/usr/sbin/dnsmasq",
- "/sbin/dnsmasq",
- NULL
- };
- const char **binary = paths;
-
- while (*binary != NULL) {
- if (**binary && g_file_test (*binary, G_FILE_TEST_EXISTS))
- return *binary;
- binary++;
- }
- return NULL;
-}
-
static gboolean
add_ip4_config (GString *str, NMIP4Config *ip4, gboolean split)
{
@@ -225,6 +206,7 @@ update (NMDnsPlugin *plugin,
const char *hostname)
{
NMDnsDnsmasq *self = NM_DNS_DNSMASQ (plugin);
+ const char *dm_binary;
GString *conf;
GSList *iter;
const char *argv[15];
@@ -240,6 +222,12 @@ update (NMDnsPlugin *plugin,
*/
nm_dns_plugin_child_kill (plugin);
+ dm_binary = nm_utils_find_helper ("dnsmasq", DNSMASQ_PATH, NULL);
+ if (!dm_binary) {
+ nm_log_warn (LOGD_DNS, "Could not find dnsmasq binary");
+ return FALSE;
+ }
+
/* Build up the new dnsmasq config file */
conf = g_string_sized_new (150);
@@ -281,7 +269,7 @@ update (NMDnsPlugin *plugin,
nm_log_dbg (LOGD_DNS, "dnsmasq local caching DNS configuration:");
nm_log_dbg (LOGD_DNS, "%s", conf->str);
- argv[idx++] = find_dnsmasq ();
+ argv[idx++] = dm_binary;
argv[idx++] = "--no-resolv"; /* Use only commandline */
argv[idx++] = "--keep-in-foreground";
argv[idx++] = "--no-hosts"; /* don't use /etc/hosts to resolve */