From owner-freebsd-bugs Mon Dec 28 21:46:31 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id VAA20712 for freebsd-bugs-outgoing; Mon, 28 Dec 1998 21:46:31 -0800 (PST) (envelope-from owner-freebsd-bugs@FreeBSD.ORG) Received: from neptune.oceancomputer.com (ns1.oceancomputer.com [209.36.77.133]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id VAA20695; Mon, 28 Dec 1998 21:46:28 -0800 (PST) (envelope-from jooji@neptune.oceancomputer.com) Received: from localhost (jooji@localhost) by neptune.oceancomputer.com (8.9.1/8.8.8) with SMTP id AAA07383; Tue, 29 Dec 1998 00:46:14 -0500 (EST) (envelope-from jooji@neptune.oceancomputer.com) Date: Tue, 29 Dec 1998 00:46:13 -0500 (EST) From: "Jasper O'Malley" To: FreeBSD-gnats-submit@FreeBSD.ORG, freebsd-bugs@FreeBSD.ORG Subject: Re: bin/9226: telnetd can log wrong IP address to utmp In-Reply-To: <199812282310.PAA17612@freefall.freebsd.org> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org I've found the easiest bit to fix to clear up the instant problem. In src/libexec/telnetd/sys_term.c, a line reads: int utmp_len = MAXHOSTNAMELEN; It should probably read: int utmp_len = UT_HOSTSIZE; and should be moved after the #ifdef NEWINIT/#endif block (in which utmp.h is included). The diff provided should work okay. This will prevent telnetd from passing hostnames longer than UT_HOSTSIZE on as arguments to "login -h", which is what gets the hostname relooked up by login(1) in the first place. It doesn't appear this change will break anything else, but I can't swear to it. Better solutions would be to: a) Make UT_HOSTSIZE bigger, which would break 4.4BSD utmp compatibility, which isn't why it hasn't been done yet. b) Rewrite/patch login(1), xterm(1), sshd(8) et al. to stop logging hostnames in utmp altogether (how many people have hostnames less than 16 characters long these days?). Make other applications do the reverse lookups later, a la w(1) and netstat(1). Here's the patch: *** /usr/src/libexec/telnetd/sys_term.c Wed Dec 24 14:23:18 1997 --- sys_term.c Mon Dec 28 23:05:37 1998 *************** *** 52,58 **** # define PARENT_DOES_UTMP #endif - int utmp_len = MAXHOSTNAMELEN; #ifdef NEWINIT #include #else /* NEWINIT*/ --- 52,57 ---- *************** *** 99,104 **** --- 98,109 ---- # endif /* _SC_CRAY_SECURE_SYS */ # endif /* CRAY */ #endif /* NEWINIT */ + + #ifdef UT_HOSTSIZE + int utmp_len = UT_HOSTSIZE; + #else + int utmp_len = MAXHOSTNAMELEN; + #endif /* UT_HOSTSIZE */ #ifdef STREAMSPTY #include To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message