Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 31 Mar 1997 14:42:44 +0200 (CEST)
From:      blank@fox.uni-trier.de
To:        FreeBSD-gnats-submit@freebsd.org
Subject:   bin/3152: FreeBSD 2.2-STABLE: getty does not initialize %m, %s, %r and %v
Message-ID:  <199703311242.OAA09728@sliphost37.uni-trier.de>
Resent-Message-ID: <199703311250.EAA15804@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>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:          open
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Mar 31 04:50:02 PST 1997
>Last-Modified:
>Originator:     Sascha Blank
>Organization:
Computer Center of the University of Trier, Germany
>Release:        FreeBSD 2.2-STABLE i386
>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.
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199703311242.OAA09728>