diff mbox

libnsdb: NFS URI is incorrect when storing FSLs in NSDBs

Message ID 20140609213155.3379.56192.stgit@seurat.1015granger.net
State Accepted
Headers show

Commit Message

Chuck Lever June 9, 2014, 9:51 p.m. UTC
Ditang Chen <chendt.fnst@cn.fujitsu.com> says:
> I tested in Fedora20, when junction type is nfs-fedfs, the nfsref
> cannot resolve FSN if the export path is "/".
>
> # nfsref -d --type=nfs-fedfs add /.domainroot/example.net/s2 server2.example.net /
> ...
> nfsref: nsdb_normalize_path: result = '/'
> nfsref: nsdb_count_components: length = 4, count = 0, path = '/'
> nfsref: nsdb_alloc_zero_component_pathname: Zero-component pathname
> nfsref: nsdb_construct_nfsuri: NFS URI: nfs://Server2.example.net/
> ...
>
> # nfsref -d lookup s2/
> ..
> nfsref: nsdb_parse_nfs_uri: parsing 'nfs://server2.example.net/'
> nfsref: nsdb_uri_pathname_to_path_array: NFS URI has short pathname component
> nfsref: nsdb_resolve_fsn_parse_entry: parsing failed: FEDFS_ERR_BADNAME
> nfsref: nfsref_lookup_resolve_fsn: Failed to resolve FSN 5f4bace9-14b3-4626-8d39-4b0
> ...

For a server pathname of "/", nsdb_construct_nfsuri() was
constructing an NFS URI with just a single terminating /, which is
incorrect according to section 2.8.1.2 of:

 http://datatracker.ietf.org/doc/draft-ietf-nfsv4-federated-fs-protocol/

Then "nfsref" is storing the incorrect URI in the NSDB.

Fixes: 750fdf4bba4f5d4880ce7ad5b56451bd771cc3e2
Reported-by: Ditang Chen <chendt.fnst@cn.fujitsu.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---
Hi Ditang-

This approach is more verbose, but doesn't hard-code the URI path
segment separator character.

 src/libnsdb/path.c |    9 +++++++++
 1 file changed, 9 insertions(+)
diff mbox

Patch

diff --git a/src/libnsdb/path.c b/src/libnsdb/path.c
index c58dc8979848..298a029ba561 100644
--- a/src/libnsdb/path.c
+++ b/src/libnsdb/path.c
@@ -635,6 +635,15 @@  nsdb_path_array_to_uri_pathname(char * const *path_array, UriUriA *uri)
 		return FEDFS_ERR_SVRFAULT;
 	result = pos;
 
+	/* Zero-component pathname? */
+	if (path_array[0] == NULL) {
+		pos->next = nsdb_new_uri_path_segment("");
+		if (pos->next == NULL) {
+			status = FEDFS_ERR_SVRFAULT;
+			goto out_err;
+		}
+	}
+
 	length = 0;
 	for (i = 0; path_array[i] != NULL; i++) {
 		component = path_array[i];