<pre style='margin:0'>
Clemens Lang (neverpanic) pushed a commit to branch master
in repository macports-base.
</pre>
<p><a href="https://github.com/macports/macports-base/commit/652c0b2aa03562ff4c1cdbb1676994b5a6886624">https://github.com/macports/macports-base/commit/652c0b2aa03562ff4c1cdbb1676994b5a6886624</a></p>
<pre style="white-space: pre; background: #F8F8F8">The following commit(s) were added to refs/heads/master by this push:
<span style='display:block; white-space:pre;color:#404040;'> new 652c0b2a sandbox: handle /opt/local on separate mountpoint
</span>652c0b2a is described below
<span style='display:block; white-space:pre;color:#808000;'>commit 652c0b2aa03562ff4c1cdbb1676994b5a6886624
</span>Author: Dan Villiom Podlaski Christiansen <danchr@gmail.com>
AuthorDate: Mon Aug 31 12:04:48 2020 +0200
<span style='display:block; white-space:pre;color:#404040;'> sandbox: handle /opt/local on separate mountpoint
</span><span style='display:block; white-space:pre;color:#404040;'>
</span><span style='display:block; white-space:pre;color:#404040;'> Some Xcode builds will fail when /opt is on a separate volume. The
</span><span style='display:block; white-space:pre;color:#404040;'> nature of the errors vary, for example `tiffutil` will frequently
</span><span style='display:block; white-space:pre;color:#404040;'> fail. They're all permission-related errors, though.
</span><span style='display:block; white-space:pre;color:#404040;'>
</span><span style='display:block; white-space:pre;color:#404040;'> Looking at the system logs, I noticed this:
</span><span style='display:block; white-space:pre;color:#404040;'>
</span><span style='display:block; white-space:pre;color:#404040;'> localhost kernel[0]: (Sandbox) Sandbox: tiffutil(99434) deny(1) file-write-create /opt/.TemporaryItems/folders.502/TemporaryItems/(A Document Being Saved By tiffutil)
</span><span style='display:block; white-space:pre;color:#404040;'>
</span><span style='display:block; white-space:pre;color:#404040;'> To address this, I added some code that should detect the mountpoint
</span><span style='display:block; white-space:pre;color:#404040;'> for `${prefix}`, and add its `.TemporaryItems` to the allowed
</span><span style='display:block; white-space:pre;color:#404040;'> directories.
</span>---
src/port1.0/portsandbox.tcl | 17 ++++++++++++++++-
src/port1.0/portutil.tcl | 19 +++++++++++++++++++
2 files changed, 35 insertions(+), 1 deletion(-)
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/src/port1.0/portsandbox.tcl b/src/port1.0/portsandbox.tcl
</span><span style='display:block; white-space:pre;color:#808080;'>index e03d0e22..6a2c2cc3 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/src/port1.0/portsandbox.tcl
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/src/port1.0/portsandbox.tcl
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -29,6 +29,7 @@
</span>
package provide portsandbox 1.0
package require porttrace 1.0
<span style='display:block; white-space:pre;background:#e0ffe0;'>+package require portutil 1.0
</span>
namespace eval portsandbox {
}
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -44,7 +45,7 @@ default portsandbox_profile {}
</span> proc portsandbox::set_profile {target} {
global os.major portsandbox_profile workpath distpath \
package.destpath configure.ccache ccache_dir \
<span style='display:block; white-space:pre;background:#ffe0e0;'>- sandbox_network configure.distcc porttrace
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ sandbox_network configure.distcc porttrace prefix
</span>
switch $target {
activate -
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -100,6 +101,20 @@ proc portsandbox::set_profile {target} {
</span> lappend perms file-write-setugid
}
<span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ # If ${prefix} is own its own volume, grant access to its
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ # temporary items directory, used by Xcode tools
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set mountpoint [get_mountpoint ${prefix}]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {$mountpoint != "/"} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set extradir [file join $mountpoint ".TemporaryItems"]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[file isdirectory $extradir]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ui_debug "adding $extradir to allowed Sandbox paths"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ lappend allow_dirs $extradir
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span> foreach dir $allow_dirs {
foreach perm $perms {
append portsandbox_profile " (allow $perm ("
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/src/port1.0/portutil.tcl b/src/port1.0/portutil.tcl
</span><span style='display:block; white-space:pre;color:#808080;'>index c809b99f..4ab8369e 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/src/port1.0/portutil.tcl
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/src/port1.0/portutil.tcl
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -3469,3 +3469,22 @@ proc _archive_available {} {
</span> set archive_available_result 0
return 0
}
<span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+# get the mountpoint providing a given directory
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+proc get_mountpoint {target_dir} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ file stat ${target_dir} target_stat
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set parentdir ${target_dir}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ while {$parentdir ne "/"} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ file stat [file dirname $parentdir] stat
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {$stat(dev) != $target_stat(dev)} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return $parentdir
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set parentdir [file dirname $parentdir]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return $parentdir
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+}
</span></pre><pre style='margin:0'>
</pre>