From 3498f76deb52fcff5c4f8d20050ec844608d108d Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Fri, 24 Sep 2010 12:41:33 +0000 Subject: * errno.cc (errmap): Map ERROR_BAD_NET_RESP to ENOSYS. * fhandler_disk_file.cc (fhandler_disk_file::facl): Handle ENOSYS and point to the explanation. * ntdll.h (STATUS_NOT_IMPLEMENTED): Define. * path.cc (symlink_info::check): Handle the inability of NT4 to use FileNetworkOpenInformation on share root dirs in either direction. * path.h (slash_unc_prefix_p): Remove unused declaration. * security.cc (get_info_from_sd): Handle ENOSYS from get_file_sd. Explain when this happens. --- winsup/cygwin/ChangeLog | 12 ++++++++++++ winsup/cygwin/errno.cc | 1 + winsup/cygwin/fhandler_disk_file.cc | 6 ++++++ winsup/cygwin/ntdll.h | 1 + winsup/cygwin/path.cc | 17 +++++++++++++++++ winsup/cygwin/path.h | 2 -- winsup/cygwin/security.cc | 7 ++++++- 7 files changed, 43 insertions(+), 3 deletions(-) (limited to 'winsup') diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 6bb775d14..1d3797abc 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,15 @@ +2010-09-24 Corinna Vinschen + + * errno.cc (errmap): Map ERROR_BAD_NET_RESP to ENOSYS. + * fhandler_disk_file.cc (fhandler_disk_file::facl): Handle ENOSYS and + point to the explanation. + * ntdll.h (STATUS_NOT_IMPLEMENTED): Define. + * path.cc (symlink_info::check): Handle the inability of NT4 to use + FileNetworkOpenInformation on share root dirs in either direction. + * path.h (slash_unc_prefix_p): Remove unused declaration. + * security.cc (get_info_from_sd): Handle ENOSYS from get_file_sd. + Explain when this happens. + 2010-09-23 Christopher Faylor * autoload.cc (std_dll_init): Use correct format type when displaying diff --git a/winsup/cygwin/errno.cc b/winsup/cygwin/errno.cc index 736510169..58cdf4ae8 100644 --- a/winsup/cygwin/errno.cc +++ b/winsup/cygwin/errno.cc @@ -39,6 +39,7 @@ static NO_COPY struct X (BAD_DEVICE, ENODEV), X (BAD_NETPATH, ENOENT), X (BAD_NET_NAME, ENOENT), + X (BAD_NET_RESP, ENOSYS), X (BAD_PATHNAME, ENOENT), X (BAD_PIPE, EINVAL), X (BAD_UNIT, ENODEV), diff --git a/winsup/cygwin/fhandler_disk_file.cc b/winsup/cygwin/fhandler_disk_file.cc index 6a28ac15c..3cb831168 100644 --- a/winsup/cygwin/fhandler_disk_file.cc +++ b/winsup/cygwin/fhandler_disk_file.cc @@ -1054,9 +1054,15 @@ cant_access_acl: set_errno(EFAULT); else res = getacl (get_stat_handle (), pc, nentries, aclbufp); + /* For this ENOSYS case, see security.cc:get_file_attribute(). */ + if (res == -1 && get_errno () == ENOSYS) + goto cant_access_acl; break; case GETACLCNT: res = getacl (get_stat_handle (), pc, 0, NULL); + /* Ditto. */ + if (res == -1 && get_errno () == ENOSYS) + goto cant_access_acl; break; default: set_errno (EINVAL); diff --git a/winsup/cygwin/ntdll.h b/winsup/cygwin/ntdll.h index f707cd28d..1bbc78bc3 100644 --- a/winsup/cygwin/ntdll.h +++ b/winsup/cygwin/ntdll.h @@ -20,6 +20,7 @@ define to avoid warnings. */ #define STATUS_INVALID_INFO_CLASS ((NTSTATUS) 0xc0000003) #endif +#define STATUS_NOT_IMPLEMENTED ((NTSTATUS) 0xc0000002) #define STATUS_INFO_LENGTH_MISMATCH ((NTSTATUS) 0xc0000004) #define STATUS_INVALID_PARAMETER ((NTSTATUS) 0xc000000d) #define STATUS_NO_SUCH_FILE ((NTSTATUS) 0xc000000f) diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc index b468e9e37..887885d22 100644 --- a/winsup/cygwin/path.cc +++ b/winsup/cygwin/path.cc @@ -2421,6 +2421,23 @@ restart: { status = NtQueryInformationFile (h, &io, pfnoi, sizeof *pfnoi, FileNetworkOpenInformation); + if ((status == STATUS_INVALID_PARAMETER + || status == STATUS_NOT_IMPLEMENTED) + && RtlEqualUnicodePathPrefix (&upath, &ro_u_uncp, FALSE)) + { + /* This occurs when accessing SMB share root dirs hosted on + NT4 (STATUS_INVALID_PARAMETER), or when trying to access + SMB share root dirs from NT4 (STATUS_NOT_IMPLEMENTED). */ + status = NtQueryInformationFile (h, &io, &fbi, sizeof fbi, + FileBasicInformation); + if (NT_SUCCESS (status)) + { + memcpy (pfnoi, &fbi, 4 * sizeof (LARGE_INTEGER)); + pfnoi->EndOfFile.QuadPart + = pfnoi->AllocationSize.QuadPart = 0; + pfnoi->FileAttributes = fbi.FileAttributes; + } + } if (NT_SUCCESS (status)) fileattr = pfnoi->FileAttributes; } diff --git a/winsup/cygwin/path.h b/winsup/cygwin/path.h index a53cf169a..fae721664 100644 --- a/winsup/cygwin/path.h +++ b/winsup/cygwin/path.h @@ -343,8 +343,6 @@ class path_conv /* Interix symlink marker */ #define INTERIX_SYMLINK_COOKIE "IntxLNK\1" -int __stdcall slash_unc_prefix_p (const char *path) __attribute__ ((regparm(1))); - enum fe_types { FE_NADA = 0, /* Nothing special */ diff --git a/winsup/cygwin/security.cc b/winsup/cygwin/security.cc index 1052f98c0..509bd1ab0 100644 --- a/winsup/cygwin/security.cc +++ b/winsup/cygwin/security.cc @@ -358,7 +358,12 @@ get_file_attribute (HANDLE handle, path_conv &pc, get_info_from_sd (sd, attribute, uidret, gidret); return 0; } - else + /* ENOSYS is returned by get_file_sd if fetching the DACL from a remote + share returns STATUS_INVALID_NETWORK_RESPONSE, which in turn is + converted to ERROR_BAD_NET_RESP. This potentially occurs when trying + to fetch DACLs from a NT4 machine which is not part of the domain of + the requesting machine. */ + else if (get_errno () != ENOSYS) { if (uidret) *uidret = ILLEGAL_UID; -- cgit v1.2.3