1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
|
$NetBSD: patch-at,v 1.2 2021/07/04 07:57:13 jnemeth Exp $
--- sendmail/domain.c.orig 2020-06-02 09:41:43.000000000 +0000
+++ sendmail/domain.c
@@ -25,6 +25,8 @@ SM_RCSID("@(#)$Id: domain.c,v 8.205 2013
#if NAMED_BIND
+extern struct __res_state sm_res;
+
# include <arpa/inet.h>
# include <sm_resolve.h>
# if DANE
@@ -49,7 +51,7 @@ static char MXHostBuf[MXHOSTBUFSIZE];
# endif
# ifndef RES_DNSRCH_VARIABLE
-# define RES_DNSRCH_VARIABLE _res.dnsrch
+# define RES_DNSRCH_VARIABLE sm_res.dnsrch
# endif
# ifndef NO_DATA
@@ -573,9 +575,9 @@ getmxrr(host, mxhosts, mxprefs, flags, r
# if DANE
cname2mx = false;
qname[0] = '\0';
- old_options = _res.options;
+ old_options = sm_res.options;
if (ad)
- _res.options |= SM_RES_DNSSEC;
+ sm_res.options |= SM_RES_DNSSEC;
# endif
if ((fallbackMX != NULL && (flags & DROPLOCALHOST) != 0 &&
@@ -743,7 +745,7 @@ getmxrr(host, mxhosts, mxprefs, flags, r
# endif
if (type != T_MX)
{
- if ((tTd(8, 8) || _res.options & RES_DEBUG)
+ if ((tTd(8, 8) || sm_res.options & RES_DEBUG)
# if DANE
&& type != T_RRSIG
# endif
@@ -1042,13 +1044,13 @@ punt:
}
done:
# if DANE
- _res.options = old_options;
+ sm_res.options = old_options;
# endif
return nmx;
error:
# if DANE
- _res.options = old_options;
+ sm_res.options = old_options;
# endif
return -1;
}
@@ -1118,7 +1120,7 @@ bestmx_map_lookup(map, name, av, statp)
int *statp;
{
int nmx;
- int saveopts = _res.options;
+ int saveopts = sm_res.options;
int i;
ssize_t len = 0;
char *result;
@@ -1130,9 +1132,9 @@ bestmx_map_lookup(map, name, av, statp)
char buf[PSBUFSIZE / 2];
# endif
- _res.options &= ~(RES_DNSRCH|RES_DEFNAMES);
+ sm_res.options &= ~(RES_DNSRCH|RES_DEFNAMES);
nmx = getmxrr(name, mxhosts, NULL, 0, statp, NULL, -1);
- _res.options = saveopts;
+ sm_res.options = saveopts;
if (nmx <= 0)
return NULL;
if (bitset(MF_MATCHONLY, map->map_mflags))
@@ -1282,16 +1284,22 @@ dns_getcanonname(host, hbsize, trymx, st
if (tTd(8, 2))
sm_dprintf("dns_getcanonname(%s, trymx=%d)\n", host, trymx);
- if ((_res.options & RES_INIT) == 0 && res_init() == -1)
- {
- *statp = EX_UNAVAILABLE;
- return HOST_NOTFOUND;
+ if ((sm_res.options & RES_INIT) == 0) {
+# if NAMED_RESN
+ memset(&sm_res, 0, sizeof(sm_res));
+ if (res_ninit(&sm_res) == -1) {
+# else
+ if (res_init() == -1) {
+# endif
+ *statp = EX_UNAVAILABLE;
+ return false;
+ }
}
# if DANE
- old_options = _res.options;
+ old_options = sm_res.options;
if (DANE_SECURE == Dane)
- _res.options |= SM_RES_DNSSEC;
+ sm_res.options |= SM_RES_DNSSEC;
# endif
*statp = EX_OK;
@@ -1341,7 +1349,7 @@ cnameloop:
searchlist[sli++] = NameSearchList;
}
# endif
- if (n >= 0 && *--cp != '.' && bitset(RES_DNSRCH, _res.options))
+ if (n >= 0 && *--cp != '.' && bitset(RES_DNSRCH, sm_res.options))
{
/* make sure there are less than MAXDNSRCH domains */
for (domain = RES_DNSRCH_VARIABLE, ret = 0;
@@ -1349,10 +1357,10 @@ cnameloop:
ret++)
searchlist[sli++] = *domain++;
}
- else if (n == 0 && bitset(RES_DEFNAMES, _res.options))
+ else if (n == 0 && bitset(RES_DEFNAMES, sm_res.options))
{
SM_ASSERT(sli < SLSIZE);
- searchlist[sli++] = _res.defdname;
+ searchlist[sli++] = sm_res.defdname;
}
else if (*cp == '.')
{
@@ -1658,13 +1666,13 @@ nexttype:
if (ttl > 0 && pttl != NULL)
*pttl = ttl;
# if DANE
- _res.options = old_options;
+ sm_res.options = old_options;
# endif
return ad ? HOST_SECURE : HOST_OK;
error:
# if DANE
- _res.options = old_options;
+ sm_res.options = old_options;
# endif
return HOST_NOTFOUND;
}
|