Today, Marcus Brinkmann ([EMAIL PROTECTED]) wrote:

# > GNU 0.2 (granite.man.uk.ekto.org init runs these programs,
# > # and restartsthem when th01) (console)
# 
# Whop!!! (Eyes falling out)

Okay, having now looked at libshouldbeinlibc/localhost.c, I understand
your suprise at this.

The code snippet in question is:

do {
        [Snip buffer (re)allocation stuff here]
} while((gethostname(buf, buf_len) == 0 && !memchr (buf, '\0', buf_len))
        || errno == ENAMETOOLONG);

Obviously the returned buffer must be null-terminated somewhere, else the
memchr() test would fail. gethostname() isn't failing, else this code
after the loop would kick in:

if (errno)
        /* gethostname() failed, abort. */
        {
          free(buf);
          buf = 0;
        }

And my test calls to localhost() in an aptly-named foo.c (just a
printf() of the result) show no unusual behaviour.

Thus, I can only conclude that either:

- Something in getty is calling localhost() and munging the result

- gethostname() in some situations is returning garbage (this could be a
case of GIGO).

I can rule out the former based on the fact that the only thing using
localhost() in getty.c is:

        char *hostname = localhost ();

        cc = asprintf( ..., hostname?: "?", ... );

So, it appears to be some libc weirdness.

I've not looked in detail at a deeper level than this; how/why does the
hostname persist? I notice that it's exactly the same
munged text that appears after every reboot (and every log out, for that
matter), although I'm not sure if that's of any significance - I doubt it
is.

It does seem strange that this is limited to getty - I would've expected
weirdness elsewhere if it was a libc issue, although maybe I've just not
hit any yet.

As an aside, this may or may not have a bearing on things:

 90% of what I'm running is straight from Marcus' tarball. The following
packages I've installed from /dist/sid/binary-i386-hurd on my friendly
debian mirror:

        binutils_2.10.0.18-2.deb
        cpp_2.95.2-14.deb
        gcc_2.95-2-14.deb
        gnumach-dev_1.2-3.deb
        hurd-dev_20000803.deb
        libc0.2-dev_2.1.3-10.deb
        libc0.2_2.1.3-10.deb
        make_3.79-2.deb

Plus, I've built from source:

        inetutils-1.3.2
        sh-utils-2.0
        bash-2.03.0(1)
        
        (And various other packages that I probably aren't relevant)

If anybody's running a pretty similar configuration, perhaps they could
try setting their hostname to something of a similar length? (to recap, my
hostname is set to 'granite.man.uk.ekto.org')

-- 
Mo McKinlay             Chief Software Architect          inter/open Labs
-------------------------------------------------------------------------
GnuPG Key: pub  1024D/76A275F9 2000-07-22 Mo McKinlay <[EMAIL PROTECTED]>






Reply via email to