]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
r6237: fix my breakage of WinXP sp2 msdfs support.
authorGerald Carter <jerry@samba.org>
Thu, 7 Apr 2005 19:43:19 +0000 (19:43 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 15:56:31 +0000 (10:56 -0500)
We did need the special case for RESOLVE_DFSPATH
in the findfirst() code.

Jeremy, please verify I haven't broken the allow_wcard
code you added to resolve_dfs_path()

source/include/msdfs.h
source/smbd/msdfs.c
source/smbd/trans2.c

index a856f5d1abc90c5b1ca05aa35d9b99c52088936e..80a0c3a4f1e7179c13beb3ea007126010fab2f2b 100644 (file)
@@ -68,14 +68,21 @@ struct dfs_path
 #define RESOLVE_DFSPATH(name, conn, inbuf, outbuf)             \
 { if ((SVAL(inbuf,smb_flg2) & FLAGS2_DFS_PATHNAMES) &&         \
       lp_host_msdfs() && lp_msdfs_root(SNUM(conn)) &&          \
-      dfs_redirect(name,conn,False))                           \
+      dfs_redirect(name, conn, False, False))                  \
              return ERROR_BOTH(NT_STATUS_PATH_NOT_COVERED,     \
                               ERRSRV, ERRbadpath);; }          
 
-#define RESOLVE_DFSPATH_WCARD(name, conn, inbuf, outbuf)               \
+#define RESOLVE_FINDFIRST_DFSPATH(name, conn, inbuf, outbuf)    \
 { if ((SVAL(inbuf,smb_flg2) & FLAGS2_DFS_PATHNAMES) &&         \
       lp_host_msdfs() && lp_msdfs_root(SNUM(conn)) &&          \
-      dfs_redirect(name,conn,True))                            \
+      dfs_redirect(name, conn, True, True))                    \
+             return ERROR_BOTH(NT_STATUS_PATH_NOT_COVERED,     \
+                              ERRSRV, ERRbadpath);; }          
+
+#define RESOLVE_DFSPATH_WCARD(name, conn, inbuf, outbuf)        \
+{ if ((SVAL(inbuf,smb_flg2) & FLAGS2_DFS_PATHNAMES) &&         \
+      lp_host_msdfs() && lp_msdfs_root(SNUM(conn)) &&          \
+      dfs_redirect(name,conn, False, True))                    \
              return ERROR_BOTH(NT_STATUS_PATH_NOT_COVERED,     \
                               ERRSRV, ERRbadpath);; }          
 
index 2e4649efed4fe7efd736e3698ff7dbb40deb1e6f..c5e9d8d21cdfaed7dcec894b96c8a05a05d39217 100644 (file)
@@ -269,7 +269,9 @@ BOOL is_msdfs_link(connection_struct* conn, char * path,
  Used by other functions to decide if a dfs path is remote,
 and to get the list of referred locations for that remote path.
  
-allow_wcards: Should we allow wildcards when parsing paths.
+findfirst_flag: For findfirsts, dfs links themselves are not
+redirected, but paths beyond the links are. For normal smb calls,
+even dfs links need to be redirected.
 
 self_referralp: clients expect a dfs referral for the same share when
 they request referrals for dfs roots on a server. 
@@ -281,7 +283,7 @@ should try the remaining path on the redirected server.
 
 static BOOL resolve_dfs_path(pstring dfspath, struct dfs_path* dp, 
                      connection_struct* conn,
-                     BOOL allow_wcards,
+                     BOOL findfirst_flag, BOOL allow_wcards,
                      struct referral** reflistpp, int* refcntp,
                      BOOL* self_referralp, int* consumedcntp)
 {
@@ -313,6 +315,12 @@ static BOOL resolve_dfs_path(pstring dfspath, struct dfs_path* dp,
 
        /* check if need to redirect */
        if (is_msdfs_link(conn, localpath, reflistpp, refcntp, NULL)) {
+               if (findfirst_flag) {
+                       DEBUG(6,("resolve_dfs_path (FindFirst) No redirection "
+                                "for dfs link %s.\n", dfspath));
+                       return False;
+               }
+               
                DEBUG(6,("resolve_dfs_path: %s resolves to a valid Dfs link.\n", dfspath));
                if (consumedcntp) 
                        *consumedcntp = strlen(dfspath);
@@ -326,6 +334,7 @@ static BOOL resolve_dfs_path(pstring dfspath, struct dfs_path* dp,
                *p = '\0';
                pstrcpy(localpath, reqpath);
                if (is_msdfs_link(conn, localpath, reflistpp, refcntp, NULL)) {
+               
                        DEBUG(4, ("resolve_dfs_path: Redirecting %s because parent %s is dfs link\n", dfspath, localpath));
 
                        /* To find the path consumed, we truncate the original
@@ -333,6 +342,7 @@ static BOOL resolve_dfs_path(pstring dfspath, struct dfs_path* dp,
                           component. The length of the resulting string is
                           the path consumed 
                        */
+                       
                        if (consumedcntp) {
                                char *q;
                                pstring buf;
@@ -361,7 +371,8 @@ static BOOL resolve_dfs_path(pstring dfspath, struct dfs_path* dp,
   If not, the pathname is converted to a tcon-relative local unix path
 *****************************************************************/
 
-BOOL dfs_redirect(pstring pathname, connection_struct* conn, BOOL allow_wcards)
+BOOL dfs_redirect( pstring pathname, connection_struct* conn, 
+                   BOOL findfirst_flag, BOOL allow_wcards )
 {
        struct dfs_path dp;
        
@@ -380,7 +391,7 @@ BOOL dfs_redirect(pstring pathname, connection_struct* conn, BOOL allow_wcards)
        if (!strequal(dp.servicename, lp_servicename(SNUM(conn)) )) 
                return False;
 
-       if (resolve_dfs_path(pathname, &dp, conn, allow_wcards,
+       if (resolve_dfs_path(pathname, &dp, conn, findfirst_flag, allow_wcards,
                             NULL, NULL, NULL, NULL)) {
                DEBUG(3,("dfs_redirect: Redirecting %s\n", pathname));
                return True;
@@ -518,7 +529,7 @@ BOOL get_referred_path(char *pathname, struct junction_map *jucn,
                return False;
 
        /* If not remote & not a self referral, return False */
-       if (!resolve_dfs_path(pathname, &dp, conn, False, 
+       if (!resolve_dfs_path(pathname, &dp, conn, False, False,
                              &jucn->referral_list, &jucn->referral_count,
                              self_referralp, consumedcntp)) {
                if (!*self_referralp) {
index 8d673c25bd3e02e6cf7d2db80e980296443b1d5b..9bc509ad549ca10391edc28832c0412fb3e746b0 100644 (file)
@@ -1626,7 +1626,7 @@ close_if_end = %d requires_resume_key = %d level = 0x%x, max_data_bytes = %d\n",
                return ERROR_NT(ntstatus);
        }
 
-       RESOLVE_DFSPATH_WCARD(directory, conn, inbuf, outbuf);
+       RESOLVE_FINDFIRST_DFSPATH(directory, conn, inbuf, outbuf);
 
        unix_convert(directory,conn,0,&bad_path,&sbuf);
        if (bad_path) {