From nobody@FreeBSD.org  Thu Jan  1 17:14:15 2004
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id C7BA916A4CE
	for <freebsd-gnats-submit@FreeBSD.org>; Thu,  1 Jan 2004 17:14:15 -0800 (PST)
Received: from www.freebsd.org (www.freebsd.org [216.136.204.117])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 6168843D2F
	for <freebsd-gnats-submit@FreeBSD.org>; Thu,  1 Jan 2004 17:14:13 -0800 (PST)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.12.10/8.12.10) with ESMTP id i021EDdL007084
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 1 Jan 2004 17:14:13 -0800 (PST)
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.12.10/8.12.10/Submit) id i021ED81007083;
	Thu, 1 Jan 2004 17:14:13 -0800 (PST)
	(envelope-from nobody)
Message-Id: <200401020114.i021ED81007083@www.freebsd.org>
Date: Thu, 1 Jan 2004 17:14:13 -0800 (PST)
From: Jeff Ito <jeffi@rcn.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: inetd hangs on non-existent config files
X-Send-Pr-Version: www-2.0

>Number:         60806
>Category:       bin
>Synopsis:       inetd hangs on non-existent config files
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    dwmalone
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Jan 01 17:20:14 PST 2004
>Closed-Date:    Sun May 30 03:55:49 PDT 2004
>Last-Modified:  Sun May 30 03:55:49 PDT 2004
>Originator:     Jeff Ito
>Release:        -CURRENT
>Organization:
>Environment:
CURRENT
>Description:
      inetd run with a non-existent config file hangs and never dies.  I don't believe this to be the desired behavior.
>How-To-Repeat:
      inetd /bah
>Fix:
I don't know if EX_USAGE is the correct exit state, but that seems consitent with similar exit scenarios


      Index: inetd.c
===================================================================
RCS file: /cvs/fbsd/src/usr.sbin/inetd/inetd.c,v
retrieving revision 1.123
diff -u -r1.123 inetd.c
--- inetd.c     30 Oct 2003 22:56:44 -0000      1.123
+++ inetd.c     12 Dec 2003 01:35:57 -0000
@@ -987,7 +987,7 @@
 
        if (!setconfig()) {
                syslog(LOG_ERR, "%s: %m", CONFIG);
-               return;
+               exit(EX_USAGE);
        }
        for (sep = servtab; sep; sep = sep->se_next)
                sep->se_checked = 0;

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->dwmalone 
Responsible-Changed-By: dwmalone 
Responsible-Changed-When: Thu Jan 8 14:15:40 PST 2004 
Responsible-Changed-Why:  
I'll take this PR as inetd is my problem. 

I think inetd is actually running and providing no services - I'd 
expect that if you create its config file and HUP it, it should 
continue happily. It isn't clear to me if this is sensible or not. 

I think that the patch, as it stands, would cause inetd to exit if 
HUPPed after its config file had been deleted, which is probably 
bad. Maybe a patch that checks for the existance of the config file 
at start-up? 

David. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=60806 

From: Jeff Ito <jeffi@rcn.com>
To: freebsd-gnats-submit@FreeBSD.org, jeffi@rcn.com
Cc:  
Subject: Re: bin/60806: inetd hangs on non-existent config files
Date: Fri, 9 Jan 2004 13:16:10 -0500

 You are correct, I tested the scenario of removing the configuration
 file and HUPing the process, it indeed causes inetd to exit.  
 
 Perhaps something similar to below is more suitable.
 
 Index: inetd.c
 ===================================================================
 RCS file: /cvs/fbsd/src/usr.sbin/inetd/inetd.c,v
 retrieving revision 1.123
 diff -u -r1.123 inetd.c
 --- inetd.c     30 Oct 2003 22:56:44 -0000      1.123
 +++ inetd.c     9 Jan 2004 18:14:57 -0000
 @@ -349,6 +349,7 @@
         const char *servname;
         int error;
         struct conninfo *conn;
 +       int tmpfd;
 
         openlog("inetd", LOG_PID | LOG_NOWAIT | LOG_PERROR,
 LOG_DAEMON);
 
 @@ -466,6 +467,19 @@
 
         if (argc > 0)
                 CONFIG = argv[0];
 +
 +       /*
 +        * Make sure the configuration file exists during
 +        * the initial program startup.
 +        */
 +
 +       if ((tmpfd = open(CONFIG, O_RDONLY)) < 0) {
 +               syslog(LOG_ERR, "%s: %m", CONFIG);
 +               exit(EX_USAGE);
 +       }
 +
 +       close(tmpfd);
 +
         if (debug == 0) {
                 FILE *fp;
                 if (daemon(0, 0) < 0) {
 
State-Changed-From-To: open->closed 
State-Changed-By: dwmalone 
State-Changed-When: Sun May 30 03:55:28 PDT 2004 
State-Changed-Why:  
Patch now in -current and -stable. Thanks! 

David. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=60806 
>Unformatted:
