From: Jeremy Allison Date: Mon, 19 Jul 2021 22:10:41 +0000 (-0700) Subject: s3: VFS: streams_depot: Allow "streams directory" outside of share path to work again. X-Git-Tag: ldb-2.5.0~891 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=649f544ab2cf564cdecf545c549ca9703cb5cda4;p=thirdparty%2Fsamba.git s3: VFS: streams_depot: Allow "streams directory" outside of share path to work again. As we're dealing with absolute paths here, we just need to temporarily replace the connectpath whilst enumerating streams. Remove knownfail file. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14760 Signed-off-by: Jeremy Allison Reviewed-by: Noel Power Autobuild-User(master): Jeremy Allison Autobuild-Date(master): Thu Aug 19 17:04:44 UTC 2021 on sn-devel-184 --- diff --git a/selftest/knownfail.d/simpleserver_streams b/selftest/knownfail.d/simpleserver_streams deleted file mode 100644 index 2b7412999de..00000000000 --- a/selftest/knownfail.d/simpleserver_streams +++ /dev/null @@ -1,6 +0,0 @@ -^samba3.smb2.streams.names\(simpleserver\) -^samba3.smb2.streams.io\(simpleserver\) -^samba3.smb2.streams.names3\(simpleserver\) -^samba3.smb2.streams.delete\(simpleserver\) -^samba3.smb2.streams.zero-byte\(simpleserver\) -^samba3.smb2.streams.sharemodes\(simpleserver\) diff --git a/source3/modules/vfs_streams_depot.c b/source3/modules/vfs_streams_depot.c index d3b511d3132..973edeeda24 100644 --- a/source3/modules/vfs_streams_depot.c +++ b/source3/modules/vfs_streams_depot.c @@ -544,6 +544,8 @@ static NTSTATUS walk_streams(vfs_handle_struct *handle, void *private_data) { char *dirname; + char *rootdir = NULL; + char *orig_connectpath = NULL; struct smb_filename *dir_smb_fname = NULL; struct smb_Dir *dir_hnd = NULL; const char *dname = NULL; @@ -576,8 +578,26 @@ static NTSTATUS walk_streams(vfs_handle_struct *handle, return NT_STATUS_NO_MEMORY; } + /* + * For OpenDir to succeed if the stream rootdir is outside + * the share path, we must temporarily swap out the connect + * path for this share. We're dealing with absolute paths + * here so we don't care about chdir calls. + */ + rootdir = stream_rootdir(handle, talloc_tos()); + if (rootdir == NULL) { + TALLOC_FREE(dir_smb_fname); + TALLOC_FREE(dirname); + return NT_STATUS_NO_MEMORY; + } + + orig_connectpath = handle->conn->connectpath; + handle->conn->connectpath = rootdir; + dir_hnd = OpenDir(talloc_tos(), handle->conn, dir_smb_fname, NULL, 0); if (dir_hnd == NULL) { + handle->conn->connectpath = orig_connectpath; + TALLOC_FREE(rootdir); TALLOC_FREE(dir_smb_fname); TALLOC_FREE(dirname); return map_nt_error_from_unix(errno); @@ -600,6 +620,9 @@ static NTSTATUS walk_streams(vfs_handle_struct *handle, TALLOC_FREE(talloced); } + /* Restore the original connectpath. */ + handle->conn->connectpath = orig_connectpath; + TALLOC_FREE(rootdir); TALLOC_FREE(dir_smb_fname); TALLOC_FREE(dir_hnd);