summaryrefslogtreecommitdiffstats
path: root/utils/mountd/cache.c
diff options
context:
space:
mode:
authorJ. Bruce Fields <bfields@redhat.com>2011-06-27 12:29:51 -0400
committerSteve Dickson <steved@redhat.com>2011-06-27 12:35:21 -0400
commit13a0a61d037f2cc09e7997a96ce5822b9317883b (patch)
tree1edd0765ed8e7efe5953a3772e1acc7c176fabfb /utils/mountd/cache.c
parentf8d26c1db9a260597828685c7f62e1b29e78285f (diff)
downloadnfs-utils-13a0a61d037f2cc09e7997a96ce5822b9317883b.tar.gz
nfs-utils-13a0a61d037f2cc09e7997a96ce5822b9317883b.tar.xz
nfs-utils-13a0a61d037f2cc09e7997a96ce5822b9317883b.zip
mountd: prefer explicit subexports over crossmnt parents
If a parent is exported with crossmnt, and if a child is also explicitly exported, then both exports could potentially produce matches in this loop; that isn't a bug. Instead of warning and ignoring the second match we find, we should instead prefer whichever export is deeper in the tree, so that children's options can override those of their parents. Reported-by: Olga Kornievskaia <aglo@citi.umich.edu> Signed-off-by: J. Bruce Fields <bfields@redhat.com> Signed-off-by: Steve Dickson <steved@redhat.com>
Diffstat (limited to 'utils/mountd/cache.c')
-rw-r--r--utils/mountd/cache.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/utils/mountd/cache.c b/utils/mountd/cache.c
index 68cccdf..c3dee13 100644
--- a/utils/mountd/cache.c
+++ b/utils/mountd/cache.c
@@ -341,6 +341,17 @@ static char *next_mnt(void **v, char *p)
return me->mnt_dir;
}
+/* True iff e1 is a child of e2 and e2 has crossmnt set: */
+static bool subexport(struct exportent *e1, struct exportent *e2)
+{
+ char *p1 = e1->e_path, *p2 = e2->e_path;
+ int l2 = strlen(p2);
+
+ return e2->e_flags & NFSEXP_CROSSMOUNT
+ && strncmp(p1, p2, l2) == 0
+ && p1[l2] == '/';
+}
+
static void nfsd_fh(FILE *f)
{
/* request are:
@@ -550,13 +561,14 @@ static void nfsd_fh(FILE *f)
if (!client_check(exp->m_client, ai))
continue;
}
- /* It's a match !! */
- if (!found) {
+ if (!found || subexport(&exp->m_export, found)) {
found = &exp->m_export;
+ free(found_path);
found_path = strdup(path);
if (found_path == NULL)
goto out;
- } else if (strcmp(found->e_path, exp->m_export.e_path)!= 0)
+ } else if (strcmp(found->e_path, exp->m_export.e_path)
+ && !subexport(found, &exp->m_export))
{
xlog(L_WARNING, "%s and %s have same filehandle for %s, using first",
found_path, path, dom);