summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Wagner <daniel.wagner@bmw-carit.de>2011-01-27 15:31:36 +0100
committerSamuel Ortiz <sameo@linux.intel.com>2011-01-31 15:58:36 +0100
commitcde0b261b8976d168af0cfa05f68f0d2543c501e (patch)
tree1afa8c5e7786fd0e8901609e4b72d72c2cf1a120 /src
parent268f4a8f7e81d8b32591e01b6dbcdca0bee1322f (diff)
downloadconnman-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.h2
-rw-r--r--src/dnsproxy.c12
-rw-r--r--src/main.c2
-rw-r--r--src/resolver.c14
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();
diff --git a/src/main.c b/src/main.c
index d8cc8eac..b64e4356 100644
--- a/src/main.c
+++ b/src/main.c
@@ -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();
}