mirror of
https://github.com/flatpak/flatpak.git
synced 2026-10-23 16:09:26 -04:00
Add options to enable bus logging
This can be useful to find out what bus names your app is actually talking to, so you can set up a bus policy that is narrowed than blanket access without breaking your application.
This commit is contained in:
1 parent
db797bf4df
commit
4283473b38
3 files changed
+16
-5
No files matched your search
@@ -39,6 +39,8 @@ static char *opt_arch;
|
||||
static char *opt_branch;
|
||||
static char *opt_command;
|
||||
static gboolean opt_devel;
|
||||
static gboolean opt_log_session_bus;
|
||||
static gboolean opt_log_system_bus;
|
||||
static char *opt_runtime;
|
||||
static char *opt_runtime_version;
|
||||
|
||||
@@ -49,6 +51,8 @@ static GOptionEntry options[] = {
|
||||
{ "devel", 'd', 0, G_OPTION_ARG_NONE, &opt_devel, "Use development runtime", NULL },
|
||||
{ "runtime", 0, 0, G_OPTION_ARG_STRING, &opt_runtime, "Runtime to use", "RUNTIME" },
|
||||
{ "runtime-version", 0, 0, G_OPTION_ARG_STRING, &opt_runtime_version, "Runtime version to use", "VERSION" },
|
||||
{ "log-session-bus", 0, 0, G_OPTION_ARG_NONE, &opt_log_session_bus, "Log session bus calls", NULL },
|
||||
{ "log-system-bus", 0, 0, G_OPTION_ARG_NONE, &opt_log_system_bus, "Log system bus calls", NULL },
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
@@ -105,7 +109,9 @@ xdg_app_builtin_run (int argc, char **argv, GCancellable *cancellable, GError **
|
||||
arg_context,
|
||||
opt_runtime,
|
||||
opt_runtime_version,
|
||||
opt_devel ? XDG_APP_RUN_FLAG_DEVEL : 0,
|
||||
(opt_devel ? XDG_APP_RUN_FLAG_DEVEL : 0) |
|
||||
(opt_log_session_bus ? XDG_APP_RUN_FLAG_LOG_SESSION_BUS : 0) |
|
||||
(opt_log_system_bus ? XDG_APP_RUN_FLAG_LOG_SYSTEM_BUS : 0),
|
||||
opt_command,
|
||||
&argv[rest_argv_start + 1],
|
||||
rest_argc - 1,
|
||||
|
||||
@@ -2120,6 +2120,7 @@ dbus_spawn_child_setup (gpointer user_data)
|
||||
static gboolean
|
||||
add_dbus_proxy_args (GPtrArray *argv_array,
|
||||
GPtrArray *dbus_proxy_argv,
|
||||
gboolean enable_logging,
|
||||
GError **error)
|
||||
{
|
||||
int sync_proxy_pipes[2];
|
||||
@@ -2136,6 +2137,8 @@ add_dbus_proxy_args (GPtrArray *argv_array,
|
||||
|
||||
g_ptr_array_insert (dbus_proxy_argv, 0, g_strdup (DBUSPROXY));
|
||||
g_ptr_array_insert (dbus_proxy_argv, 1, g_strdup_printf ("--fd=%d", sync_proxy_pipes[1]));
|
||||
if (enable_logging)
|
||||
g_ptr_array_add (dbus_proxy_argv, g_strdup ("--log"));
|
||||
|
||||
g_ptr_array_add (dbus_proxy_argv, NULL); /* NULL terminate */
|
||||
|
||||
@@ -2309,10 +2312,10 @@ xdg_app_run_app (const char *app_ref,
|
||||
if (!xdg_app_run_in_transient_unit (app_ref_parts[1], error))
|
||||
return FALSE;
|
||||
|
||||
if (!add_dbus_proxy_args (argv_array, session_bus_proxy_argv, error))
|
||||
if (!add_dbus_proxy_args (argv_array, session_bus_proxy_argv, (flags & XDG_APP_RUN_FLAG_LOG_SESSION_BUS) != 0, error))
|
||||
return FALSE;
|
||||
|
||||
if (!add_dbus_proxy_args (argv_array, system_bus_proxy_argv, error))
|
||||
if (!add_dbus_proxy_args (argv_array, system_bus_proxy_argv, (flags & XDG_APP_RUN_FLAG_LOG_SYSTEM_BUS) != 0, error))
|
||||
return FALSE;
|
||||
|
||||
app_files = xdg_app_deploy_get_files (app_deploy);
|
||||
|
||||
@@ -82,8 +82,10 @@ GFile *xdg_app_ensure_data_dir (const char *app_id,
|
||||
GError **error);
|
||||
|
||||
typedef enum {
|
||||
XDG_APP_RUN_FLAG_DEVEL = (1<<0),
|
||||
XDG_APP_RUN_FLAG_BACKGROUND = (1<<1),
|
||||
XDG_APP_RUN_FLAG_DEVEL = (1<<0),
|
||||
XDG_APP_RUN_FLAG_BACKGROUND = (1<<1),
|
||||
XDG_APP_RUN_FLAG_LOG_SESSION_BUS = (1<<2),
|
||||
XDG_APP_RUN_FLAG_LOG_SYSTEM_BUS = (1<<3),
|
||||
} XdgAppRunFlags;
|
||||
|
||||
gboolean xdg_app_run_app (const char *app_ref,
|
||||
|
||||
Reference in new issue
Block a user