diff options
author | Richard Weinberger <richard@nod.at> | 2023-04-05 12:16:24 -0400 |
---|---|---|
committer | Steve Dickson <steved@redhat.com> | 2023-04-05 12:25:17 -0400 |
commit | c0bf5895173972a0b86633c7d61d0de46798bbe1 (patch) | |
tree | 1a15d63d5eacc63748f476ea595e1aeece1e7109 | |
parent | 608591ddf1ee59c4dda82ceca3f27c90486c5618 (diff) | |
download | nfs-utils-c0bf5895173972a0b86633c7d61d0de46798bbe1.tar.gz |
export: Fix rootdir corner case in next_mnt()
Currently the following setup causes failure:
1. /etc/exports:
/ *(rw,crossmnt,no_subtree_check,fsid=root)
2. /etc/nfs.conf:
[exports]
rootdir=/nfs_srv
3. Mounts:
/root/fs1.ext4 on /nfs_srv type ext4 (rw,relatime)
/root/fs2.ext4 on /nfs_srv/fs2 type ext4 (rw,relatime)
4. On the client:
$ ls /nfs_client/fs2
ls: cannot open directory '/nfs_client/fs2': Stale file handle
The problem is that next_mnt() misses the corner case that
every mount is a sub-mount of "/".
So it fails to see that /nfs_srv/fs2 is a mountpoint when the
client asks for fs2 it and as consequence the crossmnt mechanism
fails.
Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Steve Dickson <steved@redhat.com>
-rw-r--r-- | support/export/cache.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/support/export/cache.c b/support/export/cache.c index 2497d4f..1c52627 100644 --- a/support/export/cache.c +++ b/support/export/cache.c @@ -410,12 +410,16 @@ static char *next_mnt(void **v, char *p) *v = f; } else f = *v; - while ((me = getmntent(f)) != NULL && l > 1) { + while ((me = getmntent(f)) != NULL && l >= 1) { char *mnt_dir = nfsd_path_strip_root(me->mnt_dir); if (!mnt_dir) continue; + /* Everything below "/" is a proper sub-mount */ + if (strcmp(p, "/") == 0) + return mnt_dir; + if (strncmp(mnt_dir, p, l) == 0 && mnt_dir[l] == '/') return mnt_dir; } |