From dcp1990@styx.flinkpoyd.homeunix.com  Mon Oct 24 23:47:28 2005
Return-Path: <dcp1990@styx.flinkpoyd.homeunix.com>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 4DE2F16A41F
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 24 Oct 2005 23:47:28 +0000 (GMT)
	(envelope-from dcp1990@styx.flinkpoyd.homeunix.com)
Received: from eastrmmtao03.cox.net (eastrmmtao03.cox.net [68.230.240.36])
	by mx1.FreeBSD.org (Postfix) with ESMTP id A770C43D45
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 24 Oct 2005 23:47:27 +0000 (GMT)
	(envelope-from dcp1990@styx.flinkpoyd.homeunix.com)
Received: from flinkpoyd.homeunix.com ([68.9.18.102])
          by eastrmmtao03.cox.net
          (InterMail vM.6.01.05.02 201-2131-123-102-20050715) with ESMTP
          id <20051024234651.GSQG2767.eastrmmtao03.cox.net@flinkpoyd.homeunix.com>
          for <FreeBSD-gnats-submit@freebsd.org>;
          Mon, 24 Oct 2005 19:46:51 -0400
Received: from styx.cox.net (dcp1990@localhost.danponte.net [127.0.0.1])
	by styx.cox.net (8.13.4/8.13.4) with ESMTP id j9ONgQgf001844
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 24 Oct 2005 19:42:26 -0400 (EDT)
	(envelope-from dcp1990@styx.cox.net)
Received: (from dcp1990@localhost)
	by styx.cox.net (8.13.4/8.13.1/Submit) id j9ONgQCq001843;
	Mon, 24 Oct 2005 19:42:26 -0400 (EDT)
	(envelope-from dcp1990)
Message-Id: <200510242342.j9ONgQCq001843@styx.cox.net>
Date: Mon, 24 Oct 2005 19:42:26 -0400 (EDT)
From: Dan Ponte <dcp1990@neptune.atopia.net>
Reply-To: Dan Ponte <dcp1990@neptune.atopia.net>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: [PATCH] telnetd doesn't honour if= in gettytab
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         87963
>Category:       bin
>Synopsis:       [PATCH] telnetd doesn't honour if= in gettytab
>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:   Mon Oct 24 23:50:15 GMT 2005
>Closed-Date:    Tue Oct 25 02:29:48 GMT 2005
>Last-Modified:  Tue Oct 25 02:29:48 GMT 2005
>Originator:     Dan Ponte
>Release:        FreeBSD 6.0-RC1 i386
>Organization:
Unix Users Anonymous
>Environment:
System: FreeBSD styx.cox.net 6.0-RC1 FreeBSD 6.0-RC1 #23: Mon Oct 24 17:08:58 EDT 2005 root@styx.cox.net:/usr/obj/usr/src/sys/STYX i386


>Description:
	telnetd doesn't honour the if= parameter in gettytab (as documented).
>How-To-Repeat:
	Use telnetd without this patch
>Fix:
	Apply the following patch:
--cut--
--- /usr/src/contrib/telnet/telnetd/otelnetd.c	Thu Sep  1 13:35:05 2005
+++ /usr/src/contrib/telnet/telnetd/telnetd.c	Sun Oct 16 14:06:13 2005
@@ -740,6 +740,7 @@
 	char *HE;
 	char *HN;
 	char *IM;
+	char *IF;
 	int nfd;
 
 	/*
@@ -905,15 +906,41 @@
 		HE = Getstr("he", &cp);
 		HN = Getstr("hn", &cp);
 		IM = Getstr("im", &cp);
+		IF = Getstr("if", &cp);
+
 		if (HN && *HN)
 			(void) strlcpy(host_name, HN, sizeof(host_name));
-		if (IM == 0)
+		else
+			gethostname(host_name, sizeof(host_name));
+
+		if (IM == NULL)
 			IM = strdup("");
+
+		if (IF != NULL) {
+			int tfd;
+			struct stat tst;
+			char *tbf;
+
+			tfd = open(IF, O_RDONLY);
+			if (tfd == -1) {
+				IF = NULL;
+			} else {
+				fstat(tfd, &tst);
+				tbf = (char*)mmap(NULL, tst.st_size, PROT_READ,
+					0, tfd, 0);
+				putf(tbf, ptyibuf2);
+				munmap(tbf, tst.st_size);
+				close(tfd);
+				IM = "";
+			}
+		}
+
 	} else {
 		IM = strdup(DEFAULT_IM);
 		HE = 0;
 	}
 	edithost(HE, host_name);
+		
 	if (hostinfo && *IM)
 		putf(IM, ptyibuf2);
--cut--
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: maxim 
State-Changed-When: Tue Oct 25 02:28:16 GMT 2005 
State-Changed-Why:  
Duplicate of bin/23562 and bin/80732. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=87963 
>Unformatted:
