---
 src/connman.h  |  2 +-
 src/main.c     |  6 +++++-
 src/resolver.c | 10 +++++++++-
 3 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/src/connman.h b/src/connman.h
index 35eb3f5..0d7b500 100644
--- a/src/connman.h
+++ b/src/connman.h
@@ -244,7 +244,7 @@ int __connman_inet_get_address_netmask(int ifindex,

 #include <connman/resolver.h>

-int __connman_resolver_init(gboolean dnsproxy);
+int __connman_resolver_init(gboolean dnsproxy, gboolean allowresolvmodify);
 void __connman_resolver_cleanup(void);
 int __connman_resolvfile_append(int index, const char *domain, const char 
*server);
 int __connman_resolvfile_remove(int index, const char *domain, const char 
*server);
diff --git a/src/main.c b/src/main.c
index e46fa7b..4d6f064 100644
--- a/src/main.c
+++ b/src/main.c
@@ -468,6 +468,7 @@ static gchar *option_noplugin = NULL;
 static gchar *option_wifi = NULL;
 static gboolean option_detach = TRUE;
 static gboolean option_dnsproxy = TRUE;
+static gboolean option_allowresolvmodify = TRUE;
 static gboolean option_backtrace = TRUE;
 static gboolean option_version = FALSE;

@@ -505,6 +506,9 @@ static GOptionEntry options[] = {
     { "nodnsproxy", 'r', G_OPTION_FLAG_REVERSE,
                 G_OPTION_ARG_NONE, &option_dnsproxy,
                 "Don't enable DNS Proxy" },
+    { "noresolvmodify", 's', G_OPTION_FLAG_REVERSE,
+                G_OPTION_ARG_NONE, &option_allowresolvmodify,
+                "Don't allow resolv.conf changes. Useful if ignoring the 
primary interface" },
     { "nobacktrace", 0, G_OPTION_FLAG_REVERSE,
                 G_OPTION_ARG_NONE, &option_backtrace,
                 "Don't print out backtrace information" },
@@ -687,7 +691,7 @@ int main(int argc, char *argv[])

     __connman_plugin_init(option_plugin, option_noplugin);

-    __connman_resolver_init(option_dnsproxy);
+    __connman_resolver_init(option_dnsproxy, option_allowresolvmodify);
     __connman_rtnl_start();
     __connman_dhcp_init();
     __connman_dhcpv6_init();
diff --git a/src/resolver.c b/src/resolver.c
index 6a64938..473412b 100644
--- a/src/resolver.c
+++ b/src/resolver.c
@@ -55,6 +55,7 @@ struct entry_data {

 static GSList *entry_list = NULL;
 static bool dnsproxy_enabled = false;
+static bool allowresolvmodify_enabled = true;

 struct resolvfile_entry {
     int index;
@@ -89,6 +90,9 @@ static int resolvfile_export(void)
     unsigned int count;
     mode_t old_umask;

+    if (! allowresolvmodify_enabled)
+        return 0;
+
     content = g_string_new("# Generated by Connection Manager\n");

     /*
@@ -619,11 +623,15 @@ static void free_resolvfile(gpointer data)
     g_free(entry);
 }

-int __connman_resolver_init(gboolean dnsproxy)
+int __connman_resolver_init(gboolean dnsproxy, gboolean allowresolvmodify)
 {
     int i;
     char **ns;

+    DBG("allowresolvmodify %d", allowresolvmodify);
+
+    allowresolvmodify_enabled = allowresolvmodify;
+
     DBG("dnsproxy %d", dnsproxy);

     if (!dnsproxy)
--
2.1.0

_______________________________________________
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman

Reply via email to