Changeset 129924


Ignore:
Timestamp:
Dec 23, 2014, 10:27:30 AM (5 years ago)
Author:
ionic@…
Message:

base: handle symlink as basename correctly for trace mode sandbox.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/base/src/port1.0/porttrace.tcl

    r124216 r129924  
    6969
    7070        set normalizedPath [file normalize $path]
     71        # file normalize will leave symlinks as the very last
     72        # path component intact. This will, for instance, prevent /tmp from
     73        # being resolved to /private/tmp.
     74        # Also use file readlink to counter this behavior.
     75        # file readlink returns an error, if the last component is not
     76        # a symlink. Catch that.
     77        set resolvedPath {}
     78        if {![catch {file readlink $path}]} {
     79          set resolvedPath [file readlink $path]
     80
     81          if {[string length $resolvedPath] > 0 && [string index $resolvedPath 0] ne "/"} {
     82              # Canonicalize.
     83              set resolvedPath [file normalize [file dirname $path]/$resolvedPath]
     84          }
     85        }
    7186        lappend sndbxlst "[string map $mapping $path]=$action"
    7287        if {$normalizedPath ne $path} {
    7388            lappend sndbxlst "[string map $mapping $normalizedPath]=$action"
     89        }
     90        if {[string length $resolvedPath] > 0 && $resolvedPath ne $path} {
     91            lappend sndbxlst "[string map $mapping $resolvedPath]=$action"
    7492        }
    7593    }
Note: See TracChangeset for help on using the changeset viewer.