main: Unconditionally set up mount namespace
authorColin Walters <walters@verbum.org>
Sat, 9 Jan 2021 20:42:43 +0000 (20:42 +0000)
committerColin Walters <walters@verbum.org>
Sun, 10 Jan 2021 13:40:52 +0000 (13:40 +0000)
I was being very conservative initially here, but I think it's
really safe to just unconditionally set up the mount namespace.

This avoids having to check twice for a read-only `/sysroot`
(once in the binary and once in the library).

src/ostree/ot-main.c

index bffa40c4d44f6066b4d1c25bd07015ee3febfe2f..d153dcec5c8aa4cf8afdf2572147ebe3a011d3de 100644 (file)
@@ -122,26 +122,10 @@ maybe_setup_mount_namespace (gboolean    *out_ns,
   if (errno == ENOENT)
     return TRUE;
 
-  glnx_autofd int sysroot_subdir_fd = glnx_opendirat_with_errno (AT_FDCWD, "/sysroot", TRUE);
-  if (sysroot_subdir_fd < 0)
-    {
-      if (errno != ENOENT)
-        return glnx_throw_errno_prefix (error, "opendirat");
-      /* No /sysroot - nothing to do */
-      return TRUE;
-    }
-
-  struct statvfs stvfs;
-  if (fstatvfs (sysroot_subdir_fd, &stvfs) < 0)
-    return glnx_throw_errno_prefix (error, "fstatvfs");
-  if (stvfs.f_flag & ST_RDONLY)
-    {
-      if (unshare (CLONE_NEWNS) < 0)
-        return glnx_throw_errno_prefix (error, "preparing writable sysroot: unshare (CLONE_NEWNS)");
-
-      *out_ns = TRUE;
-    }
+  if (unshare (CLONE_NEWNS) < 0)
+    return glnx_throw_errno_prefix (error, "setting up mount namespace: unshare(CLONE_NEWNS)");
 
+  *out_ns = TRUE;
   return TRUE;
 }