Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: b4aa09ee9c8a4d788f2e623c3f31abb4c1a0d51bcbf4bb67b9f0538fe6c27922
Ticket: 7de2d722bd599da5db26b42ed8addb16a66c832c
cmdAH-25.2 (Tcl_FileObjCmd: owned) fails on Windows
User & Date: sebres on 2019-09-10 12:03:58
Changes

  1. 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).
    
  2. login: "sebres"
  3. mimetype: "text/x-fossil-wiki"