summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrank Sorenson <sorenson@redhat.com>2015-12-16 10:12:38 -0500
committerSteve Dickson <steved@redhat.com>2015-12-16 10:12:38 -0500
commit4b5bd85481a45957122357feebfcd514550fc219 (patch)
treed16e96de1f36b03ded5fc8505d21f2084b867399
parent24c8c849a0118a8a204640433c4dc2c3c6ae133d (diff)
downloadnfs-utils-4b5bd85481a45957122357feebfcd514550fc219.tar.gz
nfs-utils-4b5bd85481a45957122357feebfcd514550fc219.tar.xz
nfs-utils-4b5bd85481a45957122357feebfcd514550fc219.zip
mountd: fix netgroup lookup for short hostnames
Commit 9a92ef6f to add netgroup lookup of resolvable IP addresses inadvertently broke the netgroup check for short hostnames. This patch fixes that breakage by changing the IP address lookup to use a separate variable. Signed-off-by: Frank Sorenson <sorenson@redhat.com> Signed-off-by: Steve Dickson <steved@redhat.com>
-rw-r--r--support/export/client.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/support/export/client.c b/support/export/client.c
index af9e6bb..2346f99 100644
--- a/support/export/client.c
+++ b/support/export/client.c
@@ -639,7 +639,7 @@ check_netgroup(const nfs_client *clp, const struct addrinfo *ai)
const char *netgroup = clp->m_hostname + 1;
struct addrinfo *tmp = NULL;
struct hostent *hp;
- char *dot, *hname;
+ char *dot, *hname, *ip;
int i, match;
match = 0;
@@ -687,19 +687,16 @@ check_netgroup(const nfs_client *clp, const struct addrinfo *ai)
}
/* check whether the IP itself is in the netgroup */
- for (tmp = (struct addrinfo *)ai ; tmp != NULL ; tmp = tmp->ai_next) {
- free(hname);
- hname = calloc(INET6_ADDRSTRLEN, 1);
-
- if (inet_ntop(tmp->ai_family, &(((struct sockaddr_in *)tmp->ai_addr)->sin_addr), hname, INET6_ADDRSTRLEN) != hname) {
- xlog(D_GENERAL, " %s: unable to inet_ntop addrinfo %p: %m", __func__, tmp, errno);
- goto out;
- }
- if (innetgr(netgroup, hname, NULL, NULL)) {
+ ip = calloc(INET6_ADDRSTRLEN, 1);
+ if (inet_ntop(ai->ai_family, &(((struct sockaddr_in *)ai->ai_addr)->sin_addr), ip, INET6_ADDRSTRLEN) == ip) {
+ if (innetgr(netgroup, ip, NULL, NULL)) {
+ free(hname);
+ hname = ip;
match = 1;
goto out;
}
}
+ free(ip);
/* Okay, strip off the domain (if we have one) */
dot = strchr(hname, '.');