From dougdougdougdoug@dt050n33.san.rr.com  Sun May  3 02:33:17 1998
Received: from dt050n33.san.rr.com (Studded@dt050n33.san.rr.com [204.210.31.51])
          by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id CAA03483
          for <FreeBSD-gnats-submit@freebsd.org>; Sun, 3 May 1998 02:33:17 -0700 (PDT)
          (envelope-from dougdougdougdoug@dt050n33.san.rr.com)
Received: (from dougdougdougdoug@localhost)
	by dt050n33.san.rr.com (8.8.8/8.8.8) id JAA03244;
	Sun, 3 May 1998 09:33:18 GMT
	(envelope-from dougdougdougdoug)
Message-Id: <199805030933.JAA03244@dt050n33.san.rr.com>
Date: Sun, 3 May 1998 09:33:18 GMT
From: Studded@san.rr.com
Reply-To: Studded@san.rr.com
To: FreeBSD-gnats-submit@freebsd.org
Subject: telnetd "/etc/issue-like" support
X-Send-Pr-Version: 3.2

>Number:         6492
>Category:       bin
>Synopsis:       telnetd support for an /etc/issue file and bug fix
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun May  3 02:40:01 PDT 1998
>Closed-Date:    Sun May 3 09:33:41 PDT 1998
>Last-Modified:  Sun May  3 09:35:22 PDT 1998
>Originator:     Doug
>Release:        FreeBSD 2.2.6-STABLE-0502 i386
>Organization:
AAAG
>Environment:

	-Stable and -Current

>Description:

	Support for reading the "if" file from /etc/gettytab was included in
-Current on 4/26/98 but not -Stable. A simple diff between -Current and -Stable
applies, compiles and runs cleanly so I'd like to encourage someone to commit it.

	In addition, while testing that facility it became apparent that when
telnetd printed it to the remote terminal it was missing a \r. This causes the file
to be printed out with the dreaded stairstep effect. The supplied patch to utility.c
(in the telnetd directory) should be applied to both -Current and -Stable. 

>How-To-Repeat:

	For -Current, create a multi-line file referenced with the "if=" option in
/etc/gettytab. Telnet in from a remote site and watch the file stairstep across the
terminal. :)

>Fix:
	
	Apply the following patches:

This one is straight from CVS, only needed on -Stable

diff -p -u -r1.7.2.4 -r1.14
--- src/libexec/telnetd/telnetd.c	1998/03/06 01:47:55	1.7.2.4 HEAD
+++ /home/ncvs/src/libexec/telnetd/telnetd.c	1998/04/26 06:51:36	1.14
@@ -42,7 +42,7 @@ static const char copyright[] =
 static char sccsid[] = "@(#)telnetd.c	8.2 (Berkeley) 12/15/93";
 #endif
 static const char rcsid[] =
-	"$Id: telnetd.c,v 1.7.2.4 1998/03/06 01:47:55 jkh Exp $";
+	"$Id: telnetd.c,v 1.14 1998/03/06 01:47:55 jkh Exp $";
 #endif /* not lint */
 
 #include "telnetd.h"
@@ -60,6 +60,8 @@ static const char rcsid[] =
 #include <err.h>
 #include <arpa/inet.h>
 
+#include <sys/mman.h>
+
 #if	defined(_SC_CRAY_SECURE_SYS)
 #include <sys/sysv.h>
 #include <sys/secdev.h>
@@ -892,6 +894,11 @@ telnet(f, p, host)
 	char *HE;
 	char *HN;
 	char *IM;
+	char *IF;
+	char *if_buf;
+	int if_fd;
+	struct stat statbuf;
+
 	void netflush();
 
 	/*
@@ -1090,8 +1097,11 @@ telnet(f, p, host)
 		HE = getstr("he", &cp);
 		HN = getstr("hn", &cp);
 		IM = getstr("im", &cp);
+		IF = getstr("if", &cp);
 		if (HN && *HN)
 			(void) strcpy(host_name, HN);
+		if (IF && (if_fd = open(IF, O_RDONLY, 000)) != -1)
+			IM = 0;
 		if (IM == 0)
 			IM = "";
 	} else {
@@ -1101,6 +1111,14 @@ telnet(f, p, host)
 	edithost(HE, host_name);
 	if (hostinfo && *IM)
 		putf(IM, ptyibuf2);
+	else if (IF && if_fd != -1) {
+		fstat (if_fd, &statbuf);
+		if_buf = (char *) mmap (0, statbuf.st_size, PROT_READ, 
+		    0, if_fd, 0);
+		putf(if_buf, ptyibuf2);
+		munmap (if_buf, statbuf.st_size);
+		close (if_fd);
+	}
 
 	if (pcc)
 		(void) strncat(ptyibuf2, ptyip, pcc+1);



This one should be attributed to Chip Norkus and applied to both branches:

--- utility.c.Dist	Sun May  3 01:36:55 1998
+++ utility.c	Sun May  3 01:57:41 1998
@@ -441,7 +441,12 @@
 	putlocation = where;
 
 	while (*cp) {
-		if (*cp != '%') {
+		if (*cp =='\n') {
+			putstr("\r\n");
+			cp++;
+			continue;
+		}
+		else if (*cp != '%') {
 			putchr(*cp++);
 			continue;
 		}

>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: steve 
State-Changed-When: Sun May 3 09:33:41 PDT 1998 
State-Changed-Why:  
phk's commit has been merged from -current and the new patch 
to avoid stair-stepping output applied to both branches.  Thanks 
for the patch! 
>Unformatted:
