--- src/connman.h | 2 +- src/main.c | 10 +++++++++- src/resolver.c | 9 +++++++-- 3 files changed, 17 insertions(+), 4 deletions(-)
diff --git a/src/connman.h b/src/connman.h index 35eb3f5..ee2d442 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, const char *resolvfile); 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..9ece5f8 100644 --- a/src/main.c +++ b/src/main.c @@ -466,6 +466,7 @@ static gchar *option_plugin = NULL; static gchar *option_nodevice = NULL; static gchar *option_noplugin = NULL; static gchar *option_wifi = NULL; +static gchar *option_resolvconf = NULL; static gboolean option_detach = TRUE; static gboolean option_dnsproxy = TRUE; static gboolean option_backtrace = TRUE; @@ -508,6 +509,9 @@ static GOptionEntry options[] = { { "nobacktrace", 0, G_OPTION_FLAG_REVERSE, G_OPTION_ARG_NONE, &option_backtrace, "Don't print out backtrace information" }, + { "resolvconf", 's', 0, G_OPTION_ARG_STRING, &option_resolvconf, + "Write to the specified resolv.conf file " + "instead of /etc/resolv.conf " }, { "version", 'v', 0, G_OPTION_ARG_NONE, &option_version, "Show version information and exit" }, { NULL }, @@ -687,7 +691,10 @@ int main(int argc, char *argv[]) __connman_plugin_init(option_plugin, option_noplugin); - __connman_resolver_init(option_dnsproxy); + if (! option_resolvconf) + __connman_resolver_init(option_dnsproxy, "/etc/resolv.conf"); + else + __connman_resolver_init(option_dnsproxy, option_resolvconf); __connman_rtnl_start(); __connman_dhcp_init(); __connman_dhcpv6_init(); @@ -697,6 +704,7 @@ int main(int argc, char *argv[]) __connman_machine_init(); g_free(option_config); + g_free(option_resolvconf); g_free(option_device); g_free(option_plugin); g_free(option_nodevice); diff --git a/src/resolver.c b/src/resolver.c index 6a64938..2925758 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; +const char *config_file = NULL; struct resolvfile_entry { int index; @@ -130,7 +131,7 @@ static int resolvfile_export(void) old_umask = umask(022); - fd = open("/etc/resolv.conf", O_RDWR | O_CREAT | O_CLOEXEC, + fd = open(config_file, O_RDWR | O_CREAT | O_CLOEXEC, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); if (fd < 0) { err = -errno; @@ -619,7 +620,7 @@ static void free_resolvfile(gpointer data) g_free(entry); } -int __connman_resolver_init(gboolean dnsproxy) +int __connman_resolver_init(gboolean dnsproxy, const char *resolvfile) { int i; char **ns; @@ -629,6 +630,10 @@ int __connman_resolver_init(gboolean dnsproxy) if (!dnsproxy) return 0; + DBG("resolvfile %s", resolvfile); + + config_file = resolvfile; + if (__connman_dnsproxy_init() < 0) { /* Fall back to resolv.conf */ return 0; -- 2.1.0 _______________________________________________ connman mailing list connman@connman.net https://lists.connman.net/mailman/listinfo/connman