X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=utils%2Fmountd%2Fauth.c;h=d88c46f31b52563827aac1aedfe5703e7fbc182f;hb=3ce25efd1c72fedeba514b8c14748364c42f21e4;hp=2b4051e1676a25f776ab1a19d28f14e4ff7c267e;hpb=16ff9c8020071d12496daab4acc70ecade033662;p=nfs-utils.git diff --git a/utils/mountd/auth.c b/utils/mountd/auth.c index 2b4051e..d88c46f 100644 --- a/utils/mountd/auth.c +++ b/utils/mountd/auth.c @@ -78,20 +78,10 @@ auth_authenticate_internal(char *what, struct sockaddr_in *caller, } auth_fixpath(path); - /* 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; - *hpp = get_hostent((const char *)&addr, sizeof(addr), AF_INET); - return NULL; - } else { + if (!(*hpp = gethostbyaddr((const char *)&addr, sizeof(addr), AF_INET))) + *hpp = get_hostent((const char *)&addr, sizeof(addr), + AF_INET); + else { /* must make sure the hostent is authorative. */ char **sp; struct hostent *forward = NULL; @@ -123,14 +113,12 @@ auth_authenticate_internal(char *what, struct sockaddr_in *caller, *error = no_forward_dns; 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; @@ -158,7 +146,11 @@ auth_authenticate(char *what, struct sockaddr_in *caller, char *path) struct in_addr addr = caller->sin_addr; enum auth_error error; - if (path [0] != '/') return exp; + if (path [0] != '/') { + xlog(L_WARNING, "bad path in %s request from %s: \"%s\"", + what, inet_ntoa(addr), path); + return exp; + } strncpy(epath, path, sizeof (epath) - 1); epath[sizeof (epath) - 1] = '\0';