diff options
Diffstat (limited to 'meta/recipes-connectivity/connman/connman/0002-resolve-musl-does-not-implement-res_ninit.patch')
-rw-r--r-- | meta/recipes-connectivity/connman/connman/0002-resolve-musl-does-not-implement-res_ninit.patch | 115 |
1 files changed, 60 insertions, 55 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 942b9c97b6..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,83 +1,88 @@ | |||
1 | From c7734e1547db967eccf242fe4b9e8a30b9ff141c Mon Sep 17 00:00:00 2001 | 1 | From 60783f0d885c9a0db8b6f1d528786321e53f1512 Mon Sep 17 00:00:00 2001 |
2 | From: Khem Raj <raj.khem@gmail.com> | 2 | From: Khem Raj <raj.khem@gmail.com> |
3 | Date: Mon, 6 Apr 2015 23:02:21 -0700 | 3 | Date: Mon, 6 Apr 2015 23:02:21 -0700 |
4 | Subject: [PATCH] resolve: musl does not implement res_ninit | 4 | Subject: [PATCH] gweb/gresolv.c: make use of res_ninit optional and subject to |
5 | __RES | ||
5 | 6 | ||
6 | ported from | 7 | Not all libc implementation have those functions, and the way to determine |
8 | if 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 | |||
18 | Indeed, it needs to be at least 19991006. | ||
19 | |||
20 | The portion of the patch that implements a fallback is ported from | ||
21 | Alpine Linux: | ||
7 | http://git.alpinelinux.org/cgit/aports/plain/testing/connman/libresolv.patch | 22 | http://git.alpinelinux.org/cgit/aports/plain/testing/connman/libresolv.patch |
8 | 23 | ||
9 | Upstream-Status: Pending | 24 | Upstream-Status: Submitted [to connman@lists.linux.dev,marcel@holtmann.org] |
10 | 25 | ||
11 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | 26 | Signed-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 | ||
17 | diff --git a/gweb/gresolv.c b/gweb/gresolv.c | 31 | diff --git a/gweb/gresolv.c b/gweb/gresolv.c |
18 | index 38a554e..a9e8740 100644 | 32 | index 8101d71..9f1477c 100644 |
19 | --- a/gweb/gresolv.c | 33 | --- a/gweb/gresolv.c |
20 | +++ b/gweb/gresolv.c | 34 | +++ b/gweb/gresolv.c |
21 | @@ -36,6 +36,7 @@ | 35 | @@ -879,7 +879,9 @@ GResolv *g_resolv_new(int index) |
22 | #include <arpa/inet.h> | ||
23 | #include <arpa/nameser.h> | ||
24 | #include <net/if.h> | ||
25 | +#include <ctype.h> | ||
26 | |||
27 | #include "gresolv.h" | ||
28 | |||
29 | @@ -877,8 +878,6 @@ GResolv *g_resolv_new(int index) | ||
30 | resolv->index = index; | 36 | resolv->index = index; |
31 | resolv->nameserver_list = NULL; | 37 | resolv->nameserver_list = NULL; |
32 | 38 | ||
33 | - res_ninit(&resolv->res); | 39 | +#if (__RES >= 19991006) |
34 | - | 40 | res_ninit(&resolv->res); |
41 | +#endif | ||
42 | |||
35 | return resolv; | 43 | return resolv; |
36 | } | 44 | } |
37 | 45 | @@ -920,7 +922,9 @@ void g_resolv_unref(GResolv *resolv) | |
38 | @@ -918,8 +917,6 @@ void g_resolv_unref(GResolv *resolv) | ||
39 | 46 | ||
40 | flush_nameservers(resolv); | 47 | flush_nameservers(resolv); |
41 | 48 | ||
42 | - res_nclose(&resolv->res); | 49 | +#if (__RES >= 19991006) |
43 | - | 50 | res_nclose(&resolv->res); |
51 | +#endif | ||
52 | |||
44 | g_free(resolv); | 53 | g_free(resolv); |
45 | } | 54 | } |
46 | 55 | @@ -1024,6 +1028,7 @@ guint g_resolv_lookup_hostname(GResolv *resolv, const char *hostname, | |
47 | @@ -1022,24 +1019,19 @@ guint g_resolv_lookup_hostname(GResolv *resolv, const char *hostname, | ||
48 | debug(resolv, "hostname %s", hostname); | 56 | debug(resolv, "hostname %s", hostname); |
49 | 57 | ||
50 | if (!resolv->nameserver_list) { | 58 | if (!resolv->nameserver_list) { |
51 | - int i; | 59 | +#if (__RES >= 19991006) |
52 | - | 60 | int i; |
53 | - for (i = 0; i < resolv->res.nscount; i++) { | 61 | |
54 | - char buf[100]; | 62 | for (i = 0; i < resolv->res.nscount; i++) { |
55 | - int family = resolv->res.nsaddr_list[i].sin_family; | 63 | @@ -1043,6 +1048,22 @@ guint g_resolv_lookup_hostname(GResolv *resolv, const char *hostname, |
56 | - void *sa_addr = &resolv->res.nsaddr_list[i].sin_addr; | 64 | if (inet_ntop(family, sa_addr, buf, sizeof(buf))) |
57 | - | 65 | g_resolv_add_nameserver(resolv, buf, 53, 0); |
58 | - if (family != AF_INET && | ||
59 | - resolv->res._u._ext.nsaddrs[i]) { | ||
60 | - family = AF_INET6; | ||
61 | - sa_addr = &resolv->res._u._ext.nsaddrs[i]->sin6_addr; | ||
62 | + FILE *f = fopen("/etc/resolv.conf", "r"); | ||
63 | + if (f) { | ||
64 | + char line[256], *s; | ||
65 | + int i; | ||
66 | + while (fgets(line, sizeof(line), f)) { | ||
67 | + if (strncmp(line, "nameserver", 10) || !isspace(line[10])) | ||
68 | + continue; | ||
69 | + for (s = &line[11]; isspace(s[0]); s++); | ||
70 | + for (i = 0; s[i] && !isspace(s[i]); i++); | ||
71 | + s[i] = 0; | ||
72 | + g_resolv_add_nameserver(resolv, s, 53, 0); | ||
73 | } | ||
74 | - | ||
75 | - if (family != AF_INET && family != AF_INET6) | ||
76 | - continue; | ||
77 | - | ||
78 | - if (inet_ntop(family, sa_addr, buf, sizeof(buf))) | ||
79 | - g_resolv_add_nameserver(resolv, buf, 53, 0); | ||
80 | + fclose(f); | ||
81 | } | 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 | ||
82 | 83 | ||
83 | if (!resolv->nameserver_list) | 84 | if (!resolv->nameserver_list) |
85 | g_resolv_add_nameserver(resolv, "127.0.0.1", 53, 0); | ||
86 | -- | ||
87 | 2.39.2 | ||
88 | |||