4
0
mirror of git://sourceware.org/git/newlib-cygwin.git synced 2025-02-28 20:15:24 +08:00

21 Commits

Author SHA1 Message Date
Corinna Vinschen
d4a5c2be8b Cygwin: fhandler_netdrive: fix character conversion required for NFS shares
While filenames on NFS shares are converted internally to a widechar
representation of the input bytes treated as the default system ANSI
codepage (CP_ACP), this doesn't hold for share names.  The names
returned by WNetEnumResourceW are just the original bytes dropped
verbatim into WCHAR.

The original conversion from 7db1c6fc4e2a ("Cygwin: //server: revert
to using WNet and support NFS shares") was erroneous in that it
treated the bytes as ISO-8859-1, not as CP_ACP codepoints.

Fix the conversion to convert from CP_ACP to widechar.  Use a tmp_pathbuf
buffer for the new widechar string instead of malloc/free.  Extend the
comment, better explaining the encoding difference between files and
shares.

Fixes: 7db1c6fc4e2a ("Cygwin: //server: revert to using WNet and support NFS shares")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2025-02-27 13:51:39 +01:00
Corinna Vinschen
15b52ba69d Cygwin: fhandler_netdrive: support enumerating connected disks
Some providers don't implement share enumeration.  Allow to find
the server's connected resources in this case.  Enable this feature
for the WNNC_NET_DAV provider.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2025-02-26 20:15:18 +01:00
Corinna Vinschen
809c212093 Cygwin: fhandler_netdrive: try harder to find shares of weird providers
For some provider types, WNetGetResourceInformationW fails, namely
WNNC_NET_DAV.  When that happens, try to find the server's provider
by enumerating all WNet containers from the top.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2025-02-26 20:12:09 +01:00
Corinna Vinschen
323729f654 Cygwin: fhandler_netdrive: rework share enumeration
- As before, first try NFS for dotted names, but additionally check if
  the NFS profvider is installed.
- Next try *any* provider (i.e. provider = 0). Move the necessary
  heuristics into thread_netdrive_wnet with lots of comments.
- Last, but not least, if the server was already tried for NFS,
  but WNetGetResourceInformationW returns WNNC_NET_MS_NFS again
  when trying any provider, bail out and retry with SMB, since
  many NFS servers could be SMB servers as well.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2025-02-26 15:37:56 +01:00
Corinna Vinschen
7aae9f323a Cygwin: fhandler_netdrive: use correct thread names
Fix the cygthread names used for debugging when calling the
thread_netdrive_wnet thread, so they actually show the provider
getting enumerated.

Fixes: 7db1c6fc4e2a ("Cygwin: //server: revert to using WNet and support NFS shares")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2025-02-24 16:52:27 +01:00
Corinna Vinschen
01bcd7d29e Cygwin: fhandler_netdrive: skip enumerating WebDAV shares
So far there's no known way to enumerate connected WebDAV resources.
WNetGetResourceInformationW/WNetOpenEnumW both return ERROR_BAD_NET_NAME.

Windows Explorer also shows an error dialog when trying to open a
Nextcloud instance to see the shares.

However, `net use' enumerates the connected cloud shares, so
there must be a way to do this.

For the time being, we just don't even try to enumerate WebDAV
shares and return an empty list.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2025-02-24 16:42:01 +01:00
Corinna Vinschen
7124d1c23d Cygwin: fhandler_netdrive: don't enumerate NFS shares on WebDAV server
WebDAV resources trigger the code trying to enumerate NFS shares
on the server.  Disable this by checking for an at-sign as well.

Fixes: 8cebbb2b42bf ("Cygwin: fhandler_netdrive::exists: handle WebDAV URLs")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2025-02-24 16:35:46 +01:00
Corinna Vinschen
8cebbb2b42 Cygwin: fhandler_netdrive::exists: handle WebDAV URLs
WebDAV URLs may contain an at-sign followed by a port number or SSL.
This will throw GetAddrInfoW, so remove the at-sign prior to calling
GetAddrInfoW.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2025-02-21 21:56:03 +01:00
Corinna Vinschen
8cc55d819b Cygwin: fhandler_netdrive::exists: fix new debug statement
The debug statement was wrong twice: Not only was it in the wrong
spot, it was also supposed to print the share name and missed to
add said argument.

Fixes: df307349a09e ("Cygwin: fhandler_netdrive::exists: add debug statement")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2025-02-21 10:51:51 +01:00
Corinna Vinschen
df307349a0 Cygwin: fhandler_netdrive::exists: add debug statement
Add a debug_printf printing the return code from GetAddrInfoW.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2025-02-20 20:28:01 +01:00
Corinna Vinschen
d52d983e5b Cygwin: implement posix_close
per
https://pubs.opengroup.org/onlinepubs/9799919799/functions/posix_close.html

Add a flag value to fhandler_*::close() and close_with_arch() methods,
taking -1 as default argument, used to indicate default close(2)
behaviour.

The only fhandlers capable of returning EINTR are the INET based
socket fhandlers.  Handle -1 and POSIX_CLOSE_RESTART equivalent,
making close() and posix_close(POSIX_CLOSE_RESTART) behaving
identically.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2025-01-28 16:50:12 +01:00
Corinna Vinschen
b7f5a33200 Cygwin: //: fetch only one item per loop
Simplify code in that it only fetches a single entry per
IEnumShellItems::Next call.  For some reason this appears to
be quicker most of the time.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-03-27 21:57:32 +01:00
Corinna Vinschen
178a8fca15 Cygwin: // and //server: add support for WSL
Root dirs of WSL installations are exposed via \\wsl$.
Add support to expose \\wsl$.

While at it, check if TERMSRV and P9 provider exist before
exposing them.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-03-24 20:02:15 +01:00
Corinna Vinschen
18b8a104ac Cygwin: dir_cache::add: constify input string
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-03-24 19:40:36 +01:00
Corinna Vinschen
b95ab5982e Cygwin: fhandler_netdrive: use WNNC_NET_SMB instead of WNNC_NET_LANMAN
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-03-24 19:39:49 +01:00
Corinna Vinschen
cc74a38d4a Cygwin: //tsclient: allow to enumerate shares
The //tsclient provider is WNNC_NET_TERMSRV.

Fixes: 7db1c6fc4e2a ("Cygwin: //server: revert to using WNet and support NFS shares")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-03-23 23:54:26 +01:00
Corinna Vinschen
7db1c6fc4e Cygwin: //server: revert to using WNet and support NFS shares
Continue using WSD for enumerating //, but switch back to
WNet for enumerating shares.

Add trying to enumerate NFS shares for machine names given as FQDN.

Only downcase server names, keep case of shares intact.
Move downcasing into dir_cache class.

Add a comment to explain an extrem weirdness in Windows.

Fixes: 205190a80bd0 ("Cygwin: // and //server: switch to Network Discovery")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-03-23 22:32:42 +01:00
Corinna Vinschen
8d2c1b4ce6 Cygwin: //server: check existence of server with getaddrinfo
Checking server existence by trying to enumerate its shares
may result in 2 minutes delay until some internal timeout is hit.

In the light that every network is an IP network anyway these
days, let's try with a simple getaddrinfo() call.  This is usually
back in 3 secs even if the server doesn't exist, and it's usually
back in 8 secs if the DNS server can't be connected.  This is the
fastest method I found to check server existence yet.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-03-22 15:34:29 +01:00
Corinna Vinschen
205190a80b Cygwin: // and //server: switch to Network Discovery
SMBv1 is ultimately deprecated since Novemer 2023.  It's also
not installed by default on latest Windows versions.

Drop using the WNet (SMBv1) API in favor of using Network Discovery.
Given there's no documented Win32 API for that, the code now uses
the Shell API.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-03-20 14:46:49 +01:00
Corinna Vinschen
1719169604 Cygwin: (mostly) drop NT4 and Samba < 3.0 support
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-03-20 12:31:50 +01:00
Corinna Vinschen
007e23d639 Cygwin: Reorganize cygwin source dir
Create subdirs and move files accordingly:

- DevDocs:  doc files
- fhandler: fhandler sources, split fhandler.cc into base.cc and null.cc
- local_includes: local include files
- scripts:  scripts called during build
- sec:      security sources

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-05 12:02:11 +02:00