Deleted Added
full compact
tcpdmatch.c (44744) tcpdmatch.c (56977)
1 /*
2 * tcpdmatch - explain what tcpd would do in a specific case
3 *
4 * usage: tcpdmatch [-d] [-i inet_conf] daemon[@host] [user@]host
5 *
6 * -d: use the access control tables in the current directory.
7 *
8 * -i: location of inetd.conf file.
9 *
10 * All errors are reported to the standard error stream, including the errors
11 * that would normally be reported via the syslog daemon.
12 *
13 * Author: Wietse Venema, Eindhoven University of Technology, The Netherlands.
1 /*
2 * tcpdmatch - explain what tcpd would do in a specific case
3 *
4 * usage: tcpdmatch [-d] [-i inet_conf] daemon[@host] [user@]host
5 *
6 * -d: use the access control tables in the current directory.
7 *
8 * -i: location of inetd.conf file.
9 *
10 * All errors are reported to the standard error stream, including the errors
11 * that would normally be reported via the syslog daemon.
12 *
13 * Author: Wietse Venema, Eindhoven University of Technology, The Netherlands.
14 *
15 * $FreeBSD: head/contrib/tcp_wrappers/tcpdmatch.c 56977 2000-02-03 10:27:03Z shin $
14 */
15
16#ifndef lint
17static char sccsid[] = "@(#) tcpdmatch.c 1.5 96/02/11 17:01:36";
18#endif
19
20/* System libraries. */
21

--- 41 unchanged lines hidden (view full) ---

63 char *server;
64 char *addr;
65 char *user;
66 char *daemon;
67 struct request_info request;
68 int ch;
69 char *inetcf = 0;
70 int count;
16 */
17
18#ifndef lint
19static char sccsid[] = "@(#) tcpdmatch.c 1.5 96/02/11 17:01:36";
20#endif
21
22/* System libraries. */
23

--- 41 unchanged lines hidden (view full) ---

65 char *server;
66 char *addr;
67 char *user;
68 char *daemon;
69 struct request_info request;
70 int ch;
71 char *inetcf = 0;
72 int count;
73#ifdef INET6
74 struct sockaddr_storage server_sin;
75 struct sockaddr_storage client_sin;
76 char *ap;
77 int alen;
78#else
71 struct sockaddr_in server_sin;
72 struct sockaddr_in client_sin;
79 struct sockaddr_in server_sin;
80 struct sockaddr_in client_sin;
81#endif
73 struct stat st;
74
75 /*
76 * Show what rule actually matched.
77 */
78 hosts_access_verbose = 2;
79
80 /*

--- 87 unchanged lines hidden (view full) ---

168 * most one address. eval_hostname() warns the user about name server
169 * problems, while using the request.server structure as a cache for host
170 * address and name conversion results.
171 */
172 if (NOT_INADDR(server) == 0 || HOSTNAME_KNOWN(server)) {
173 if ((hp = find_inet_addr(server)) == 0)
174 exit(1);
175 memset((char *) &server_sin, 0, sizeof(server_sin));
82 struct stat st;
83
84 /*
85 * Show what rule actually matched.
86 */
87 hosts_access_verbose = 2;
88
89 /*

--- 87 unchanged lines hidden (view full) ---

177 * most one address. eval_hostname() warns the user about name server
178 * problems, while using the request.server structure as a cache for host
179 * address and name conversion results.
180 */
181 if (NOT_INADDR(server) == 0 || HOSTNAME_KNOWN(server)) {
182 if ((hp = find_inet_addr(server)) == 0)
183 exit(1);
184 memset((char *) &server_sin, 0, sizeof(server_sin));
185#ifdef INET6
186 server_sin.ss_family = hp->h_addrtype;
187 switch (hp->h_addrtype) {
188 case AF_INET:
189 ap = (char *)&((struct sockaddr_in *)&server_sin)->sin_addr;
190 alen = sizeof(struct sockaddr_in);
191 break;
192 case AF_INET6:
193 ap = (char *)&((struct sockaddr_in6 *)&server_sin)->sin6_addr;
194 alen = sizeof(struct sockaddr_in6);
195 break;
196 default:
197 exit(1);
198 }
199#ifdef SIN6_LEN
200 server_sin.ss_len = alen;
201#endif
202#else
176 server_sin.sin_family = AF_INET;
203 server_sin.sin_family = AF_INET;
204#endif
177 request_set(&request, RQ_SERVER_SIN, &server_sin, 0);
178
179 for (count = 0; (addr = hp->h_addr_list[count]) != 0; count++) {
205 request_set(&request, RQ_SERVER_SIN, &server_sin, 0);
206
207 for (count = 0; (addr = hp->h_addr_list[count]) != 0; count++) {
208#ifdef INET6
209 memcpy(ap, addr, alen);
210#else
180 memcpy((char *) &server_sin.sin_addr, addr,
181 sizeof(server_sin.sin_addr));
211 memcpy((char *) &server_sin.sin_addr, addr,
212 sizeof(server_sin.sin_addr));
213#endif
182
183 /*
184 * Force evaluation of server host name and address. Host name
185 * conflicts will be reported while eval_hostname() does its job.
186 */
187 request_set(&request, RQ_SERVER_NAME, "", RQ_SERVER_ADDR, "", 0);
188 if (STR_EQ(eval_hostname(request.server), unknown))
189 tcpd_warn("host address %s->name lookup failed",

--- 35 unchanged lines hidden (view full) ---

225 * in real life the client address is available (at least with IP). Let
226 * eval_hostname() figure out if this host is properly registered, while
227 * using the request.client structure as a cache for host name and
228 * address conversion results.
229 */
230 if ((hp = find_inet_addr(client)) == 0)
231 exit(1);
232 memset((char *) &client_sin, 0, sizeof(client_sin));
214
215 /*
216 * Force evaluation of server host name and address. Host name
217 * conflicts will be reported while eval_hostname() does its job.
218 */
219 request_set(&request, RQ_SERVER_NAME, "", RQ_SERVER_ADDR, "", 0);
220 if (STR_EQ(eval_hostname(request.server), unknown))
221 tcpd_warn("host address %s->name lookup failed",

--- 35 unchanged lines hidden (view full) ---

257 * in real life the client address is available (at least with IP). Let
258 * eval_hostname() figure out if this host is properly registered, while
259 * using the request.client structure as a cache for host name and
260 * address conversion results.
261 */
262 if ((hp = find_inet_addr(client)) == 0)
263 exit(1);
264 memset((char *) &client_sin, 0, sizeof(client_sin));
265#ifdef INET6
266 client_sin.ss_family = hp->h_addrtype;
267 switch (hp->h_addrtype) {
268 case AF_INET:
269 ap = (char *)&((struct sockaddr_in *)&client_sin)->sin_addr;
270 alen = sizeof(struct sockaddr_in);
271 break;
272 case AF_INET6:
273 ap = (char *)&((struct sockaddr_in6 *)&client_sin)->sin6_addr;
274 alen = sizeof(struct sockaddr_in6);
275 break;
276 default:
277 exit(1);
278 }
279#ifdef SIN6_LEN
280 client_sin.ss_len = alen;
281#endif
282#else
233 client_sin.sin_family = AF_INET;
283 client_sin.sin_family = AF_INET;
284#endif
234 request_set(&request, RQ_CLIENT_SIN, &client_sin, 0);
235
236 for (count = 0; (addr = hp->h_addr_list[count]) != 0; count++) {
285 request_set(&request, RQ_CLIENT_SIN, &client_sin, 0);
286
287 for (count = 0; (addr = hp->h_addr_list[count]) != 0; count++) {
288#ifdef INET6
289 memcpy(ap, addr, alen);
290#else
237 memcpy((char *) &client_sin.sin_addr, addr,
238 sizeof(client_sin.sin_addr));
291 memcpy((char *) &client_sin.sin_addr, addr,
292 sizeof(client_sin.sin_addr));
293#endif
239
240 /*
241 * Force evaluation of client host name and address. Host name
242 * conflicts will be reported while eval_hostname() does its job.
243 */
244 request_set(&request, RQ_CLIENT_NAME, "", RQ_CLIENT_ADDR, "", 0);
245 if (STR_EQ(eval_hostname(request.client), unknown))
246 tcpd_warn("host address %s->name lookup failed",

--- 82 unchanged lines hidden ---
294
295 /*
296 * Force evaluation of client host name and address. Host name
297 * conflicts will be reported while eval_hostname() does its job.
298 */
299 request_set(&request, RQ_CLIENT_NAME, "", RQ_CLIENT_ADDR, "", 0);
300 if (STR_EQ(eval_hostname(request.client), unknown))
301 tcpd_warn("host address %s->name lookup failed",

--- 82 unchanged lines hidden ---