From 5fb066bf903ba2d31625e940d4b5a402a6230f28 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Fri, 24 Jun 2016 01:52:55 -0400 Subject: [PATCH 1/2] Add an option for journal sockets Untested, I couldn't find a runtime that has systemd-cat or a similar tool in it. --- common/flatpak-run.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/common/flatpak-run.c b/common/flatpak-run.c index 3c063713..b1f9e593 100644 --- a/common/flatpak-run.c +++ b/common/flatpak-run.c @@ -72,6 +72,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_JOURNAL = 1 << 5, } FlatpakContextSockets; /* Same order as enum */ @@ -81,6 +82,7 @@ const char *flatpak_context_sockets[] = { "pulseaudio", "session-bus", "system-bus", + "journal", NULL }; @@ -1531,6 +1533,27 @@ flatpak_run_add_pulseaudio_args (GPtrArray *argv_array, } } +static void +flatpak_run_add_journal_args (GPtrArray *argv_array, + char ***envp_p) +{ + const char *journal_socket_socket = g_strdup ("/run/systemd/journal/socket"); + const char *journal_stdout_socket = g_strdup ("/run/systemd/journal/stdout"); + + if (g_file_test (journal_socket_socket, G_FILE_TEST_EXISTS)) + { + add_args (argv_array, + "--bind", journal_socket_socket, journal_socket_socket, + NULL); + } + if (g_file_test (journal_stdout_socket, G_FILE_TEST_EXISTS)) + { + add_args (argv_array, + "--bind", journal_stdout_socket, journal_stdout_socket, + NULL); + } +} + static char * create_proxy_socket (char *template) { @@ -1974,6 +1997,12 @@ flatpak_run_add_environment_args (GPtrArray *argv_array, flatpak_run_add_pulseaudio_args (argv_array, fd_array, envp_p); } + if (context->sockets & FLATPAK_CONTEXT_SOCKET_JOURNAL) + { + g_debug ("Allowing journal access"); + flatpak_run_add_journal_args (argv_array, envp_p); + } + unrestricted_session_bus = (context->sockets & FLATPAK_CONTEXT_SOCKET_SESSION_BUS) != 0; if (unrestricted_session_bus) g_debug ("Allowing session-dbus access"); From f6af5702db88e906c782f9c7028390a554d7a5cb Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Fri, 24 Jun 2016 02:01:05 -0400 Subject: [PATCH 2/2] Document new socket option --- doc/flatpak-build-finish.xml | 4 ++-- doc/flatpak-build.xml | 4 ++-- doc/flatpak-override.xml | 4 ++-- doc/flatpak-run.xml | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/doc/flatpak-build-finish.xml b/doc/flatpak-build-finish.xml index 5db1bed5..980cd2c2 100644 --- a/doc/flatpak-build-finish.xml +++ b/doc/flatpak-build-finish.xml @@ -114,7 +114,7 @@ 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, pulseaudio, system-bus, session-bus, journal. This option can be used multiple times. @@ -125,7 +125,7 @@ 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, pulseaudio, system-bus, session-bus, journal. This option can be used multiple times. diff --git a/doc/flatpak-build.xml b/doc/flatpak-build.xml index a802753c..f2cdc6fe 100644 --- a/doc/flatpak-build.xml +++ b/doc/flatpak-build.xml @@ -139,7 +139,7 @@ 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, pulseaudio, system-bus, session-bus, journal. This option can be used multiple times. @@ -150,7 +150,7 @@ 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, pulseaudio, system-bus, session-bus, journal. This option can be used multiple times. diff --git a/doc/flatpak-override.xml b/doc/flatpak-override.xml index 5946f332..11108470 100644 --- a/doc/flatpak-override.xml +++ b/doc/flatpak-override.xml @@ -95,7 +95,7 @@ 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, pulseaudio, system-bus, session-bus, journal. This option can be used multiple times. @@ -106,7 +106,7 @@ 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, pulseaudio, system-bus, session-bus, journal. This option can be used multiple times. diff --git a/doc/flatpak-run.xml b/doc/flatpak-run.xml index 2911e8aa..7fc0b27d 100644 --- a/doc/flatpak-run.xml +++ b/doc/flatpak-run.xml @@ -173,7 +173,7 @@ 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, pulseaudio, system-bus, session-bus, journal. This option can be used multiple times. @@ -184,7 +184,7 @@ 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, pulseaudio, system-bus, session-bus, journal. This option can be used multiple times.