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 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 |
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), |
661 NULL, 0, NI_NUMERICHOST); |
662 } 663 } else { 664 getnameinfo((struct sockaddr *)&peermax, 665 peer.sa_len, 666 pname, sizeof(pname), |
667 NULL, 0, NI_NUMERICHOST); |
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), |
2111 NULL, 0, NI_NUMERICHOST); |
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, |
2146 NI_NUMERICHOST); |
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, |
2340 NI_NUMERICHOST); |
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), |
2390 NULL, 0, NI_NUMERICHOST) != 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, |
2396 NI_NUMERICHOST) == 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, |
2433 NI_NUMERICHOST); |
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 --- |