Bug 82296

Summary: ttys(5) man page misleads about use for non-getty processes
Product: Documentation Reporter: Chris Lightfoot <chris>
Component: Books & ArticlesAssignee: freebsd-doc (Nobody) <doc>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Latest   
Hardware: Any   
OS: Any   

Description Chris Lightfoot 2005-06-15 22:50:15 UTC
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.

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.
How-To-Repeat: Obey advice of man page to run a non-getty process from init; observe that it doesn't work.
Comment 1 Giorgos Keramidas freebsd_committer freebsd_triage 2006-04-07 22:09:32 UTC
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
Comment 2 Chris Lightfoot 2006-04-08 18:28:11 UTC
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)
Comment 3 Giorgos Keramidas freebsd_committer freebsd_triage 2006-04-10 09:55:34 UTC
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
Comment 4 Giorgos Keramidas freebsd_committer freebsd_triage 2006-05-12 01:43:48 UTC
State Changed
From-To: open->feedback

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.
Comment 5 ru freebsd_committer freebsd_triage 2006-10-23 21:23:45 UTC
State Changed
From-To: feedback->closed

It's been long fixed (see rev. 1.59 of init.c in HEAD).