summaryrefslogtreecommitdiffstats
path: root/meta/recipes-connectivity/connman/connman/0002-resolve-musl-does-not-implement-res_ninit.patch
diff options
context:
space:
mode:
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.patch115
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 @@
-From c7734e1547db967eccf242fe4b9e8a30b9ff141c Mon Sep 17 00:00:00 2001
+From 60783f0d885c9a0db8b6f1d528786321e53f1512 Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Mon, 6 Apr 2015 23:02:21 -0700
-Subject: [PATCH] resolve: musl does not implement res_ninit
+Subject: [PATCH] gweb/gresolv.c: make use of res_ninit optional and subject to
+ __RES
-ported from
+Not all libc implementation have those functions, and the way to determine
+if they do is to check __RES which is explained in resolv.h thusly:
+
+/*
+ * Revision information. This is the release date in YYYYMMDD format.
+ * It can change every day so the right thing to do with it is use it
+ * in preprocessor commands such as "#if (__RES > 19931104)". Do not
+ * compare for equality; rather, use it to determine whether your resolver
+ * is new enough to contain a certain feature.
+ */
+
+Indeed, it needs to be at least 19991006.
+
+The portion of the patch that implements a fallback is ported from
+Alpine Linux:
http://git.alpinelinux.org/cgit/aports/plain/testing/connman/libresolv.patch
-Upstream-Status: Pending
+Upstream-Status: Submitted [to connman@lists.linux.dev,marcel@holtmann.org]
Signed-off-by: Khem Raj <raj.khem@gmail.com>
-
---
- gweb/gresolv.c | 34 +++++++++++++---------------------
- 1 file changed, 13 insertions(+), 21 deletions(-)
+ gweb/gresolv.c | 21 +++++++++++++++++++++
+ 1 file changed, 21 insertions(+)
diff --git a/gweb/gresolv.c b/gweb/gresolv.c
-index 38a554e..a9e8740 100644
+index 8101d71..9f1477c 100644
--- a/gweb/gresolv.c
+++ b/gweb/gresolv.c
-@@ -36,6 +36,7 @@
- #include <arpa/inet.h>
- #include <arpa/nameser.h>
- #include <net/if.h>
-+#include <ctype.h>
-
- #include "gresolv.h"
-
-@@ -877,8 +878,6 @@ GResolv *g_resolv_new(int index)
+@@ -879,7 +879,9 @@ GResolv *g_resolv_new(int index)
resolv->index = index;
resolv->nameserver_list = NULL;
-- res_ninit(&resolv->res);
--
++#if (__RES >= 19991006)
+ res_ninit(&resolv->res);
++#endif
+
return resolv;
}
-
-@@ -918,8 +917,6 @@ void g_resolv_unref(GResolv *resolv)
+@@ -920,7 +922,9 @@ void g_resolv_unref(GResolv *resolv)
flush_nameservers(resolv);
-- res_nclose(&resolv->res);
--
++#if (__RES >= 19991006)
+ res_nclose(&resolv->res);
++#endif
+
g_free(resolv);
}
-
-@@ -1022,24 +1019,19 @@ guint g_resolv_lookup_hostname(GResolv *resolv, const char *hostname,
+@@ -1024,6 +1028,7 @@ guint g_resolv_lookup_hostname(GResolv *resolv, const char *hostname,
debug(resolv, "hostname %s", hostname);
if (!resolv->nameserver_list) {
-- int i;
--
-- for (i = 0; i < resolv->res.nscount; i++) {
-- char buf[100];
-- int family = resolv->res.nsaddr_list[i].sin_family;
-- void *sa_addr = &resolv->res.nsaddr_list[i].sin_addr;
--
-- if (family != AF_INET &&
-- resolv->res._u._ext.nsaddrs[i]) {
-- family = AF_INET6;
-- sa_addr = &resolv->res._u._ext.nsaddrs[i]->sin6_addr;
-+ FILE *f = fopen("/etc/resolv.conf", "r");
-+ if (f) {
-+ char line[256], *s;
-+ int i;
-+ while (fgets(line, sizeof(line), f)) {
-+ if (strncmp(line, "nameserver", 10) || !isspace(line[10]))
-+ continue;
-+ for (s = &line[11]; isspace(s[0]); s++);
-+ for (i = 0; s[i] && !isspace(s[i]); i++);
-+ s[i] = 0;
-+ g_resolv_add_nameserver(resolv, s, 53, 0);
- }
--
-- if (family != AF_INET && family != AF_INET6)
-- continue;
--
-- if (inet_ntop(family, sa_addr, buf, sizeof(buf)))
-- g_resolv_add_nameserver(resolv, buf, 53, 0);
-+ fclose(f);
++#if (__RES >= 19991006)
+ int i;
+
+ for (i = 0; i < resolv->res.nscount; i++) {
+@@ -1043,6 +1048,22 @@ guint g_resolv_lookup_hostname(GResolv *resolv, const char *hostname,
+ if (inet_ntop(family, sa_addr, buf, sizeof(buf)))
+ g_resolv_add_nameserver(resolv, buf, 53, 0);
}
++#else
++ FILE *f = fopen("/etc/resolv.conf", "r");
++ if (f) {
++ char line[256], *s;
++ int i;
++ while (fgets(line, sizeof(line), f)) {
++ if (strncmp(line, "nameserver", 10) || !isspace(line[10]))
++ continue;
++ for (s = &line[11]; isspace(s[0]); s++);
++ for (i = 0; s[i] && !isspace(s[i]); i++);
++ s[i] = 0;
++ g_resolv_add_nameserver(resolv, s, 53, 0);
++ }
++ fclose(f);
++ }
++#endif
if (!resolv->nameserver_list)
+ g_resolv_add_nameserver(resolv, "127.0.0.1", 53, 0);
+--
+2.39.2
+