OSDN Git Service

* errno.cc (errmap): Map ERROR_BAD_NET_RESP to ENOSYS.
authorcorinna <corinna>
Fri, 24 Sep 2010 12:41:32 +0000 (12:41 +0000)
committercorinna <corinna>
Fri, 24 Sep 2010 12:41:32 +0000 (12:41 +0000)
* 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
winsup/cygwin/errno.cc
winsup/cygwin/fhandler_disk_file.cc
winsup/cygwin/ntdll.h
winsup/cygwin/path.cc
winsup/cygwin/path.h
winsup/cygwin/security.cc

index 6bb775d..1d3797a 100644 (file)
@@ -1,3 +1,15 @@
+2010-09-24  Corinna Vinschen  <corinna@vinschen.de>
+
+       * 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  <me+cygwin@cgf.cx>
 
        * autoload.cc (std_dll_init): Use correct format type when displaying
index 7365101..58cdf4a 100644 (file)
@@ -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),
index 6a28ac1..3cb8311 100644 (file)
@@ -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);
index f707cd2..1bbc78b 100644 (file)
@@ -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)
index b468e9e..887885d 100644 (file)
@@ -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;
            }
index a53cf16..fae7216 100644 (file)
@@ -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 */
index 1052f98..509bd1a 100644 (file)
@@ -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;