From nobody@FreeBSD.org  Fri Dec 15 02:14:05 2000
Return-Path: <nobody@FreeBSD.org>
Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21])
	by hub.freebsd.org (Postfix) with ESMTP id 3403337B402
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 15 Dec 2000 02:14:05 -0800 (PST)
Received: (from nobody@localhost)
	by freefall.freebsd.org (8.11.1/8.11.1) id eBFAE5K68822;
	Fri, 15 Dec 2000 02:14:05 -0800 (PST)
	(envelope-from nobody)
Message-Id: <200012151014.eBFAE5K68822@freefall.freebsd.org>
Date: Fri, 15 Dec 2000 02:14:05 -0800 (PST)
From: tanes73@yahoo.com
Sender: nobody@FreeBSD.org
To: freebsd-gnats-submit@FreeBSD.org
Subject: telnetd doesn't show message in file specified by if in gettytab.
X-Send-Pr-Version: www-1.0

>Number:         23562
>Category:       bin
>Synopsis:       [patch] telnetd(8) doesn't show message in file specified by if in gettytab.
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    markm
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Dec 15 02:20:01 PST 2000
>Closed-Date:    Mon Aug 26 12:55:51 UTC 2013
>Last-Modified:  Mon Aug 26 12:55:51 UTC 2013
>Originator:     Tanes Sriviroolchai
>Release:        4.2 Release
>Organization:
NCR (Thailand) Ltd.
>Environment:
FreeBSD checkserv.Thailand.ncr.com 4.2-RELEASE FreeBSD 4.2-RELEASE #0: Mon Nov 2
0 13:02:55 GMT 2000     jkh@bento.FreeBSD.org:/usr/src/sys/compile/GENERIC  i386
>Description:
Telnetd(8) said that we can use s5 style /etc/issue by using if capability, which would overide im. However, no matter how I set if=/etc/issue: in /etc/gettytab and create (with proper mode) /etc/issue, the content of /etc/issue will not be shown. However, getty does show content inside /etc/issue on console.
>How-To-Repeat:
in /etc/gettytab add if as shown below.
:cb:ce:ck:lc:fd#1000:im=\r\n%s/%m (%h) (%t)\r\n\r\n:sp#1200:if=/etc/issu
e:

create /etc/issue with mode 644 root/wheel and contain any messages such as
Hello Issue<LF>

Reboot. After the system restart, the console will display:

Hello Issue

FreeBSD/i386 (checkserv.Thailand.ncr.com) (ttyv0)

login:

Login and telnet localhost, you will see that it shows:

FreeBSD/i386 (checkserv.Thailand.ncr.com) (ttyp2)

login:

instead of

Hello Issue
login:
>Fix:

Recompile telnetd from /usr/src/libexec/telnetd (4.2 Release) and update new telnetd back into distribution.



>Release-Note:
>Audit-Trail:

From: Philipp Mergenthaler <un1i@rz.uni-karlsruhe.de>
To: freebsd-gnats-submit@FreeBSD.org, tanes73@yahoo.com
Cc:  
Subject: Re: i386/23562: telnetd doesn't show message in file specified by if in gettytab
Date: Sun, 18 Feb 2001 23:06:25 +0100

   Hi,
 
 the following patch adds the "issue file" capability to the telnetd
 in the crypto source tree.  It is almost identical to this commit:
 http://www.freebsd.org/cgi/cvsweb.cgi/src/libexec/telnetd/telnetd.c#rev1.14
 
 (This patch also initializes altlogin to NULL.  Without this, there
 can be crashes in start_login() in sys_term.c.  They only seem to
 occur when telnetd is run with option -debug, though.)
 
 Bye, Philipp
 
 
 diff -u telnetd/telnetd.8 telnetd.new/telnetd.8
 --- telnetd/telnetd.8	Sun Feb  4 11:44:19 2001
 +++ telnetd.new/telnetd.8	Sun Feb 18 19:26:49 2001
 @@ -527,10 +527,34 @@
  indicates a willingness to decrypt
  the data stream.
  .El
 -.Sh ENVIRONMENT
 +.Sh NOTES
 +By default
 +.Nm
 +will read the
 +.Em \&he ,
 +.Em \&hn ,
 +and
 +.Em \&im
 +capabilities from
 +.Pa /etc/gettytab
 +and use that information (if present) to determine
 +what to display before the login: prompt. You can
 +also use a System V style
 +.Pa /etc/issue
 +file by using the
 +.Em \&if
 +capability, which will override
 +.Em \&im .
 +The information specified in either
 +.Em \&im
 +or
 +.Em \&if
 +will be displayed to both console and remote logins.
 +.\" .Sh ENVIRONMENT
  .Sh FILES
  .Bl -tag -width /usr/ucb/bftp -compact
  .It Pa /etc/services
 +.It Pa /etc/gettytab
  .It Pa /etc/inittab
  (UNICOS systems only)
  .It Pa /etc/iptos
 @@ -541,6 +565,7 @@
  .Sh "SEE ALSO"
  .Xr bftp 1 ,
  .Xr login 1 ,
 +.Xr gettytab 5 ,
  .Xr telnet 1
  (if supported)
  .Sh STANDARDS
 diff -u telnetd/telnetd.c telnetd.new/telnetd.c
 --- telnetd/telnetd.c	Wed Feb  7 20:45:07 2001
 +++ telnetd.new/telnetd.c	Sun Feb 18 14:48:05 2001
 @@ -60,6 +60,7 @@
  #include <err.h>
  #include <arpa/inet.h>
  
 +#include <sys/mman.h>
  #include <libutil.h>
  #include <utmp.h>
  
 @@ -149,7 +150,7 @@
  
  int debug = 0;
  int keepalive = 1;
 -char *altlogin;
 +char *altlogin = NULL;
  
  void doit __P((struct sockaddr *));
  int terminaltypeok __P((char *));
 @@ -958,6 +959,11 @@
  	char *HE;
  	char *HN;
  	char *IM;
 +	char *IF;
 +	char *if_buf;
 +	int if_fd;
 +	struct stat statbuf;
 +
  	void netflush();
  	int nfd;
  
 @@ -1157,8 +1163,11 @@
  		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 (IF && (if_fd = open(IF, O_RDONLY, 000)) != -1)
 +			IM = 0;
  		if (IM == 0)
  			IM = "";
  	} else {
 @@ -1168,6 +1177,14 @@
  	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);
 
Responsible-Changed-From-To: freebsd-bugs->markm 
Responsible-Changed-By: yar 
Responsible-Changed-When: Tue Jun 17 00:33:48 PDT 2003 
Responsible-Changed-Why:  
Over to the maintainer of crypto telnetd. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=23562 

From: Dan Ponte <dcp1990@neptune.atopia.net>
To: bug-followup@FreeBSD.org, tanes73@yahoo.com
Cc:  
Subject: Re: bin/23562: [patch] telnetd doesn't show message in file specified by if in gettytab.
Date: Tue, 25 Oct 2005 15:41:19 -0400

 Hi. I had opened another PR for this patch, which got closed
 (understandably). It does the same thing as the above one, however this
 one applies on my tree (6.0-RC1 as of yesterday).
 
 --cut--
 --- telnetd.c.orig	Sat May 21 11:28:42 2005
 +++ telnetd.c	Tue Oct 25 15:28:47 2005
 @@ -161,7 +161,7 @@
  	 * change resolves problem reports bin/771 and bin/1037.
  	 */
  
 -	linemode=1;	/*Default to mode that works on bulk of clients*/
 +	linemode = 1;	/*Default to mode that works on bulk of clients*/
  
  	while ((ch = getopt(argc, argv, valid_opts)) != -1) {
  		switch(ch) {
 @@ -740,6 +740,7 @@
  	char *HE;
  	char *HN;
  	char *IM;
 +	char *IF;
  	int nfd;
  
  	/*
 @@ -900,20 +901,47 @@
  	 */
  
  	if (getent(defent, "default") == 1) {
 -		char *cp=defstrs;
 +		char *cp;
 +
 +		cp = defstrs;
  
  		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-- 
 
 -Dan

From: "Devon H. O'Dell" <devon.odell@gmail.com>
To: bug-followup@FreeBSD.org, tanes73@yahoo.com, 
	Dan Ponte <dcp1990@neptune.atopia.net>
Cc:  
Subject: Re: bin/23562: [patch] telnetd doesn't show message in file specified by if in gettytab.
Date: Tue, 25 Oct 2005 13:59:27 -0700

 This patch applies cleanly against current@ as well. It shouldn't hurt
 hushlogin.
State-Changed-From-To: open->closed 
State-Changed-By: markm 
State-Changed-When: Mon Aug 26 12:55:01 UTC 2013 
State-Changed-Why:  
Stale. 

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