Update darwin build for optional sandbox paths

Fixes #1132

(cherry picked from commit 8bf378e999)
This commit is contained in:
Shea Levy 2016-11-17 08:06:00 -05:00 committed by Eelco Dolstra
parent 2eb840eefa
commit 612c77a399
No known key found for this signature in database
GPG key ID: 8170B4726D7198DE

View file

@ -2540,15 +2540,18 @@ void DerivationGoal::runChild()
*/ */
sandboxProfile += "(allow file-read* file-write* process-exec\n"; sandboxProfile += "(allow file-read* file-write* process-exec\n";
for (auto & i : dirsInChroot) { for (auto & i : dirsInChroot) {
if (i.first != i.second) if (i.first != i.second.source)
throw Error(format( throw Error(format(
"can't map '%1%' to '%2%': mismatched impure paths not supported on Darwin") "can't map '%1%' to '%2%': mismatched impure paths not supported on Darwin")
% i.first % i.second); % i.first % i.second.source);
string path = i.first; string path = i.first;
struct stat st; struct stat st;
if (lstat(path.c_str(), &st)) if (lstat(path.c_str(), &st)) {
if (i.second.optional && errno == ENOENT)
continue;
throw SysError(format("getting attributes of path %1%") % path); throw SysError(format("getting attributes of path %1%") % path);
}
if (S_ISDIR(st.st_mode)) if (S_ISDIR(st.st_mode))
sandboxProfile += (format("\t(subpath \"%1%\")\n") % path).str(); sandboxProfile += (format("\t(subpath \"%1%\")\n") % path).str();
else else