public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Too many level of symbolic links (still have problem with sbmfs network drives)
@ 2022-03-04 20:43 Philippe Debanne
  2022-03-05  2:23 ` Takashi Yano
  0 siblings, 1 reply; 10+ messages in thread
From: Philippe Debanne @ 2022-03-04 20:43 UTC (permalink / raw)
  To: cygwin

Hello Cygwin list,

Since updating my Cygwin installation to the latest version, I am having 
the problem of  "Too many levels of symbolic links" on certain network 
drives, that was reported in other threads.  I tried replacing the  
'cygwin1.dll' with the snapshots from 2022-02-17 and 2022-03-01 
(x86_64).  This did fix the link to one of the network drives, but not 
others.

The mount command in my case gives :

$ mount
D:/cygwin64/bin on /usr/bin type ntfs (binary,auto)
D:/cygwin64/lib on /usr/lib type ntfs (binary,auto)
D:/cygwin64 on / type ntfs (binary,auto)
C: on /cygdrive/c type ntfs (binary,posix=0,user,noumount,auto)
D: on /cygdrive/d type ntfs (binary,posix=0,user,noumount,auto)
L: on /cygdrive/l type cifs (binary,posix=0,user,noumount,auto)
V: on /cygdrive/v type smbfs (binary,posix=0,user,noumount,auto)
W: on /cygdrive/w type smbfs (binary,posix=0,user,noumount,auto)
X: on /cygdrive/x type smbfs (binary,posix=0,user,noumount,auto)
Y: on /cygdrive/y type smbfs (binary,posix=0,user,noumount,auto)
Z: on /cygdrive/z type smbfs (binary,posix=0,user,noumount,auto)

No problem with the local drives, and I can now go to the X: drive 
thanks to the recent snapshot.  But not other 'smbfs' ones :

$ cd Z:
-bash: cd: Z:: Too many levels of symbolic links

Any ideas what could be wrong ?  It seems to be limited to certain SAMBA 
shared drives.

- Philippe



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Too many level of symbolic links (still have problem with sbmfs network drives)
  2022-03-04 20:43 Too many level of symbolic links (still have problem with sbmfs network drives) Philippe Debanne
@ 2022-03-05  2:23 ` Takashi Yano
  2022-03-07 15:14   ` Takashi Yano
  0 siblings, 1 reply; 10+ messages in thread
From: Takashi Yano @ 2022-03-05  2:23 UTC (permalink / raw)
  To: cygwin; +Cc: Philippe Debanne

On Fri, 4 Mar 2022 15:43:55 -0500
Philippe Debanne wrote:
> Hello Cygwin list,
> 
> Since updating my Cygwin installation to the latest version, I am having 
> the problem of  "Too many levels of symbolic links" on certain network 
> drives, that was reported in other threads.  I tried replacing the  
> 'cygwin1.dll' with the snapshots from 2022-02-17 and 2022-03-01 
> (x86_64).  This did fix the link to one of the network drives, but not 
> others.
> 
> The mount command in my case gives :
> 
> $ mount
> D:/cygwin64/bin on /usr/bin type ntfs (binary,auto)
> D:/cygwin64/lib on /usr/lib type ntfs (binary,auto)
> D:/cygwin64 on / type ntfs (binary,auto)
> C: on /cygdrive/c type ntfs (binary,posix=0,user,noumount,auto)
> D: on /cygdrive/d type ntfs (binary,posix=0,user,noumount,auto)
> L: on /cygdrive/l type cifs (binary,posix=0,user,noumount,auto)
> V: on /cygdrive/v type smbfs (binary,posix=0,user,noumount,auto)
> W: on /cygdrive/w type smbfs (binary,posix=0,user,noumount,auto)
> X: on /cygdrive/x type smbfs (binary,posix=0,user,noumount,auto)
> Y: on /cygdrive/y type smbfs (binary,posix=0,user,noumount,auto)
> Z: on /cygdrive/z type smbfs (binary,posix=0,user,noumount,auto)
> 
> No problem with the local drives, and I can now go to the X: drive 
> thanks to the recent snapshot.  But not other 'smbfs' ones :
> 
> $ cd Z:
> -bash: cd: Z:: Too many levels of symbolic links
> 
> Any ideas what could be wrong ?  It seems to be limited to certain SAMBA 
> shared drives.

Hmm, could you please provide the version of samba
and hopefully smb.conf file if possible?

-- 
Takashi Yano <takashi.yano@nifty.ne.jp>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Too many level of symbolic links (still have problem with sbmfs network drives)
  2022-03-05  2:23 ` Takashi Yano
@ 2022-03-07 15:14   ` Takashi Yano
  2022-03-07 15:32     ` Philippe Debanne
  0 siblings, 1 reply; 10+ messages in thread
From: Takashi Yano @ 2022-03-07 15:14 UTC (permalink / raw)
  To: cygwin; +Cc: Philippe Debanne

On Sat, 5 Mar 2022 11:23:26 +0900
Takashi Yano wrote:
> On Fri, 4 Mar 2022 15:43:55 -0500
> Philippe Debanne wrote:
> > Hello Cygwin list,
> > 
> > Since updating my Cygwin installation to the latest version, I am having 
> > the problem of  "Too many levels of symbolic links" on certain network 
> > drives, that was reported in other threads.  I tried replacing the  
> > 'cygwin1.dll' with the snapshots from 2022-02-17 and 2022-03-01 
> > (x86_64).  This did fix the link to one of the network drives, but not 
> > others.
> > 
> > The mount command in my case gives :
> > 
> > $ mount
> > D:/cygwin64/bin on /usr/bin type ntfs (binary,auto)
> > D:/cygwin64/lib on /usr/lib type ntfs (binary,auto)
> > D:/cygwin64 on / type ntfs (binary,auto)
> > C: on /cygdrive/c type ntfs (binary,posix=0,user,noumount,auto)
> > D: on /cygdrive/d type ntfs (binary,posix=0,user,noumount,auto)
> > L: on /cygdrive/l type cifs (binary,posix=0,user,noumount,auto)
> > V: on /cygdrive/v type smbfs (binary,posix=0,user,noumount,auto)
> > W: on /cygdrive/w type smbfs (binary,posix=0,user,noumount,auto)
> > X: on /cygdrive/x type smbfs (binary,posix=0,user,noumount,auto)
> > Y: on /cygdrive/y type smbfs (binary,posix=0,user,noumount,auto)
> > Z: on /cygdrive/z type smbfs (binary,posix=0,user,noumount,auto)
> > 
> > No problem with the local drives, and I can now go to the X: drive 
> > thanks to the recent snapshot.  But not other 'smbfs' ones :
> > 
> > $ cd Z:
> > -bash: cd: Z:: Too many levels of symbolic links
> > 
> > Any ideas what could be wrong ?  It seems to be limited to certain SAMBA 
> > shared drives.
> 
> Hmm, could you please provide the version of samba
> and hopefully smb.conf file if possible?

I cannot reproduce your problem, so more information
is required.

-- 
Takashi Yano <takashi.yano@nifty.ne.jp>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Too many level of symbolic links (still have problem with sbmfs network drives)
  2022-03-07 15:14   ` Takashi Yano
@ 2022-03-07 15:32     ` Philippe Debanne
  2022-03-08 23:52       ` Takashi Yano
  0 siblings, 1 reply; 10+ messages in thread
From: Philippe Debanne @ 2022-03-07 15:32 UTC (permalink / raw)
  To: Takashi Yano, cygwin

[-- Attachment #1: Type: text/plain, Size: 2140 bytes --]

Hello Takashi,

sorry for the delay.  I don't manage the server in question, so I can't 
call 'smbstatus' directly on it, but if it's any indication of version 
there is a path :

/usr/share/doc/samba-4.10.16/

Also, attached is the /etc/smb.conf file, somewhat redacted.

Thanks for looking at this.
Philippe

Le 2022-03-07 à 10:14, Takashi Yano a écrit :
> On Sat, 5 Mar 2022 11:23:26 +0900
> Takashi Yano wrote:
>> On Fri, 4 Mar 2022 15:43:55 -0500
>> Philippe Debanne wrote:
>>> Hello Cygwin list,
>>>
>>> Since updating my Cygwin installation to the latest version, I am having
>>> the problem of  "Too many levels of symbolic links" on certain network
>>> drives, that was reported in other threads.  I tried replacing the
>>> 'cygwin1.dll' with the snapshots from 2022-02-17 and 2022-03-01
>>> (x86_64).  This did fix the link to one of the network drives, but not
>>> others.
>>>
>>> The mount command in my case gives :
>>>
>>> $ mount
>>> D:/cygwin64/bin on /usr/bin type ntfs (binary,auto)
>>> D:/cygwin64/lib on /usr/lib type ntfs (binary,auto)
>>> D:/cygwin64 on / type ntfs (binary,auto)
>>> C: on /cygdrive/c type ntfs (binary,posix=0,user,noumount,auto)
>>> D: on /cygdrive/d type ntfs (binary,posix=0,user,noumount,auto)
>>> L: on /cygdrive/l type cifs (binary,posix=0,user,noumount,auto)
>>> V: on /cygdrive/v type smbfs (binary,posix=0,user,noumount,auto)
>>> W: on /cygdrive/w type smbfs (binary,posix=0,user,noumount,auto)
>>> X: on /cygdrive/x type smbfs (binary,posix=0,user,noumount,auto)
>>> Y: on /cygdrive/y type smbfs (binary,posix=0,user,noumount,auto)
>>> Z: on /cygdrive/z type smbfs (binary,posix=0,user,noumount,auto)
>>>
>>> No problem with the local drives, and I can now go to the X: drive
>>> thanks to the recent snapshot.  But not other 'smbfs' ones :
>>>
>>> $ cd Z:
>>> -bash: cd: Z:: Too many levels of symbolic links
>>>
>>> Any ideas what could be wrong ?  It seems to be limited to certain SAMBA
>>> shared drives.
>> Hmm, could you please provide the version of samba
>> and hopefully smb.conf file if possible?
> I cannot reproduce your problem, so more information
> is required.
>
>

[-- Attachment #2: smb.conf --]
[-- Type: text/plain, Size: 1459 bytes --]

[global]
   workgroup = DEPT
   realm = DEPT.INSTITUTION.CA
   netbios name = groupefs
   security = ADS
   idmap config *:backend = tdb
   idmap config *:range = 200-999
   idmap config DEPT:backend = ad
   idmap config DEPT:schema_mode = rfc2307
   idmap config DEPT:range = 1000-999999
   idmap config DEPT : read only = yes
   winbind nss info = rfc2307
   client signing = yes
   client use spnego = yes
   kerberos method = secrets and keytab
   log file = /var/log/samba/%m.log
   log level = 1 auth:5 winbind:5
   host msdfs = Yes
   hosts allow = 127.0.0.1 (...)
   hosts deny = 0.0.0.0/0
   smb ports = 445 139
   acl allow execute always = True

[homes]
        comment = homes
        read only = No
        directory mask = 0700
        force directory mode = 0700
        create mask = 0600
        force create mode = 0600
        browseable = No
        valid users = %S
        follow symlinks = yes

[recherche$]
       comment = Section Groupe Recherche
       path = /store2/share/recherche
       valid users = @recherche
       #force user = root
       force group = recherche
       read only = No
       create mask = 0660
       directory mask = 0770

[recherche2$]
       comment = Section Groupe Recherche2
       path = /store2/share/recherche2
       valid users = @recherche,user1,user2,user3
       #force user = root
       force group = recherche
       read only = No
       create mask = 0660
       directory mask = 0770


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Too many level of symbolic links (still have problem with sbmfs network drives)
  2022-03-07 15:32     ` Philippe Debanne
@ 2022-03-08 23:52       ` Takashi Yano
  2022-03-09  0:16         ` Philippe Debanne
  0 siblings, 1 reply; 10+ messages in thread
From: Takashi Yano @ 2022-03-08 23:52 UTC (permalink / raw)
  To: cygwin; +Cc: Philippe Debanne

On Mon, 7 Mar 2022 10:32:51 -0500
Philippe Debanne wrote:
> sorry for the delay.  I don't manage the server in question, so I can't 
> call 'smbstatus' directly on it, but if it's any indication of version 
> there is a path :
> 
> /usr/share/doc/samba-4.10.16/
> 
> Also, attached is the /etc/smb.conf file, somewhat redacted.

I installed CentOS 7 with samba 4.10.16, and add following
section to /etc/samba/smb.conf which is similar section to
one in smb.conf you had provided.

[share$]
	comment = Test share
	path = /home/share
	valud users = @yano
	force group = yano
	read only = No
	create mask 0660
	directory mask = 0770

However, the issue could not be reproduced.

If I provide you with a test cygwin1.dll that outputs debug
messages, can you try it out?

-- 
Takashi Yano <takashi.yano@nifty.ne.jp>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Too many level of symbolic links (still have problem with sbmfs network drives)
  2022-03-08 23:52       ` Takashi Yano
@ 2022-03-09  0:16         ` Philippe Debanne
  2022-03-09  0:58           ` Takashi Yano
  0 siblings, 1 reply; 10+ messages in thread
From: Philippe Debanne @ 2022-03-09  0:16 UTC (permalink / raw)
  To: Takashi Yano, cygwin

Yes OK, you can send me the DLL, I will test it in the next couple of days.

Le 2022-03-08 à 18:52, Takashi Yano a écrit :
> On Mon, 7 Mar 2022 10:32:51 -0500
> Philippe Debanne wrote:
>> sorry for the delay.  I don't manage the server in question, so I can't
>> call 'smbstatus' directly on it, but if it's any indication of version
>> there is a path :
>>
>> /usr/share/doc/samba-4.10.16/
>>
>> Also, attached is the /etc/smb.conf file, somewhat redacted.
> I installed CentOS 7 with samba 4.10.16, and add following
> section to /etc/samba/smb.conf which is similar section to
> one in smb.conf you had provided.
>
> [share$]
> 	comment = Test share
> 	path = /home/share
> 	valud users = @yano
> 	force group = yano
> 	read only = No
> 	create mask 0660
> 	directory mask = 0770
>
> However, the issue could not be reproduced.
>
> If I provide you with a test cygwin1.dll that outputs debug
> messages, can you try it out?
>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Too many level of symbolic links (still have problem with sbmfs network drives)
  2022-03-09  0:16         ` Philippe Debanne
@ 2022-03-09  0:58           ` Takashi Yano
  2022-03-11  9:09             ` Takashi Yano
  0 siblings, 1 reply; 10+ messages in thread
From: Takashi Yano @ 2022-03-09  0:58 UTC (permalink / raw)
  To: cygwin; +Cc: Philippe Debanne

On Tue, 8 Mar 2022 19:16:29 -0500
Philippe Debanne wrote:
> Yes OK, you can send me the DLL, I will test it in the next couple of days.

Thanks for your cooperation. I have just sent you cygwin1.dll
for the test. Please test it and let me know the resulted
debug messages.

-- 
Takashi Yano <takashi.yano@nifty.ne.jp>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Too many level of symbolic links (still have problem with sbmfs network drives)
  2022-03-09  0:58           ` Takashi Yano
@ 2022-03-11  9:09             ` Takashi Yano
  2022-03-12  2:36               ` Takashi Yano
  0 siblings, 1 reply; 10+ messages in thread
From: Takashi Yano @ 2022-03-11  9:09 UTC (permalink / raw)
  To: cygwin; +Cc: Philippe Debanne

On Wed, 9 Mar 2022 09:58:40 +0900
Takashi Yano wrote:
> On Tue, 8 Mar 2022 19:16:29 -0500
> Philippe Debanne wrote:
> > Yes OK, you can send me the DLL, I will test it in the next couple of days.
> 
> Thanks for your cooperation. I have just sent you cygwin1.dll
> for the test. Please test it and let me know the resulted
> debug messages.

I received the debug messages and understood what is happening.
I added a workaround for this issue, so could you please test
the cygwin1.dll with the workaround patch, and let me know the
test result?

I will send you the patched cygwin1.dll shortly.

-- 
Takashi Yano <takashi.yano@nifty.ne.jp>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Too many level of symbolic links (still have problem with sbmfs network drives)
  2022-03-11  9:09             ` Takashi Yano
@ 2022-03-12  2:36               ` Takashi Yano
  2022-03-14  9:49                 ` Corinna Vinschen
  0 siblings, 1 reply; 10+ messages in thread
From: Takashi Yano @ 2022-03-12  2:36 UTC (permalink / raw)
  To: cygwin

[-- Attachment #1: Type: text/plain, Size: 1108 bytes --]

On Fri, 11 Mar 2022 18:09:30 +0900
Takashi Yano wrote:
> On Wed, 9 Mar 2022 09:58:40 +0900
> Takashi Yano wrote:
> > On Tue, 8 Mar 2022 19:16:29 -0500
> > Philippe Debanne wrote:
> > > Yes OK, you can send me the DLL, I will test it in the next couple of days.
> > 
> > Thanks for your cooperation. I have just sent you cygwin1.dll
> > for the test. Please test it and let me know the resulted
> > debug messages.
> 
> I received the debug messages and understood what is happening.
> I added a workaround for this issue, so could you please test
> the cygwin1.dll with the workaround patch, and let me know the
> test result?
> 
> I will send you the patched cygwin1.dll shortly.

The problem was that GetDosDeviceW() returns unexpected string such as
"\Device\Mup\DfsClient\;Z:000000000003fb89\dfsserver\dfs\linkname"
for the mounted UNC path:
"\??\UNC\fileserver\share"
.

This happens when UNC path for DFS is mounted to a drive with drive letter.

Therefore, I would like to propose a workaround patch attached.
I will appreciate any comments for the patch.

-- 
Takashi Yano <takashi.yano@nifty.ne.jp>

[-- Attachment #2: 0001-Cygwin-path-Add-fallback-for-DFS-mounted-drive.patch --]
[-- Type: application/octet-stream, Size: 2546 bytes --]

From 769a4af50181cb7569130ea407e4f6980d00ff14 Mon Sep 17 00:00:00 2001
From: Takashi Yano <takashi.yano@nifty.ne.jp>
Date: Fri, 11 Mar 2022 17:26:30 +0900
Subject: [PATCH] Cygwin: path: Add fallback for DFS mounted drive.

- If UNC path for DFS is mounted to a drive with drive letter, the
  error "Too many levels of symbolic links" occurs when accessing
  to that drive. This is because GetDosDeviceW() returns unexpected
  string such as "\Device\Mup\DfsClient\;Z:000000000003fb89\dfsserver
  \dfs\linkname" for the mounted UNC path "\??\UNC\fileserver\share".
  This patch adds a workaround for this issue.

  Addresses: https://cygwin.com/pipermail/cygwin/2022-March/250979.html
---
 winsup/cygwin/path.cc | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc
index 4ad4e0821..00c6aa1aa 100644
--- a/winsup/cygwin/path.cc
+++ b/winsup/cygwin/path.cc
@@ -3526,8 +3526,8 @@ restart:
 
 		      int remlen = QueryDosDeviceW (drive, remote, MAX_PATH);
 		      if (remlen < 3)
-			goto file_not_symlink; /* fallback */
-		      remlen -= 2;
+			goto file_not_symlink; /* fallback (not expected) */
+		      remlen -= 2; /* Two L'\0' */
 
 		      if (remote[remlen - 1] == L'\\')
 			remlen--;
@@ -3535,20 +3535,26 @@ restart:
 		      UNICODE_STRING rpath;
 		      RtlInitCountedUnicodeString (&rpath, remote,
 						   remlen * sizeof (WCHAR));
+		      int uncp_len = wcslen (ro_u_uncp.Buffer) - 1;
 		      if (RtlEqualUnicodePathPrefix (&rpath, &ro_u_uncp, TRUE))
-			remlen -= 6;
+			{
+			  remlen -= uncp_len;
+			  p = remote + uncp_len;
+			}
 		      else if ((p = wcschr (remote, L';'))
 			       && p + 3 < remote + remlen
 			       && wcsncmp (p + 1, drive, 2) == 0
 			       && (p = wcschr (p + 3, L'\\')))
-			remlen -= p - remote - 1;
+			remlen -= p - remote;
 		      else
-			goto file_not_symlink; /* fallback */
+			goto file_not_symlink; /* fallback (not expected) */
+		      if (wcsncasecmp (fpath.Buffer + uncp_len, p, remlen))
+			goto file_not_symlink; /* fallback (not expected) */
 		      /* Hackfest */
 		      fpath.Buffer[4] = drive[0]; /* Drive letter */
 		      fpath.Buffer[5] = L':';
-		      WCHAR *to = fpath.Buffer + 6;
-		      WCHAR *from = to + remlen;
+		      WCHAR *to = fpath.Buffer + 6; /* Next to L':' */
+		      WCHAR *from = fpath.Buffer + uncp_len + remlen;
 		      memmove (to, from,
 			       (wcslen (from) + 1) * sizeof (WCHAR));
 		      fpath.Length -= (from - to) * sizeof (WCHAR);
-- 
2.35.1


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Too many level of symbolic links (still have problem with sbmfs network drives)
  2022-03-12  2:36               ` Takashi Yano
@ 2022-03-14  9:49                 ` Corinna Vinschen
  0 siblings, 0 replies; 10+ messages in thread
From: Corinna Vinschen @ 2022-03-14  9:49 UTC (permalink / raw)
  To: cygwin

Hi Takashi,

On Mar 12 11:36, Takashi Yano wrote:
> The problem was that GetDosDeviceW() returns unexpected string such as
> "\Device\Mup\DfsClient\;Z:000000000003fb89\dfsserver\dfs\linkname"
> for the mounted UNC path:
> "\??\UNC\fileserver\share"
> 
> This happens when UNC path for DFS is mounted to a drive with drive letter.
> 
> Therefore, I would like to propose a workaround patch attached.
> I will appreciate any comments for the patch.

> -			goto file_not_symlink; /* fallback */
> -		      remlen -= 2;
> +			goto file_not_symlink; /* fallback (not expected) */

Why do you add this "not expected:?  It doesn't add any info, afaics,
and just makes the patch bigger.

> +		      remlen -= 2; /* Two L'\0' */
>  
>  		      if (remote[remlen - 1] == L'\\')
>  			remlen--;
> @@ -3535,20 +3535,26 @@ restart:
>  		      UNICODE_STRING rpath;
>  		      RtlInitCountedUnicodeString (&rpath, remote,
>  						   remlen * sizeof (WCHAR));
> +		      int uncp_len = wcslen (ro_u_uncp.Buffer) - 1;

You don't have to call wcslen, you already have the length in the
UNICODE_STRING.  I'd also constify this:

		      const USHORT uncp_len = ro_u_uncp.Length / sizeof (WCHAR)
					      - 1;

Other than that, looks good to me.


Thanks,
Corinna

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2022-03-14  9:54 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-04 20:43 Too many level of symbolic links (still have problem with sbmfs network drives) Philippe Debanne
2022-03-05  2:23 ` Takashi Yano
2022-03-07 15:14   ` Takashi Yano
2022-03-07 15:32     ` Philippe Debanne
2022-03-08 23:52       ` Takashi Yano
2022-03-09  0:16         ` Philippe Debanne
2022-03-09  0:58           ` Takashi Yano
2022-03-11  9:09             ` Takashi Yano
2022-03-12  2:36               ` Takashi Yano
2022-03-14  9:49                 ` Corinna Vinschen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).