https://bugs.winehq.org/show_bug.cgi?id=37834
Bug ID: 37834 Summary: RtlSetCurrentDirectory_U prepends "UNC" for network paths; the resulting path is invalid Product: Wine Version: 1.7.33 Hardware: x86-64 OS: Linux Status: UNCONFIRMED Severity: minor Priority: P2 Component: ntdll Assignee: wine-bugs@winehq.org Reporter: atakama0512@yahoo.com Distribution: ---
Created attachment 50382 --> https://bugs.winehq.org/attachment.cgi?id=50382 cmd.exe output showing how UNC\ gets prepended when running cd \server\share
Calling RtlSetCurrentDirectory_U with a network share argument like "\server\share" sets the current directory to "UNC\server\share". Subsequent calls to GetCurrentDirectory will return the modified path. The resulting path is invalid and unusable: attempting to read the directory or writing a file to it results in ERROR_PATH_NOT_FOUND. The bug can be reproduced using the internal command prompt, as seen in the attachment.
From what I've gathered from the source code, RtlSetCurrentDirectory_U calls
RtlDosPathNameToNtPathName_U, which prepends UncPfxW to the supplied path. The last edits to dlls/ntdll/path.c were made in 2003-2004.
I stumbled across this behavior while investigating why Total Commander cannot copy files to network shares. The sequence of calls in Total Commander is: SetCurrentDirectory to the network path, then GetCurrentDirectory (which returns the modified path in the form "UNC\server\share") and then it builds the destination parameter by concatenating this path with the destination file name. This gets passed to CopyFileEx, which fails with ERROR_PATH_NOT_FOUND because of the "UNC" prefix.
https://bugs.winehq.org/show_bug.cgi?id=37834
Gabriel Ivăncescu gabrielopcode@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |gabrielopcode@gmail.com
--- Comment #1 from Gabriel Ivăncescu gabrielopcode@gmail.com --- Quite late but thanks for the detailed report, I managed to find the culprit.
Note that the prefix is actually correct, because it is using the NT naming scheme, so it looks like ??\UNC\server\share thus it uses the unc dir under dosdevices, and it's perfectly valid.
The issue seems to be when changing the current directory, because it will strip the ??\ from the NT naming scheme, and end up with UNC\sever\share, which no other code will handle. The rest of the Wine code handles current directories of \server\share just fine, and that's what it should be anyway, so I've sent a patch to fix this when setting the directory, to convert it to the \server\share form.
This fixes many issues with UNC for me: I can use Wine's cmd to "cd" into subdirectories from a UNC path just fine now, where previously it failed, I can also create subdirectories with "md" from UNC paths. However "dir" command will still fail to work, but "dir" fails even with an absolute \server\share path, because it's hardcoded to assume drive letters, so that is the fault of Wine's cmd at this point, not UNC paths (and a separate bug should be filed for it).
Other commands have their own issues, for example "md \?\unc\server\share\foo" doesn't work, but "md \server\share\foo" works... again this is the fault of Wine's cmd not handling UNC paths properly, so it's bug in cmd and a completely separate thing (application bug).
UNC paths should now be fully supported for apps that handle them properly, but please test if you can (and are still around to see this), there might be other corner cases that still break with UNC paths that I'm not aware of. For example, I can copy files with Total Commander just fine now to a UNC path.
Please don't test with Wine's cmd and report it as a bug here, instead test it with a Windows application known-to-work with UNC paths and see if it breaks under Wine. (note that only paths should be fully supported now, enumerating network shares is not implemented yet)
https://bugs.winehq.org/show_bug.cgi?id=37834
--- Comment #2 from Gabriel Ivăncescu gabrielopcode@gmail.com --- Created attachment 62120 --> https://bugs.winehq.org/attachment.cgi?id=62120 Properly set the current directory for UNC paths
diff of sent patch, if you want to test now
https://bugs.winehq.org/show_bug.cgi?id=37834
Gabriel Ivăncescu gabrielopcode@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Resolution|--- |FIXED
--- Comment #3 from Gabriel Ivăncescu gabrielopcode@gmail.com --- Fixed by https://source.winehq.org/git/wine.git/commit/3acc0b0968fc2fd92220708f6a6629...
https://bugs.winehq.org/show_bug.cgi?id=37834
Gijs Vermeulen gijsvrm@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Fixed by SHA1| |3acc0b0968fc2fd92220708f6a6 | |629d2dfd28815
https://bugs.winehq.org/show_bug.cgi?id=37834
Alexandre Julliard julliard@winehq.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |CLOSED
--- Comment #4 from Alexandre Julliard julliard@winehq.org --- Closing bugs fixed in 3.15.
https://bugs.winehq.org/show_bug.cgi?id=37834
Michael Stefaniuc mstefani@winehq.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Target Milestone|--- |3.0.x
https://bugs.winehq.org/show_bug.cgi?id=37834
Michael Stefaniuc mstefani@winehq.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Target Milestone|3.0.x |---
--- Comment #5 from Michael Stefaniuc mstefani@winehq.org --- Removing the 3.0.x milestone from bug fixes included in 3.0.4.