102
103
memset(&my_client, 0, sizeof(my_client));
103
104
xtab_export_read();
104
105
check_useipaddr();
113
static char *get_client_hostname(struct sockaddr_in *caller, struct hostent *hp, enum auth_error *error)
118
return strdup(inet_ntoa(caller->sin_addr));
119
n = client_compose(hp);
120
*error = unknown_host;
126
return strdup("DEFAULT");
129
/* return static nfs_export with details filled in */
131
auth_authenticate_newcache(char *what, struct sockaddr_in *caller,
132
char *path, struct hostent *hp,
133
enum auth_error *error)
138
free(my_client.m_hostname);
140
my_client.m_hostname = get_client_hostname(caller, hp, error);
141
if (my_client.m_hostname == NULL)
144
my_client.m_naddr = 1;
145
my_client.m_addrlist[0] = caller->sin_addr;
146
my_exp.m_client = &my_client;
149
for (i = 0; !exp && i < MCL_MAXTYPES; i++)
150
for (exp = exportlist[i].p_head; exp; exp = exp->m_next) {
151
if (strcmp(path, exp->m_export.e_path))
153
if (!use_ipaddr && !client_member(my_client.m_hostname, exp->m_client->m_hostname))
155
if (use_ipaddr && !client_check(exp->m_client, hp))
159
*error = not_exported;
163
my_exp.m_export = exp->m_export;
110
168
static nfs_export *
111
169
auth_authenticate_internal(char *what, struct sockaddr_in *caller,
112
170
char *path, struct hostent *hp,
113
171
enum auth_error *error)
119
/* return static nfs_export with details filled in */
121
free(my_client.m_hostname);
123
my_client.m_hostname =
124
strdup(inet_ntoa(caller->sin_addr));
126
n = client_compose(hp);
127
*error = unknown_host;
129
my_client.m_hostname = NULL;
131
my_client.m_hostname = n;
134
my_client.m_hostname = strdup("DEFAULT");
137
if (my_client.m_hostname == NULL)
139
my_client.m_naddr = 1;
140
my_client.m_addrlist[0] = caller->sin_addr;
141
my_exp.m_client = &my_client;
144
for (i = 0; !exp && i < MCL_MAXTYPES; i++)
145
for (exp = exportlist[i].p_head; exp; exp = exp->m_next) {
146
if (strcmp(path, exp->m_export.e_path))
148
if (!use_ipaddr && !client_member(my_client.m_hostname, exp->m_client->m_hostname))
150
if (use_ipaddr && !client_check(exp->m_client, hp))
154
*error = not_exported;
176
exp = auth_authenticate_newcache(what, caller, path, hp, error);
158
my_exp.m_export = exp->m_export;
162
180
if (!(exp = export_find(hp, path))) {
163
181
*error = no_entry;
166
if (!exp->m_mayexport) {
167
*error = not_exported;
185
if (exp->m_export.e_flags & NFSEXP_V4ROOT) {
171
189
if (!(exp->m_export.e_flags & NFSEXP_INSECURE_PORT) &&
172
(ntohs(caller->sin_port) < IPPORT_RESERVED/2 ||
173
ntohs(caller->sin_port) >= IPPORT_RESERVED)) {
190
ntohs(caller->sin_port) >= IPPORT_RESERVED) {
174
191
*error = illegal_port;