[129924] trunk/base/src/port1.0/porttrace.tcl

ionic at macports.org ionic at macports.org
Tue Dec 23 02:27:30 PST 2014


Revision: 129924
          https://trac.macports.org/changeset/129924
Author:   ionic at macports.org
Date:     2014-12-23 02:27:30 -0800 (Tue, 23 Dec 2014)
Log Message:
-----------
base: handle symlink as basename correctly for trace mode sandbox.

Modified Paths:
--------------
    trunk/base/src/port1.0/porttrace.tcl

Modified: trunk/base/src/port1.0/porttrace.tcl
===================================================================
--- trunk/base/src/port1.0/porttrace.tcl	2014-12-23 08:07:12 UTC (rev 129923)
+++ trunk/base/src/port1.0/porttrace.tcl	2014-12-23 10:27:30 UTC (rev 129924)
@@ -68,10 +68,28 @@
         lappend mapping "=" "\\="
 
         set normalizedPath [file normalize $path]
+        # file normalize will leave symlinks as the very last
+        # path component intact. This will, for instance, prevent /tmp from
+        # being resolved to /private/tmp.
+        # Also use file readlink to counter this behavior.
+        # file readlink returns an error, if the last component is not
+        # a symlink. Catch that.
+        set resolvedPath {}
+        if {![catch {file readlink $path}]} {
+          set resolvedPath [file readlink $path]
+
+          if {[string length $resolvedPath] > 0 && [string index $resolvedPath 0] ne "/"} {
+              # Canonicalize.
+              set resolvedPath [file normalize [file dirname $path]/$resolvedPath]
+          }
+        }
         lappend sndbxlst "[string map $mapping $path]=$action"
         if {$normalizedPath ne $path} {
             lappend sndbxlst "[string map $mapping $normalizedPath]=$action"
         }
+        if {[string length $resolvedPath] > 0 && $resolvedPath ne $path} {
+            lappend sndbxlst "[string map $mapping $resolvedPath]=$action"
+        }
     }
 
     ##
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/macports-changes/attachments/20141223/2ba3ae1f/attachment.html>


More information about the macports-changes mailing list