From owner-freebsd-bugs@FreeBSD.ORG Sat May 7 13:30:02 2005 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A25DC16A4DB for ; Sat, 7 May 2005 13:30:02 +0000 (GMT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7158D43D41 for ; Sat, 7 May 2005 13:30:02 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.3/8.13.3) with ESMTP id j47DU2Gv000859 for ; Sat, 7 May 2005 13:30:02 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.3/8.13.1/Submit) id j47DU2xq000858; Sat, 7 May 2005 13:30:02 GMT (envelope-from gnats) Resent-Date: Sat, 7 May 2005 13:30:02 GMT Resent-Message-Id: <200505071330.j47DU2xq000858@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Rostislav Krasny Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 04ECF16A4DB for ; Sat, 7 May 2005 13:22:08 +0000 (GMT) Received: from www.freebsd.org (www.freebsd.org [216.136.204.117]) by mx1.FreeBSD.org (Postfix) with ESMTP id DE0DA43DAB for ; Sat, 7 May 2005 13:22:07 +0000 (GMT) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.13.1/8.13.1) with ESMTP id j47DM7Io062111 for ; Sat, 7 May 2005 13:22:07 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.13.1/8.13.1/Submit) id j47DM7DA062105; Sat, 7 May 2005 13:22:07 GMT (envelope-from nobody) Message-Id: <200505071322.j47DM7DA062105@www.freebsd.org> Date: Sat, 7 May 2005 13:22:07 GMT From: Rostislav Krasny To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-2.3 Subject: bin/80732: [PATCH]: getty(8) and telnetd(8) ignore the 'if' option of gettytab(5) and don't print initial message from a file (by default /etc/issue) before the login prompt X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 07 May 2005 13:30:02 -0000 >Number: 80732 >Category: bin >Synopsis: [PATCH]: getty(8) and telnetd(8) ignore the 'if' option of gettytab(5) and don't print initial message from a file (by default /etc/issue) before the login prompt >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sat May 07 13:30:02 GMT 2005 >Closed-Date: >Last-Modified: >Originator: Rostislav Krasny >Release: 5.4-RC4 >Organization: >Environment: FreeBSD mercury 5.4-RC4 FreeBSD 5.4-RC4 #0: Sun May 1 23:22:09 IDT 2005 root@mercury:/usr/obj/usr/src/sys/MYKERNEL i386 >Description: By default /etc/gettytab have following lines: default:\ :cb:ce:ck:lc:fd#1000:im=\r\n%s/%m (%h) (%t)\r\n\r\n:sp#1200:\ :if=/etc/issue: The 'if' option specifies a text file that their contents will be processed like contents of a 'im' gettytab(5) option. Both getty(8) and telnetd(8) ignore the 'if' option, the first because of a bug in the code and the second because it is not implemented. However, the telnetd(8) manual page states that it is implemented. >How-To-Repeat: Just create the /etc/issue file with some text in it and see how telnetd(8) and getty(8) work. You don't have to reboot when you test getty(8). Instead you can press [Ctrl]+[D] to restart getty(8) or [Enter] to just make it reprint the full login prompt. Also, you might need to enable inetd(8) and eding an /etc/inetd.conf to make telnetd working. >Fix: --- main.c.orig Sat May 7 03:52:29 2005 +++ /usr/src/libexec/getty/main.c Sat May 7 12:48:11 2005 @@ -184,7 +184,7 @@ main(int argc, char *argv[]) { extern char **environ; - int first_sleep = 1, first_time = 1; + int first_sleep = 1; struct rlimit limit; int rval; @@ -312,24 +312,22 @@ putpad(CL); edithost(HE); - /* if this is the first time through this, and an - issue file has been given, then send it */ - if (first_time && IF) { - int fd; + if (!(PL && PP)) { + int fd = -1; - if ((fd = open(IF, O_RDONLY)) != -1) { - char * cp; - - while ((cp = getline(fd)) != NULL) { - putf(cp); + if (IF) { + if ((fd = open(IF, O_RDONLY)) != -1) { + char * cp; + + while ((cp = getline(fd)) != NULL) + putf(cp); + close(fd); } - close(fd); } + if (fd == -1 && IM && *IM) + putf(IM); } - first_time = 0; - if (IM && *IM && !(PL && PP)) - putf(IM); if (setjmp(timeout)) { cfsetispeed(&tmode, B0); cfsetospeed(&tmode, B0); --- telnetd.c.orig Sat May 7 01:57:16 2005 +++ /usr/src/contrib/telnet/telnetd/telnetd.c Sat May 7 15:08:11 2005 @@ -740,6 +740,7 @@ char *HE; char *HN; char *IM; + char *IF; int nfd; /* @@ -900,18 +901,36 @@ */ if (getent(defent, "default") == 1) { - char *cp=defstrs; + char *cp = defstrs; HE = Getstr("he", &cp); HN = Getstr("hn", &cp); - IM = Getstr("im", &cp); - if (HN && *HN) + IF = Getstr("if", &cp); + if (HN != NULL && *HN != 0) (void) strlcpy(host_name, HN, sizeof(host_name)); - if (IM == 0) - IM = strdup(""); + if (IF != NULL) { + int if_fd; + + if ((if_fd = open(IF, O_RDONLY)) != -1) { + struct stat if_fst; + + fstat(if_fd, &if_fst); + IM = malloc(if_fst.st_size + 1); + read(if_fd, IM, if_fst.st_size); + IM[if_fst.st_size] = 0; + close(if_fd); + } else { + IF = NULL; + } + } + if (IF == NULL) { + IM = Getstr("im", &cp); + if (IM == NULL) + IM = strdup(""); + } } else { IM = strdup(DEFAULT_IM); - HE = 0; + HE = NULL; } edithost(HE, host_name); if (hostinfo && *IM) >Release-Note: >Audit-Trail: >Unformatted: