summaryrefslogtreecommitdiffstats
path: root/meta/recipes-connectivity/connman/connman
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-connectivity/connman/connman')
-rw-r--r--meta/recipes-connectivity/connman/connman/0002-resolve-musl-does-not-implement-res_ninit.patch107
1 files changed, 60 insertions, 47 deletions
diff --git a/meta/recipes-connectivity/connman/connman/0002-resolve-musl-does-not-implement-res_ninit.patch b/meta/recipes-connectivity/connman/connman/0002-resolve-musl-does-not-implement-res_ninit.patch
index aefdd3aa06..9e2cc34995 100644
--- a/meta/recipes-connectivity/connman/connman/0002-resolve-musl-does-not-implement-res_ninit.patch
+++ b/meta/recipes-connectivity/connman/connman/0002-resolve-musl-does-not-implement-res_ninit.patch
@@ -1,75 +1,88 @@
1From 01974865e4d331eeaf25248bee1bb96539c450d9 Mon Sep 17 00:00:00 2001 1From 60783f0d885c9a0db8b6f1d528786321e53f1512 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com> 2From: Khem Raj <raj.khem@gmail.com>
3Date: Mon, 6 Apr 2015 23:02:21 -0700 3Date: Mon, 6 Apr 2015 23:02:21 -0700
4Subject: [PATCH] resolve: musl does not implement res_ninit 4Subject: [PATCH] gweb/gresolv.c: make use of res_ninit optional and subject to
5 __RES
5 6
6ported from 7Not all libc implementation have those functions, and the way to determine
8if they do is to check __RES which is explained in resolv.h thusly:
9
10/*
11 * Revision information. This is the release date in YYYYMMDD format.
12 * It can change every day so the right thing to do with it is use it
13 * in preprocessor commands such as "#if (__RES > 19931104)". Do not
14 * compare for equality; rather, use it to determine whether your resolver
15 * is new enough to contain a certain feature.
16 */
17
18Indeed, it needs to be at least 19991006.
19
20The portion of the patch that implements a fallback is ported from
21Alpine Linux:
7http://git.alpinelinux.org/cgit/aports/plain/testing/connman/libresolv.patch 22http://git.alpinelinux.org/cgit/aports/plain/testing/connman/libresolv.patch
8 23
9Upstream-Status: Pending 24Upstream-Status: Submitted [to connman@lists.linux.dev,marcel@holtmann.org]
10 25
11Signed-off-by: Khem Raj <raj.khem@gmail.com> 26Signed-off-by: Khem Raj <raj.khem@gmail.com>
12
13--- 27---
14 gweb/gresolv.c | 34 +++++++++++++--------------------- 28 gweb/gresolv.c | 21 +++++++++++++++++++++
15 1 file changed, 13 insertions(+), 21 deletions(-) 29 1 file changed, 21 insertions(+)
16 30
17diff --git a/gweb/gresolv.c b/gweb/gresolv.c 31diff --git a/gweb/gresolv.c b/gweb/gresolv.c
18index 954e7cf..2a9bc51 100644 32index 8101d71..9f1477c 100644
19--- a/gweb/gresolv.c 33--- a/gweb/gresolv.c
20+++ b/gweb/gresolv.c 34+++ b/gweb/gresolv.c
21@@ -878,8 +879,6 @@ GResolv *g_resolv_new(int index) 35@@ -879,7 +879,9 @@ GResolv *g_resolv_new(int index)
22 resolv->index = index; 36 resolv->index = index;
23 resolv->nameserver_list = NULL; 37 resolv->nameserver_list = NULL;
24 38
25- res_ninit(&resolv->res); 39+#if (__RES >= 19991006)
26- 40 res_ninit(&resolv->res);
41+#endif
42
27 return resolv; 43 return resolv;
28 } 44 }
29 45@@ -920,7 +922,9 @@ void g_resolv_unref(GResolv *resolv)
30@@ -919,8 +918,6 @@ void g_resolv_unref(GResolv *resolv)
31 46
32 flush_nameservers(resolv); 47 flush_nameservers(resolv);
33 48
34- res_nclose(&resolv->res); 49+#if (__RES >= 19991006)
35- 50 res_nclose(&resolv->res);
51+#endif
52
36 g_free(resolv); 53 g_free(resolv);
37 } 54 }
38 55@@ -1024,6 +1028,7 @@ guint g_resolv_lookup_hostname(GResolv *resolv, const char *hostname,
39@@ -1023,24 +1020,19 @@ guint g_resolv_lookup_hostname(GResolv *resolv, const char *hostname,
40 debug(resolv, "hostname %s", hostname); 56 debug(resolv, "hostname %s", hostname);
41 57
42 if (!resolv->nameserver_list) { 58 if (!resolv->nameserver_list) {
43- int i; 59+#if (__RES >= 19991006)
44- 60 int i;
45- for (i = 0; i < resolv->res.nscount; i++) { 61
46- char buf[100]; 62 for (i = 0; i < resolv->res.nscount; i++) {
47- int family = resolv->res.nsaddr_list[i].sin_family; 63@@ -1043,6 +1048,22 @@ guint g_resolv_lookup_hostname(GResolv *resolv, const char *hostname,
48- void *sa_addr = &resolv->res.nsaddr_list[i].sin_addr; 64 if (inet_ntop(family, sa_addr, buf, sizeof(buf)))
49- 65 g_resolv_add_nameserver(resolv, buf, 53, 0);
50- if (family != AF_INET &&
51- resolv->res._u._ext.nsaddrs[i]) {
52- family = AF_INET6;
53- sa_addr = &resolv->res._u._ext.nsaddrs[i]->sin6_addr;
54+ FILE *f = fopen("/etc/resolv.conf", "r");
55+ if (f) {
56+ char line[256], *s;
57+ int i;
58+ while (fgets(line, sizeof(line), f)) {
59+ if (strncmp(line, "nameserver", 10) || !isspace(line[10]))
60+ continue;
61+ for (s = &line[11]; isspace(s[0]); s++);
62+ for (i = 0; s[i] && !isspace(s[i]); i++);
63+ s[i] = 0;
64+ g_resolv_add_nameserver(resolv, s, 53, 0);
65 }
66-
67- if (family != AF_INET && family != AF_INET6)
68- continue;
69-
70- if (inet_ntop(family, sa_addr, buf, sizeof(buf)))
71- g_resolv_add_nameserver(resolv, buf, 53, 0);
72+ fclose(f);
73 } 66 }
67+#else
68+ FILE *f = fopen("/etc/resolv.conf", "r");
69+ if (f) {
70+ char line[256], *s;
71+ int i;
72+ while (fgets(line, sizeof(line), f)) {
73+ if (strncmp(line, "nameserver", 10) || !isspace(line[10]))
74+ continue;
75+ for (s = &line[11]; isspace(s[0]); s++);
76+ for (i = 0; s[i] && !isspace(s[i]); i++);
77+ s[i] = 0;
78+ g_resolv_add_nameserver(resolv, s, 53, 0);
79+ }
80+ fclose(f);
81+ }
82+#endif
74 83
75 if (!resolv->nameserver_list) 84 if (!resolv->nameserver_list)
85 g_resolv_add_nameserver(resolv, "127.0.0.1", 53, 0);
86--
872.39.2
88