summaryrefslogtreecommitdiffstats
path: root/utils/mountd/auth.c
diff options
context:
space:
mode:
authorhjl <hjl>2000-08-10 03:02:40 +0000
committerhjl <hjl>2000-08-10 03:02:40 +0000
commit9b2a1e5430e9bcca39eddc25464234fd95d50b83 (patch)
tree3785f8bf61802ee2a4c92477629087ca4f7c26f0 /utils/mountd/auth.c
parent311607be93bc843e5d170b3e56b7d9d2587b3e1e (diff)
downloadnfs-utils-9b2a1e5430e9bcca39eddc25464234fd95d50b83.tar.gz
nfs-utils-9b2a1e5430e9bcca39eddc25464234fd95d50b83.tar.xz
nfs-utils-9b2a1e5430e9bcca39eddc25464234fd95d50b83.zip
2000-08-02 H.J. Lu <hjl@lucon.org>
* utils/mountd/auth.c (auth_authenticate_internal): Try to avoid the reverse name lookup.
Diffstat (limited to 'utils/mountd/auth.c')
-rw-r--r--utils/mountd/auth.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/utils/mountd/auth.c b/utils/mountd/auth.c
index 98c3944..49567c9 100644
--- a/utils/mountd/auth.c
+++ b/utils/mountd/auth.c
@@ -78,10 +78,19 @@ auth_authenticate_internal(char *what, struct sockaddr_in *caller,
}
auth_fixpath(path);
- if (!(*hpp = gethostbyaddr((const char *)&addr, sizeof(addr), AF_INET)))
- *hpp = get_hostent((const char *)&addr, sizeof(addr),
- AF_INET);
- else {
+ /* First try it w/o doing a hostname lookup... */
+ *hpp = get_hostent((const char *)&addr, sizeof(addr), AF_INET);
+ exp = export_find(*hpp, path);
+
+ if (!exp) {
+ /* Ok, that didn't fly. Try it with a reverse lookup. */
+ free (*hpp);
+ *hpp = gethostbyaddr((const char *)&addr, sizeof(addr),
+ AF_INET);
+ if (!(*hpp)) {
+ *error = no_entry;
+ return NULL;
+ } else {
/* must make sure the hostent is authorative. */
char **sp;
struct hostent *forward = NULL;
@@ -113,12 +122,14 @@ auth_authenticate_internal(char *what, struct sockaddr_in *caller,
*hpp = hostent_dup (*hpp);
return NULL;
}
- }
+ }
- if (!(exp = export_find(*hpp, path))) {
+ if (!(exp = export_find(*hpp, path))) {
*error = no_entry;
return NULL;
+ }
}
+
if (!exp->m_mayexport) {
*error = not_exported;
return NULL;