diff options
author | Signed-off-by: NeilBrown <neilb@suse.de> | 2013-05-28 12:59:22 -0400 |
---|---|---|
committer | Steve Dickson <steved@redhat.com> | 2013-05-28 14:28:38 -0400 |
commit | c93e8d8eeafec3e3228e24dfebef113e0a79a788 (patch) | |
tree | 787ea328a35d6a302d5bfc685073a1271e7c9638 /utils/gssd/gssd_proc.c | |
parent | 72bf5b15946db37a6663c93bb9c9dadcdb996f18 (diff) | |
download | nfs-utils-c93e8d8eeafec3e3228e24dfebef113e0a79a788.tar.gz nfs-utils-c93e8d8eeafec3e3228e24dfebef113e0a79a788.tar.xz nfs-utils-c93e8d8eeafec3e3228e24dfebef113e0a79a788.zip |
gssd: Fix recent fix to Avoid DNS reverse resolution in gssd.
The final version for this fix that was committed inverted the test
so makes no change in the important cases.
The documentation didn't really help a naive user know when the new -D
flag should be used.
And the code (once fixed) avoided DNS resolution on non-qualified names too,
which probably isn't a good idea.
This patch fixes all three issues.
Signed-off-by: NeilBrown <neilb@suse.de>
Signed-off-by: Steve Dickson <steved@redhat.com>
Diffstat (limited to 'utils/gssd/gssd_proc.c')
-rw-r--r-- | utils/gssd/gssd_proc.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/utils/gssd/gssd_proc.c b/utils/gssd/gssd_proc.c index 6cd4276..b7e2bbb 100644 --- a/utils/gssd/gssd_proc.c +++ b/utils/gssd/gssd_proc.c @@ -175,7 +175,6 @@ get_servername(const char *name, const struct sockaddr *sa, const char *addr) char *hostname; char hbuf[NI_MAXHOST]; unsigned char buf[sizeof(struct in6_addr)]; - int servername = 0; if (avoid_dns) { /* @@ -183,15 +182,18 @@ get_servername(const char *name, const struct sockaddr *sa, const char *addr) * If it is an IP address, do the DNS lookup otherwise * skip the DNS lookup. */ - servername = 0; - if (strchr(name, '.') && inet_pton(AF_INET, name, buf) == 1) - servername = 1; /* IPv4 */ - else if (strchr(name, ':') && inet_pton(AF_INET6, name, buf) == 1) - servername = 1; /* or IPv6 */ - - if (servername) { + int is_fqdn = 1; + if (strchr(name, '.') == NULL) + is_fqdn = 0; /* local name */ + else if (inet_pton(AF_INET, name, buf) == 1) + is_fqdn = 0; /* IPv4 address */ + else if (inet_pton(AF_INET6, name, buf) == 1) + is_fqdn = 0; /* IPv6 addrss */ + + if (is_fqdn) { return strdup(name); } + /* Sorry, cannot avoid dns after all */ } switch (sa->sa_family) { |