For deep referrals, track consumed path using a counter, and calculate the
authorShirish Kalele <kalele@samba.org>
Wed, 23 Apr 2003 19:06:21 +0000 (19:06 +0000)
committerShirish Kalele <kalele@samba.org>
Wed, 23 Apr 2003 19:06:21 +0000 (19:06 +0000)
consumed count only if and when it is needed. Check into SAMBA_3_0.
(This used to be commit d6a326ba46b0e45a2d97b7aa9762bfefca347d89)

source3/msdfs/msdfs.c

index fa6617cb52c78f06398f07cfe245aa126e2034b7..69a315d4e40bf4236792a4c6ed95eb58c5fdf208 100644 (file)
@@ -212,10 +212,9 @@ static BOOL resolve_dfs_path(char* dfspath, struct dfs_path* dp,
                      BOOL* self_referralp, int* consumedcntp)
 {
        fstring localpath;
-
+       int consumed_level = 1;
        char *p;
        fstring reqpath;
-       pstring consumedbuf;
 
        if (!dp || !conn) {
                DEBUG(1,("resolve_dfs_path: NULL dfs_path* or NULL connection_struct*!\n"));
@@ -248,9 +247,6 @@ static BOOL resolve_dfs_path(char* dfspath, struct dfs_path* dp,
                }
        } 
 
-       pstrcpy(consumedbuf, dfspath);
-       trim_string(consumedbuf, NULL, "\\");
-
        /* redirect if any component in the path is a link */
        fstrcpy(reqpath, dp->reqpath);
        p = strrchr(reqpath, '/');
@@ -269,16 +265,21 @@ static BOOL resolve_dfs_path(char* dfspath, struct dfs_path* dp,
                        */
                        if (consumedcntp) {
                                char *q;
-                               q = strrchr(consumedbuf, '\\');
-                               if (q) 
-                                       *q = '\0';
-                               *consumedcntp = strlen(consumedbuf);
-                               DEBUG(10, ("resolve_dfs_path: Path consumed: %d\n", *consumedcntp));
+                               pstring buf;
+                               pstrcpy(buf, dfspath);
+                               trim_string(buf, NULL, "\\");
+                               for (; consumed_level; consumed_level--) {
+                                       q = strrchr(buf, '\\');
+                                       if (q) *q = 0;
+                               }
+                               *consumedcntp = strlen(buf);
+                               DEBUG(10, ("resolve_dfs_path: Path consumed: %s (%d)\n", buf, *consumedcntp));
                        }
                        
                        return True;
                }
                p = strrchr(reqpath, '/');
+               consumed_level++;
        }
        
        return False;