Incorrect mode field returned by file stat command
Closed / Fixed2935503fffffffffffffffffffffffffffffffffCreated 17 years agoUpdated 14 years ago
Descriptionplain2010-01-20 09:25:12
From c.l.t posting by keithv -
----
Is the mode value from file stat meaningful on Windows.
Under tcl 8.5, it always seems to return 0644
even if you have permission write to the file.
(This problem came up when I was trying to figure
out why tcllib's ftpd package wouldn't let me delete
a file.)
Thanks,
Keith
----
Looking at the code, the problem is in the NativeStatMode function in tclWinFile.c
The lines propagating the owner bits to group and others -
mode |= (mode & 0x0700) >> 3;
mode |= (mode & 0x0700) >> 6;
should be
mode |= (mode & 0700) >> 3;
mode |= (mode & 0700) >> 6;
(i.e. octal 700, not hex)
/Ashok
apnadkarniplain2011-08-25 22:21:49
Reassigned to dgp as per instruction from him
nijtmansplain2011-10-11 20:39:22
This one is so trivial, just let's fix it..... Test io-40.2, which was previously unix-only adapted to show how valid this bug report is. Fixed in all open branches.
dgpplain2011-10-13 00:24:34
Test fails in a tcl/unix build on OSX Snow Leopard:
==== io-40.2 POSIX open access modes: CREAT FAILED
==== Contents of test case:
file delete $path(test3)
set f [open $path(test3) {WRONLY CREAT} 0o666]
file stat $path(test3) stats
set x [format "0o%o" [expr $stats(mode)&0o777]]
puts $f "line 1"
close $f
set f [open $path(test3) r]
lappend x [gets $f]
close $f
set x
---- Result was:
0o644 {line 1}
---- Result should have been (exact matching):
0o666 {line 1}
==== io-40.2 FAILED
dgpplain2011-10-13 01:43:15
Same failure on Centos system.
dgpplain2011-10-13 01:46:55
Just because we ask for permissions 0o666 doesn't mean we'll get them depending on what permissions we have on the containing dir.
andreas_kupriesplain2011-10-13 01:53:39
And the user's 'umask' settings in the current shell may effect results too.
nijtmansplain2011-10-13 15:04:21
Reverting test-case, als the actual change is Windows-only anyway. So it was not that trivial.......
nijtmansplain2012-06-22 20:01:56
allow_comments - 1
Log in (anonymous is fine) to add a comment.