summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNiels de Vos <ndevos@redhat.com>2017-08-01 14:41:54 +0200
committerShyamsundar Ranganathan <srangana@redhat.com>2017-08-02 15:09:13 +0000
commit726797d3e62bfe1ebf0c3af63b00084e1b159886 (patch)
tree6e3f7d54521e347d5b18c3e2eccbdf1afdf90064
parent87edff6e20ff3ff7bc1dc5a1b0186127effee364 (diff)
nfs: use "/" as subdir for volume mounts
For cases where subdir mounting is checked, it makes it much easier to return a subdir of "/" in case no subdir is passed. This reduces the number of corner cases where permissions are checked for subdir mounts, but not for volume mounts (or the other way around). The problem was identified by WebNFS mounting a volume, which got denied after commit e3f48fa2. Handling this would require an exception for non-subdir mounts, or make non-subdir mounts equal to subdir mounts. This change takes the 2nd approach. Cherry picked from commit 45c973576d6356dbe4da897e9f0528eac7529d48: > Change-Id: I0d810ae90b267a2cc3eac8d55368a0f1b0787f6a > Fixes: e3f48fa2 ("nfs: add permission checking for mounting over WebNFS") > BUG: 1468291 > Signed-off-by: Niels de Vos <ndevos@redhat.com> > Reviewed-on: https://review.gluster.org/17898 > Smoke: Gluster Build System <jenkins@build.gluster.org> > Reviewed-by: soumya k <skoduri@redhat.com> > CentOS-regression: Gluster Build System <jenkins@build.gluster.org> > Reviewed-by: jiffin tony Thottan <jthottan@redhat.com> Change-Id: I0d810ae90b267a2cc3eac8d55368a0f1b0787f6a BUG: 1477190 Signed-off-by: Niels de Vos <ndevos@redhat.com> Reviewed-on: https://review.gluster.org/17947 Smoke: Gluster Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Shyamsundar Ranganathan <srangana@redhat.com>
-rw-r--r--xlators/nfs/server/src/mount3.c31
1 files changed, 14 insertions, 17 deletions
diff --git a/xlators/nfs/server/src/mount3.c b/xlators/nfs/server/src/mount3.c
index a05c08cc606..64f10948425 100644
--- a/xlators/nfs/server/src/mount3.c
+++ b/xlators/nfs/server/src/mount3.c
@@ -947,18 +947,26 @@ err:
char *
mnt3_get_volume_subdir (char *dirpath, char **volname)
{
- char *subdir = NULL;
- int volname_len = 0;
+ /* subdir points to the first / after the volume name while dirpath
+ * points to the first char of the volume name.
+ */
+ char *subdir = NULL;
+ int volname_len = 0;
+ static char *root = "/";
- if (!dirpath)
- return NULL;
+ /* all callers are expected to pass a valid *dirpath */
+ GF_ASSERT (dirpath);
if (dirpath[0] == '/')
dirpath++;
subdir = index (dirpath, (int)'/');
- if (!subdir)
- goto out;
+ if (!subdir) {
+ subdir = root;
+ volname_len = strlen (dirpath);
+ } else {
+ volname_len = subdir - dirpath;
+ }
if (!volname)
goto out;
@@ -966,10 +974,6 @@ mnt3_get_volume_subdir (char *dirpath, char **volname)
if (!*volname)
goto out;
- /* subdir points to the first / after the volume name while dirpath
- * points to the first char of the volume name.
- */
- volname_len = subdir - dirpath;
strncpy (*volname, dirpath, volname_len);
*(*volname + volname_len) = '\0';
out:
@@ -1588,8 +1592,6 @@ mnt3_resolve_export_subdir (rpcsvc_request_t *req, struct mount3_state *ms,
return ret;
volume_subdir = mnt3_get_volume_subdir (exp->expname, NULL);
- if (!volume_subdir)
- goto err;
ret = mnt3_resolve_subdir (req, ms, exp, volume_subdir, _gf_true);
if (ret < 0) {
@@ -1788,11 +1790,6 @@ mnt3_parse_dir_exports (rpcsvc_request_t *req, struct mount3_state *ms,
volname_ptr = volname;
subdir = mnt3_get_volume_subdir (path, &volname_ptr);
- if (!subdir) {
- gf_msg_trace (GF_MNT, 0, "Could not parse volname/subdir from "
- "%s", path);
- goto err;
- }
/* first try to match the full export/subdir */
exp = mnt3_mntpath_to_export (ms, path, _gf_false);