[OpenAFS] Re: How to remove a bogus (127.0.1.1) server entry for readonly volume?

Harald Barth haba@kth.se
Fri, 13 Dec 2013 16:19:04 +0100 (CET)


> All of the places in the code tree that filter eventually test each
> address with rx_IsLoopbackAddr() which is defined in rx.h.

When I look at vos.c, then I find GetServer which uses
rx_IsLoopbackAddr. Now let's assume we feed that something that
resolves to loopback. That will be detected at #1, and as
a second route we look up the local hostname we are on. But
if that at #2 is STILL loopback, that goes through at #3...

GetServer(char *aname)
{
    struct hostent *th;
    afs_uint32 addr; /* in network byte order */
    afs_int32 code;
    char hostname[MAXHOSTCHARS];

    if ((addr = GetServerNoresolve(aname)) == 0) {
        th = gethostbyname(aname);
        if (!th)
            return 0;
        memcpy(&addr, th->h_addr, sizeof(addr));
    }

    if (rx_IsLoopbackAddr(ntohl(addr))) {       /* local host */  #1
        code = gethostname(hostname, MAXHOSTCHARS);
        if (code)
            return 0;
        th = gethostbyname(hostname); #2
        if (!th)
            return 0;
        memcpy(&addr, th->h_addr, sizeof(addr)); #3
    }

    return (addr);
}

I think there should be a "is this still $#%^&* a loopback addr" test
just before return(addr).

Does that sound correct?

Harald.