msdfs on 3.0.25b - incorrect PATH_NOT_FOUND on deep links
Jan Martin
Jan.Martin at rwedea.com
Mon Aug 6 14:12:16 GMT 2007
Note: This is the second one of three similar msdfs problems. To avoid
confusion, we call this one the "deep link problem"
Hi all,
Samba 3.0.25b incorrectly answers PATH_NOT_FOUND when being asked about
something in a sub-subdirectory of a DFS link.
This is because dfs_path_lookop() in smbd/msdfs.c issues a call to
unix_convert() (line 390) which does many things, including a sanity
check of the whole path (except the last component). For example, it
returns an error if the local(!) path doesn't exist at all. This result
is correct and valueable - if there is no msdfs redirection in between.
Otherwise, the result is wrong - dfs_path_lookup() gives up too early.
It should return PATH_NOT_COVERED instead of PATH_NOT_FOUND.
To fix that problem, we postponed the return of the error message to the
end of dfs_path_lookup(), after all DFS stuff is done.
This is our patch:
-------------------------------------------------
diff -rU5 samba-3.0.25b-orig/source/smbd/msdfs.c
samba-3.0.25b-deeplink-fix/source/smbd/msdfs.c
--- samba-3.0.25b-orig/source/smbd/msdfs.c 2007-05-11
00:09:34.000000000 +0200
+++ samba-3.0.25b-deeplink-fix/source/smbd/msdfs.c 2007-08-06
15:37:29.000000000 +0200
@@ -386,13 +386,17 @@
* think this is needed. JRA.
*/
pstrcpy(localpath, pdp->reqpath);
status = unix_convert(conn, localpath, search_flag, NULL,
&sbuf);
- if (!NT_STATUS_IS_OK(status)) {
- return status;
- }
+ /* the unix conversion is done (and needed) even if the file
+ * doesn't exist locally
+ * 'status' is the best we know now about the path
+ * keep it for function return, but try our DFS stuff before
...
+ * ... if successful, we return the new NT_STATUS_* immediately
+ * and don't use our old status
+ */
/* Optimization - check if we can redirect the whole path. */
if (is_msdfs_link(conn, localpath, targetpath, NULL)) {
if (search_flag) {
@@ -458,11 +462,12 @@
/* And in the canonicalized dfs path. */
q = strrchr_m(canon_dfspath, '/');
}
}
- return NT_STATUS_OK;
+ /* We didn't find a DFS link, so consider it a local resource */
+ return status;
}
/*****************************************************************
Decides if a dfs pathname should be redirected or not.
If not, the pathname is converted to a tcon-relative local unix path
-------------------------------------------------
With this patch, our installation does not show the problem any more.
Would you please check and add it (or a better one, of course) to the
Samba sources?
Thank you very much in advance
And again - this is the second one of three similar problems; please
don't get confused. This one is the deep link problem.
Jan Martin
More information about the samba-technical
mailing list