From nobody@FreeBSD.org  Wed Jun 15 21:44:05 2005
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 2A6E616A41C
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 15 Jun 2005 21:44:05 +0000 (GMT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [216.136.204.117])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 1124943D4C
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 15 Jun 2005 21:44:05 +0000 (GMT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.13.1/8.13.1) with ESMTP id j5FLi4nq052314
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 15 Jun 2005 21:44:04 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.13.1/8.13.1/Submit) id j5FLi43R052313;
	Wed, 15 Jun 2005 21:44:04 GMT
	(envelope-from nobody)
Message-Id: <200506152144.j5FLi43R052313@www.freebsd.org>
Date: Wed, 15 Jun 2005 21:44:04 GMT
From: Chris Lightfoot <chris@ex-parrot.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: ttys(5) man page misleads about use for non-getty processes
X-Send-Pr-Version: www-2.3

>Number:         82296
>Category:       docs
>Synopsis:       ttys(5) man page misleads about use for non-getty processes
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    freebsd-doc
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          doc-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Jun 15 21:50:15 GMT 2005
>Closed-Date:    Mon Oct 23 20:25:43 GMT 2006
>Last-Modified:  Mon Oct 23 20:25:43 GMT 2006
>Originator:     Chris Lightfoot
>Release:        5.2.1-RELEASE-p13
>Organization:
>Environment:
FreeBSD very.unfortu.net 5.2.1-RELEASE-p13 FreeBSD 5.2.1-RELEASE-p13 #5: Wed Dec 29 16:45:15 GMT 2004     james@very.unfortu.net:/usr/obj/usr/src/sys/VERY  i386

>Description:
The ttys(5) man page states in respect of each line of /etc/ttys,

     The first field is normally the name of the terminal special file as it
     is found in /dev.  However, it can be any arbitrary string when the asso-
     ciated command is not related to a tty.

However, this is not true -- the new_session command in init.c will drop any /etc/ttys line whose first field does not give the name of a file in /dev which can be opened: (line 937 et seq)

        /*
         * Attempt to open the device, if we get "device not configured"
         * then don't add the device to the session list.
         */
        if ((fd = open(sp->se_device, O_RDONLY | O_NONBLOCK, 0)) < 0) {
                if (errno == ENXIO || errno == ENOENT) {
                        free_session(sp);
                        return (0);
                }
        } else
                close(fd);

The same error is present in ttys(5) in the 5.4-RC2 release in respect of the init source code on that release.
>How-To-Repeat:
Obey advice of man page to run a non-getty process from init; observe that it doesn't work.
>Fix:
Change the man page or the code in init.c. The latter looks harder since I don't think init.c knows whether a given line refers to a getty process or not.
>Release-Note:
>Audit-Trail:

From: Giorgos Keramidas <keramida@freebsd.org>
To: Chris Lightfoot <chris@ex-parrot.com>
Cc: bug-followup@freebsd.org
Subject: Re: docs/82296: ttys(5) man page misleads about use for non-getty processes
Date: Sat, 8 Apr 2006 00:09:32 +0300

 On 2005-06-15 21:44, Chris Lightfoot <chris@ex-parrot.com> wrote:
 > The ttys(5) man page states in respect of each line of /etc/ttys,
 >
 >      The first field is normally the name of the terminal special file as it
 >      is found in /dev.  However, it can be any arbitrary string when the asso-
 >      ciated command is not related to a tty.
 >
 > However, this is not true -- the new_session command in init.c will
 > drop any /etc/ttys line whose first field does not give the name of a
 > file in /dev which can be opened: (line 937 et seq)
 
 Is this still true on the 5.X branch?  I've just tested on CURRENT and
 the following entry worked as expected, even though I certainly don't
 have a /dev/nproc device node:
 
     nproc "/root/script" unknown on secure
 

From: Chris Lightfoot <chris@ex-parrot.com>
To: Giorgos Keramidas <keramida@freebsd.org>
Cc: bug-followup@freebsd.org
Subject: Re: docs/82296: ttys(5) man page misleads about use for non-getty processes
Date: Sat, 8 Apr 2006 18:28:11 +0100

 On Sat, Apr 08, 2006 at 12:09:32AM +0300, Giorgos Keramidas wrote:
 > On 2005-06-15 21:44, Chris Lightfoot <chris@ex-parrot.com> wrote:
 > > The ttys(5) man page states in respect of each line of /etc/ttys,
 > >
 > >      The first field is normally the name of the terminal special file as it
 > >      is found in /dev.  However, it can be any arbitrary string when the asso-
 > >      ciated command is not related to a tty.
 > >
 > > However, this is not true -- the new_session command in init.c will
 > > drop any /etc/ttys line whose first field does not give the name of a
 > > file in /dev which can be opened: (line 937 et seq)
 > 
 > Is this still true on the 5.X branch?  I've just tested on CURRENT and
 > the following entry worked as expected, even though I certainly don't
 > have a /dev/nproc device node:
 > 
 >     nproc "/root/script" unknown on secure
 
 hmm. The machine where I encountered the problem is
 5.2.1-RELEASE. I haven't tried on anything subsequent.
 
 -- 
 ``Ashford Skiing Club is cancelled this evening due to the snow.''
   (allegedly heard on local radio in Kent)

From: Giorgos Keramidas <keramida@freebsd.org>
To: Chris Lightfoot <chris@ex-parrot.com>
Cc: bug-followup@freebsd.org
Subject: Re: docs/82296: ttys(5) man page misleads about use for non-getty processes
Date: Mon, 10 Apr 2006 11:55:34 +0300

 On 2006-04-08 18:28, Chris Lightfoot <chris@ex-parrot.com> wrote:
 >On Sat, Apr 08, 2006 at 12:09:32AM +0300, Giorgos Keramidas wrote:
 >>On 2005-06-15 21:44, Chris Lightfoot <chris@ex-parrot.com> wrote:
 >>> The ttys(5) man page states in respect of each line of /etc/ttys,
 >>>
 >>>      The first field is normally the name of the terminal special file as it
 >>>      is found in /dev.  However, it can be any arbitrary string when the asso-
 >>>      ciated command is not related to a tty.
 >>>
 >>> However, this is not true -- the new_session command in init.c will
 >>> drop any /etc/ttys line whose first field does not give the name of a
 >>> file in /dev which can be opened: (line 937 et seq)
 >>
 >> Is this still true on the 5.X branch?  I've just tested on CURRENT and
 >> the following entry worked as expected, even though I certainly don't
 >> have a /dev/nproc device node:
 >>
 >>     nproc "/root/script" unknown on secure
 >
 > hmm. The machine where I encountered the problem is
 > 5.2.1-RELEASE. I haven't tried on anything subsequent.
 
 Good enough.  Thanks for following up so fast.
 
 I believe 5.2.1-RELEASE was a developer-preview release, and many
 things have changed since then.  If you (or anyone else, for that
 matter) test this with a newer release, i.e. 5-STABLE or one of
 the 6.X series, please let me know with a followup :-)
 
 - Giorgos
 
State-Changed-From-To: open->feedback 
State-Changed-By: keramida 
State-Changed-When: Fri May 12 00:43:48 UTC 2006 
State-Changed-Why:  
The problem was only observed in 5.2.1. I tried a newer build and 
things seem to work as documented in ttys(5).  Set this PR to 
'feedback', until we receive information about a newer build/release 
of FreeBSD or it times out as isnormal for feedback PRs. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=82296 
State-Changed-From-To: feedback->closed 
State-Changed-By: ru 
State-Changed-When: Mon Oct 23 20:23:45 UTC 2006 
State-Changed-Why:  
It's been long fixed (see rev. 1.59 of init.c in HEAD). 

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