public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* False positive from access("/proc/registry/...", F_OK)
@ 2011-04-27 12:35 Christian Franke
  2011-04-27 14:50 ` Corinna Vinschen
  0 siblings, 1 reply; 3+ messages in thread
From: Christian Franke @ 2011-04-27 12:35 UTC (permalink / raw)
  To: Cygwin

access("/proc/registry/...", F_OK) returns 0 for all (including
nonexistent) entries below a registry key which cannot be opened:

Testcase (run with admin rights):

# cygcheck -f /bin/cygwin1.dll
cygwin-1.7.9-1

# cd /proc/registry/HKEY_LOCAL_MACHINE

# ls SECURITY
Cache  Policy  RXACT  SAM

# cygdrop -- ls SECURITY
ls: reading directory SECURITY: Permission denied

# test -e SECURITY/NoSuchFile && echo yes

# cygdrop -- test -e SECURITY/NoSuchFile && echo yes
yes


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).

Christian




--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: False positive from access("/proc/registry/...", F_OK)
  2011-04-27 12:35 False positive from access("/proc/registry/...", F_OK) Christian Franke
@ 2011-04-27 14:50 ` Corinna Vinschen
  2011-04-30  7:01   ` Christian Franke
  0 siblings, 1 reply; 3+ messages in thread
From: Corinna Vinschen @ 2011-04-27 14:50 UTC (permalink / raw)
  To: cygwin

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:
> 
> Testcase (run with admin rights):
> 
> # cygcheck -f /bin/cygwin1.dll
> cygwin-1.7.9-1
> 
> # cd /proc/registry/HKEY_LOCAL_MACHINE
> 
> # ls SECURITY
> Cache  Policy  RXACT  SAM
> 
> # cygdrop -- ls SECURITY
> ls: reading directory SECURITY: Permission denied
> 
> # test -e SECURITY/NoSuchFile && echo yes
> 
> # cygdrop -- test -e SECURITY/NoSuchFile && echo yes
> yes
> 
> 
> 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.


Thanks,
Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: False positive from access("/proc/registry/...", F_OK)
  2011-04-27 14:50 ` Corinna Vinschen
@ 2011-04-30  7:01   ` Christian Franke
  0 siblings, 0 replies; 3+ messages in thread
From: Christian Franke @ 2011-04-30  7:01 UTC (permalink / raw)
  To: cygwin

Corinna Vinschen wrote:
> On Apr 27 12:26, Christian Franke wrote:
>    
>> 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.
>    

:-)

I presume this fixed the access-denied-on-last-component case:

"/proc/registry/HKEY_LOCAL_MACHINE/SECURITY" -> filetype = 1 (OK)

but unfortunately then the same info is returned for all ".../SECURITY/*".


> But what you say sounds right to me.  Please create a patch.
>
>    

I'll try next week. A fix likely needs to enhance open_key() such that 
it returns info whether the access was denied on last component or not.

Christian


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-04-29 20:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-27 12:35 False positive from access("/proc/registry/...", F_OK) Christian Franke
2011-04-27 14:50 ` Corinna Vinschen
2011-04-30  7:01   ` Christian Franke

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).