Linux NFS development
 help / color / mirror / Atom feed
* fix mountd netgroup lookup for short hostnames
       [not found] <1054854128.30230518.1450131093639.JavaMail.zimbra@redhat.com>
@ 2015-12-14 22:15 ` Frank Sorenson
  2015-12-16 15:17   ` Steve Dickson
  0 siblings, 1 reply; 2+ messages in thread
From: Frank Sorenson @ 2015-12-14 22:15 UTC (permalink / raw)
  To: linux-nfs; +Cc: Steve Dickson


Commit 9a92ef6f194926904b1289e0ce1daecb42bd5e8b to add netgroup
lookup of resolvable IP addresses inadvertently broke the
netgroup check for short hostnames by clobbering the 'hname'
variable.
    
This patch fixes that breakage by changing the IP address
lookup to use a separate variable.  The 'hname' variable
used in the short hostname lookup is now untouched in
the IP lookup code.



Author: Frank Sorenson <sorenson@redhat.com>
Date:   Mon Dec 14 15:50:30 2015 -0600

    mountd: fix netgroup lookup for short hostnames
    
    Commit 9a92ef6f194926904b1289e0ce1daecb42bd5e8b 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>

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, '.');

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: fix mountd netgroup lookup for short hostnames
  2015-12-14 22:15 ` fix mountd netgroup lookup for short hostnames Frank Sorenson
@ 2015-12-16 15:17   ` Steve Dickson
  0 siblings, 0 replies; 2+ messages in thread
From: Steve Dickson @ 2015-12-16 15:17 UTC (permalink / raw)
  To: Frank Sorenson, linux-nfs



On 12/14/2015 05:15 PM, Frank Sorenson wrote:
> 
> Commit 9a92ef6f194926904b1289e0ce1daecb42bd5e8b to add netgroup
> lookup of resolvable IP addresses inadvertently broke the
> netgroup check for short hostnames by clobbering the 'hname'
> variable.
>     
> This patch fixes that breakage by changing the IP address
> lookup to use a separate variable.  The 'hname' variable
> used in the short hostname lookup is now untouched in
> the IP lookup code.
> 
> 
> 
> Author: Frank Sorenson <sorenson@redhat.com>
> Date:   Mon Dec 14 15:50:30 2015 -0600
> 
>     mountd: fix netgroup lookup for short hostnames
>     
>     Commit 9a92ef6f194926904b1289e0ce1daecb42bd5e8b 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>
Committed... Thanks!

steved.

> 
> 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, '.');
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-12-16 15:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <1054854128.30230518.1450131093639.JavaMail.zimbra@redhat.com>
2015-12-14 22:15 ` fix mountd netgroup lookup for short hostnames Frank Sorenson
2015-12-16 15:17   ` Steve Dickson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox