From owner-freebsd-bugs@FreeBSD.ORG Sun Jul 25 01:50:02 2010 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 600EC1065677 for ; Sun, 25 Jul 2010 01:50:02 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 523AC8FC12 for ; Sun, 25 Jul 2010 01:50:02 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.4/8.14.4) with ESMTP id o6P1o19C051717 for ; Sun, 25 Jul 2010 01:50:01 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.4/8.14.4/Submit) id o6P1o1rJ051716; Sun, 25 Jul 2010 01:50:01 GMT (envelope-from gnats) Resent-Date: Sun, 25 Jul 2010 01:50:01 GMT Resent-Message-Id: <201007250150.o6P1o1rJ051716@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, Dan Ponte Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5DFCA106566B for ; Sun, 25 Jul 2010 01:49:02 +0000 (UTC) (envelope-from dcp1990@fez.theamigan.net) Received: from vms173007pub.verizon.net (vms173007pub.verizon.net [206.46.173.7]) by mx1.freebsd.org (Postfix) with ESMTP id 536D18FC0A for ; Sun, 25 Jul 2010 01:48:10 +0000 (UTC) Received: from fez.theamigan.net ([unknown] [72.87.82.41]) by vms173007.mailsrvcs.net (Sun Java(tm) System Messaging Server 7u2-7.02 32bit (built Apr 16 2009)) with ESMTPA id <0L63001DC8VDDEN2@vms173007.mailsrvcs.net> for FreeBSD-gnats-submit@freebsd.org; Sat, 24 Jul 2010 19:47:39 -0500 (CDT) Received: from fez.theamigan.net (dcp1990@localhost [127.0.0.1]) by fez.theamigan.net (8.14.4/8.14.4) with ESMTP id o6P0lbCu003448; Sat, 24 Jul 2010 20:47:37 -0400 Received: (from dcp1990@localhost) by fez.theamigan.net (8.14.4/8.14.4/Submit) id o6P0lbNT003447; Sat, 24 Jul 2010 20:47:37 -0400 (EDT envelope-from dcp1990) Message-Id: <201007250047.o6P0lbNT003447@fez.theamigan.net> Date: Sat, 24 Jul 2010 20:47:37 -0400 (EDT) From: Dan Ponte To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Cc: amigan@gmail.com Subject: bin/148915: [patch] fix telnetd if and im options to behave like getty X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Dan Ponte List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 25 Jul 2010 01:50:02 -0000 >Number: 148915 >Category: bin >Synopsis: [patch] fix telnetd if and im options to behave like getty >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sun Jul 25 01:50:01 UTC 2010 >Closed-Date: >Last-Modified: >Originator: Dan Ponte >Release: FreeBSD 8.1-PRERELEASE amd64 >Organization: D3ath D3sk Records >Environment: System: FreeBSD fez.theamigan.net 8.1-PRERELEASE FreeBSD 8.1-PRERELEASE #2: Wed Jul 14 14:05:35 EDT 2010 root@fez.theamigan.net:/usr/obj/usr/src/sys/FEZ8 amd64 >Description: This patch fixes telnetd to behave exactly as getty does when if and im are encountered. If both are encountered, if= outputs before im=. Otherwise, whichever is set in gettytab is output. This patch improves upon bin/80732 and bin/23562 to make telnetd's handling of these options similar to getty's. It also makes sure that %h works inside the issue file (which requires the putf() to occur after the hostname editing is complete). >How-To-Repeat: >Fix: Apply the following patch to src/contrib/telnet/telnetd/telnetd.c. --- telnetd.c.diff begins here --- --- telnetd.c.orig 2009-08-03 04:13:06.000000000 -0400 +++ telnetd.c 2010-07-24 19:58:11.000000000 -0400 @@ -742,6 +742,8 @@ char *HE; char *HN; char *IM; + char *IF = NULL; + char issbuf[BUFSIZ]; int nfd; /* @@ -907,17 +909,47 @@ 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(""); + + } else { IM = strdup(DEFAULT_IM); HE = 0; } edithost(HE, host_name); + + bzero(issbuf, sizeof(issbuf)); + + 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); + strlcpy(issbuf, tbf, sizeof(issbuf)); + munmap(tbf, tst.st_size); + close(tfd); + } + } + if (hostinfo && *IM) - putf(IM, ptyibuf2); + strlcat(issbuf, IM, sizeof(issbuf)); + + putf(issbuf, ptyibuf2); if (pcc) (void) strncat(ptyibuf2, ptyip, pcc+1); --- telnetd.c.diff ends here --- Thanks. -Dan >Release-Note: >Audit-Trail: >Unformatted: