diff --git a/pressure-vessel/runtime.c b/pressure-vessel/runtime.c index 9f85a3fc436f11a884de7402ec59fcf663107704..396c5e26bce883d61a76c0a2bbc09e19ed66e585 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 151e59e2e4d522c7e56ad0475d0168e4bede16f7..1fe178e51d1f344945c6d9092460da350706b111 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 ba37233a7ed98402efbbbca77801f7f9f657c4fe..f46a44d6bdbb1e2bf2da440754422cc7927e46cd 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) {