diff options
-rw-r--r-- | common/flatpak-context.c | 7 | ||||
-rw-r--r-- | common/flatpak-context.h | 1 | ||||
-rw-r--r-- | common/flatpak-run.c | 19 | ||||
-rw-r--r-- | doc/flatpak-build-finish.xml | 4 | ||||
-rw-r--r-- | doc/flatpak-build.xml | 4 | ||||
-rw-r--r-- | doc/flatpak-metadata.xml | 2 | ||||
-rw-r--r-- | doc/flatpak-override.xml | 4 | ||||
-rw-r--r-- | doc/flatpak-run.xml | 4 |
8 files changed, 31 insertions, 14 deletions
diff --git a/common/flatpak-context.c b/common/flatpak-context.c index 209e84fc..1aa327d9 100644 --- a/common/flatpak-context.c +++ b/common/flatpak-context.c @@ -58,6 +58,7 @@ const char *flatpak_context_sockets[] = { "pulseaudio", "session-bus", "system-bus", + "fallback-x11", NULL }; @@ -815,6 +816,9 @@ option_socket_cb (const gchar *option_name, if (socket == 0) return FALSE; + if (socket == FLATPAK_CONTEXT_SOCKET_FALLBACK_X11) + socket |= FLATPAK_CONTEXT_SOCKET_X11; + flatpak_context_add_sockets (context, socket); return TRUE; @@ -833,6 +837,9 @@ option_nosocket_cb (const gchar *option_name, if (socket == 0) return FALSE; + if (socket == FLATPAK_CONTEXT_SOCKET_FALLBACK_X11) + socket |= FLATPAK_CONTEXT_SOCKET_X11; + flatpak_context_remove_sockets (context, socket); return TRUE; diff --git a/common/flatpak-context.h b/common/flatpak-context.h index ad92eecc..0beb8e71 100644 --- a/common/flatpak-context.h +++ b/common/flatpak-context.h @@ -39,6 +39,7 @@ typedef enum { FLATPAK_CONTEXT_SOCKET_PULSEAUDIO = 1 << 2, FLATPAK_CONTEXT_SOCKET_SESSION_BUS = 1 << 3, FLATPAK_CONTEXT_SOCKET_SYSTEM_BUS = 1 << 4, + FLATPAK_CONTEXT_SOCKET_FALLBACK_X11 = 1 << 5, /* For backwards compat, also set SOCKET_X11 */ } FlatpakContextSockets; typedef enum { diff --git a/common/flatpak-run.c b/common/flatpak-run.c index 91ba05af..2475e26a 100644 --- a/common/flatpak-run.c +++ b/common/flatpak-run.c @@ -266,12 +266,13 @@ flatpak_run_add_x11_args (FlatpakBwrap *bwrap, } -static void +static gboolean flatpak_run_add_wayland_args (FlatpakBwrap *bwrap) { const char *wayland_display; g_autofree char *wayland_socket = NULL; g_autofree char *sandbox_wayland_socket = NULL; + gboolean res = FALSE; wayland_display = g_getenv ("WAYLAND_DISPLAY"); if (!wayland_display) @@ -282,10 +283,12 @@ flatpak_run_add_wayland_args (FlatpakBwrap *bwrap) if (g_file_test (wayland_socket, G_FILE_TEST_EXISTS)) { + res = TRUE; flatpak_bwrap_add_args (bwrap, "--bind", wayland_socket, sandbox_wayland_socket, NULL); } + return res; } /* Try to find a default server from a pulseaudio confguration file */ @@ -764,6 +767,8 @@ flatpak_run_add_environment_args (FlatpakBwrap *bwrap, g_autoptr(GPtrArray) system_bus_proxy_argv = NULL; g_autoptr(GPtrArray) a11y_bus_proxy_argv = NULL; int sync_fds[2] = {-1, -1}; + gboolean has_wayland = FALSE; + gboolean allow_x11 = FALSE; if ((flags & FLATPAK_RUN_FLAG_NO_SESSION_BUS_PROXY) == 0) session_bus_proxy_argv = g_ptr_array_new_with_free_func (g_free); @@ -826,15 +831,19 @@ flatpak_run_add_environment_args (FlatpakBwrap *bwrap, flatpak_context_append_bwrap_filesystem (context, bwrap, app_id, app_id_dir, &exports); - flatpak_run_add_x11_args (bwrap, - (context->sockets & FLATPAK_CONTEXT_SOCKET_X11) != 0); - if (context->sockets & FLATPAK_CONTEXT_SOCKET_WAYLAND) { g_debug ("Allowing wayland access"); - flatpak_run_add_wayland_args (bwrap); + has_wayland = flatpak_run_add_wayland_args (bwrap); } + if ((context->sockets & FLATPAK_CONTEXT_SOCKET_FALLBACK_X11) != 0) + allow_x11 = !has_wayland; + else + allow_x11 = (context->sockets & FLATPAK_CONTEXT_SOCKET_X11) != 0; + + flatpak_run_add_x11_args (bwrap, allow_x11); + if (context->sockets & FLATPAK_CONTEXT_SOCKET_PULSEAUDIO) { g_debug ("Allowing pulseaudio access"); diff --git a/doc/flatpak-build-finish.xml b/doc/flatpak-build-finish.xml index 8a08e811..423884c1 100644 --- a/doc/flatpak-build-finish.xml +++ b/doc/flatpak-build-finish.xml @@ -122,7 +122,7 @@ <listitem><para> Expose a well known socket to the application. This updates the [Context] group in the metadata. - SOCKET must be one of: x11, wayland, pulseaudio, system-bus, session-bus. + SOCKET must be one of: x11, wayland, fallback-x11, pulseaudio, system-bus, session-bus. This option can be used multiple times. </para></listitem> </varlistentry> @@ -133,7 +133,7 @@ <listitem><para> Don't expose a well known socket to the application. This updates the [Context] group in the metadata. - SOCKET must be one of: x11, wayland, pulseaudio, system-bus, session-bus. + SOCKET must be one of: x11, wayland, fallback-x11, pulseaudio, system-bus, session-bus. This option can be used multiple times. </para></listitem> </varlistentry> diff --git a/doc/flatpak-build.xml b/doc/flatpak-build.xml index a5fae029..e3d5ff1b 100644 --- a/doc/flatpak-build.xml +++ b/doc/flatpak-build.xml @@ -140,7 +140,7 @@ <listitem><para> Expose a well-known socket to the application. This overrides to the Context section from the application metadata. - SOCKET must be one of: x11, wayland, pulseaudio, system-bus, session-bus. + SOCKET must be one of: x11, wayland, fallback-x11, pulseaudio, system-bus, session-bus. This option can be used multiple times. </para></listitem> </varlistentry> @@ -151,7 +151,7 @@ <listitem><para> Don't expose a well-known socket to the application. This overrides to the Context section from the application metadata. - SOCKET must be one of: x11, wayland, pulseaudio, system-bus, session-bus. + SOCKET must be one of: x11, wayland, fallback-x11, pulseaudio, system-bus, session-bus. This option can be used multiple times. </para></listitem> </varlistentry> diff --git a/doc/flatpak-metadata.xml b/doc/flatpak-metadata.xml index 122aec21..bc330c16 100644 --- a/doc/flatpak-metadata.xml +++ b/doc/flatpak-metadata.xml @@ -142,7 +142,7 @@ <term><option>sockets</option> (list)</term> <listitem><para> List of well-known sockets to make available in the sandbox. - Possible sockets: x11, wayland, pulseaudio, session-bus, system-bus. + Possible sockets: x11, wayland, fallback-x11, pulseaudio, session-bus, system-bus. When making a socket available, flatpak also sets well-known environment variables like DISPLAY or DBUS_SYSTEM_BUS_ADDRESS to let the application diff --git a/doc/flatpak-override.xml b/doc/flatpak-override.xml index b5ce3784..73f8bc18 100644 --- a/doc/flatpak-override.xml +++ b/doc/flatpak-override.xml @@ -130,7 +130,7 @@ <listitem><para> Expose a well-known socket to the application. This overrides to the Context section from the application metadata. - SOCKET must be one of: x11, wayland, pulseaudio, system-bus, session-bus. + SOCKET must be one of: x11, wayland, fallback-x11, pulseaudio, system-bus, session-bus. This option can be used multiple times. </para></listitem> </varlistentry> @@ -141,7 +141,7 @@ <listitem><para> Don't expose a well-known socket to the application. This overrides to the Context section from the application metadata. - SOCKET must be one of: x11, wayland, pulseaudio, system-bus, session-bus. + SOCKET must be one of: x11, wayland, fallback-x11, pulseaudio, system-bus, session-bus. This option can be used multiple times. </para></listitem> </varlistentry> diff --git a/doc/flatpak-run.xml b/doc/flatpak-run.xml index 0294a150..4de12bb3 100644 --- a/doc/flatpak-run.xml +++ b/doc/flatpak-run.xml @@ -181,7 +181,7 @@ <listitem><para> Expose a well known socket to the application. This overrides to the Context section from the application metadata. - SOCKET must be one of: x11, wayland, pulseaudio, system-bus, session-bus. + SOCKET must be one of: x11, wayland, fallback-x11, pulseaudio, system-bus, session-bus. This option can be used multiple times. </para></listitem> </varlistentry> @@ -192,7 +192,7 @@ <listitem><para> Don't expose a well known socket to the application. This overrides to the Context section from the application metadata. - SOCKET must be one of: x11, wayland, pulseaudio, system-bus, session-bus. + SOCKET must be one of: x11, wayland, fallback-x11, pulseaudio, system-bus, session-bus. This option can be used multiple times. </para></listitem> </varlistentry> |