From d8695f307115df2eac1996cd23e24e07d452ebb2 Mon Sep 17 00:00:00 2001 From: Erick555 <37542552+Erick555@users.noreply.github.com> Date: Sun, 6 Nov 2022 23:35:05 +0000 Subject: [PATCH] Clear more temporary file paths from env This supplements clearing TMPDIR env variable which is only one among variables used for storing temporary files. Any of those leaking from host may confuse flatpak apps which try to save temporary files under non-existing directory in sandbox. See https://github.com/flathub/com.logseq.Logseq/issues/29 for real world example. --- common/flatpak-run.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/common/flatpak-run.c b/common/flatpak-run.c index b650be46..8e3c8ad7 100644 --- a/common/flatpak-run.c +++ b/common/flatpak-run.c @@ -1880,7 +1880,11 @@ static const ExportData default_exports[] = { {"XDG_CONFIG_DIRS", "/app/etc/xdg:/etc/xdg"}, {"XDG_DATA_DIRS", "/app/share:/usr/share"}, {"SHELL", "/bin/sh"}, - {"TMPDIR", NULL}, /* Unset TMPDIR as it may not exist in the sandbox */ + /* Unset temporary file paths as they may not exist in the sandbox */ + {"TEMP", NULL}, + {"TEMPDIR", NULL}, + {"TMP", NULL}, + {"TMPDIR", NULL}, /* We always use /run/user/UID, even if the user's XDG_RUNTIME_DIR * outside the sandbox is somewhere else. Don't allow a different * setting from outside the sandbox to overwrite this. */