libnetwork: Check for ipv4 flag in resolv.conf
* Add option for forced IPv4 resolution. * Helps with #8293 * Very slightly modified patch by donn
This commit is contained in:
@@ -238,6 +238,7 @@ union res_sockaddr_union {
|
|||||||
#define RES_NOTLDQUERY 0x00100000 /* don't unqualified name as a tld */
|
#define RES_NOTLDQUERY 0x00100000 /* don't unqualified name as a tld */
|
||||||
#define RES_USE_DNSSEC 0x00200000 /* use DNSSEC using OK bit in OPT */
|
#define RES_USE_DNSSEC 0x00200000 /* use DNSSEC using OK bit in OPT */
|
||||||
/* #define RES_DEBUG2 0x00400000 */ /* nslookup internal */
|
/* #define RES_DEBUG2 0x00400000 */ /* nslookup internal */
|
||||||
|
#define RES_USE_INET4 0x00800000 /* use IPv4 in gethostbyname() */
|
||||||
/* KAME extensions: use higher bit to avoid conflict with ISC use */
|
/* KAME extensions: use higher bit to avoid conflict with ISC use */
|
||||||
#define RES_USE_DNAME 0x10000000 /* use DNAME */
|
#define RES_USE_DNAME 0x10000000 /* use DNAME */
|
||||||
#define RES_USE_EDNS0 0x40000000 /* use EDNS0 if configured */
|
#define RES_USE_EDNS0 0x40000000 /* use EDNS0 if configured */
|
||||||
|
|||||||
@@ -328,6 +328,7 @@ getaddrinfo(hostname, servname, hints, res)
|
|||||||
struct addrinfo ai, ai0, *afai = NULL;
|
struct addrinfo ai, ai0, *afai = NULL;
|
||||||
struct addrinfo *pai;
|
struct addrinfo *pai;
|
||||||
const struct explore *ex;
|
const struct explore *ex;
|
||||||
|
struct net_data *net_data;
|
||||||
|
|
||||||
memset(&sentinel, 0, sizeof(sentinel));
|
memset(&sentinel, 0, sizeof(sentinel));
|
||||||
cur = &sentinel;
|
cur = &sentinel;
|
||||||
@@ -501,6 +502,11 @@ getaddrinfo(hostname, servname, hints, res)
|
|||||||
if (hostname == NULL)
|
if (hostname == NULL)
|
||||||
SETERROR(EAI_NONAME);
|
SETERROR(EAI_NONAME);
|
||||||
|
|
||||||
|
/* init after numeric lookups to avoid recursion in resolv.conf */
|
||||||
|
net_data = init();
|
||||||
|
if ((net_data->res->options & RES_USE_INET4) && ai0.ai_family == PF_UNSPEC)
|
||||||
|
ai0.ai_family = PF_INET;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* hostname as alphabetical name.
|
* hostname as alphabetical name.
|
||||||
* We'll make sure that
|
* We'll make sure that
|
||||||
|
|||||||
@@ -680,6 +680,7 @@ p_option(u_long option) {
|
|||||||
case RES_INSECURE2: return "insecure2";
|
case RES_INSECURE2: return "insecure2";
|
||||||
case RES_NOALIASES: return "noaliases";
|
case RES_NOALIASES: return "noaliases";
|
||||||
case RES_USE_INET6: return "inet6";
|
case RES_USE_INET6: return "inet6";
|
||||||
|
case RES_USE_INET4: return "inet4";
|
||||||
#ifdef RES_USE_EDNS0 /*%< KAME extension */
|
#ifdef RES_USE_EDNS0 /*%< KAME extension */
|
||||||
case RES_USE_EDNS0: return "edns0";
|
case RES_USE_EDNS0: return "edns0";
|
||||||
case RES_NSID: return "nsid";
|
case RES_NSID: return "nsid";
|
||||||
|
|||||||
@@ -594,6 +594,8 @@ res_setoptions(res_state statp, const char *options, const char *source)
|
|||||||
statp->options |= RES_NOTLDQUERY;
|
statp->options |= RES_NOTLDQUERY;
|
||||||
} else if (!strncmp(cp, "inet6", sizeof("inet6") - 1)) {
|
} else if (!strncmp(cp, "inet6", sizeof("inet6") - 1)) {
|
||||||
statp->options |= RES_USE_INET6;
|
statp->options |= RES_USE_INET6;
|
||||||
|
} else if (!strncmp(cp, "inet4", sizeof("inet4") - 1)) {
|
||||||
|
statp->options |= RES_USE_INET4;
|
||||||
} else if (!strncmp(cp, "rotate", sizeof("rotate") - 1)) {
|
} else if (!strncmp(cp, "rotate", sizeof("rotate") - 1)) {
|
||||||
statp->options |= RES_ROTATE;
|
statp->options |= RES_ROTATE;
|
||||||
} else if (!strncmp(cp, "no-check-names",
|
} else if (!strncmp(cp, "no-check-names",
|
||||||
|
|||||||
Reference in New Issue
Block a user