Skip to contentSkip to conversation

BUG(?): resolved hostnames in etab instead of IPs

DISCUSSION Denis Vlasenko 1 participant 1 message Mar 4, 2005

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

I'm doing my testing locally, therefore I use 127.0.0.1, but I believe this will happen with any numeric IP:

# cat /etc/exports
/       127.0.0.1(rw,no_root_squash,async)
# rm /var/lib/nfs/etab
# exportfs -r
# cat /var/lib/nfs/etab
/       localhost(rw,async,wdelay,hide,nocrossmnt,secure,no_root_squash,no_all_squash,subtree_check,secure_locks,mapping=identity,anonuid=-2,anongid=-2)

Looks like bug to me, because I said explicitly that I allow 127.0.0.1 to mount /, not it's hostname.

One of consequences of this bug is mount failures if mountd gets restarted while name resolution isn't working (DNS server down etc).

In case this is indeed a bug, here is where it happens. (I'm not sure I will be able to cook up a sane patch so at least I'll try to explain how 'exportfs -r' did it):

int main(...)
-> int export_read(char *fname)
-> nfs_export* export_lookup(char *hname, char *path, int canonical) -> nfs_client* client_lookup(char *hname, int canonical)

nfs-utils-1.0.7/support/export/client.c:
nfs_client *
client_lookup(char *hname, int canonical)

{
        nfs_client      *clp = NULL;
        int             htype;
        struct hostent  *hp = NULL;

        htype = client_gettype(hname);

        if (htype == MCL_FQDN && !canonical) {
                struct hostent *hp2;
                hp = gethostbyname(hname);
                if (hp == NULL || hp->h_addrtype != AF_INET) {
                        xlog(L_ERROR, "%s has non-inet addr", hname);
                        return NULL;
                }
                /* make sure we have canonical name */
                hp2 = hostent_dup(hp);
HERE ====>      hp = gethostbyaddr(hp2->h_addr, hp2->h_length,
                                   hp2->h_addrtype);
                if (hp) {

Hmm... maybe we need to introduce MCL_NUMERIC_IP or something like that? --
vda

-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs