Scott Blachowicz <[EMAIL PROTECTED]> 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 <sys/utsname.h>
    #include <stdio.h>

    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 [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message

Reply via email to