From 767d03ebf5291d64f2d18fe8ac7faf21e6db2e8d Mon Sep 17 00:00:00 2001 From: Simon McVittie <smcv@collabora.com> Date: Fri, 11 Dec 2020 18:05:03 +0000 Subject: [PATCH] runtime: Cope with /tmp being a symlink If /tmp is a symlink in the current execution environment, then when we ask bwrap to bind-mount /tmp/pressure-vessel-wrap.XXXXXX/overrides over itself, it will try to create the parent directory /tmp, and fail because there's a symlink in the way. Canonicalize the path and use that instead. Partially addresses https://github.com/ValveSoftware/steam-runtime/issues/321 (symlinks "above" the home directory have the same problem, but are harder to fix). Signed-off-by: Simon McVittie <smcv@collabora.com> --- pressure-vessel/runtime.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pressure-vessel/runtime.c b/pressure-vessel/runtime.c index 925d96ea3..5c0322f1c 100644 --- a/pressure-vessel/runtime.c +++ b/pressure-vessel/runtime.c @@ -887,11 +887,17 @@ pv_runtime_initable_init (GInitable *initable, { /* We currently only need a temporary directory if we don't have * a mutable sysroot to work with. */ - self->tmpdir = g_dir_make_tmp ("pressure-vessel-wrap.XXXXXX", error); + g_autofree gchar *tmpdir = g_dir_make_tmp ("pressure-vessel-wrap.XXXXXX", + error); - if (self->tmpdir == NULL) + if (tmpdir == NULL) return FALSE; + self->tmpdir = realpath (tmpdir, NULL); + + if (self->tmpdir == NULL) + return glnx_throw_errno_prefix (error, "realpath(\"%s\")", tmpdir); + self->overrides = g_build_filename (self->tmpdir, "overrides", NULL); self->overrides_in_container = "/overrides"; self->runtime_files = self->source_files; -- GitLab