Bug 18181

Summary: Getty can fail to observe :de: specification unless present in default
Product: Base System Reporter: Cyrus Rahman <cr>
Component: binAssignee: Yar Tikhiy <yar>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 4.0-STABLE   
Hardware: Any   
OS: Any   

Description Cyrus Rahman 2000-04-23 22:50:01 UTC
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.

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().
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.
Comment 1 Mike Barcroft freebsd_committer freebsd_triage 2001-07-22 02:46:47 UTC
State Changed
From-To: open->feedback


Does this problem still occur in newer versions of FreeBSD, 
such as 4.3-RELEASE?
Comment 2 Mike Barcroft freebsd_committer freebsd_triage 2001-07-22 06:53:47 UTC
State Changed
From-To: feedback->suspended


Originator's comments are in the Audit-Trail.  Awaiting fix and 
committer.
Comment 3 Mike Barcroft freebsd_committer freebsd_triage 2001-07-22 06:58:01 UTC
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
>
Comment 4 Yar Tikhiy freebsd_committer freebsd_triage 2003-06-13 11:27:24 UTC
State Changed
From-To: suspended->patched

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. 


Comment 5 Yar Tikhiy freebsd_committer freebsd_triage 2003-06-13 11:27:24 UTC
Responsible Changed
From-To: freebsd-bugs->yar

MFC reminder.
Comment 6 Yar Tikhiy freebsd_committer freebsd_triage 2003-07-21 16:43:55 UTC
State Changed
From-To: patched->closed

This bug has been fixed along with some other getty(8) bugs.