hierynomus / smbj

Server Message Block (SMB2, SMB3) implementation in Java
Other
708 stars 179 forks source link

DFS link evaluation issue for links pointed at subfolders #744

Open necouchman opened 1 year ago

necouchman commented 1 year ago

Sorry, I'm having trouble coming up with a succinct title for this. We're using the SMBJ library in an application, and we are connecting to DFS links and shares. We're seeing an issue where the DFS link is not properly evaluated if it points to something other than a top-level share. It appears that this may be limited to situations where the Share itself is a DFS link pointing to a different location.

To elaborate, I have a Samba server, that has a share configured as so:

[share1]
    comment = My DFS file share
    msdfs root = yes
    msdfs proxy = \fileserver1.example.com\shares\share1

When accessing this share from Windows, the contents of the "\fileserver1.example.com\shares\share1\" folder are (correctly) shown. When accessing this DFS share from SMBJ, the evaluation of the DFS link appears to be one level up - at the "\fileserver1.example.com\shares" folder. To be fair, smbclient seems to behave the same way as SMBJ, so I'm unsure if the fact that Windows clients traverse the entire specified path is the "correct" way or not.

If, instead of using "msdfs proxy", I create a folder and then use a DFS link within that folder, it works as expected across all client platforms. So, if I have a share:

[shares]
    comment = My DFS Share root
    msdfs root = yes
    path = /shares

and, within that /shares folder, I have a symlink:

share1 -> msdfs:fileserver1.example.com\shares\share1

the link is properly evaluated to the correct location. The failure to traverse to the intended directory seems to only occur with a DFS proxy share, and only when that share is pointed at a level deeper than the root share on the destination.

necouchman commented 1 year ago

Just one other comment on how various clients behave: