]> git.decadent.org.uk Git - nfs-utils.git/commitdiff
bexport: Add a common exit label to check_netgroup()
authorChuck Lever <chuck.lever@oracle.com>
Tue, 24 Aug 2010 11:06:14 +0000 (07:06 -0400)
committerSteve Dickson <steved@redhat.com>
Tue, 24 Aug 2010 11:22:51 +0000 (07:22 -0400)
check_netgroup() is going to be changed to free dynamically
allocated resources before it returns, so a common
exit point is needed.

Reviewed-by: Neil Brown <neilb@suse.de>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Steve Dickson <steved@redhat.com>
support/export/client.c

index dc0106767a4d5cc64eaa424cba80f71d461c2589..b1a3a09d680d32b2f5e70aaf3c847bf4b1b0b18f 100644 (file)
@@ -496,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 */