From owner-freebsd-hackers Wed Mar 27 6:44:48 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from reiher.informatik.uni-wuerzburg.de (wi4d22.informatik.uni-wuerzburg.de [132.187.101.122]) by hub.freebsd.org (Postfix) with ESMTP id 0993137B416 for ; Wed, 27 Mar 2002 06:44:34 -0800 (PST) Received: from reiher.informatik.uni-wuerzburg.de (localhost [127.0.0.1]) by reiher.informatik.uni-wuerzburg.de (Postfix) with ESMTP id 4CE71AEB8; Wed, 27 Mar 2002 15:44:32 +0100 (CET) From: Matthias Buelow To: Scott Blachowicz Cc: freebsd-hackers@freebsd.org Subject: Re: ports/36307: nmh port cuts off last part of sender domain In-Reply-To: Your message of "Tue, 26 Mar 2002 20:14:08 PST." <20020326201407.A55900@sabami.seaslug.org> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <89211.1017240272.1@reiher.informatik.uni-wuerzburg.de> Date: Wed, 27 Mar 2002 15:44:32 +0100 Message-Id: <20020327144432.4CE71AEB8@reiher.informatik.uni-wuerzburg.de> Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Scott Blachowicz writes: (freebsd-hackers, please see comment about sys/utsname.h / SYS_NMLN below; you might ignore the nmh bug correspondence above.) >OK...it looks like there's this zotnet/mts/mts.c file with a LocalName() >function that calls various functions (uname(), gethostbyname(), ...) to get >the canonical hostname for a system. I've put some debug tracing in my copy >to figure out which calls are returning what. Also, I put some code in the >mts/smtp/smtp.c to dump everything written to the SMTP socket into a /tmp/ >file. Those files should be attached to this message. > >So, after building with this stuff, you do > > env DEBUG_SMTP=1 comp > >to send something. I just did that here and got this: Heh, I've found the bug. Your debugging code put me on the correct trail. nmh now spits out: What now? s LocalName() - got from uname(): reiher.informatik.uni-wuerzburg LocalName() - returning: reiher.informatik.uni-wuerzburg LocalName() - got from uname(): reiher.informatik.uni-wuerzburg LocalName() - returning: reiher.informatik.uni-wuerzburg smtp.c[138]: calling LocalName() which made me look up uname(3) and write a little test program: #include #include int main() { struct utsname u; if (-1 == (uname(&u))) { perror("uname failed"); return 1; } printf("sysname: %s\nnodename: %s\nrelease: %s\nmachine: %s\n", u.sysname, u.nodename, u.release, u.version, u.machine); return 0; } which prints: $ ./a.out sysname: FreeBSD nodename: reiher.informatik.uni-wuerzburg release: 4.5-STABLE machine: FreeBSD 4.5-STABLE #0: Fri Mar Note that not only the "nodename" is truncated but the "machine" entry also. Which made me look into sys/utsname.h, suspecting a small constant width for these struct entries, which actually turns out to be the case: #define SYS_NMLN 32 ... char nodename[SYS_NMLN]; /* Name of this network node. */ ... Thus, if nmh calls uname(3) to get the name, everything longer than 31 characters is truncated. This is both a problem in nmh aswell as FreeBSD; nmh shouldn't rely on uname(3) for getting a full Internet hostname as "nodename"; FreeBSD should raise SYS_NMLN to provide enough place for an Internet hostname. For example, on Solaris 8, it is defined as: #define _SYS_NMLN 257 /* 4.0 size of utsname elements */ /* Must be at least 257 to */ /* support Internet hostnames. */ On NetBSD (1.5.1) it is: #define _SYS_NMLN 256 That's also the reason why the "problem" didn't show up on NetBSD or Solaris. My proposal: Make nmh depend on sth. else than uname(3), and also push up FreeBSD's SYS_NMLN (if not already done so in -CURRENT, haven't checked.) --mkb To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message