This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Test command giving inconsistent results.


On 12/15/2010 05:04 PM, Andy Hall wrote:
> This is one in the same vein as the one I reported back in October.
> 
> The test command is giving different results depending on the path used.

I'm not yet sure if it is a bug, or just a flaw in your expectations.

> 
> ahall@ahall-pc /cygdrive/c/Program Files/Java/j2sdk1.4.2_16/bin
> $ ls -l
> total 1320
> ... <Some files deleted for clarity>
> -rwx------+ 1 ahall None 45168 2007-09-17 02:27 java.exe
> ... <More files deleted for clarity>

Note that this file has ACLs.  To be a complete report, you should also
provide: getfacl java.exe as well as id output, to make sure we know
which ids have which permissions, and which id you are running as.

When you access the file via a POSIX name (such as it's relative path),
then access() uses POSIX permissions to determine who can read the file,
including checking against the ACLs.

> <Simple file name used.>
> ahall@ahall-pc /cygdrive/c/Program Files/Java/j2sdk1.4.2_16/bin
> $ test -r java.exe && echo readable
> readable
> 
> <Here the full path is used!>
> ahall@ahall-pc /cygdrive/c/Program Files/Java/j2sdk1.4.2_16/bin
> $ test -r /cygdrive/c/j2sdk1.4.2_16/bin/java.exe && echo readable

But when you go through /cygdrive, then the default mount settings
assume noacl, and ACL checks are bypassed, which may change the results.

Then again, a relative path to a file within a noacl directory ought to
have the same behavior as the absolute path to the same file.  So maybe
there's a bug after all.

Would you mind also checking if /bin/test vs. bash's builtin test have
different behaviors, since coreutils and bash might be using slightly
different syscalls in implementing 'test -r'?

-- 
Eric Blake   eblake@redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]