Corinna Vinschen wrote:
On Apr 27 12:26, Christian Franke wrote:access("/proc/registry/...", F_OK) returns 0 for all (including nonexistent) entries below a registry key which cannot be opened:... Problem was likely introduced by fhandler_registry.cc change 1.52: fhandler_registry::exists () ... if (!val_only) hKey = open_key (path, KEY_READ, wow64, false); - if (hKey != (HKEY) INVALID_HANDLE_VALUE) + if (hKey != (HKEY) INVALID_HANDLE_VALUE || get_errno () == EACCES) file_type = 1; else open_key() returns INVALID_HANDLE_VALUE and EACCESS also if an upper level key cannot be opened. The exists() function returns 1 (virt_directory) then, it should return 0 (virt_none).I don't remember anymore why I did that and naturally I also didn't write a comment. But what you say sounds right to me. Please create a patch.
Done, tested and attached. Christian
2011-05-04 Christian Franke <[email protected]> * fhandler_registry.cc (fhandler_registry::exists): Fix regression in EACCES handling. (fhandler_registry::open): Fix "%val" case. diff --git a/winsup/cygwin/fhandler_registry.cc b/winsup/cygwin/fhandler_registry.cc index f2e80ce..beeb0ed 100644 --- a/winsup/cygwin/fhandler_registry.cc +++ b/winsup/cygwin/fhandler_registry.cc @@ -317,10 +317,12 @@ fhandler_registry::exists () if (!val_only) hKey = open_key (path, KEY_READ, wow64, false); - if (hKey != (HKEY) INVALID_HANDLE_VALUE || get_errno () == EACCES) + if (hKey != (HKEY) INVALID_HANDLE_VALUE) file_type = virt_directory; else { + /* Key does not exist or open failed with EACCESS, + enumerate subkey and value names of parent key. */ hKey = open_key (path, KEY_READ, wow64, true); if (hKey == (HKEY) INVALID_HANDLE_VALUE) return virt_none; @@ -797,7 +799,7 @@ fhandler_registry::open (int flags, mode_t mode) handle = open_key (path, KEY_READ, wow64, false); if (handle == (HKEY) INVALID_HANDLE_VALUE) { - if (get_errno () != EACCES) + if (val_only || get_errno () != EACCES) handle = open_key (path, KEY_READ, wow64, true); if (handle == (HKEY) INVALID_HANDLE_VALUE) {
