From bd1b2617db4b4a7b66fedf413f4dae993ec52ea5 Mon Sep 17 00:00:00 2001 From: Simon McVittie <smcv@collabora.com> Date: Wed, 17 Mar 2021 16:17:49 +0000 Subject: [PATCH] pv-runtime: Configure libasound.so.2 in Flatpak subsandbox too Signed-off-by: Simon McVittie <smcv@collabora.com> --- pressure-vessel/runtime.c | 25 +++++++++++++++++++++++-- pressure-vessel/runtime.h | 7 ++++--- pressure-vessel/wrap.c | 6 +++++- 3 files changed, 32 insertions(+), 6 deletions(-) diff --git a/pressure-vessel/runtime.c b/pressure-vessel/runtime.c index 9f85a3fc4..396c5e26b 100644 --- a/pressure-vessel/runtime.c +++ b/pressure-vessel/runtime.c @@ -4844,10 +4844,11 @@ pv_runtime_set_search_paths (PvRuntime *self, pv_environ_lock_env (container_env, "LD_LIBRARY_PATH", ld_library_path->str); } -void +gboolean pv_runtime_use_shared_sockets (PvRuntime *self, FlatpakBwrap *bwrap, - PvEnviron *container_env) + PvEnviron *container_env, + GError **error) { if (pv_environ_is_locked (container_env, "PULSE_SERVER") || self->is_flatpak_env) @@ -4865,7 +4866,27 @@ pv_runtime_use_shared_sockets (PvRuntime *self, "/etc/asound.conf", NULL); } + else if (self->mutable_sysroot_fd >= 0) + { + /* In a Flatpak sub-sandbox, we can rely on the fact that + * Flatpak will mount each item in our copy of the runtime's + * usr/etc/ into /etc, including some that we would normally + * skip. */ + if (!glnx_file_replace_contents_at (self->mutable_sysroot_fd, + "usr/etc/asound.conf", + (const guint8 *) alsa_config, + strlen (alsa_config), + GLNX_FILE_REPLACE_NODATASYNC, + NULL, error)) + return FALSE; + } + else + { + g_warning ("Unable to configure libasound.so.2 to use PulseAudio"); + } } + + return TRUE; } static void diff --git a/pressure-vessel/runtime.h b/pressure-vessel/runtime.h index 151e59e2e..1fe178e51 100644 --- a/pressure-vessel/runtime.h +++ b/pressure-vessel/runtime.h @@ -109,8 +109,9 @@ gboolean pv_runtime_garbage_collect_legacy (const char *variable_dir, const char *runtime_base, GError **error); -void pv_runtime_use_shared_sockets (PvRuntime *self, - FlatpakBwrap *bwrap, - PvEnviron *container_env); +gboolean pv_runtime_use_shared_sockets (PvRuntime *self, + FlatpakBwrap *bwrap, + PvEnviron *container_env, + GError **error); G_DEFINE_AUTOPTR_CLEANUP_FUNC (PvRuntime, g_object_unref) diff --git a/pressure-vessel/wrap.c b/pressure-vessel/wrap.c index ba37233a7..f46a44d6b 100644 --- a/pressure-vessel/wrap.c +++ b/pressure-vessel/wrap.c @@ -2418,7 +2418,11 @@ main (int argc, is_flatpak_env); if (runtime != NULL) - pv_runtime_use_shared_sockets (runtime, bwrap, container_env); + { + if (!pv_runtime_use_shared_sockets (runtime, bwrap, container_env, + error)) + goto out; + } if (is_flatpak_env) { -- GitLab