diff options
author | Adam Joseph <adam@westernsemico.com> | 2022-07-19 03:49:52 -0700 |
---|---|---|
committer | Adam Joseph <adam@westernsemico.com> | 2022-07-19 03:53:20 -0700 |
commit | 36e1383b6b32abd414c8402dd66f7ef78f93f4e1 (patch) | |
tree | 73d3bc0d27b17ba81facd3fe8b6b97bda8d21633 | |
parent | a9e75eca00f7efe361545c6e77ecb65244230dc3 (diff) |
local-derivation-goal.cc: save global errno to the stack before performing tests which might clobber it
-rw-r--r-- | src/libstore/build/local-derivation-goal.cc | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/libstore/build/local-derivation-goal.cc b/src/libstore/build/local-derivation-goal.cc index 43df41e34..79a241ae0 100644 --- a/src/libstore/build/local-derivation-goal.cc +++ b/src/libstore/build/local-derivation-goal.cc @@ -851,10 +851,11 @@ void LocalDerivationGoal::startBuilder() flags &= ~CLONE_NEWUSER; child = clone(childEntry, stack + stackSize, flags, this); } - if (child == -1) + if (child == -1) { switch(errno) { case EPERM: case EINVAL: { + int errno_ = errno; if (!userNamespacesEnabled && errno==EPERM) notice("user namespaces appear to be disabled; they are required for sandboxing; check /proc/sys/user/max_user_namespaces"); if (userNamespacesEnabled) { @@ -875,11 +876,12 @@ void LocalDerivationGoal::startBuilder() /* Mention sandbox-fallback in the error message so the user knows that having it disabled contributed to the unrecoverability of this failure */ - throw SysError("creating sandboxed builder process using clone(), without sandbox-fallback"); + throw SysError(errno_, "creating sandboxed builder process using clone(), without sandbox-fallback"); } default: throw SysError("creating sandboxed builder process using clone()"); } + } writeFull(builderOut.writeSide.get(), fmt("%d %d\n", usingUserNamespace, child)); _exit(0); |