diff options
author | guido <guido@FreeBSD.org> | 1998-05-07 18:32:00 +0000 |
---|---|---|
committer | guido <guido@FreeBSD.org> | 1998-05-07 18:32:00 +0000 |
commit | 779723654b931ce05465367f3c13d9e35d52f6f2 (patch) | |
tree | 58d6df7457ced15169d2d0fd1f79adc51a438658 | |
parent | 952a7718da1bec2930e83ff7c0d02ddfcd2d6dfa (diff) | |
download | FreeBSD-src-779723654b931ce05465367f3c13d9e35d52f6f2.zip FreeBSD-src-779723654b931ce05465367f3c13d9e35d52f6f2.tar.gz |
Redo tcpmux stuff. tcpmux handling is now performed after inetd
forks. Furthermore, invalid input for tcpmux does not lead to
an exiting inetd.
This patch is recommended for people running tcpmux (which is NOT
enabled by default)
-rw-r--r-- | usr.sbin/inetd/inetd.c | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/usr.sbin/inetd/inetd.c b/usr.sbin/inetd/inetd.c index 72b8366..bc658fad 100644 --- a/usr.sbin/inetd/inetd.c +++ b/usr.sbin/inetd/inetd.c @@ -42,7 +42,7 @@ static const char copyright[] = static char sccsid[] = "@(#)from: inetd.c 8.4 (Berkeley) 4/13/94"; #endif static const char rcsid[] = - "$Id: inetd.c,v 1.29 1997/10/29 21:49:04 dima Exp $"; + "$Id: inetd.c,v 1.30 1998/02/24 21:55:14 pst Exp $"; #endif /* not lint */ /* @@ -409,6 +409,8 @@ main(argc, argv, envp) sigvec(SIGHUP, &sv, (struct sigvec *)0); sv.sv_handler = reapchild; sigvec(SIGCHLD, &sv, (struct sigvec *)0); + sv.sv_handler = SIG_IGN; + sigvec(SIGPIPE, &sv, (struct sigvec *)0); { /* space for daemons to overwrite environment for ps */ @@ -474,20 +476,6 @@ main(argc, argv, envp) sep->se_service, inet_ntoa(peer.sin_addr)); } - /* - * Call tcpmux to find the real service to exec. - */ - if (sep->se_bi && - sep->se_bi->bi_fn == (void (*)()) tcpmux) { - struct servtab *tsep; - - tsep = tcpmux(ctrl); - if (tsep == NULL) { - close(ctrl); - continue; - } - sep = tsep; - } } else ctrl = sep->se_fd; (void) sigblock(SIGBLOCK); @@ -540,6 +528,17 @@ main(argc, argv, envp) if (tmpint != ctrl) (void) close(tmpint); } + /* + * Call tcpmux to find the real service to exec. + */ + if (sep->se_bi && + sep->se_bi->bi_fn == (void (*)()) tcpmux) { + sep = tcpmux(ctrl); + if (sep == NULL) { + close(ctrl); + _exit(0); + } + } if (sep->se_bi) { (*sep->se_bi->bi_fn)(ctrl, sep); /* NOTREACHED */ @@ -1742,9 +1741,15 @@ getline(fd, buf, len) int len; { int count = 0, n; + struct sigvec sv; + memset(&sv, 0, sizeof(sv)); + sv.sv_handler = SIG_DFL; + sigvec(SIGALRM, &sv, (struct sigvec *)0); do { + alarm(10); n = read(fd, buf, len-count); + alarm(0); if (n == 0) return (count); if (n < 0) |