This patch fixes access("/proc/registry/HKEY_PERFORMANCE_DATA", R_OK) which always fails with EBADF.

Christian

2011-05-05  Christian Franke  <fra...@computer.org>

	* security.cc (check_registry_access): Handle missing
	security descriptor of HKEY_PERFORMANCE_DATA.

diff --git a/winsup/cygwin/security.cc b/winsup/cygwin/security.cc
index a52fc26..430a65f 100644
--- a/winsup/cygwin/security.cc
+++ b/winsup/cygwin/security.cc
@@ -1085,8 +1085,13 @@ check_registry_access (HANDLE hdl, int flags, bool effective)
     desired |= KEY_SET_VALUE;
   if (flags & X_OK)
     desired |= KEY_QUERY_VALUE;
-  if (!get_reg_sd (hdl, sd))
+
+  if ((HKEY) hdl == HKEY_PERFORMANCE_DATA)
+    /* RegGetKeySecurity() always fails with ERROR_INVALID_HANDLE.  */
+    ret = 0;
+  else if (!get_reg_sd (hdl, sd))
     ret = check_access (sd, reg_mapping, desired, flags, effective);
+
   /* As long as we can't write the registry... */
   if (flags & W_OK)
     {

Reply via email to