summaryrefslogtreecommitdiffstats
path: root/utils/mountd/auth.c
diff options
context:
space:
mode:
authorJ. Bruce Fields <bfields@citi.umich.edu>2009-11-27 15:54:11 -0500
committerSteve Dickson <steved@redhat.com>2010-01-13 15:39:14 -0500
commit250c232f53bce01ffd0696f7a55b1e2b0feca51a (patch)
tree172ebbc69e043f44c4b2437b038542b943a3b6e2 /utils/mountd/auth.c
parent195d28eb8136260a456dffa880ed80850115983a (diff)
downloadnfs-utils-250c232f53bce01ffd0696f7a55b1e2b0feca51a.tar.gz
nfs-utils-250c232f53bce01ffd0696f7a55b1e2b0feca51a.tar.xz
nfs-utils-250c232f53bce01ffd0696f7a55b1e2b0feca51a.zip
mountd: auth_authenticate_internal further cleanup
Move newcache case into its own function. Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
Diffstat (limited to 'utils/mountd/auth.c')
-rw-r--r--utils/mountd/auth.c70
1 files changed, 42 insertions, 28 deletions
diff --git a/utils/mountd/auth.c b/utils/mountd/auth.c
index 6fbf72b..0aac273 100644
--- a/utils/mountd/auth.c
+++ b/utils/mountd/auth.c
@@ -126,42 +126,56 @@ static char *get_client_hostname(struct sockaddr_in *caller, struct hostent *hp,
return strdup("DEFAULT");
}
+/* return static nfs_export with details filled in */
+static nfs_export *
+auth_authenticate_newcache(char *what, struct sockaddr_in *caller,
+ char *path, struct hostent *hp,
+ enum auth_error *error)
+{
+ nfs_export *exp;
+ int i;
+
+ free(my_client.m_hostname);
+
+ my_client.m_hostname = get_client_hostname(caller, hp, error);
+ if (my_client.m_hostname == NULL)
+ return NULL;
+
+ my_client.m_naddr = 1;
+ my_client.m_addrlist[0] = caller->sin_addr;
+ my_exp.m_client = &my_client;
+
+ exp = NULL;
+ for (i = 0; !exp && i < MCL_MAXTYPES; i++)
+ for (exp = exportlist[i].p_head; exp; exp = exp->m_next) {
+ if (strcmp(path, exp->m_export.e_path))
+ continue;
+ if (!use_ipaddr && !client_member(my_client.m_hostname, exp->m_client->m_hostname))
+ continue;
+ if (use_ipaddr && !client_check(exp->m_client, hp))
+ continue;
+ break;
+ }
+ *error = not_exported;
+ if (!exp)
+ return NULL;
+
+ my_exp.m_export = exp->m_export;
+ exp = &my_exp;
+ return exp;
+}
+
static nfs_export *
auth_authenticate_internal(char *what, struct sockaddr_in *caller,
char *path, struct hostent *hp,
enum auth_error *error)
{
- nfs_export *exp;
+ nfs_export *exp;
if (new_cache) {
- int i;
- /* return static nfs_export with details filled in */
- free(my_client.m_hostname);
- my_client.m_hostname = get_client_hostname(caller, hp, error);
- if (my_client.m_hostname == NULL)
- return NULL;
- my_client.m_naddr = 1;
- my_client.m_addrlist[0] = caller->sin_addr;
- my_exp.m_client = &my_client;
-
- exp = NULL;
- for (i = 0; !exp && i < MCL_MAXTYPES; i++)
- for (exp = exportlist[i].p_head; exp; exp = exp->m_next) {
- if (strcmp(path, exp->m_export.e_path))
- continue;
- if (!use_ipaddr && !client_member(my_client.m_hostname, exp->m_client->m_hostname))
- continue;
- if (use_ipaddr && !client_check(exp->m_client, hp))
- continue;
- break;
- }
- *error = not_exported;
+ exp = auth_authenticate_newcache(what, caller, path, hp, error);
if (!exp)
- return exp;
-
- my_exp.m_export = exp->m_export;
- exp = &my_exp;
-
+ return NULL;
} else {
if (!(exp = export_find(hp, path))) {
*error = no_entry;