Check if resolvconf is actually installed
authorMarcel Holtmann <marcel@holtmann.org>
Sat, 9 Aug 2008 02:39:52 +0000 (04:39 +0200)
committerMarcel Holtmann <marcel@holtmann.org>
Sat, 9 Aug 2008 02:39:52 +0000 (04:39 +0200)
plugins/resolvconf.c

index 1d4927b..b065060 100644 (file)
 #include <config.h>
 #endif
 
+#include <unistd.h>
 #include <stdlib.h>
 
 #include <connman/plugin.h>
 #include <connman/driver.h>
 #include <connman/log.h>
 
+#define RESOLVCONF "/sbin/resolvconf"
+
 static int resolvconf_probe(struct connman_element *element)
 {
        const char *nameserver = NULL;
@@ -38,14 +41,18 @@ static int resolvconf_probe(struct connman_element *element)
 
        DBG("element %p name %s", element, element->name);
 
+       if (access(RESOLVCONF, X_OK) < 0)
+               return -errno;
+
        connman_element_get_value(element,
                        CONNMAN_PROPERTY_TYPE_IPV4_NAMESERVER, &nameserver);
 
        if (nameserver == NULL)
                return -EINVAL;
 
-       cmd = g_strdup_printf("echo \"nameserver %s\" | resolvconf -a %s",
-                                       nameserver, element->netdev.name);
+       cmd = g_strdup_printf("echo \"nameserver %s\" | %s -a %s",
+                                               RESOLVCONF, nameserver,
+                                                       element->netdev.name);
 
        DBG("%s", cmd);
 
@@ -78,7 +85,7 @@ static void resolvconf_remove(struct connman_element *element)
 
        connman_element_unref(internet);
 
-       cmd = g_strdup_printf("resolvconf -d %s", element->netdev.name);
+       cmd = g_strdup_printf("%s -d %s", RESOLVCONF, element->netdev.name);
 
        DBG("%s", cmd);