Skip to content

Commit a3b91cd

Browse files
flatpak-spawn: Add "--sandbox-a11y-own-name"
This is the flatpak-spawn counterpart to the new option of the Flatpak portal. See flatpak/flatpak#5898
1 parent b24e62e commit a3b91cd

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

src/flatpak-spawn.c

+36
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,28 @@ sandbox_flag_callback (G_GNUC_UNUSED const gchar *option_name,
370370
return FALSE;
371371
}
372372

373+
static GPtrArray *sandbox_a11y_own_names = NULL;
374+
375+
static gboolean
376+
sandbox_a11y_own_name_callback (G_GNUC_UNUSED const gchar *option_name,
377+
const gchar *value,
378+
G_GNUC_UNUSED gpointer data,
379+
GError **error)
380+
{
381+
if (sandbox_a11y_own_names == NULL)
382+
sandbox_a11y_own_names = g_ptr_array_new ();
383+
384+
if (!g_dbus_is_name (value) || g_dbus_is_unique_name (value))
385+
{
386+
g_set_error (error, G_OPTION_ERROR, G_OPTION_ERROR_FAILED,
387+
"Invalid bus name");
388+
return FALSE;
389+
}
390+
391+
g_ptr_array_add (sandbox_a11y_own_names, g_strdup (value));
392+
return TRUE;
393+
}
394+
373395
static guint32
374396
get_portal_version (void)
375397
{
@@ -809,6 +831,7 @@ main (int argc,
809831
{ "sandbox-expose-path-try", 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &opt_sandbox_expose_path_try, "Expose access to path if it exists", "PATH" },
810832
{ "sandbox-expose-path-ro-try", 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &opt_sandbox_expose_path_ro_try, "Expose readonly access to path if it exists", "PATH" },
811833
{ "sandbox-flag", 0, 0, G_OPTION_ARG_CALLBACK, sandbox_flag_callback, "Enable sandbox flag", "FLAG" },
834+
{ "sandbox-a11y-own-name", 0, 0, G_OPTION_ARG_CALLBACK, sandbox_a11y_own_name_callback, "Allow owning the name on the a11y bus", "DBUS_NAME" },
812835
{ "host", 0, 0, G_OPTION_ARG_NONE, &opt_host, "Start the command on the host", NULL },
813836
{ "directory", 0, 0, G_OPTION_ARG_FILENAME, &opt_directory, "Working directory in which to run the command", "DIR" },
814837
{ "app-path", 0, 0, G_OPTION_ARG_FILENAME, &opt_app_path, "Replace runtime's /app with DIR or empty", "DIR|\"\"" },
@@ -1167,6 +1190,19 @@ main (int argc,
11671190
g_variant_new_variant (g_variant_builder_end (g_steal_pointer (&expose_fd_builder))));
11681191
}
11691192

1193+
if (sandbox_a11y_own_names != NULL)
1194+
{
1195+
g_autoptr(GVariantBuilder) sandbox_a11y_own_names_builder = g_variant_builder_new (G_VARIANT_TYPE ("as"));
1196+
1197+
check_portal_version ("sandbox-a11y-own-names", 7);
1198+
1199+
for (size_t i = 0; i < sandbox_a11y_own_names->len; i++)
1200+
g_variant_builder_add (sandbox_a11y_own_names_builder, "s", g_ptr_array_index (sandbox_a11y_own_names, i));
1201+
1202+
g_variant_builder_add (&options_builder, "{s@v}", "sandbox-a11y-own-names",
1203+
g_variant_new_variant (g_variant_builder_end (g_steal_pointer (&sandbox_a11y_own_names_builder))));
1204+
}
1205+
11701206
if (opt_app_path != NULL)
11711207
{
11721208
gint32 handle;

0 commit comments

Comments
 (0)