Skip to content

Commit 940e9eb

Browse files
authored
Merge pull request #8240 from tweag/macos-sandbox
ci: Always run with sandbox, even on Darwin
2 parents f41dd2c + 2c46248 commit 940e9eb

File tree

6 files changed

+25
-3
lines changed

6 files changed

+25
-3
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ jobs:
2020
with:
2121
fetch-depth: 0
2222
- uses: cachix/install-nix-action@v20
23+
with:
24+
# The sandbox would otherwise be disabled by default on Darwin
25+
extra_nix_config: "sandbox = true"
2326
- run: echo CACHIX_NAME="$(echo $GITHUB_REPOSITORY-install-tests | tr "[A-Z]/" "[a-z]-")" >> $GITHUB_ENV
2427
- uses: cachix/cachix-action@v12
2528
if: needs.check_secrets.outputs.cachix == 'true'

src/libexpr/eval.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2620,7 +2620,7 @@ Strings EvalSettings::getDefaultNixPath()
26202620
{
26212621
Strings res;
26222622
auto add = [&](const Path & p, const std::string & s = std::string()) {
2623-
if (pathExists(p)) {
2623+
if (pathAccessible(p)) {
26242624
if (s.empty()) {
26252625
res.push_back(p);
26262626
} else {

src/libstore/globals.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ bool Settings::isWSL1()
183183
Path Settings::getDefaultSSLCertFile()
184184
{
185185
for (auto & fn : {"/etc/ssl/certs/ca-certificates.crt", "/nix/var/nix/profiles/default/etc/ssl/certs/ca-bundle.crt"})
186-
if (pathExists(fn)) return fn;
186+
if (pathAccessible(fn)) return fn;
187187
return "";
188188
}
189189

src/libutil/tests/tests.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ namespace nix {
202202
}
203203

204204
TEST(pathExists, bogusPathDoesNotExist) {
205-
ASSERT_FALSE(pathExists("/home/schnitzel/darmstadt/pommes"));
205+
ASSERT_FALSE(pathExists("/schnitzel/darmstadt/pommes"));
206206
}
207207

208208
/* ----------------------------------------------------------------------------

src/libutil/util.cc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,17 @@ bool pathExists(const Path & path)
266266
return false;
267267
}
268268

269+
bool pathAccessible(const Path & path)
270+
{
271+
try {
272+
return pathExists(path);
273+
} catch (SysError & e) {
274+
// swallow EPERM
275+
if (e.errNo == EPERM) return false;
276+
throw;
277+
}
278+
}
279+
269280

270281
Path readLink(const Path & path)
271282
{

src/libutil/util.hh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,14 @@ struct stat lstat(const Path & path);
120120
*/
121121
bool pathExists(const Path & path);
122122

123+
/**
124+
* A version of pathExists that returns false on a permission error.
125+
* Useful for inferring default paths across directories that might not
126+
* be readable.
127+
* @return true iff the given path can be accessed and exists
128+
*/
129+
bool pathAccessible(const Path & path);
130+
123131
/**
124132
* Read the contents (target) of a symbolic link. The result is not
125133
* in any way canonicalised.

0 commit comments

Comments
 (0)