From cr@jcmax.com  Sun Apr 23 14:48:06 2000
Return-Path: <cr@jcmax.com>
Received: from vortex.jcmax.com (vortex.jcmax.com [204.69.248.1])
	by hub.freebsd.org (Postfix) with ESMTP id 09E0D37BA79
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 23 Apr 2000 14:48:05 -0700 (PDT)
	(envelope-from cr@jcmax.com)
Received: from plasma.jcmax.com (plasma.jcmax.com [204.69.248.13])
	by vortex.jcmax.com (8.9.3/8.9.3) with ESMTP id RAA06845
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 23 Apr 2000 17:48:04 -0400 (EDT)
	(envelope-from cr@jcmax.com)
Received: (from cr@localhost)
	by plasma.jcmax.com (8.9.3/8.9.3) id RAA26544;
	Sun, 23 Apr 2000 17:48:03 -0400 (EDT)
	(envelope-from cr@jcmax.com)
Message-Id: <200004232148.RAA26544@plasma.jcmax.com>
Date: Sun, 23 Apr 2000 17:48:03 -0400 (EDT)
From: Cyrus Rahman <cr@jcmax.com>
Reply-To: cr@jcmax.com
To: FreeBSD-gnats-submit@freebsd.org
Subject: Getty can fail to observe :de: specification unless present in default
X-Send-Pr-Version: 3.2

>Number:         18181
>Category:       bin
>Synopsis:       Getty can fail to observe :de: specification unless present in default
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    yar
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Apr 23 14:50:01 PDT 2000
>Closed-Date:    Mon Jul 21 08:44:37 PDT 2003
>Last-Modified:  Mon Jul 21 08:44:37 PDT 2003
>Originator:     Cyrus Rahman
>Release:        FreeBSD 4.0-STABLE i386
>Organization:
>Environment:
>Description:

Getty does not process the :de: delay unless it is present in the default
terminal class.  This is somewhat annoying, since a 15 second delay can be
most useful with a modem, but is generally unappreciated on the console.

Here's what happens:

As getty enters its main loop, it encounters the following code:

		/*
		 * if a delay was specified then sleep for that 
		 * number of seconds before writing the initial prompt
		 */
		if (first_sleep && DE) {
		    sleep(DE);
		    /* remove any noise */
		    (void)tcflush(STDIN_FILENO, TCIOFLUSH);
		}
		first_sleep = 0;

		setttymode(tname, 0);

Until the setttymode(), only the default gettytab terminal class has been loaded.
Setttymode() contains the following code:

	gettable(tname, tabent);
	if (OPset || EPset || APset)
		APset++, OPset++, EPset++;
	setdefaults();

After which the correct terminal class is loaded.


>How-To-Repeat:

Set up hylafax to run a getty(8) upon detection of a data call, invoking getty
via "dly.152000 -", where the dly.152000 class has a non-null de field value.
Watch the connection process and observe that getty did not wait as required.
Notice that for once this bug isn't in hylafax.

>Fix:

Initializing the global class values from within setttymode() is not very pretty,
but was put there to move the tty-mode specific processing of the APset and other
flags there.

Gettable() should be moved to the top of the main loop, followed by a setdefaults().

>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->feedback 
State-Changed-By: mike 
State-Changed-When: Sat Jul 21 18:46:47 PDT 2001 
State-Changed-Why:  

Does this problem still occur in newer versions of FreeBSD, 
such as 4.3-RELEASE? 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=18181 

From: Mike Barcroft <mike@FreeBSD.org>
To: freebsd-gnats-submit@FreeBSD.org
Cc:  
Subject: Re: bin/18181: Getty can fail to observe :de: specification unle
Date: Sun, 22 Jul 2001 01:58:01 -0400

 Adding to Audit-Trail.
 
 On Sun, Jul 22, 2001 at 01:38:17AM -0400, Cyrus Rahman wrote:
 > On 22-Jul-01 mike@FreeBSD.org wrote:
 > > Synopsis: Getty can fail to observe :de: specification unless present in
 > > default
 > > 
 > > State-Changed-From-To: open->feedback
 > > State-Changed-By: mike
 > > State-Changed-When: Sat Jul 21 18:46:47 PDT 2001
 > > State-Changed-Why: 
 > > 
 > > Does this problem still occur in newer versions of FreeBSD,
 > > such as 4.3-RELEASE?
 > > 
 > > http://www.FreeBSD.org/cgi/query-pr.cgi?pr=18181
 > 
 > As I recall, the problem is that the code (in main.c):
 > 
 >         for (;;) {
 >                 /*
 >                  * if a delay was specified then sleep for that
 >                  * number of seconds before writing the initial prompt
 >                  */
 >                 if (first_sleep && DE) {
 >                     sleep(DE);
 >                     /* remove any noise */
 >                     (void)tcflush(STDIN_FILENO, TCIOFLUSH);
 >                 }
 >                 first_sleep = 0;
 > 
 >                 setttymode(tname, 0);
 > 
 > expects to find the correct delay value in DE.  However, this is no longer set
 > this early in the loop, since the code that would load it with the value
 > from gettytab:
 > 
 >                 gettable(tname, tabent);
 >                 setdefaults();
 > 
 > has been moved into setttymode(), which isn't run until after the test.
 > 
 > Although not elegant, I fixed the problem by adding an extra
 > 
 >                 gettable(tname, tabent);
 >                 setdefaults();
 > 
 > at the top of the loop before the first lookup of DE.
 > 
 > Inspection of the latest copy of getty/main.c indicates that the problem has
 > not been corrected in 1.28.2.3.
 > 
 > Cyrus
 > 
State-Changed-From-To: feedback->suspended 
State-Changed-By: mike 
State-Changed-When: Sat Jul 21 22:53:47 PDT 2001 
State-Changed-Why:  

Originator's comments are in the Audit-Trail.  Awaiting fix and 
committer. 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=18181 
State-Changed-From-To: suspended->patched 
State-Changed-By: yar 
State-Changed-When: Fri Jun 13 03:27:24 PDT 2003 
State-Changed-Why:  
The bug has been fixed in CURRENT. 
The fix will be merged to STABLE in a month. 
Thank you! 
And excuse us for it took so long to get rid of this bug. 


Responsible-Changed-From-To: freebsd-bugs->yar 
Responsible-Changed-By: yar 
Responsible-Changed-When: Fri Jun 13 03:27:24 PDT 2003 
Responsible-Changed-Why:  
MFC reminder. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=18181 
State-Changed-From-To: patched->closed 
State-Changed-By: yar 
State-Changed-When: Mon Jul 21 08:43:55 PDT 2003 
State-Changed-Why:  
This bug has been fixed along with some other getty(8) bugs. 

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