Deleted Added
full compact
inetd.c (135823) inetd.c (146187)
1/*
2 * Copyright (c) 1983, 1991, 1993, 1994
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

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

35
36#ifndef lint
37#if 0
38static char sccsid[] = "@(#)from: inetd.c 8.4 (Berkeley) 4/13/94";
39#endif
40#endif /* not lint */
41
42#include <sys/cdefs.h>
1/*
2 * Copyright (c) 1983, 1991, 1993, 1994
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

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

35
36#ifndef lint
37#if 0
38static char sccsid[] = "@(#)from: inetd.c 8.4 (Berkeley) 4/13/94";
39#endif
40#endif /* not lint */
41
42#include <sys/cdefs.h>
43__FBSDID("$FreeBSD: head/usr.sbin/inetd/inetd.c 135823 2004-09-26 13:47:25Z stefanf $");
43__FBSDID("$FreeBSD: head/usr.sbin/inetd/inetd.c 146187 2005-05-13 16:31:11Z ume $");
44
45/*
46 * Inetd - Internet super-server
47 *
48 * This program invokes all internet services as needed. Connection-oriented
49 * services are invoked each time a connection is made, by creating a process.
50 * This process is passed the connection as file descriptor 0 and is expected
51 * to do a getpeername to find out the source host and port.

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

145
146#ifdef IPSEC
147#include <netinet6/ipsec.h>
148#ifndef IPSEC_POLICY_IPSEC /* no ipsec support on old ipsec */
149#undef IPSEC
150#endif
151#endif
152
44
45/*
46 * Inetd - Internet super-server
47 *
48 * This program invokes all internet services as needed. Connection-oriented
49 * services are invoked each time a connection is made, by creating a process.
50 * This process is passed the connection as file descriptor 0 and is expected
51 * to do a getpeername to find out the source host and port.

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

145
146#ifdef IPSEC
147#include <netinet6/ipsec.h>
148#ifndef IPSEC_POLICY_IPSEC /* no ipsec support on old ipsec */
149#undef IPSEC
150#endif
151#endif
152
153/* wrapper for KAME-special getnameinfo() */
154#ifndef NI_WITHSCOPEID
155#define NI_WITHSCOPEID 0
156#endif
157
158#ifndef LIBWRAP_ALLOW_FACILITY
159# define LIBWRAP_ALLOW_FACILITY LOG_AUTH
160#endif
161#ifndef LIBWRAP_ALLOW_SEVERITY
162# define LIBWRAP_ALLOW_SEVERITY LOG_INFO
163#endif
164#ifndef LIBWRAP_DENY_FACILITY
165# define LIBWRAP_DENY_FACILITY LOG_AUTH

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

658 sl = sizeof peermax;
659 if (recvfrom(ctrl, buf, sizeof(buf),
660 MSG_PEEK,
661 (struct sockaddr *)&peermax,
662 &sl) >= 0) {
663 getnameinfo((struct sockaddr *)&peermax,
664 peer.sa_len,
665 pname, sizeof(pname),
153#ifndef LIBWRAP_ALLOW_FACILITY
154# define LIBWRAP_ALLOW_FACILITY LOG_AUTH
155#endif
156#ifndef LIBWRAP_ALLOW_SEVERITY
157# define LIBWRAP_ALLOW_SEVERITY LOG_INFO
158#endif
159#ifndef LIBWRAP_DENY_FACILITY
160# define LIBWRAP_DENY_FACILITY LOG_AUTH

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

653 sl = sizeof peermax;
654 if (recvfrom(ctrl, buf, sizeof(buf),
655 MSG_PEEK,
656 (struct sockaddr *)&peermax,
657 &sl) >= 0) {
658 getnameinfo((struct sockaddr *)&peermax,
659 peer.sa_len,
660 pname, sizeof(pname),
666 NULL, 0,
667 NI_NUMERICHOST|
668 NI_WITHSCOPEID);
661 NULL, 0, NI_NUMERICHOST);
669 }
670 } else {
671 getnameinfo((struct sockaddr *)&peermax,
672 peer.sa_len,
673 pname, sizeof(pname),
662 }
663 } else {
664 getnameinfo((struct sockaddr *)&peermax,
665 peer.sa_len,
666 pname, sizeof(pname),
674 NULL, 0,
675 NI_NUMERICHOST|
676 NI_WITHSCOPEID);
667 NULL, 0, NI_NUMERICHOST);
677 }
678 syslog(LOG_INFO,"%s from %s", sep->se_service, pname);
679 }
680 (void) sigblock(SIGBLOCK);
681 pid = 0;
682 /*
683 * Fork for all external services, builtins which need to
684 * fork and anything we're wrapping (as wrapping might

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

2112{
2113 socklen_t size;
2114 struct sockaddr_storage ss;
2115 char buf[80], pbuf[INET6_ADDRSTRLEN];
2116
2117 size = sizeof(ss);
2118 if (getpeername(s, (struct sockaddr *)&ss, &size) == 0) {
2119 getnameinfo((struct sockaddr *)&ss, size, pbuf, sizeof(pbuf),
668 }
669 syslog(LOG_INFO,"%s from %s", sep->se_service, pname);
670 }
671 (void) sigblock(SIGBLOCK);
672 pid = 0;
673 /*
674 * Fork for all external services, builtins which need to
675 * fork and anything we're wrapping (as wrapping might

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

2103{
2104 socklen_t size;
2105 struct sockaddr_storage ss;
2106 char buf[80], pbuf[INET6_ADDRSTRLEN];
2107
2108 size = sizeof(ss);
2109 if (getpeername(s, (struct sockaddr *)&ss, &size) == 0) {
2110 getnameinfo((struct sockaddr *)&ss, size, pbuf, sizeof(pbuf),
2120 NULL, 0, NI_NUMERICHOST|NI_WITHSCOPEID);
2111 NULL, 0, NI_NUMERICHOST);
2121 (void) sprintf(buf, "%s [%s]", a, pbuf);
2122 } else
2123 (void) sprintf(buf, "%s", a);
2124 setproctitle("%s", buf);
2125}
2126
2127int
2128check_loop(const struct sockaddr *sa, const struct servtab *sep)

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

2147 goto isloop;
2148 continue;
2149#endif
2150 default:
2151 continue;
2152 }
2153 isloop:
2154 getnameinfo(sa, sa->sa_len, pname, sizeof(pname), NULL, 0,
2112 (void) sprintf(buf, "%s [%s]", a, pbuf);
2113 } else
2114 (void) sprintf(buf, "%s", a);
2115 setproctitle("%s", buf);
2116}
2117
2118int
2119check_loop(const struct sockaddr *sa, const struct servtab *sep)

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

2138 goto isloop;
2139 continue;
2140#endif
2141 default:
2142 continue;
2143 }
2144 isloop:
2145 getnameinfo(sa, sa->sa_len, pname, sizeof(pname), NULL, 0,
2155 NI_NUMERICHOST|NI_WITHSCOPEID);
2146 NI_NUMERICHOST);
2156 syslog(LOG_WARNING, "%s/%s:%s/%s loop request REFUSED from %s",
2157 sep->se_service, sep->se_proto,
2158 se2->se_service, se2->se_proto,
2159 pname);
2160 return 1;
2161 }
2162 return 0;
2163}

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

2341 }
2342 }
2343 if ((cnt * 60) / (CHTSIZE * CHTGRAN) > sep->se_maxcpm) {
2344 char pname[INET6_ADDRSTRLEN];
2345
2346 getnameinfo((struct sockaddr *)&rss,
2347 ((struct sockaddr *)&rss)->sa_len,
2348 pname, sizeof(pname), NULL, 0,
2147 syslog(LOG_WARNING, "%s/%s:%s/%s loop request REFUSED from %s",
2148 sep->se_service, sep->se_proto,
2149 se2->se_service, se2->se_proto,
2150 pname);
2151 return 1;
2152 }
2153 return 0;
2154}

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

2332 }
2333 }
2334 if ((cnt * 60) / (CHTSIZE * CHTGRAN) > sep->se_maxcpm) {
2335 char pname[INET6_ADDRSTRLEN];
2336
2337 getnameinfo((struct sockaddr *)&rss,
2338 ((struct sockaddr *)&rss)->sa_len,
2339 pname, sizeof(pname), NULL, 0,
2349 NI_NUMERICHOST|NI_WITHSCOPEID);
2340 NI_NUMERICHOST);
2350 r = -1;
2351 syslog(LOG_ERR,
2352 "%s from %s exceeded counts/min (limit %d/min)",
2353 sep->se_service, pname,
2354 sep->se_maxcpm);
2355 }
2356 }
2357 return(r);

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

2391 /*
2392 * Since we only support AF_INET and AF_INET6, just
2393 * let other than AF_INET and AF_INET6 through.
2394 */
2395 return NULL;
2396 }
2397
2398 if (getnameinfo((struct sockaddr *)&ss, sslen, pname, sizeof(pname),
2341 r = -1;
2342 syslog(LOG_ERR,
2343 "%s from %s exceeded counts/min (limit %d/min)",
2344 sep->se_service, pname,
2345 sep->se_maxcpm);
2346 }
2347 }
2348 return(r);

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

2382 /*
2383 * Since we only support AF_INET and AF_INET6, just
2384 * let other than AF_INET and AF_INET6 through.
2385 */
2386 return NULL;
2387 }
2388
2389 if (getnameinfo((struct sockaddr *)&ss, sslen, pname, sizeof(pname),
2399 NULL, 0, NI_NUMERICHOST | NI_WITHSCOPEID) != 0)
2390 NULL, 0, NI_NUMERICHOST) != 0)
2400 return NULL;
2401
2402 LIST_FOREACH(conn, &sep->se_conn[hv], co_link) {
2403 if (getnameinfo((struct sockaddr *)&conn->co_addr,
2404 conn->co_addr.ss_len, pname2, sizeof(pname2), NULL, 0,
2391 return NULL;
2392
2393 LIST_FOREACH(conn, &sep->se_conn[hv], co_link) {
2394 if (getnameinfo((struct sockaddr *)&conn->co_addr,
2395 conn->co_addr.ss_len, pname2, sizeof(pname2), NULL, 0,
2405 NI_NUMERICHOST | NI_WITHSCOPEID) == 0 &&
2396 NI_NUMERICHOST) == 0 &&
2406 strcmp(pname, pname2) == 0)
2407 break;
2408 }
2409
2410 if (conn == NULL) {
2411 if ((conn = malloc(sizeof(struct conninfo))) == NULL) {
2412 syslog(LOG_ERR, "malloc: %m");
2413 exit(EX_OSERR);

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

2434static int
2435room_conn(struct servtab *sep, struct conninfo *conn)
2436{
2437 char pname[NI_MAXHOST];
2438
2439 if (conn->co_numchild >= sep->se_maxperip) {
2440 getnameinfo((struct sockaddr *)&conn->co_addr,
2441 conn->co_addr.ss_len, pname, sizeof(pname), NULL, 0,
2397 strcmp(pname, pname2) == 0)
2398 break;
2399 }
2400
2401 if (conn == NULL) {
2402 if ((conn = malloc(sizeof(struct conninfo))) == NULL) {
2403 syslog(LOG_ERR, "malloc: %m");
2404 exit(EX_OSERR);

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

2425static int
2426room_conn(struct servtab *sep, struct conninfo *conn)
2427{
2428 char pname[NI_MAXHOST];
2429
2430 if (conn->co_numchild >= sep->se_maxperip) {
2431 getnameinfo((struct sockaddr *)&conn->co_addr,
2432 conn->co_addr.ss_len, pname, sizeof(pname), NULL, 0,
2442 NI_NUMERICHOST | NI_WITHSCOPEID);
2433 NI_NUMERICHOST);
2443 syslog(LOG_ERR, "%s from %s exceeded counts (limit %d)",
2444 sep->se_service, pname, sep->se_maxperip);
2445 return 0;
2446 }
2447 return 1;
2448}
2449
2450static void

--- 137 unchanged lines hidden ---
2434 syslog(LOG_ERR, "%s from %s exceeded counts (limit %d)",
2435 sep->se_service, pname, sep->se_maxperip);
2436 return 0;
2437 }
2438 return 1;
2439}
2440
2441static void

--- 137 unchanged lines hidden ---