614
614
return qword_eol(f);
617
void nfsd_export(FILE *f)
621
* determine export options and return:
622
* domain path expiry flags anonuid anongid fsid
628
nfs_export *exp, *found = NULL;
617
static int is_subdirectory(char *subpath, char *path)
619
int l = strlen(path);
621
return strcmp(subpath, path) == 0
622
|| (strncmp(subpath, path, l) == 0 && path[l] == '/');
625
static int path_matches(nfs_export *exp, char *path)
627
if (exp->m_export.e_flags & NFSEXP_CROSSMOUNT)
628
return is_subdirectory(path, exp->m_export.e_path);
629
return strcmp(path, exp->m_export.e_path) == 0;
632
static int client_matches(nfs_export *exp, char *dom, struct hostent *he)
635
return client_check(exp->m_client, he);
636
return client_member(dom, exp->m_client->m_hostname);
639
static int export_matches(nfs_export *exp, char *dom, char *path, struct hostent *he)
641
return path_matches(exp, path) && client_matches(exp, dom, he);
644
static nfs_export *lookup_export(char *dom, char *path, struct hostent *he)
647
nfs_export *found = NULL;
629
648
int found_type = 0;
631
struct hostent *he = NULL;
634
if (readline(fileno(f), &lbuf, &lbuflen) != 1)
637
xlog(D_CALL, "nfsd_export: inbuf '%s'", lbuf);
640
dom = malloc(strlen(cp));
641
path = malloc(strlen(cp));
646
if (qword_get(&cp, dom, strlen(lbuf)) <= 0)
648
if (qword_get(&cp, path, strlen(lbuf)) <= 0)
653
/* now find flags for this export point in this domain */
654
651
for (i=0 ; i < MCL_MAXTYPES; i++) {
655
652
for (exp = exportlist[i].p_head; exp; exp = exp->m_next) {
656
if (!use_ipaddr && !client_member(dom, exp->m_client->m_hostname))
658
if (exp->m_export.e_flags & NFSEXP_CROSSMOUNT) {
659
/* if path is a mountpoint below e_path, then OK */
660
int l = strlen(exp->m_export.e_path);
661
if (strcmp(path, exp->m_export.e_path) == 0 ||
662
(strncmp(path, exp->m_export.e_path, l) == 0 &&
664
is_mountpoint(path)))
668
} else if (strcmp(path, exp->m_export.e_path) != 0)
672
if (!inet_aton(dom, &addr))
674
he = client_resolve(addr);
676
if (!client_check(exp->m_client, he))
653
if (!export_matches(exp, dom, path, he))
661
/* Always prefer non-V4ROOT mounts */
662
if (found->m_export.e_flags & NFSEXP_V4ROOT)
684
665
/* If one is a CROSSMOUNT, then prefer the longest path */
685
666
if (((found->m_export.e_flags & NFSEXP_CROSSMOUNT) ||
686
667
(exp->m_export.e_flags & NFSEXP_CROSSMOUNT)) &&
690
void nfsd_export(FILE *f)
694
* determine export options and return:
695
* domain path expiry flags anonuid anongid fsid
700
nfs_export *found = NULL;
702
struct hostent *he = NULL;
705
if (readline(fileno(f), &lbuf, &lbuflen) != 1)
708
xlog(D_CALL, "nfsd_export: inbuf '%s'", lbuf);
711
dom = malloc(strlen(cp));
712
path = malloc(strlen(cp));
717
if (qword_get(&cp, dom, strlen(lbuf)) <= 0)
719
if (qword_get(&cp, path, strlen(lbuf)) <= 0)
725
if (!inet_aton(dom, &addr))
727
he = client_resolve(addr);
730
found = lookup_export(dom, path, he);
708
733
if (dump_to_cache(f, dom, path, &found->m_export) < 0) {