diff options
author | J. Bruce Fields <bfields@citi.umich.edu> | 2009-11-27 15:52:22 -0500 |
---|---|---|
committer | Steve Dickson <steved@redhat.com> | 2010-01-13 15:39:14 -0500 |
commit | 195d28eb8136260a456dffa880ed80850115983a (patch) | |
tree | f852b18b892027b97b481d5977ac8e0fbfa561da /utils/mountd | |
parent | 1ca2e791eee22895907bceac07f2cbd2ea0193e8 (diff) | |
download | nfs-utils-195d28eb8136260a456dffa880ed80850115983a.tar.gz nfs-utils-195d28eb8136260a456dffa880ed80850115983a.tar.xz nfs-utils-195d28eb8136260a456dffa880ed80850115983a.zip |
mountd: auth_authenticate_internal cleanup
Break up another big function.
Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
Diffstat (limited to 'utils/mountd')
-rw-r--r-- | utils/mountd/auth.c | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/utils/mountd/auth.c b/utils/mountd/auth.c index 2ed80bc..6fbf72b 100644 --- a/utils/mountd/auth.c +++ b/utils/mountd/auth.c @@ -110,6 +110,22 @@ auth_reload() return counter; } +static char *get_client_hostname(struct sockaddr_in *caller, struct hostent *hp, enum auth_error *error) +{ + char *n; + + if (use_ipaddr) + return strdup(inet_ntoa(caller->sin_addr)); + n = client_compose(hp); + *error = unknown_host; + if (!n) + return NULL; + if (*n) + return n; + free(n); + return strdup("DEFAULT"); +} + static nfs_export * auth_authenticate_internal(char *what, struct sockaddr_in *caller, char *path, struct hostent *hp, @@ -120,23 +136,8 @@ auth_authenticate_internal(char *what, struct sockaddr_in *caller, if (new_cache) { int i; /* return static nfs_export with details filled in */ - char *n; free(my_client.m_hostname); - if (use_ipaddr) { - my_client.m_hostname = - strdup(inet_ntoa(caller->sin_addr)); - } else { - n = client_compose(hp); - *error = unknown_host; - if (!n) - my_client.m_hostname = NULL; - else if (*n) - my_client.m_hostname = n; - else { - free(n); - my_client.m_hostname = strdup("DEFAULT"); - } - } + my_client.m_hostname = get_client_hostname(caller, hp, error); if (my_client.m_hostname == NULL) return NULL; my_client.m_naddr = 1; |