aboutsummaryrefslogtreecommitdiff
path: root/src/libutil/util.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/libutil/util.cc')
-rw-r--r--src/libutil/util.cc16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/libutil/util.cc b/src/libutil/util.cc
index a6552ebca..5468d1ed1 100644
--- a/src/libutil/util.cc
+++ b/src/libutil/util.cc
@@ -562,7 +562,7 @@ Path getConfigDir()
std::vector<Path> getConfigDirs()
{
Path configHome = getConfigDir();
- string configDirs = getEnv("XDG_CONFIG_DIRS").value_or("");
+ string configDirs = getEnv("XDG_CONFIG_DIRS").value_or("/etc/xdg");
std::vector<Path> result = tokenizeString<std::vector<string>>(configDirs, ":");
result.insert(result.begin(), configHome);
return result;
@@ -1631,6 +1631,7 @@ void setStackSize(size_t stackSize)
}
#endif
}
+
static AutoCloseFD fdSavedMountNamespace;
void saveMountNamespace()
@@ -1638,9 +1639,10 @@ void saveMountNamespace()
#if __linux__
static std::once_flag done;
std::call_once(done, []() {
- fdSavedMountNamespace = open("/proc/self/ns/mnt", O_RDONLY);
- if (!fdSavedMountNamespace)
+ AutoCloseFD fd = open("/proc/self/ns/mnt", O_RDONLY);
+ if (!fd)
throw SysError("saving parent mount namespace");
+ fdSavedMountNamespace = std::move(fd);
});
#endif
}
@@ -1648,8 +1650,12 @@ void saveMountNamespace()
void restoreMountNamespace()
{
#if __linux__
- if (fdSavedMountNamespace && setns(fdSavedMountNamespace.get(), CLONE_NEWNS) == -1)
- throw SysError("restoring parent mount namespace");
+ try {
+ if (fdSavedMountNamespace && setns(fdSavedMountNamespace.get(), CLONE_NEWNS) == -1)
+ throw SysError("restoring parent mount namespace");
+ } catch (Error & e) {
+ debug(e.msg());
+ }
#endif
}