Artifacts Associated With Ticket 7de2d722bd
Ticket change [46fcab78e8] (rid 174834) by fvogel on 2019-09-05 20:09:59:
- assignee initialized to: "nobody"
- closer initialized to: "nobody"
- cmimetype initialized to: "text/x-fossil-wiki"
- comment initialized to:
core-8-6-branch built with MS Visual Studio Express 2008 on Vista, or also on Win10: <verbatim> ==== cmdAH-25.2 Tcl_FileObjCmd: owned FAILED ==== Contents of test case: file owned $gorpfile ---- Result was: 0 ---- Result should have been (exact matching): 1 ==== cmdAH-25.2 FAILED </verbatim> - foundin initialized to: "core-8-6-branch"
- is_private initialized to: "0"
- login: "fvogel"
- priority initialized to: "5 Medium"
- private_contact initialized to: "a013af67114eccc19ad12b04f14923acea9e96b7"
- resolution initialized to: "None"
- severity initialized to: "Minor"
- status initialized to: "Open"
- submitter initialized to: "fvogel"
- subsystem initialized to: "16. Commands A-H"
- title initialized to:
cmdAH-25.2 (Tcl_FileObjCmd: owned) fails on Windows
- type initialized to: "Bug"
Ticket change [d56bb37c33] (rid 174957) by fvogel on 2019-09-08 10:38:11:
- icomment:
A quick debug session shows that on [https://core.tcl-lang.org/tcl/artifact/cafdd9f99c799981?ln=3331|this line] 'owned' becomes false because EqualSid() returns false. Simple test case derived from cmdAH-25.2: <verbatim> set gorpfile "C:/gorp.file" set fd [open $gorpfile w] puts $fd abcdef close $fd file owned $gorpfile ; # returns 0, but 1 is expected file delete $gorpfile </verbatim> I would haved expected that 'file owned' returned true for files I had just created myself as in the above test script.
- login: "fvogel"
- mimetype: "text/x-fossil-wiki"
- icomment:
Ticket change [80ec6f9ad7] (rid 174969) by sebres on 2019-09-09 08:13:48:
- icomment:
<i>> I would haved expected that 'file owned' returned true for files I had just created myself</i> Nope, it is related to NTFS default security for drive (since Vista/Win7 it is owned by default owner after creation, also note that creator owner should have permission to take ownership, as well as the policies for that). Anyway many tests would only work properly if you start tcl-test from %TEMP% folder.<br/> In automake (mingw) build I extended tcltest target with helpers doing that, here is for example auto-generated <code>tcltest.cmd</code>: <pre style="padding-left:10pt"> @echo off set BDP=%~dp0 set OWD=%CD% cd /d %TEMP% rem "%BDP%\tclsh86.exe" "%BDP%/../../tests/all.tcl" %TESTFLAGS% -load "package ifneeded Tcltest 8.6.9 [list load [file normalize tcltest86.dll] Tcltest]; package ifneeded dde 1.4.1 [list load [file normalize tcldde14.dll] dde]; package ifneeded registry 1.3.3 [list load [file normalize tclreg13.dll] registry]" %* "%BDP%\tcltest.exe" ""%BDP%/../../tests/all.tcl" %TESTFLAGS% -load "package ifneeded dde 1.4.1 [list load [file normalize tcldde14.dll] dde]; package ifneeded registry 1.3.3 [list load [file normalize tclreg13.dll] registry]" %* cd /d %OWD% </pre> Can you test your build using this method?<br/> Then we could create such helpers and test from it also in VS-build. I have also fixed several tests (or provided few additional constraint) on github to satisfy travis, have still to rebase that all to fossil from github. For 8.5 - https://github.com/sebres/tcl/compare/core-8-5-branch...test/travis-8-5-branch <br/> For 8.6 - https://github.com/sebres/tcl/compare/core-8-6-branch...tests/sebres-travis-windows-debug
- login: "sebres"
- mimetype: "text/x-fossil-wiki"
- icomment:
Ticket change [62e29556b3] (rid 174994) by fvogel on 2019-09-09 21:11:14:
- icomment:
Thanks for your answer! I have tried your tcltest.cmd idea (the file needs to be installed in .../tcl/win/Debug_VC9 for me). Here is the outcome: * cmdAH-25.2 still fails. Don't you also see this test failing on Windows? * three tests fail with your tcltest.cmd that do not fail when the tests are launched directly: basic-48.25.1 (because testevalex is unknown) and lrange-3.7c.2 and lrange-3.7d.2 (because testpurebytesobj is unknown). This should be fixable. * the winFCmd tests that I see failing (see [ad28319dc2]) when launched directly do not longer fail with tcltest.cmd <i>> note that creator owner should have permission to take ownership, as well as the policies for that</i> Couldn't this be implemented in the cmdAH-25.2 test? I mean, add a step to take ownership of the gorpfile, and only afterwards exercise 'file owned $gorpfile'?
- login: "fvogel"
- mimetype: "text/x-fossil-wiki"
- icomment:
Ticket change [b4aa09ee9c] (rid 175007) by sebres on 2019-09-10 12:03:58:
- icomment:
<i>> Don't you also see this test failing on Windows?</i> Nope, it works on my system (Win 7 as well as Win 10 in VM) for x86 and x64 builds (mingw, VC9.0 or VS2015): <pre style="padding-left:10pt; font-size:90%"> > d:\Projects\tcl8.6\win\Release_VC1900\tcltest.cmd -file "cmdAH.test" -match "cmdAH-25.2" Tests running in interp: d:/Projects/tcl8.6/win/Release_VC1900/tcltest.exe Tests located in: D:/Projects/tcl8.6/tests Tests running in: C:/Temp Temporary files stored in C:/Temp Test files run in separate interpreters Running tests that match: cmdAH-25.2 Skipping test files that match: l.*.test Only running test files that match: cmdAH.test Tests began at Tue Sep 10 12:57:46 +0200 2019 cmdAH.test Tests ended at Tue Sep 10 12:57:47 +0200 2019 all.tcl: Total 323 Passed 1 Skipped 322 Failed 0 Sourced 1 Test Files. </pre> If I debug the test (output a file name), I see the file is pretty well created in my <code>%TEMP%</code> directory so as <code>C:/Temp/gorp.file</code> and I'm an owner (normally default policies for TEMP should set owner for the creater). May be we should use sub-directory (often it gets other permissions per default)...<br/> Do you see 1 if you execute both of this in tclsh? <pre style="padding-left:10pt; font-size:90%"> close [open [set fn $::env(TEMP)/test-owner-from-tcl.txt] w]; puts [file owned $fn]; file delete $fn set fn $::env(TEMP)/test-owner-from-tcl/1.txt; file mkdir [file dirname $fn]; close [open $fn w]; puts [file owned $fn]; file delete -force [file dirname $fn] </pre> <i>> three tests fail with your tcltest.cmd ...</i> Well I posted the helper for release build, may be for debug it miss some suffix (like g) in some loads or we've just issues with constraints recognizing tcltest is available. Anyway I see no tests failing if calling test suite from TEMP folder. <i>> Couldn't this be implemented in the cmdAH-25.2 test?</i> Well we can rewrite it to use env(TEMP) folder (the test has a constraint win). But it seems to fail on your PC for some reason. Another variant would be to write a helper in tcltest taking ownership to current user (for example using <code>takeown</code> command or coded in C like described in https://docs.microsoft.com/en-us/windows/win32/secauthz/taking-object-ownership-in-c--), just it can cause another issues due to default security on some systems (and/or UAC). Better would be to skip it by some constraint (e. g. <code>takeown</code> would fail). Can you try to change the owner using <code>takeown</code> if above mentioned script fails for you.<br/> But somehow I'm pretty sure <code>exec takeown /F [file nativename $fn]</code> would fail for you. Also note that in Windows (since 8.6) we check ownership using TclWinFileOwned, which can return 0 in case of GetNamedSecurityInfo, OpenProcessToken or GetTokenInformation fail, as well as the method with EqualSid by token-info may be a bit questionable in case of special permissions for a drive (at least with UAC and/or custom UAC-control set).<br/> But not in case of TEMP-folder (this makes no sense).
- login: "sebres"
- mimetype: "text/x-fossil-wiki"
- icomment:
Ticket change [f082a97fbe] (rid 175053) by fvogel on 2019-09-10 22:12:36:
- icomment:
<i>> If I debug the test (output a file name), I see the file is pretty well created in my %TEMP% directory so as C:/Temp/gorp.file</i> For me the file is <code>C:/Users/francois/AppData/Local/Temp/gorp.file</code> and <code>echo %TEMP%</code> returns <code>C:\Users\francois\AppData\Local\Temp</code>. So yes for me too the file is pretty well created in my %TEMP% directory. A difference is that %TEMP% is located in my Windows profile (does this really make a difference?). <i>> Do you see 1 if you execute both of this in tclsh? <verbatim> > close [open [set fn $::env(TEMP)/test-owner-from-tcl.txt] w]; puts [file owned $fn]; file delete $fn > > set fn $::env(TEMP)/test-owner-from-tcl/1.txt; file mkdir [file dirname $fn]; > close [open $fn w]; puts [file owned $fn]; file delete -force [file dirname $fn] </verbatim> </i> Actually no, I see two zeroes. <i>> Can you try to change the owner using takeown if above mentioned script fails for you. But somehow I'm pretty sure exec takeown /F [file nativename $fn] would fail for you. </i> Nope, it works. I'm seeing 0 and 1 when executing the following: <verbatim> close [open [set fn $::env(TEMP)/test-owner-from-tcl.txt] w]; puts [file owned $fn] exec takeown /F [file nativename $fn]; puts [file owned $fn] </verbatim> This is on a Vista computer on which I'm logged in and using from an account 'francois' having administrator privileges. Before running <code>takeown</code>, the owner of the file is mycomputername\Administrators, but after taking ownership it becomes mycomputername\francois. User 'francois' has admin privileges. I didnt yet check on another computer, running Win 10, on which I'm logged in as an ordinary user. I'm seeing the problem described in the present ticket on both computers. <i>> Also note that in Windows (since 8.6) we check ownership using TclWinFileOwned, which can return 0 in case of GetNamedSecurityInfo, OpenProcessToken or GetTokenInformation fail</i> I have already confirmed that TclWinFileOwned returns false not because of the above but really because <code>EqualSid()</> returns zero (see my first comment below dated 2019-09-08 10:38:11, first line). Given the switch made by <code>takeown</code> and the change of result for 'file owner', this is all consistent.
- login: "fvogel"
- mimetype: "text/x-fossil-wiki"
- icomment:
Ticket change [370c1cca18] (rid 175069) by sebres on 2019-09-11 11:54:16:
- icomment:
Revision [1b22a4a786] should fix it now (regardless which test-directory or system is used), can you please test it and close ticked if it'd work.
- login: "sebres"
- mimetype: "text/x-fossil-wiki"
- resolution changed to: "Fixed"
- status changed to: "Pending"
- icomment:
Ticket change [8a97fcea93] (rid 175102) by fvogel on 2019-09-11 19:46:21:
- icomment:
Great! At [7395c026b7] his is now working (cmdAH-25.2 PASSES) on both my Vista and my Win10 computers. What I'm seeing now is that another test is failing, on Win10 only. I didn't notice this before but perhaps it was already there. The test looks similar. <verbatim> ==== cmdAH-25.3.1 Tcl_FileObjCmd: owned FAILED ==== Contents of test case: file owned $env(windir) ---- Result was: 1 ---- Result should have been (exact matching): 0 ==== cmdAH-25.3.1 FAILED </verbatim> - login: "fvogel"
- mimetype: "text/x-fossil-wiki"
- icomment:
Ticket change [2f7b7edd67] (rid 175104) by sebres on 2019-09-11 21:04:40:
- icomment:
How it can be? Have we some bug in core or Tcl_FileObjCmd for some constelation, or are you really owner of C:\Windows folder? (Did you tacking the ownership manually at some point?) For this case we'd need to check the owner is not a caller of test (like dir /q).
- login: "sebres"
- mimetype: "text/plain"
- icomment:
Ticket change [ef0bd4da1e] (rid 175143) by fvogel on 2019-09-12 16:16:40:
- icomment:
On the Win10 PC where cmdAH-25.3.1 is failing, the owner of <code>C:\Windows</code> is 'TrustedInstaller'. That's not me. What is weird is that running <code>file owned $env(windir)</code> directly in tclsh returns the 0 expected by the test. So the test must be testing the owner of <code>$env(windir)</code> but this variable does not, at the time the test is executed, contain <code>C:\Windows</code>. Adding a puts inside the test indeed reveals that <code>$env(windir)</code> actually is <code>E:\tcltk-fossil\tcl\win\..\win</code>, i.e. the 'win' subdirectory of the tcl repository. On the Vista PC on which cmdAH-25.3.1 is passing, the owner of <code>C:\Windows</code> also is 'TrustedInstaller', which is not me. The puts in cmdAH-25.3.1 reveals that again <code>$env(windir)</code> is not <code>C:\Windows</code> but the 'win' subdirectory of the tcl repository. So on this Vista PC the test passes by pure accident. Conclusion: cmdAH-25.3.1 is not testing the owner of <code>C:\Windows</code> as was probably the original intent. It seems that something sets <code>$env(windir)</code> so that it rather contains the 'win' subdirectory of the tcl repository, and the test passes or fails depending on which user runs the tests. I think the original intent in cmdAH-25.3.1 rather was to test something like <code>file owned $env(SystemRoot)</code>, don't you think so?
- login: "fvogel"
- mimetype: "text/x-fossil-wiki"
- icomment:
Ticket change [849a107989] (rid 175144) by sebres on 2019-09-12 18:11:03:
- icomment:
As for SystemRoot vs WinDir, yes we can switch it (also in init.tcl etc, because auto_execok may then also stop to work or add some invalid path). SystemRoot is readonly in opposite to WinDir and WinDir was superseded by SystemRoot at some point (but does not exists in earlier Windows versions). (see also https://superuser.com/questions/638321/what-is-difference-between-windir-and-systemroot). Also I suspect many scripts still depending on env(WinDir), so possibly still better to cover that... So crucial question is what exactly overwrites it in your case? Just good to know.<br/> Does it also happen if you starts only this test alone, so using <code>-file cmdAH.test -match cmdAH-25.3.1</code>?<br/> Can you possibly extend your tests (init.tcl, tcltest.tcl, whatever) with some trace over ::env in order to see who exactly changes that?
- login: "sebres"
- mimetype: "text/x-fossil-wiki"
- icomment:
Ticket change [5ce40de6c5] (rid 175145) by sebres on 2019-09-12 18:31:02:
- icomment:
Oh... I think I know what it could be (I guess you're starting test-sute using nmake? or in shell where nmake was previously executed) - it could be then this one - [/artifact?name=299e8aa5388b5861&ln=114|rules.vc#114]. Perhaps we should use another name for this. Anyway in win/Makefile.in it is called <code>WIN_DIR</code> and not <code>WINDIR</code>.
- login: "sebres"
- mimetype: "text/x-fossil-wiki"
- icomment:
Ticket change [7f0039826f] (rid 175160) by sebres on 2019-09-12 19:41:36:
- icomment:
I think cmdAH-25.3.1 (and related issues) are fixed now ([1b04153fe9] and [4be8da3560])... Please test it, Francois. @Jan: I know now why you've used some constraint on this test (resp. why it could fail in Travis :)
- login: "sebres"
- mimetype: "text/x-fossil-wiki"
- icomment:
Ticket change [99619dc5bf] (rid 175164) by fvogel on 2019-09-12 20:01:31:
- closedate changed to: "2458739.33439608"
- closer changed to: "fvogel"
- icomment:
That was it, nice catch! Now on neither Vista or Win10 $env(windir) is 'C:\Windows' as we may expect. And the test passes on both OSes. Great! And many thanks, Serguey! Actually it works even without [4be8da3560].
- login: "fvogel"
- mimetype: "text/x-fossil-wiki"
- status changed to: "Closed"