From owner-freebsd-bugs Thu Aug 22 14:50:12 2002 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 3DCD637B401 for ; Thu, 22 Aug 2002 14:50:03 -0700 (PDT) Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 644DA43E75 for ; Thu, 22 Aug 2002 14:50:02 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.4/8.12.4) with ESMTP id g7MLo2JU073643 for ; Thu, 22 Aug 2002 14:50:02 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.4/8.12.4/Submit) id g7MLo2P8073642; Thu, 22 Aug 2002 14:50:02 -0700 (PDT) Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 98A1837B400 for ; Thu, 22 Aug 2002 14:42:26 -0700 (PDT) Received: from cube.gelatinous.com (cube.gelatinous.com [204.176.81.81]) by mx1.FreeBSD.org (Postfix) with ESMTP id 54D3143E86 for ; Thu, 22 Aug 2002 14:42:26 -0700 (PDT) (envelope-from aaron@gelatinous.com) Received: (qmail 92055 invoked by uid 0); 22 Aug 2002 21:42:25 -0000 Message-Id: <20020822214225.92054.qmail@cube.gelatinous.com> Date: 22 Aug 2002 21:42:25 -0000 From: Aaron Smith Reply-To: Aaron Smith To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: bin/41912: inetd incorrectly reports exit status/signal status Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org >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 >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