From init@easton-15.student.umd.edu  Mon Apr 20 19:14:47 1998
Received: from easton-15.student.umd.edu (init@easton-15.student.umd.edu [129.2.140.15])
          by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id TAA17820
          for <FreeBSD-gnats-submit@freebsd.org>; Mon, 20 Apr 1998 19:14:36 GMT
          (envelope-from init@easton-15.student.umd.edu)
Received: (from init@localhost)
	by easton-15.student.umd.edu (8.8.7/8.8.7) id PAA11230;
	Mon, 20 Apr 1998 15:14:29 -0400 (EDT)
	(envelope-from init)
Message-Id: <199804201914.PAA11230@easton-15.student.umd.edu>
Date: Mon, 20 Apr 1998 15:14:29 -0400 (EDT)
From: init@risen.org
Reply-To: init@risen.org
To: FreeBSD-gnats-submit@freebsd.org
Subject: Patch to allow telnetd to recognize if gettytab flag
X-Send-Pr-Version: 3.2

>Number:         6365
>Category:       bin
>Synopsis:       Patch to allow telnetd to recognize if gettytab flag
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Mon Apr 20 12:20:01 PDT 1998
>Closed-Date:    Sat Apr 25 23:51:45 PDT 1998
>Last-Modified:  Sat Apr 25 23:52:00 PDT 1998
>Originator:     Jason Garman <init@risen.org>
>Release:        FreeBSD 2.2.5-RELEASE i386
>Organization:
>Environment:

>Description:

telnetd does not recognize the if (display file before login) gettytab
flag.

>How-To-Repeat:

add an if=<filename> entry to the gettytab database and telnet into your
machine.  It is ignored.

>Fix:
	
Patch for 2.2.5 telnetd follows:

--- telnetd.c.old       Mon Apr 20 14:47:38 1998
+++ telnetd.c   Mon Apr 20 15:02:49 1998
@@ -60,6 +60,8 @@
 #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 @@
        char *HE;
        char *HN;
        char *IM;
+       char *IF;
+       char *if_buf;
+       int if_fd;
+       struct stat statbuf;
+
        void netflush();
 
        /*
@@ -1090,8 +1097,11 @@
                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,7 +1111,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);
        ptyip = ptyibuf2;

>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: phk 
State-Changed-When: Sat Apr 25 23:51:45 PDT 1998 
State-Changed-Why:  
committed, thanks! 
>Unformatted:
no
