aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCole Helbling <cole.e.helbling@outlook.com>2022-04-04 08:19:49 -0700
committerCole Helbling <cole.e.helbling@outlook.com>2022-04-04 08:20:11 -0700
commite5b70d47aa656833e4609106f9f1ef48b67664cc (patch)
treee5633158df23d5b57579c740884e7b56efd9cb05 /src
parent2a45cf54e4201a894254604676dcb51f4c1a471c (diff)
libutil: cleanup savedCwd logic
Co-authored-by: Eelco Dolstra <edolstra@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/libutil/util.cc15
1 files changed, 1 insertions, 14 deletions
diff --git a/src/libutil/util.cc b/src/libutil/util.cc
index 28ab77adc..9b34d5d72 100644
--- a/src/libutil/util.cc
+++ b/src/libutil/util.cc
@@ -1698,20 +1698,7 @@ void saveMountNamespace()
#if __linux__
static std::once_flag done;
std::call_once(done, []() {
-#ifdef __GNU__
- // getcwd allocating its return value is a GNU extension.
- char *cwd = getcwd(NULL, 0);
- if (cwd == NULL)
-#else
- char cwd[PATH_MAX];
- if (!getcwd(cwd, sizeof(cwd)))
-#endif
- throw SysError("getting cwd");
- savedCwd.emplace(cwd);
-#ifdef __GNU__
- free(cwd);
-#endif
-
+ savedCwd = absPath(".");
AutoCloseFD fd = open("/proc/self/ns/mnt", O_RDONLY);
if (!fd)
throw SysError("saving parent mount namespace");