blob: 639ccfa2a20b6047edb1957601b8fceff687aed3 [file] [log] [blame]
Patrick Williamsf1e5d692016-03-30 15:21:19 -05001From 10b0d16d04b811b1ccd1f9b0cfe757bce8d876a1 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Mon, 6 Apr 2015 23:02:21 -0700
4Subject: [PATCH 2/3] resolve: musl does not implement res_ninit
5
6ported from
7http://git.alpinelinux.org/cgit/aports/plain/testing/connman/libresolv.patch
8
9Upstream-Status: Pending
10
11Signed-off-by: Khem Raj <raj.khem@gmail.com>
12---
13 gweb/gresolv.c | 33 ++++++++++++---------------------
14 1 file changed, 12 insertions(+), 21 deletions(-)
15
16diff --git a/gweb/gresolv.c b/gweb/gresolv.c
17index 5cf7a9a..3ad8e70 100644
18--- a/gweb/gresolv.c
19+++ b/gweb/gresolv.c
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080020@@ -36,6 +36,7 @@
21 #include <arpa/inet.h>
22 #include <arpa/nameser.h>
23 #include <net/if.h>
24+#include <ctype.h>
25
26 #include "gresolv.h"
27
Patrick Williamsf1e5d692016-03-30 15:21:19 -050028@@ -875,8 +875,6 @@ GResolv *g_resolv_new(int index)
29 resolv->index = index;
30 resolv->nameserver_list = NULL;
31
32- res_ninit(&resolv->res);
33-
34 return resolv;
35 }
36
37@@ -916,8 +914,6 @@ void g_resolv_unref(GResolv *resolv)
38
39 flush_nameservers(resolv);
40
41- res_nclose(&resolv->res);
42-
43 g_free(resolv);
44 }
45
46@@ -1020,24 +1016,19 @@ guint g_resolv_lookup_hostname(GResolv *resolv, const char *hostname,
47 debug(resolv, "hostname %s", hostname);
48
49 if (!resolv->nameserver_list) {
50- int i;
51-
52- for (i = 0; i < resolv->res.nscount; i++) {
53- char buf[100];
54- int family = resolv->res.nsaddr_list[i].sin_family;
55- void *sa_addr = &resolv->res.nsaddr_list[i].sin_addr;
56-
57- if (family != AF_INET &&
58- resolv->res._u._ext.nsaddrs[i]) {
59- family = AF_INET6;
60- sa_addr = &resolv->res._u._ext.nsaddrs[i]->sin6_addr;
61+ FILE *f = fopen("/etc/resolv.conf", "r");
62+ if (f) {
63+ char line[256], *s;
64+ int i;
65+ while (fgets(line, sizeof(line), f)) {
66+ if (strncmp(line, "nameserver", 10) || !isspace(line[10]))
67+ continue;
68+ for (s = &line[11]; isspace(s[0]); s++);
69+ for (i = 0; s[i] && !isspace(s[i]); i++);
70+ s[i] = 0;
71+ g_resolv_add_nameserver(resolv, s, 53, 0);
72 }
73-
74- if (family != AF_INET && family != AF_INET6)
75- continue;
76-
77- if (inet_ntop(family, sa_addr, buf, sizeof(buf)))
78- g_resolv_add_nameserver(resolv, buf, 53, 0);
79+ fclose(f);
80 }
81
82 if (!resolv->nameserver_list)
83--
842.5.1
85