return counter;
}
+static char *get_client_ipaddr_name(const struct sockaddr *caller)
+{
+ char buf[INET6_ADDRSTRLEN + 1];
+
+ buf[0] = '$';
+ host_ntop(caller, buf + 1, sizeof(buf) - 1);
+ return strdup(buf);
+}
+
static char *
get_client_hostname(const struct sockaddr *caller, struct addrinfo *ai,
enum auth_error *error)
{
- char buf[INET6_ADDRSTRLEN];
char *n;
if (use_ipaddr)
- return strdup(host_ntop(caller, buf, sizeof(buf)));
+ return get_client_ipaddr_name(caller);
n = client_compose(ai);
*error = unknown_host;
if (!n)
bool client_matches(nfs_export *exp, char *dom, struct addrinfo *ai)
{
- if (use_ipaddr)
+ if (is_ipaddr_client(dom))
return ipaddr_client_matches(exp, ai);
return namelist_client_matches(exp, dom);
}
struct addrinfo *ret;
struct addrinfo *tmp;
+ dom++; /* skip initial "$" */
+
tmp = host_pton(dom);
if (tmp == NULL)
return NULL;
auth_reload();
- if (use_ipaddr) {
+ if (is_ipaddr_client(dom)) {
ai = lookup_client_addr(dom);
if (!ai)
goto out;
next_exp = exp->m_next;
}
- if (!use_ipaddr && !namelist_client_matches(exp, dom))
+ if (!is_ipaddr_client(dom)
+ && !namelist_client_matches(exp, dom))
continue;
if (exp->m_export.e_mountpoint &&
!is_mountpoint(exp->m_export.e_mountpoint[0]?
if (!match_fsid(&parsed, exp, path))
continue;
- if (use_ipaddr && !ipaddr_client_matches(exp, ai))
+ if (is_ipaddr_client(dom)
+ && !ipaddr_client_matches(exp, ai))
continue;
if (!found || subexport(&exp->m_export, found)) {
found = &exp->m_export;
auth_reload();
- if (use_ipaddr) {
+ if (is_ipaddr_client(dom)) {
ai = lookup_client_addr(dom);
if (!ai)
goto out;
bool namelist_client_matches(nfs_export *exp, char *dom);
bool client_matches(nfs_export *exp, char *dom, struct addrinfo *ai);
+static inline bool is_ipaddr_client(char *dom)
+{
+ return dom[0] == '$';
+}
+
#endif /* MOUNTD_H */