Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/inetd/inetd.c
Show First 20 Lines • Show All 330 Lines • ▼ Show 20 Lines | main(int argc, char **argv) | ||||
struct group *grp; | struct group *grp; | ||||
struct sigaction sa, saalrm, sachld, sahup, sapipe; | struct sigaction sa, saalrm, sachld, sahup, sapipe; | ||||
int ch, dofork; | int ch, dofork; | ||||
pid_t pid; | pid_t pid; | ||||
char buf[50]; | char buf[50]; | ||||
#ifdef LOGIN_CAP | #ifdef LOGIN_CAP | ||||
login_cap_t *lc = NULL; | login_cap_t *lc = NULL; | ||||
#endif | #endif | ||||
#ifdef LIBWRAP | |||||
struct request_info req; | struct request_info req; | ||||
int denied; | int denied; | ||||
char *service = NULL; | char *service = NULL; | ||||
#endif | |||||
struct sockaddr_storage peer; | struct sockaddr_storage peer; | ||||
int i; | int i; | ||||
struct addrinfo hints, *res; | struct addrinfo hints, *res; | ||||
const char *servname; | const char *servname; | ||||
int error; | int error; | ||||
struct conninfo *conn; | struct conninfo *conn; | ||||
openlog("inetd", LOG_PID | LOG_NOWAIT | LOG_PERROR, LOG_DAEMON); | openlog("inetd", LOG_PID | LOG_NOWAIT | LOG_PERROR, LOG_DAEMON); | ||||
▲ Show 20 Lines • Show All 393 Lines • ▼ Show 20 Lines | while (--nsig >= 0) { | ||||
if (sep->se_bi && | if (sep->se_bi && | ||||
sep->se_bi->bi_fn == (bi_fn_t *) tcpmux) { | sep->se_bi->bi_fn == (bi_fn_t *) tcpmux) { | ||||
sep = tcpmux(ctrl); | sep = tcpmux(ctrl); | ||||
if (sep == NULL) { | if (sep == NULL) { | ||||
close(ctrl); | close(ctrl); | ||||
_exit(0); | _exit(0); | ||||
} | } | ||||
} | } | ||||
#ifdef LIBWRAP | |||||
if (ISWRAP(sep)) { | if (ISWRAP(sep)) { | ||||
inetd_setproctitle("wrapping", ctrl); | inetd_setproctitle("wrapping", ctrl); | ||||
service = sep->se_server_name ? | service = sep->se_server_name ? | ||||
sep->se_server_name : sep->se_service; | sep->se_server_name : sep->se_service; | ||||
request_init(&req, RQ_DAEMON, service, RQ_FILE, ctrl, 0); | request_init(&req, RQ_DAEMON, service, RQ_FILE, ctrl, 0); | ||||
fromhost(&req); | fromhost(&req); | ||||
deny_severity = LIBWRAP_DENY_FACILITY|LIBWRAP_DENY_SEVERITY; | deny_severity = LIBWRAP_DENY_FACILITY|LIBWRAP_DENY_SEVERITY; | ||||
allow_severity = LIBWRAP_ALLOW_FACILITY|LIBWRAP_ALLOW_SEVERITY; | allow_severity = LIBWRAP_ALLOW_FACILITY|LIBWRAP_ALLOW_SEVERITY; | ||||
Show All 12 Lines | #ifdef LIBWRAP | ||||
} | } | ||||
if (dolog) { | if (dolog) { | ||||
syslog(allow_severity, | syslog(allow_severity, | ||||
"connection from %.500s, service %s (%s%s)", | "connection from %.500s, service %s (%s%s)", | ||||
eval_client(&req), service, sep->se_proto, | eval_client(&req), service, sep->se_proto, | ||||
(whichaf(&req) == AF_INET6) ? "6" : ""); | (whichaf(&req) == AF_INET6) ? "6" : ""); | ||||
} | } | ||||
} | } | ||||
#endif | |||||
if (sep->se_bi) { | if (sep->se_bi) { | ||||
(*sep->se_bi->bi_fn)(ctrl, sep); | (*sep->se_bi->bi_fn)(ctrl, sep); | ||||
} else { | } else { | ||||
if (debug) | if (debug) | ||||
warnx("%d execl %s", | warnx("%d execl %s", | ||||
getpid(), sep->se_server); | getpid(), sep->se_server); | ||||
/* Clear close-on-exec. */ | /* Clear close-on-exec. */ | ||||
if (fcntl(ctrl, F_SETFD, 0) < 0) { | if (fcntl(ctrl, F_SETFD, 0) < 0) { | ||||
▲ Show 20 Lines • Show All 1,787 Lines • Show Last 20 Lines |