X-Git-Url: https://git.decadent.org.uk/gitweb/?p=nfs-utils.git;a=blobdiff_plain;f=utils%2Fmountd%2Fcache.c;h=c3dee13c61714c50342fe6370b2782b7aa9fe327;hp=df6b38f9b5c737d5f9e87a9380ef854d3e464b16;hb=13a0a61d037f2cc09e7997a96ce5822b9317883b;hpb=5604b35a61e22930873ffc4e9971002f578e7978 diff --git a/utils/mountd/cache.c b/utils/mountd/cache.c index df6b38f..c3dee13 100644 --- a/utils/mountd/cache.c +++ b/utils/mountd/cache.c @@ -138,7 +138,7 @@ static void auth_unix_gid(FILE *f) static gid_t *groups = NULL; static int groups_len = 0; gid_t *more_groups; - int ngroups = 0; + int ngroups; int rv, i; char *cp; @@ -147,9 +147,11 @@ static void auth_unix_gid(FILE *f) if (!groups) return; - groups_len = ngroups = INITIAL_MANAGED_GROUPS; + groups_len = INITIAL_MANAGED_GROUPS; } + ngroups = groups_len; + if (readline(fileno(f), &lbuf, &lbuflen) != 1) return; @@ -339,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: @@ -548,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); @@ -827,11 +841,11 @@ struct { FILE *f; char vbuf[RPC_CHAN_BUF_SIZE]; } cachelist[] = { - { "auth.unix.ip", auth_unix_ip, NULL}, - { "auth.unix.gid", auth_unix_gid, NULL}, - { "nfsd.export", nfsd_export, NULL}, - { "nfsd.fh", nfsd_fh, NULL}, - { NULL, NULL, NULL } + { "auth.unix.ip", auth_unix_ip, NULL, ""}, + { "auth.unix.gid", auth_unix_gid, NULL, ""}, + { "nfsd.export", nfsd_export, NULL, ""}, + { "nfsd.fh", nfsd_fh, NULL, ""}, + { NULL, NULL, NULL, ""} }; extern int manage_gids;