diff options
| author | mycroft <mycroft@NetBSD.org> | 1997-03-13 14:57:34 +0000 |
|---|---|---|
| committer | mycroft <mycroft@NetBSD.org> | 1997-03-13 14:57:34 +0000 |
| commit | 7c7f4379a00a67210e4a1532d3c4ba20a8e1d4e8 (patch) | |
| tree | 5d6aac8e490312534ed20ed1cbef53a0d130483b /usr.sbin/inetd | |
| parent | d6dc78d4c1bdf4615379dcb85340ac1a9052e689 (diff) | |
When rejecting a UDP connection, make sure to flush the right socket.
Diffstat (limited to 'usr.sbin/inetd')
| -rw-r--r-- | usr.sbin/inetd/inetd.c | 36 |
1 files changed, 17 insertions, 19 deletions
diff --git a/usr.sbin/inetd/inetd.c b/usr.sbin/inetd/inetd.c index 2583ff7aa2d..2d6f7e1f042 100644 --- a/usr.sbin/inetd/inetd.c +++ b/usr.sbin/inetd/inetd.c @@ -1,4 +1,4 @@ -/* $NetBSD: inetd.c,v 1.21 1997/03/13 14:29:15 mycroft Exp $ */ +/* $NetBSD: inetd.c,v 1.22 1997/03/13 14:57:34 mycroft Exp $ */ /* * Copyright (c) 1983,1991 The Regents of the University of California. @@ -41,7 +41,7 @@ char copyright[] = #ifndef lint /*static char sccsid[] = "from: @(#)inetd.c 5.30 (Berkeley) 6/3/91";*/ -static char rcsid[] = "$NetBSD: inetd.c,v 1.21 1997/03/13 14:29:15 mycroft Exp $"; +static char rcsid[] = "$NetBSD: inetd.c,v 1.22 1997/03/13 14:57:34 mycroft Exp $"; #endif /* not lint */ /* @@ -524,9 +524,7 @@ main(argc, argv, envp) syslog(deny_severity, "refused " "connection from %.500s, service %s (%s)", eval_client(&req), service, sep->se_proto); - if (sep->se_socktype != SOCK_STREAM) - recv(0, buf, sizeof (buf), 0); - _exit(1); + goto reject; } if (lflag) { syslog(allow_severity, @@ -539,20 +537,16 @@ main(argc, argv, envp) else { if ((pwd = getpwnam(sep->se_user)) == NULL) { syslog(LOG_ERR, - "getpwnam: %s: No such user", - sep->se_user); - if (sep->se_socktype != SOCK_STREAM) - recv(0, buf, sizeof (buf), 0); - _exit(1); + "getpwnam: %s: No such user", + sep->se_user); + goto reject; } if (sep->se_group && (grp = getgrnam(sep->se_group)) == NULL) { syslog(LOG_ERR, - "getgrnam: %s: No such group", - sep->se_group); - if (sep->se_socktype != SOCK_STREAM) - recv(0, buf, sizeof (buf), 0); - _exit(1); + "getgrnam: %s: No such group", + sep->se_group); + goto reject; } if (pwd->pw_uid) { if (sep->se_group) @@ -570,8 +564,11 @@ main(argc, argv, envp) if (sep->se_log) dolog(sep, ctrl); #endif - dup2(ctrl, 0); - close(ctrl); + if (ctrl != 0) { + dup2(ctrl, 0); + close(ctrl); + ctrl = 0; + } dup2(0, 1); dup2(0, 2); #ifdef RLIMIT_NOFILE @@ -584,9 +581,10 @@ main(argc, argv, envp) for (tmpint = rlim_ofile_cur-1; --tmpint > 2; ) (void)close(tmpint); execv(sep->se_server, sep->se_argv); - if (sep->se_socktype != SOCK_STREAM) - recv(0, buf, sizeof (buf), 0); syslog(LOG_ERR, "execv %s: %m", sep->se_server); + reject: + if (sep->se_socktype != SOCK_STREAM) + recv(ctrl, buf, sizeof (buf), 0); _exit(1); } } |
