Tcl Source Code

View Ticket
Login
Ticket UUID: 8527d8becf29df06d2563a2abde5983043285f18
Title: Commands cd, glob and normalize may fail on Windows if used with network locations containing NTFS junctions
Type: Bug Created on: 2016-03-02 21:29:24
Submitter: mfriedrich Assigned to: nobody
Subsystem: 36. Pathname Management Severity: Important
Priority: 5 Medium Last modified: 2016-03-02 21:29:24
Status: Open Closed by: nobody
Resolution: None Closed on:
Version: 8.6.4.1
Description:
On Windows, it seems if paths are used which point to network locations. and those network locations contain junctions, then Tcl resolves those junctions, but should not. Those junctions always point to drives on the server. Tcl treats them as local drives, which they are not.

To test:
On a Windows server (must not be the same as the below Windows client):
* add a new drive/partition, format as NTFS and give it the letter P
* create this folder structure: P:\Share\Bar\subdir
* create a junction: P:\Share\Foo pointing to --> P:\Share\Bar
* create a dummy file: P:\Share\Bar\subdir\dummy.txt
* create local user "user" with password "password"
* share the folder P:\Share as ShareOnDriveP for user "user" full access

On the Windows client/workstation side with a Tcl installation:
* mount the network share as drive M:
   net use m: \\server\ShareOnDriveP /user:server\user password
* make sure you have no local drive with letter P
* run this on tclsh.exe

set result 0

puts "M:/Foo/subdir=[file normalize M:/Foo/subdir]"
puts "M:/Bar/subdir=[file normalize M:/Bar/subdir]"
puts "\n"

if {[catch {
    cd M:/Bar/subdir
    set dir [pwd]
    if {$dir ne "M:/Bar/subdir"} {
      puts stderr "test 1 failed"
      set result 1
    } else {
      puts stderr "test 1 passed"
    }
} status]} {
    puts stderr "test 1 failed\n$errorInfo"
    set result 1
}

puts "\n"

if {[catch {
    cd M:/Bar
    cd subdir

    set dir [pwd]
    if {$dir ne "M:/Bar/subdir"} {
      puts stderr "test 2 failed"
      set result 1
    } else {
      puts stderr "test 2 passed"
    }
} status]} {
    puts stderr "test 2 failed\n$errorInfo"
    set result 1
}

puts "\n"

if {[catch {
    cd C:/

    set list [glob -directory M:/Bar/subdir -tail *]
    if {$list ne {dummy.txt}} {
      puts stderr "test 3 failed"
      set result 1
    } else {
      puts stderr "test 3 passed"
    }
} status]} {
    puts stderr "test 3 failed\n$errorInfo"
    set result 1
}

cd C:/
file delete C:/test-link
file delete -force C:/test-target
exit $result



It produces the output:
M:/Foo/subdir=M:/Foo/subdir
M:/Bar/subdir=/Bar/subdir


test 1 failed
couldn't change working directory to "M:/Bar/subdir": no such file or directory
    while executing
"cd M:/Bar/subdir"


test 2 passed


test 3 failed
couldn't read directory "/Bar/subdir/*": no such file or directory
    while executing
"glob -directory M:/Bar/subdir -tail *"