Add --socket=gpg-agent

This commit is contained in:
Nick Reiley
2022-06-21 00:51:18 +05:00
committed by Alexander Larsson
parent 061102df30
commit 764e5a4d0c
7 changed files with 55 additions and 8 deletions

View File

@@ -49,6 +49,7 @@ typedef enum {
FLATPAK_CONTEXT_SOCKET_SSH_AUTH = 1 << 6,
FLATPAK_CONTEXT_SOCKET_PCSC = 1 << 7,
FLATPAK_CONTEXT_SOCKET_CUPS = 1 << 8,
FLATPAK_CONTEXT_SOCKET_GPG_AGENT = 1 << 9,
} FlatpakContextSockets;
typedef enum {

View File

@@ -61,6 +61,7 @@ const char *flatpak_context_sockets[] = {
"ssh-auth",
"pcsc",
"cups",
"gpg-agent",
NULL
};

View File

@@ -601,6 +601,46 @@ flatpak_run_add_cups_args (FlatpakBwrap *bwrap)
NULL);
}
static void
flatpak_run_add_gpg_agent_args (FlatpakBwrap *bwrap)
{
const char * agent_socket;
g_autofree char * sandbox_agent_socket = NULL;
g_autoptr(GError) gpgconf_error = NULL;
g_autoptr(GSubprocess) process = NULL;
g_autoptr(GInputStream) base_stream = NULL;
g_autoptr(GDataInputStream) data_stream = NULL;
process = g_subprocess_new (G_SUBPROCESS_FLAGS_STDOUT_PIPE,
&gpgconf_error,
"gpgconf", "--list-dir", "agent-socket", NULL);
if (gpgconf_error)
{
g_debug ("GPG-Agent directories: %s", gpgconf_error->message);
return;
}
base_stream = g_subprocess_get_stdout_pipe (process);
data_stream = g_data_input_stream_new (base_stream);
agent_socket = g_data_input_stream_read_line (data_stream,
NULL, NULL,
&gpgconf_error);
if (!agent_socket || gpgconf_error)
{
g_debug ("GPG-Agent directories: %s", gpgconf_error->message);
return;
}
sandbox_agent_socket = g_strdup_printf ("/run/user/%d/gnupg/S.gpg-agent", getuid ());
flatpak_bwrap_add_args (bwrap,
"--ro-bind-try", agent_socket, sandbox_agent_socket,
NULL);
}
/* Try to find a default server from a pulseaudio confguration file */
static char *
flatpak_run_get_pulseaudio_server_user_config (const char *path)
@@ -1783,6 +1823,11 @@ flatpak_run_add_environment_args (FlatpakBwrap *bwrap,
flatpak_run_add_cups_args (bwrap);
}
if (context->sockets & FLATPAK_CONTEXT_SOCKET_GPG_AGENT)
{
flatpak_run_add_gpg_agent_args (bwrap);
}
flatpak_run_add_session_dbus_args (bwrap, proxy_arg_bwrap, context, flags, app_id);
flatpak_run_add_system_dbus_args (bwrap, proxy_arg_bwrap, context, flags);
flatpak_run_add_a11y_dbus_args (bwrap, proxy_arg_bwrap, context, flags);

View File

@@ -134,7 +134,7 @@
Expose a well-known socket to the application. This updates
the [Context] group in the metadata.
SOCKET must be one of: x11, wayland, fallback-x11, pulseaudio, system-bus, session-bus,
ssh-auth, pcsc, cups.
ssh-auth, pcsc, cups, gpg-agent.
This option can be used multiple times.
</para><para>
The fallback-x11 option makes the X11 socket available only if
@@ -151,7 +151,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, fallback-x11, pulseaudio, system-bus, session-bus,
ssh-auth, pcsc, cups.
ssh-auth, pcsc, cups, gpg-agent.
This option can be used multiple times.
</para></listitem>
</varlistentry>

View File

@@ -149,7 +149,7 @@
Expose a well-known socket to the application. This overrides to
the Context section from the application metadata.
<arg choice="plain">SOCKET</arg> must be one of: x11, wayland, fallback-x11, pulseaudio, system-bus, session-bus,
ssh-auth, pcsc, cups.
ssh-auth, pcsc, cups, gpg-agent.
This option can be used multiple times.
</para></listitem>
</varlistentry>
@@ -161,7 +161,7 @@
Don't expose a well-known socket to the application. This overrides to
the Context section from the application metadata.
<arg choice="plain">SOCKET</arg> must be one of: x11, wayland, fallback-x11, pulseaudio, system-bus, session-bus,
ssh-auth, pcsc, cups.
ssh-auth, pcsc, cups, gpg-agent.
This option can be used multiple times.
</para></listitem>
</varlistentry>

View File

@@ -134,7 +134,7 @@
Expose a well-known socket to the application. This overrides to
the Context section from the application metadata.
<arg choice="plain">SOCKET</arg> must be one of: x11, wayland, fallback-x11, pulseaudio, system-bus, session-bus,
ssh-auth, pcsc, cups.
ssh-auth, pcsc, cups, gpg-agent.
This option can be used multiple times.
</para></listitem>
</varlistentry>
@@ -146,7 +146,7 @@
Don't expose a well-known socket to the application. This overrides to
the Context section from the application metadata.
<arg choice="plain">SOCKET</arg> must be one of: x11, wayland, fallback-x11, pulseaudio, system-bus, session-bus,
ssh-auth, pcsc, cups.
ssh-auth, pcsc, cups, gpg-agent.
This option can be used multiple times.
</para></listitem>
</varlistentry>

View File

@@ -299,7 +299,7 @@
Expose a well known socket to the application. This overrides to
the Context section from the application metadata.
<arg choice="plain">SOCKET</arg> must be one of: x11, wayland, fallback-x11, pulseaudio, system-bus, session-bus,
ssh-auth, pcsc, cups.
ssh-auth, pcsc, cups, gpg-agent.
This option can be used multiple times.
</para></listitem>
</varlistentry>
@@ -311,7 +311,7 @@
Don't expose a well known socket to the application. This overrides to
the Context section from the application metadata.
<arg choice="plain">SOCKET</arg> must be one of: x11, wayland, fallback-x11, pulseaudio, system-bus, session-bus,
ssh-auth, pcsc, cups.
ssh-auth, pcsc, cups, gpg-agent.
This option can be used multiple times.
</para></listitem>
</varlistentry>