Date: 22 Aug 2002 21:42:25 -0000 From: Aaron Smith <aaron@mutex.org> To: FreeBSD-gnats-submit@FreeBSD.org Subject: bin/41912: inetd incorrectly reports exit status/signal status Message-ID: <20020822214225.92054.qmail@cube.gelatinous.com>
next in thread | raw e-mail | index | archive | help
>Number: 41912
>Category: bin
>Synopsis: inetd incorrectly reports exit status/signal status
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Thu Aug 22 14:50:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator: Aaron Smith <aaron@mutex.org>
>Release: FreeBSD 4.6-STABLE i386
>Organization:
>Environment:
System: FreeBSD cube.gelatinous.com 4.6-STABLE FreeBSD 4.6-STABLE #0: Tue Aug 6 21:12:44 PDT 2002 aaron@cube.gelatinous.com:/tmp/obj/usr/src/sys/CUBE i386
>Description:
The status returned from wait3 is a compound value that must be
interpreted via WIFEXITED and WIFSIGNALED macros. inetd is currently
treating it as a pure status value and assuming WIFEXITED is always
true. This can be very misleading and confuses debugging, because
the debug message is wrongly reporting status. See man page for
wait3.
>How-To-Repeat:
Enabled fingerd. Try "finger @localhost", causing a "must provide
username" error. You will cause this to appear in syslog:
inetd[204]: /usr/libexec/fingerd[65087]: exit status 0x100
Here you can see the problem. The exit was caused by a signal, and
wait3's status does not have the exit status -- it has the signal
value. The exit status logged is blatantly wrong. See attached
patch; it works for both -stable and -current.
>Fix:
Index: inetd.c
===================================================================
RCS file: /usr/cvs/src/usr.sbin/inetd/inetd.c,v
retrieving revision 1.80.2.9
diff -u -r1.80.2.9 inetd.c
--- inetd.c 21 Aug 2002 10:00:24 -0000 1.80.2.9
+++ inetd.c 22 Aug 2002 19:19:24 -0000
@@ -900,7 +900,10 @@
if (pid <= 0)
break;
if (debug)
- warnx("%d reaped, status %#x", pid, status);
+ warnx("%d reaped, %s %u", pid,
+ WIFEXITED(status) ? "status" : "signal",
+ WIFEXITED(status) ? WEXITSTATUS(status)
+ : WTERMSIG(status));
for (sep = servtab; sep; sep = sep->se_next) {
for (k = 0; k < sep->se_numchild; k++)
if (sep->se_pids[k] == pid)
@@ -910,10 +913,13 @@
if (sep->se_numchild == sep->se_maxchild)
enable(sep);
sep->se_pids[k] = sep->se_pids[--sep->se_numchild];
- if (status)
+ if (WIFSIGNALED(status) || WEXITSTATUS(status))
syslog(LOG_WARNING,
- "%s[%d]: exit status 0x%x",
- sep->se_server, pid, status);
+ "%s[%d]: exited, %s %u",
+ sep->se_server, pid,
+ WIFEXITED(status) ? "status" : "signal",
+ WIFEXITED(status) ? WEXITSTATUS(status)
+ : WTERMSIG(status));
break;
}
reapchild_conn(pid);
>Release-Note:
>Audit-Trail:
>Unformatted:
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020822214225.92054.qmail>
