X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=utils%2Fmountd%2Fmountd.c;h=6571454f6dd61e7fc22f929a3c61405456f1a71e;hb=9d5eaa2e939723c47649f0f112b43cc8ff414740;hp=ecd7c35cd66e43b0ea2b9634bc6c841c7028a537;hpb=8ec371fe01e96c008cdc6143db716f1a9bfb6566;p=nfs-utils.git diff --git a/utils/mountd/mountd.c b/utils/mountd/mountd.c index ecd7c35..6571454 100644 --- a/utils/mountd/mountd.c +++ b/utils/mountd/mountd.c @@ -80,10 +80,10 @@ static int nfs_version = -1; static void unregister_services (void) { - if (nfs_version & 0x1) + if (nfs_version & (0x1 << 1)) { pmap_unset (MOUNTPROG, MOUNTVERS); - if (nfs_version & (0x1 << 1)) pmap_unset (MOUNTPROG, MOUNTVERS_POSIX); + } if (nfs_version & (0x1 << 2)) pmap_unset (MOUNTPROG, MOUNTVERS_NFSV3); } @@ -536,22 +536,21 @@ static void free_exportlist(exports *elist) static void prune_clients(nfs_export *exp, struct exportnode *e) { - struct hostent *hp; + struct addrinfo *ai = NULL; struct groupnode *c, **cp; cp = &e->ex_groups; while ((c = *cp) != NULL) { if (client_gettype(c->gr_name) == MCL_FQDN - && (hp = gethostbyname(c->gr_name))) { - hp = hostent_dup(hp); - if (client_check(exp->m_client, hp)) { + && (ai = host_addrinfo(c->gr_name))) { + if (client_check(exp->m_client, ai)) { *cp = c->gr_next; xfree(c->gr_name); xfree(c); - xfree (hp); + freeaddrinfo(ai); continue; } - xfree (hp); + freeaddrinfo(ai); } cp = &(c->gr_next); } @@ -612,20 +611,17 @@ get_exportlist(void) continue; e = lookup_or_create_elist_entry(&elist, exp); - /* We need to check if we should remove - previous ones. */ + /* exports to "*" absorb any others */ if (i == MCL_ANONYMOUS && e->ex_groups) { remove_all_clients(e); continue; } - - if (i != MCL_FQDN && e->ex_groups) { + /* non-FQDN's absorb FQDN's they contain: */ + if (i != MCL_FQDN && e->ex_groups) prune_clients(exp, e); - } - if (exp->m_export.e_hostname [0] != '\0') { + if (exp->m_export.e_hostname[0] != '\0') insert_group(e, exp->m_export.e_hostname); - } } } @@ -715,8 +711,10 @@ main(int argc, char **argv) usage(argv [0], 1); } - /* No more arguments allowed. */ - if (optind != argc || !(nfs_version & 0x7)) + /* No more arguments allowed. + * Require at least one valid version (2, 3, or 4) + */ + if (optind != argc || !(nfs_version & 0xE)) usage(argv [0], 1); if (chdir(state_dir)) { @@ -764,12 +762,12 @@ main(int argc, char **argv) if (new_cache) cache_open(); - if (nfs_version & 0x1) + if (nfs_version & (0x1 << 1)) { rpc_init("mountd", MOUNTPROG, MOUNTVERS, mount_dispatch, port); - if (nfs_version & (0x1 << 1)) rpc_init("mountd", MOUNTPROG, MOUNTVERS_POSIX, mount_dispatch, port); + } if (nfs_version & (0x1 << 2)) rpc_init("mountd", MOUNTPROG, MOUNTVERS_NFSV3, mount_dispatch, port);