From 3a282e573395c4d0db21b0444848fb872d00b9f0 Mon Sep 17 00:00:00 2001
From: Simon McVittie <smcv@collabora.com>
Date: Fri, 19 Apr 2024 17:01:41 +0100
Subject: [PATCH] pv-utils: Reserve more paths used internally by
 pressure-vessel

This avoids a failure mode seen on ClearLinux where including /var/cache
in XDG_DATA_DIRS would prevent pressure-vessel startup.

It also preemptively avoids the same situation potentially happening for
/run/host, /run/parent and similar paths.

steamrt/tasks#434

Resolves: https://github.com/ValveSoftware/steam-for-linux/issues/10789
Signed-off-by: Simon McVittie <smcv@collabora.com>
---
 pressure-vessel/utils.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/pressure-vessel/utils.c b/pressure-vessel/utils.c
index 05c2d7167..021aa7c07 100644
--- a/pressure-vessel/utils.c
+++ b/pressure-vessel/utils.c
@@ -48,6 +48,10 @@
  * Return reserved directories above or below which user-specified "exports"
  * are not allowed.
  *
+ * For example, `/var/cache/ldconfig/ld.so.cache` needs to be controlled
+ * by the runtime, so any attempt to export `/var/cache/ldconfig`,
+ * `/var/cache` or `/var` needs to be ignored.
+ *
  * Returns: (array zero-terminated=1) (transfer none): A NULL-terminated
  *  array of absolute paths
  */
@@ -56,6 +60,8 @@ pv_get_reserved_paths (void)
 {
   static const char * const paths[] =
   {
+    /* Reserved by Flatpak-derived code */
+    "/.flatpak-info",
     /* Reserved by Flatpak-derived code */
     "/app",
     /* Conceptually part of /usr */
@@ -72,6 +78,16 @@ pv_get_reserved_paths (void)
     "/lib64",
     /* Managed separately */
     "/proc",
+    /* Reserved by Flatpak-derived code */
+    "/run/flatpak",
+    /* Used to mount the graphics provider if not the host */
+    "/run/gfx",
+    /* Used to mount the host filesystem */
+    "/run/host",
+    /* Used to mount the real host filesystem under FEX-Emu */
+    "/run/interpreter-host",
+    /* Used when running in a Flatpak subsandbox */
+    "/run/parent",
     /* Sockets, /run/pressure-vessel/pv-from-host, etc. */
     "/run/pressure-vessel",
     /* Conceptually part of /usr */
@@ -80,6 +96,8 @@ pv_get_reserved_paths (void)
     "/usr",
     /* Used to mount parts of the graphics stack provider */
     "/var/pressure-vessel",
+    /* We need to manage this for compatibility with ClearLinux ld.so */
+    "/var/cache/ldconfig",
     NULL
   };
 
-- 
GitLab