directory recursion problem
Shirish Kalele
kalele at veritas.com
Mon Apr 21 22:53:36 GMT 2003
Makes sense. I'll apply the fix to cvs right away.
Thanks a lot,
Shirish
On Mon, 21 Apr 2003, John P Janosik wrote:
>
>
>
>
>Shirish -
>
>I tested your patch today and found it is not keeping track of the path
>consumed, so deep referral requests still fail. Here is the patch I am
>using now that works:
>
>[root at rchsker msdfs]# diff -u msdfs.c.orig msdfs.c
>--- msdfs.c.orig Fri Feb 28 09:56:19 2003
>+++ msdfs.c Mon Apr 21 17:28:27 2003
>@@ -216,8 +216,9 @@
> {
> fstring localpath;
>
>- char *p;
>+ char *p, *q;
> fstring reqpath;
>+ pstring consumedbuf;
>
> if (!dp || !conn) {
> DEBUG(1,("resolve_dfs_path: NULL dfs_path* or NULL
>connection_struct*!\n"));
>@@ -250,14 +251,20 @@
> }
> }
>
>- /* also redirect if the parent directory is a dfs link */
>+ pstrcpy(consumedbuf, dfspath);
>+ trim_string(consumedbuf, NULL, "\\");
>+
>+ /* redirect if any component in the path is a link */
> fstrcpy(reqpath, dp->reqpath);
> p = strrchr(reqpath, '/');
>- if (p) {
>+ q = strrchr(consumedbuf, '\\');
>+ while (p) {
> *p = '\0';
>+ *q = '\0';
> fstrcpy(localpath, conn->connectpath);
> fstrcat(localpath, "/");
> fstrcat(localpath, reqpath);
>+ DEBUG(3, ("localpath is now %s\n", localpath));
> 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));
>
>@@ -267,19 +274,14 @@
> the path consumed
> */
> if (consumedcntp) {
>- char *q;
>- pstring buf;
>- pstrcpy(buf, dfspath);
>- trim_string(buf, NULL, "\\");
>- q = strrchr(buf, '\\');
>- if (q)
>- *q = '\0';
>- *consumedcntp = strlen(buf);
>+ *consumedcntp = strlen(consumedbuf);
> DEBUG(10, ("resolve_dfs_path: Path
>consumed: %d\n", *consumedcntp));
> }
>
> return True;
> }
>+ p = strrchr(reqpath, '/');
>+ q = strrchr(consumedbuf, '\\');
> }
>
> return False;
>@@ -606,8 +608,7 @@
> /* Trim pathname sent by client so it begins with only one
>backslash.
> Two backslashes confuse some dfs clients
> */
>- while (strlen(pathnamep) > 1 && pathnamep[0] == '\\'
>- && pathnamep[1] == '\\')
>+ while (pathnamep[0] == '\\' && pathnamep[1] == '\\')
> pathnamep++;
>
> pstrcpy(buf, pathnamep);
>
>
>Thanks,
>
>John Janosik
>
>
>
>
> Shirish Kalele
> <kalele at veritas.c To: John P Janosik/Rochester/IBM at IBMUS
> om> cc: Robin.SOPER at tfeeuk.co.uk, <samba-technical at lists.samba.org>
> Subject: Re: directory recursion problem
> 04/10/2003 02:44
> PM
>
>
>
>
>
>
>John,
>
>You're right. It seems the behaviour Robin is seeing is because the
>redirector directly makes deep referral requests when its cached referral
>expires. Since your patch fixes deep referrals, it should also fix Robin's
>problem.
>
>I'm going to apply this slightly optimized form of your patch to 2.2, 3.0
>and HEAD. This should fix both problems.
>
>Thanks,
>Shirish
>
>Index: msdfs/msdfs.c
>===================================================================
>RCS file: /data/cvs/samba/source/msdfs/msdfs.c,v
>retrieving revision 1.10.4.30
>diff -u -r1.10.4.30 msdfs.c
>--- msdfs/msdfs.c 24 Feb 2003 19:35:31 -0000 1.10.4.30
>+++ msdfs/msdfs.c 10 Apr 2003 19:34:10 -0000
>@@ -218,6 +218,7 @@
>
> char *p;
> fstring reqpath;
>+ pstring consumedbuf;
>
> if (!dp || !conn) {
> DEBUG(1,("resolve_dfs_path: NULL dfs_path* or NULL
>connection_struct*!\n"));
>@@ -250,10 +251,13 @@
> }
> }
>
>- /* also redirect if the parent directory is a dfs link */
>+ pstrcpy(consumedbuf, dfspath);
>+ trim_string(consumedbuf, NULL, "\\");
>+
>+ /* redirect if any component in the path is a link */
> fstrcpy(reqpath, dp->reqpath);
> p = strrchr(reqpath, '/');
>- if (p) {
>+ while (p) {
> *p = '\0';
> fstrcpy(localpath, conn->connectpath);
> fstrcat(localpath, "/");
>@@ -268,18 +272,16 @@
> */
> if (consumedcntp) {
> char *q;
>- pstring buf;
>- pstrcpy(buf, dfspath);
>- trim_string(buf, NULL,
>"\\");
>- q = strrchr(buf, '\\');
>+ q = strrchr(consumedbuf,
>'\\');
> if (q)
> *q = '\0';
>- *consumedcntp =
>strlen(buf);
>+ *consumedcntp =
>strlen(consumedbuf);
> DEBUG(10,
>("resolve_dfs_path: Path consumed: %d\n", *consumedcntp));
> }
>
> return True;
> }
>+ p = strrchr(reqpath, '/');
> }
>
> return False;
>@@ -606,8 +608,7 @@
> /* Trim pathname sent by client so it begins with only one
>backslash.
> Two backslashes confuse some dfs clients
> */
>- while (strlen(pathnamep) > 1 && pathnamep[0] == '\\'
>- && pathnamep[1] == '\\')
>+ while (pathnamep[0] == '\\' && pathnamep[1] == '\\')
> pathnamep++;
>
> pstrcpy(buf, pathnamep);
>
>
>
>On Thu, 10 Apr 2003, John P Janosik wrote:
>
>>
>>
>>
>>
>>Shirish -
>>
>>I agree that Robin's problem is different than the one I posted. We were
>>seeing both problems last summer but after I applied the patch the problem
>>Robin reported went away on our clients(both Win2k and XP). I never took
>>the time to look into the cause of the directory recursion problem because
>>it went away.
>>
>>Thanks,
>>
>>John Janosik
>>
>>
>>
>>
>> "Shirish Kalele"
>> <kalele at veritas.c To:
><Robin.SOPER at tfeeuk.co.uk>, John P Janosik/Rochester/IBM at IBMUS
>> om> cc:
><samba-technical at lists.samba.org>
>> Subject: Re: directory
>recursion problem
>> 04/10/2003 12:58
>> PM
>>
>>
>>
>>
>>
>>
>>John,
>>
>>Apologies for not getting back to you on this, but at the time, I thought
>>this was an expensive way to fix what seemed like a corner case and was
>>wondering how it could be fixed better. And it must have slipped through.
>>I'll make sure to fix it in cvs this time.
>>
>>I don't think Robin's problem is the same as yours. The last time I'd
>>investigated the directory recursion problem he reports, afaicr, I could
>>reproduce it with a Windows 2000 based DFS as well, and I concluded the
>>problem actually is with the client (probably the Explorer.exe program).
>>I'll try and confirm this.
>>
>>- Shirish
>>
>>----- Original Message -----
>>From: "John P Janosik" <jpjanosi at us.ibm.com>
>>To: <Robin.SOPER at tfeeuk.co.uk>
>>Cc: <samba-technical at lists.samba.org>
>>Sent: Thursday, April 10, 2003 9:47 AM
>>Subject: Re: directory recursion problem
>>
>>
>>>
>>>
>>>
>>>
>>> Robin -
>>>
>>> We were having the same problem along with a problem running binaries
>via
>>a
>>> UNC instead of a mapped drive if the binaries were more than two levels
>>> down a tree when the first level was a DFS referral. I made the
>>following
>>> patch to Samba to fix the second problem, but we never saw the directory
>>> recursion problem again after this. Shirish Kalele said he would take a
>>> look at applying the patch or something similar, but I never heard back
>>and
>>> never saw the patch get applied. Here is a link to my post about the
>>> problem:
>>> http://lists.samba.org/pipermail/samba-technical/2002-August/038903.html
>.
>>>
>>> [rchfs2:root samba-2.2.5]# diff -urN
>>> source/msdfs/msdfs.c.origsource/msdfs/msdfs.c
>>> --- source/msdfs/msdfs.c.orig Tue Jun 18 20:13:44 2002
>>> +++ source/msdfs/msdfs.c Wed Aug 21 10:20:20 2002
>>> @@ -215,7 +215,7 @@
>>> BOOL* self_referralp, int* consumedcntp)
>>> {
>>> fstring localpath;
>>> -
>>> + int levels;
>>> char *p;
>>> fstring reqpath;
>>> @@ -253,7 +253,7 @@
>>> /* also redirect if the parent directory is a dfs link */
>>> fstrcpy(reqpath, dp->reqpath);
>>> p = strrchr(reqpath, '/');
>>> - if (p) {
>>> + for(levels=1; p; levels++) {
>>> *p = '\0';
>>> fstrcpy(localpath, conn->connectpath);
>>> fstrcat(localpath, "/");
>>> @@ -267,19 +267,23 @@
>>> the path consumed
>>> */
>>> if (consumedcntp) {
>>> - char *q;
>>> - pstring buf;
>>> + char *q;
>>> + pstring buf;
>>> + int j;
>>> safe_strcpy(buf, dfspath, sizeof(buf));
>>> trim_string(buf, NULL, "\\");
>>> - q = strrchr(buf, '\\');
>>> - if (q)
>>> - *q = '\0';
>>> + for(j=0; j<levels; j++) {
>>> + q = strrchr(buf, '\\');
>>> + if (q)
>>> + *q = '\0';
>>> + }
>>> *consumedcntp = strlen(buf);
>>> DEBUG(10, ("resolve_dfs_path:
>>Pathconsumed:
>>> %d\n", *consumedcntp));
>>> }
>>> return True;
>>> - }
>>> + }
>>> + p = strrchr(reqpath, '/');
>>> }
>>> return False;
>>>
>>>
>>> Date: Thu, 10 Apr 2003 09:52:22 +0100
>>> From: Robin.SOPER at tfeeuk.co.uk
>>> To: samba-technical at samba.org
>>> Subject: directory recursion problem
>>> Message-ID:
><OF902C93F9.3D996294-ON80256D04.0030B9D0 at uk.ad.ep.corp.local>
>>> Content-Type: text/plain; charset="us-ascii"
>>> MIME-Version: 1.0
>>> Precedence: list
>>> Message: 29
>>>
>>> Hi,
>>>
>>> Hopefully you can help me with this one. I am using Samba 2.2.6 on two
>>> Solaris servers . The PC users all see all the shares as being on one
>>> system and it implements MSDFS to redirect any shares that are
>physically
>>> located on another system to the samba server on that system. We have
>>> been using this config successfully for a good while now, but recently
>>> it's been getting more and more use and we are experiencing an
>>> intermittent problem - sometimes when the users look in a directory
>>> (windows explorer) they see a directory within it with the same, when
>>they
>>> open that they see a directory within it with the same name etc etc.
>i.e.
>>> a kind of recursive directory thing. Meanwhile other users will be using
>>> the samba shares with no problem. Restarting the PC seems to fix the
>>> problem - which maybe seems to suggest it's client related? However I
>>am
>>> uncertain whether the problem lies with the WindowsNT4 clients (having a
>>> problem with DFS maybe) or with the samba server .
>>>
>>> Can you advise/help?
>>>
>>> Thanks in advance
>>>
>>>
>>> Robin Soper
>>> TotalFinaElf Exploration UK PLC
>>> Crawpeel Road, Altens,
>>> Aberdeen
>>> AB12 3FG
>>>
>>> Tel (01224) 297290
>>>
>>>
>>> John Janosik
>>>
>>
>>
>>
>
>
>
More information about the samba-technical
mailing list