NTFS: [file writable $directory] lies
Closed / Fixed749876ffffffffffffffffffffffffffffffffffCreated 24 years agoUpdated 23 years ago
Descriptionplain2003-06-05 23:20:49
[file writable $directory] returns 1, yet [open [file join $directory newFile] w] fails. More detail from original user report: "On Windows, with the NTFS file system, there appears to be two ways to set file permissions. You can use the old FAT based system, where you can set a read-only attribute bit. It looks like this is what is checked by the Tcl 'file writable' command. Alternatively, there is a "security" tab in the file properties dialog box, which allows you to grant various access on a group-by-group basis. I've been testing this against Tcl 8.4.2 (Active Tcl release), and haven't found any way to detect the latter restriction, other than trying the access directly."
vincentdarleyplain2003-06-23 14:51:22
Logged In: YES
user_id=32170
This all filters through to 'NativeAccess' in tclWinFile.c, which
in turn calls:
attr = (*tclWinProcs->getFileAttributesProc)(nativePath);
so presumably that call isn't aware of the NTFS permissions.
Tcl also has a tclWinProcs->getFileAttributesExProc available,
which might return more information. In fact 'file stat' uses it,
so perhaps that could be used to test something of this, even
from pure Tcl.
dgpplain2003-06-24 01:24:52
Logged In: YES user_id=80530 "[file stat] was the first thing I tried. On my Win2K laptop, I create two files, one with write access enabled, one without. Other than the timestamps, the file stat arrays are identical."
vincentdarleyplain2003-06-24 02:20:22
Logged In: YES user_id=32170 yeah... a quick search on msdn shows up nothing extra which is useful on the 'Ex' proc. No idea how to gather this information at present.
vincentdarleyplain2003-06-24 18:29:16
Logged In: YES user_id=32170 It appears as if 'GetSecurityInfo' or 'GetNamedSecurityInfo' are the correct APIs to use to get this information. We should also examine what possible performance hit will be imposed by adding these to every 'access/stat' call in WinTcl. http://msdn.microsoft.com/library/default.asp?url=/library/en- us/security/security/getsecurityinfo.asp
vincentdarleyplain2003-06-24 18:30:53
Logged In: YES user_id=32170 And 'GetFileSecurity' may be a quicker way to the right info we need.
dgp Ticket [749876ffff]: 1 change
[History diff]2003-10-03 05:04:38
vincentdarleyplain2003-10-03 16:59:09
Logged In: YES user_id=32170 I've taken a closer look at this, 'GetFileSecurity' is clearly the way to go, but it is more complicated (as ever) than it ought to be, and I don't think I am going to be able to get this into 8.4.5.
vincentdarleyplain2003-10-13 22:18:33
Logged In: YES
user_id=32170
I have a patch which does this (but mixed in with other
changes at present so can't attach here). However, the
performance hit is quite large ('file readable' will be 5-6
times slower than 'file exists' after this change), and the
code is complex enough I don't think we should drop it into
Tcl 8.4.5 at such short notice.
vincentdarleyplain2003-10-13 23:48:59
Logged In: YES user_id=32170 Fixed in Tcl 8.5a0.
vincentdarley Closed ticket [749876ffff].
[History diff]2003-10-13 23:49:23
Log in (anonymous is fine) to add a comment.