diff options
author | Daniel Wagner <daniel.wagner@bmw-carit.de> | 2011-01-27 15:31:36 +0100 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2011-01-31 15:58:36 +0100 |
commit | cde0b261b8976d168af0cfa05f68f0d2543c501e (patch) | |
tree | 1afa8c5e7786fd0e8901609e4b72d72c2cf1a120 /src | |
parent | 268f4a8f7e81d8b32591e01b6dbcdca0bee1322f (diff) | |
download | connman-cde0b261b8976d168af0cfa05f68f0d2543c501e.tar.gz connman-cde0b261b8976d168af0cfa05f68f0d2543c501e.tar.bz2 connman-cde0b261b8976d168af0cfa05f68f0d2543c501e.zip |
dnsproxy: Fallback to resolv.conf if dnsproxy fails
In case dnsproxy can't create the socket listener we
should fall back to resolv.conf.
Reported by Kalle Valo <kalle.valo@canonical.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/connman.h | 2 | ||||
-rw-r--r-- | src/dnsproxy.c | 12 | ||||
-rw-r--r-- | src/main.c | 2 | ||||
-rw-r--r-- | src/resolver.c | 14 |
4 files changed, 16 insertions, 14 deletions
diff --git a/src/connman.h b/src/connman.h index 979c5646..bf31b62b 100644 --- a/src/connman.h +++ b/src/connman.h @@ -607,7 +607,7 @@ int __connman_iptables_command(const char *format, ...) __attribute__((format(printf, 1, 2))); int __connman_iptables_commit(const char *table_name); -int __connman_dnsproxy_init(connman_bool_t dnsproxy); +int __connman_dnsproxy_init(void); void __connman_dnsproxy_cleanup(void); int __connman_dnsproxy_append(const char *interface, const char *domain, const char *server); int __connman_dnsproxy_remove(const char *interface, const char *domain, const char *server); diff --git a/src/dnsproxy.c b/src/dnsproxy.c index 9c2f023e..b7667a61 100644 --- a/src/dnsproxy.c +++ b/src/dnsproxy.c @@ -114,7 +114,6 @@ struct request_data { gsize resplen; }; -static connman_bool_t dnsproxy_enabled = TRUE; static GSList *server_list = NULL; static GSList *request_list = NULL; static GSList *request_pending_list = NULL; @@ -1446,15 +1445,11 @@ static void destroy_listener(void) destroy_udp_listener(); } -int __connman_dnsproxy_init(connman_bool_t dnsproxy) +int __connman_dnsproxy_init(void) { int err; - DBG("dnsproxy %d", dnsproxy); - - dnsproxy_enabled = dnsproxy; - if (dnsproxy_enabled == FALSE) - return 0; + DBG(""); err = create_listener(); if (err < 0) @@ -1476,9 +1471,6 @@ void __connman_dnsproxy_cleanup(void) { DBG(""); - if (dnsproxy_enabled == FALSE) - return; - connman_notifier_unregister(&dnsproxy_notifier); destroy_listener(); @@ -221,7 +221,6 @@ int main(int argc, char *argv[]) __connman_stats_init(); __connman_resolver_init(option_dnsproxy); - __connman_dnsproxy_init(option_dnsproxy); __connman_ipconfig_init(); __connman_rtnl_init(); __connman_task_init(); @@ -257,7 +256,6 @@ int main(int argc, char *argv[]) __connman_task_cleanup(); __connman_rtnl_cleanup(); __connman_ipconfig_cleanup(); - __connman_dnsproxy_cleanup(); __connman_resolver_cleanup(); __connman_stats_cleanup(); diff --git a/src/resolver.c b/src/resolver.c index 42be0304..73175b30 100644 --- a/src/resolver.c +++ b/src/resolver.c @@ -447,11 +447,23 @@ int __connman_resolver_init(connman_bool_t dnsproxy) { DBG("dnsproxy %d", dnsproxy); - dnsproxy_enabled = dnsproxy; + if (dnsproxy == FALSE) + return 0; + + if (__connman_dnsproxy_init() < 0) { + /* Fall back to resolv.conf */ + return 0; + } + + dnsproxy_enabled = TRUE; + return 0; } void __connman_resolver_cleanup(void) { DBG(""); + + if (dnsproxy_enabled == TRUE) + __connman_dnsproxy_cleanup(); } |