diff options
author | Niels de Vos <ndevos@redhat.com> | 2017-07-25 09:25:53 +0200 |
---|---|---|
committer | jiffin tony Thottan <jthottan@redhat.com> | 2017-08-01 05:11:48 +0000 |
commit | 45c973576d6356dbe4da897e9f0528eac7529d48 (patch) | |
tree | 1fd1cfcbc997164a064b04b19a7cdc94c5153cad | |
parent | 18cb1a87bb7c88657b499b22894b81f1f694b6ad (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.
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>
-rw-r--r-- | xlators/nfs/server/src/mount3.c | 31 |
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); |