X-Git-Url: https://git.decadent.org.uk/gitweb/?p=nfs-utils.git;a=blobdiff_plain;f=utils%2Fexportfs%2Fexportfs.c;h=0070b544d654400f9dbafa1127423e55609c5ea0;hp=50f1e34e92eb3e93ecb4b2dc8e60819adf80c00a;hb=0509d3428f523776ddd9d6e9fa318587d3ec7d84;hpb=3ca5879be32c4c11750e12230ff588195fff0738 diff --git a/utils/exportfs/exportfs.c b/utils/exportfs/exportfs.c index 50f1e34..0070b54 100644 --- a/utils/exportfs/exportfs.c +++ b/utils/exportfs/exportfs.c @@ -232,7 +232,7 @@ exportfs(char *arg, char *options, int verbose) { struct exportent *eep; nfs_export *exp; - struct hostent *hp = NULL; + struct addrinfo *ai = NULL; char *path; char *hname = arg; int htype; @@ -245,21 +245,14 @@ exportfs(char *arg, char *options, int verbose) return; } - if ((htype = client_gettype(hname)) == MCL_FQDN && - (hp = gethostbyname(hname)) != NULL) { - struct hostent *hp2 = hostent_dup (hp); - hp = gethostbyaddr(hp2->h_addr, hp2->h_length, - hp2->h_addrtype); - if (hp) { - free(hp2); - hp = hostent_dup(hp); - } else - hp = hp2; - exp = export_find(hp, path); - hname = hp->h_name; - } else { + if ((htype = client_gettype(hname)) == MCL_FQDN) { + ai = host_addrinfo(hname); + if (ai != NULL) { + exp = export_find(ai, path); + hname = ai->ai_canonname; + } + } else exp = export_lookup(hname, path, 0); - } if (!exp) { if (!(eep = mkexportent(hname, path, options)) || @@ -278,7 +271,7 @@ exportfs(char *arg, char *options, int verbose) validate_export(exp); out: - if (hp) free (hp); + freeaddrinfo(ai); } static void