Tcl Source Code

View Ticket
Login
Ticket UUID: 1394972
Title: file readable lies for certain XP files
Type: Bug Version: obsolete: 8.4.12
Submitter: fvogel Created on: 2006-01-01 21:27:48
Subsystem: 37. File System Assigned To: vincentdarley
Priority: 5 Medium Severity:
Status: Closed Last Modified: 2014-02-19 20:32:03
Resolution: Wont Fix Closed By: vincentdarley
    Closed on: 2006-03-18 18:18:44
Description:
Consider this, on Windows XP or 2000 (replace 
<my_account> by your real info):

file exists "C:/Documents and 
Settings/<my_account>/NTUSER.DAT"
1
file readable "C:/Documents and 
Settings/<my_account>/NTUSER.DAT"
1
open "C:/Documents and 
Settings/<my_account>/NTUSER.DAT" r
couldn't open "C:/Documents and 
Settings/<my_account>/NTUSER.DAT": permission denied

How come?

I know that Windows has this file permanently open 
while my session is open, but shouldn't file readable 
spit 0 instead of 1?

Is this perhaps another incarnation of bug 1193497?
User Comments: vincentdarley added on 2006-03-19 01:18:44:
Logged In: YES 
user_id=32170

I added a 'knownBug' test to fCmd.test for this.

nobody added on 2006-03-17 05:39:22:
Logged In: NO 

Certainly tclWinFile.c contains code to read ACLs.  I
believe the code is correct, but, frankly, I don't fully
understand this stuff (and why it has to be so complicated,
and why there are file vs directory differences).

So, do look over the code there, but otherwise it seems this
bug report should be closed as 'won't fix - OS limitation'.

Vince.

fvogelnew1 added on 2006-03-17 05:09:28:
Logged In: YES 
user_id=1245417

Joe,

What you say below really makes sense to me.

I have worked around this by attempting to open the file 
and catch the possible error. On 1. and 2. I fully agree.

Your question 3. also really makes sense when linked to 
bug 1193497. For my first tries (Windows only) on files, 
file readable apparently reads the read permission. For 
directories however, I'm wondering. It seems to always 
return 0, regardless of the permissions set. The readonly 
flag cannot be set through the explorer (see explanations 
about this in bug 1193497).

Francois

mistachkin added on 2006-03-16 06:54:36:
Logged In: YES 
user_id=113501

1. The "Permission denied" for the NTUSER.DAT file is
basically a sharing violation (the OS has it opened for
exclusive access).

2. There is no way that I know of on Windows to determine if
opening a file will result in a sharing violation without
actually attempting to open the file.  If the [file
readable] code actually did this, it could still end up
being inaccurate (race condition; somebody opens the file
after you check [file readable] but before you actually open
the file).

3. I believe that the intention of [file readable] is to
check to see if the user would have permission to open the
file based on the file permissions (the DACL on NT).  Vince,
does the current code check the DACL properly on Windows and
the file permissions on Unix?

vincentdarley added on 2006-03-16 06:12:55:
Logged In: YES 
user_id=32170

Indeed, even with latest cvs HEAD today, this is still wrong. Any suggestion to 
how to fix?

fvogelnew1 added on 2006-03-10 18:55:43:
Logged In: YES 
user_id=1245417

Downloaded tcl8.5a4 from  
ftp://ftp.tcl.tk/pub/tcl/tcl8_5/tcl8.5a4rc0-src.tar.gz and 
installed.

Same behavior as in my initial report, therefore not yet 
fixed.

I also tried with Tcl/Tk cvs HEAD (with patch for bug 
1193497 geared in). File readable still wrongly spits 1.

Francois

vincentdarley added on 2006-03-10 17:32:53:
Logged In: YES 
user_id=32170

Please can you check with tcl 8.5a4?

fvogelnew1 added on 2006-03-06 05:24:40:
Logged In: YES 
user_id=1245417

Hi,

Investigating a bit more on this it is clear that Windows 
has set a lock on the file I want to read from.

I found no way to detect this before trying to open the 
file in Tcl, so file readable should definitely tell me I 
can't read it.

Any idea?

Thanks.