X-Git-Url: https://git.decadent.org.uk/gitweb/?p=nfs-utils.git;a=blobdiff_plain;f=support%2Fexport%2Fclient.c;h=b1a3a09d680d32b2f5e70aaf3c847bf4b1b0b18f;hp=9a0fc9dabd1f58068a46cfea13d41838e618a830;hb=abdc32b6af6f38a741a481aeefb5623916152498;hpb=0509d3428f523776ddd9d6e9fa318587d3ec7d84 diff --git a/support/export/client.c b/support/export/client.c index 9a0fc9d..b1a3a09 100644 --- a/support/export/client.c +++ b/support/export/client.c @@ -134,9 +134,13 @@ client_add(nfs_client *clp) *cpp = clp; } -/* if canonical is set, then we *know* this is already a canonical name - * so hostname lookup is avoided. - * This is used when reading /proc/fs/nfs/exports +/** + * client_lookup - look for @hname in our list of cached nfs_clients + * @hname: '\0'-terminated ASCII string containing hostname to look for + * @canonical: if set, @hname is known to be canonical DNS name + * + * Returns pointer to a matching or freshly created nfs_client. NULL + * is returned if some problem occurs. */ nfs_client * client_lookup(char *hname, int canonical) @@ -215,6 +219,10 @@ client_dup(const nfs_client *clp, const struct addrinfo *ai) return new; } +/** + * client_release - drop a reference to an nfs_client record + * + */ void client_release(nfs_client *clp) { @@ -223,6 +231,10 @@ client_release(nfs_client *clp) clp->m_count--; } +/** + * client_freeall - deallocate all nfs_client records + * + */ void client_freeall(void) { @@ -484,37 +496,46 @@ check_netgroup(const nfs_client *clp, const struct addrinfo *ai) int i, match; char *dot; + match = 0; + /* First, try to match the hostname without * splitting off the domain */ - if (innetgr(netgroup, hname, NULL, NULL)) - return 1; + if (innetgr(netgroup, hname, NULL, NULL)) { + match = 1; + goto out; + } /* See if hname aliases listed in /etc/hosts or nis[+] * match the requested netgroup */ hp = gethostbyname(hname); if (hp != NULL) { for (i = 0; hp->h_aliases[i]; i++) - if (innetgr(netgroup, hp->h_aliases[i], NULL, NULL)) - return 1; + if (innetgr(netgroup, hp->h_aliases[i], NULL, NULL)) { + match = 1; + goto out; + } } /* If hname is ip address convert to FQDN */ tmp = host_pton(hname); if (tmp != NULL) { freeaddrinfo(tmp); - if (innetgr(netgroup, hname, NULL, NULL)) - return 1; + if (innetgr(netgroup, hname, NULL, NULL)) { + match = 1; + goto out; + } } /* Okay, strip off the domain (if we have one) */ dot = strchr(hname, '.'); if (dot == NULL) - return 0; + goto out; *dot = '\0'; match = innetgr(netgroup, hname, NULL, NULL); *dot = '.'; +out: return match; } #else /* !HAVE_INNETGR */ @@ -558,6 +579,13 @@ client_check(const nfs_client *clp, const struct addrinfo *ai) return 0; } +/** + * client_gettype - determine type of nfs_client given an identifier + * @ident: '\0'-terminated ASCII string containing a client identifier + * + * Returns the type of nfs_client record that would be used for + * this client. + */ int client_gettype(char *ident) {