From blank@sliphost37.uni-trier.de  Mon Mar 31 04:45:24 1997
Received: from sliphost37.uni-trier.de (root@sliphost37.uni-trier.de [136.199.240.37])
          by freefall.freebsd.org (8.8.5/8.8.5) with ESMTP id EAA15669
          for <FreeBSD-gnats-submit@freebsd.org>; Mon, 31 Mar 1997 04:45:20 -0800 (PST)
Received: (from blank@localhost)
	by sliphost37.uni-trier.de (8.8.5/8.8.5) id OAA09728;
	Mon, 31 Mar 1997 14:42:44 +0200 (CEST)
Message-Id: <199703311242.OAA09728@sliphost37.uni-trier.de>
Date: Mon, 31 Mar 1997 14:42:44 +0200 (CEST)
From: blank@fox.uni-trier.de
Reply-To: blank@fox.uni-trier.de
To: FreeBSD-gnats-submit@freebsd.org
Subject: FreeBSD 2.2-STABLE: getty does not initialize %m, %s, %r and %v
X-Send-Pr-Version: 3.2

>Number:         3152
>Category:       bin
>Synopsis:       FreeBSD 2.2-STABLE: getty does not initialize %m, %s, %r and %v
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:
>Keywords:
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Mar 31 04:50:02 PST 1997
>Closed-Date:    Sat Aug 23 16:13:13 MEST 1997
>Last-Modified:  Sat Aug 23 16:13:34 MEST 1997
>Originator:     Sascha Blank
>Release:        FreeBSD 2.2-STABLE i386
>Organization:
Computer Center of the University of Trier, Germany
>Environment:

FreeBSD 2.2-STABLE (current as of ctm-src-2.2 #0221)

fgrep rcsid /usr/src/libexec/getty/main.c:
static char rcsid[] = "$Id: main.c,v 1.10.2.2 1996/12/31 05:50:28 msmith Exp $";

>Description:

gettytab(5) says there are macros %m, %s, %r and %v that one can use to
display portions of the utsname structure in the initial banner message.

I inserted the following line in /etc/gettytab to keep my banner message
up to date:

default:\
        :cb:ce:ck:lc:fd#1000:im=\r\n   %s %r (%h) (%t)\r\n\r\n:sp#1200:

But getty printed

   (sliphost37.uni-trier.de) (vty00)

instead of

   FreeBSD 2.2-STABLE (sliphost37.uni-trier.de) (vty00)


>How-To-Repeat:

Change /etc/gettytab to match the line above, log yourself out and
watch, whether getty will print out all information.

>Fix:

The reason for the problem was easy to find. main.c declares 

	struct utsname kerninfo;

but actually never calls uname(3) to assign reasonable values to it.
Therefore the four macros only print empty strings.

The following small diff solves the problem. It calls uname(3) to
initialize kerninfo. In the unexpected case that this fails, kerninfo is
assigned some (more or less) reasonalbe default values.

*** main.c.CURRENT	Mon Mar 31 14:13:08 1997
--- main.c	Mon Mar 31 14:18:21 1997
***************
*** 192,197 ****
--- 192,205 ----
  	if (hostname[0] == '\0')
  		strcpy(hostname, "Amnesiac");
  
+ 	if (uname(&kerninfo) == -1) {
+ 		strcpy (kerninfo.sysname, "FreeBSD");
+ 		strcpy (kerninfo.nodename, "unknown");
+ 		strcpy (kerninfo.release, "unknown");
+ 		strcpy (kerninfo.version, "unknown");
+ 		strcpy (kerninfo.machine, "unknown");
+ 	}
+ 
  	/*
  	 * Limit running time to deal with broken or dead lines.
  	 */

--
             Sascha Blank - mailto:blank@fox.uni-trier.de
  Student and System Administrator at the University of Trier, Germany
            Finger my account to receive my Public PGP key
   I don't speak for my employers, they don't pay me enough for that.
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: joerg 
State-Changed-When: Sat Aug 23 16:13:13 MEST 1997 
State-Changed-Why:  

This problem has been fixed some time back in the past. 
>Unformatted:
