Subject: lib/28183: getttyent(3) broken
To: None <lib-bug-people@netbsd.org, gnats-admin@netbsd.org,>
From: None <marcotte@panix.com>
List: netbsd-bugs
Date: 11/10/2004 22:55:01
>Number:         28183
>Category:       lib
>Synopsis:       getttyent(3) broken
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    lib-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Nov 10 22:55:00 +0000 2004
>Originator:     Brian Marcotte
>Release:        NetBSD 2.0_RC4
>Organization:
	panix.com
>Environment:
System: NetBSD panix5.panix.com 2.0_RC4 NetBSD 2.0_RC4 (PANIX-USER) #0: Sat Nov 6 19:39:39 EST 2004 root@trinity.nyc.access.net:/devel/netbsd/release-2.0-20041022/src/sys/arch/i386/compile/PANIX-USER i386
	Userland matches kernel
Architecture: i386
Machine: i386
>Description:

In some cases, the library function "getttyent" does not set "ty_type"
correctly. This causes TERM to be set incorrectly in the cases where
TERM is set from /etc/ttys.

If the appropriate line in /etc/ttys has no flags like this one:

   ttyp0   none                            vt100

then getttyent will fill in ty_type with "vt10".

Since this function is used by "login" and others, users wind up
with TERM set to "vt10".

>How-To-Repeat:

Using a stock /etc/ttys file, this will show the problem:

#include <ttyent.h>
#include <stdio.h>
#include <stdlib.h>

int main()
{
  struct ttyent *t;

  t = getttynam("ttyp0");

  if (t==NULL) {
    printf("t: NULL\n");
    exit(1);
  }
  printf("t->ty_type: %s\n",t->ty_type);
  exit(0);
}

It should print "t->ty_type: networ".

>Fix:

I'm not entirely sure, but it looks like the bug is in the "skip" function
in src/lib/libc/gen/getttyent.c.

--
- Brian