diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2021-11-16 14:23:05 +0100 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2021-11-16 14:48:44 +0100 |
commit | 8c93a481af2ce8fbcdb9e2bbcc9559d52703112f (patch) | |
tree | 1ac6f16a86550d4e6e4dec3635608ff574033203 /src/nix/main.cc | |
parent | 51ffc19f02e78d7bea31c2916bc18798183f9ca1 (diff) |
Ignore errors unsharing/restoring the mount namespace
This prevents Nix from barfing when run in a container where it
doesn't have the appropriate privileges.
Diffstat (limited to 'src/nix/main.cc')
-rw-r--r-- | src/nix/main.cc | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/nix/main.cc b/src/nix/main.cc index 01889a71f..60b0aa410 100644 --- a/src/nix/main.cc +++ b/src/nix/main.cc @@ -257,9 +257,11 @@ void mainWrapped(int argc, char * * argv) #if __linux__ if (getuid() == 0) { - saveMountNamespace(); - if (unshare(CLONE_NEWNS) == -1) - throw SysError("setting up a private mount namespace"); + try { + saveMountNamespace(); + if (unshare(CLONE_NEWNS) == -1) + throw SysError("setting up a private mount namespace"); + } catch (Error & e) { } } #endif |