diff options
author | Alexander Kanavin <alex.kanavin@gmail.com> | 2024-04-19 14:19:44 +0200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2024-04-24 14:27:53 +0100 |
commit | 4dbd4f112b6126d54b6b4ba839a2f4083a6b23fd (patch) | |
tree | 05ced9298f77343aab64d812f2b741f255d5f5a2 | |
parent | afda33bbc25741c922999523edc97bb494206910 (diff) | |
download | poky-4dbd4f112b6126d54b6b4ba839a2f4083a6b23fd.tar.gz |
connman: make 0002-resolve-musl-does-not-implement-res_ninit.patch libc-agnostic
The patch is reworked to take musl-specific path only if the functions are
undefined by libc (which can be checked via __RES, as explained in
https://www.openwall.com/lists/musl/2020/10/23/16 ).
This should make it more suitable for upstream submission.
(From OE-Core rev: ba373050064815475a3a2de13249864f70720cd6)
Signed-off-by: Alexander Kanavin <alex@linutronix.de>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | meta/recipes-connectivity/connman/connman/0002-resolve-musl-does-not-implement-res_ninit.patch | 105 | ||||
-rw-r--r-- | meta/recipes-connectivity/connman/connman_1.42.bb | 2 |
2 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..71efd9035e 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 @@ | |||
1 | From 01974865e4d331eeaf25248bee1bb96539c450d9 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: Pending |
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 954e7cf..2a9bc51 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 | @@ -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 | -- | ||
87 | 2.39.2 | ||
88 | |||
diff --git a/meta/recipes-connectivity/connman/connman_1.42.bb b/meta/recipes-connectivity/connman/connman_1.42.bb index 91ab9895ac..5c60b9cb83 100644 --- a/meta/recipes-connectivity/connman/connman_1.42.bb +++ b/meta/recipes-connectivity/connman/connman_1.42.bb | |||
@@ -7,9 +7,9 @@ SRC_URI = "${KERNELORG_MIRROR}/linux/network/${BPN}/${BP}.tar.xz \ | |||
7 | file://no-version-scripts.patch \ | 7 | file://no-version-scripts.patch \ |
8 | file://0001-vpn-Adding-support-for-latest-pppd-2.5.0-release.patch \ | 8 | file://0001-vpn-Adding-support-for-latest-pppd-2.5.0-release.patch \ |
9 | file://0001-src-log.c-Include-libgen.h-for-basename-API.patch \ | 9 | file://0001-src-log.c-Include-libgen.h-for-basename-API.patch \ |
10 | file://0002-resolve-musl-does-not-implement-res_ninit.patch \ | ||
10 | " | 11 | " |
11 | 12 | ||
12 | SRC_URI:append:libc-musl = " file://0002-resolve-musl-does-not-implement-res_ninit.patch" | ||
13 | 13 | ||
14 | SRC_URI[sha256sum] = "a3e6bae46fc081ef2e9dae3caa4f7649de892c3de622c20283ac0ca81423c2aa" | 14 | SRC_URI[sha256sum] = "a3e6bae46fc081ef2e9dae3caa4f7649de892c3de622c20283ac0ca81423c2aa" |
15 | 15 | ||