From: Chuck Lever <chuck.lever@oracle.com>
To: steved@redhat.com
Cc: neilb@suse.de, linux-nfs@vger.kernel.org
Subject: [PATCH 1/2] libexport: Add a common exit label to check_netgroup()
Date: Wed, 04 Aug 2010 13:13:00 -0400 [thread overview]
Message-ID: <20100804171259.2657.58455.stgit@seurat.1015granger.net> (raw)
In-Reply-To: <20100804171036.2657.8657.stgit@seurat.1015granger.net>
I'm about to change check_netgroup() to free dynamically allocated
resources before it returns, so a common exit point is needed.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Reviewed-by: Neil Brown <neilb@suse.de>
---
support/export/client.c | 23 ++++++++++++++++-------
1 files changed, 16 insertions(+), 7 deletions(-)
diff --git a/support/export/client.c b/support/export/client.c
index 91b17f3..6667200 100644
--- a/support/export/client.c
+++ b/support/export/client.c
@@ -589,37 +589,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 */
next prev parent reply other threads:[~2010-08-04 17:13 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-04 17:12 [PATCH 0/2] nfs-utils: fix check_netgroup() Chuck Lever
2010-08-04 17:13 ` Chuck Lever [this message]
2010-08-04 17:13 ` [PATCH 2/2] libexport: Fix IP address check in check_netgroup() Chuck Lever
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20100804171259.2657.58455.stgit@seurat.1015granger.net \
--to=chuck.lever@oracle.com \
--cc=linux-nfs@vger.kernel.org \
--cc=neilb@suse.de \
--cc=steved@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).