summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2016-04-14 10:01:42 -0400
committerMatthias Clasen <mclasen@redhat.com>2016-04-14 10:01:42 -0400
commit4283473b38b4b8a7ea5975af5a85cb6f5b518fb1 (patch)
tree6bcda48b9d8d84acbf334582854df033d5b6b7fc
parentdb797bf4dfd4bd55b28220826cc652c5ee75093d (diff)
downloadxdg-app-4283473b38b4b8a7ea5975af5a85cb6f5b518fb1.tar.gz
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.
-rw-r--r--app/xdg-app-builtins-run.c8
-rw-r--r--common/xdg-app-run.c7
-rw-r--r--common/xdg-app-run.h6
3 files changed, 16 insertions, 5 deletions
diff --git a/app/xdg-app-builtins-run.c b/app/xdg-app-builtins-run.c
index b9c0422..0d3f8c5 100644
--- a/app/xdg-app-builtins-run.c
+++ b/app/xdg-app-builtins-run.c
@@ -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,
diff --git a/common/xdg-app-run.c b/common/xdg-app-run.c
index 85bf5a7..ecf8ede 100644
--- a/common/xdg-app-run.c
+++ b/common/xdg-app-run.c
@@ -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);
diff --git a/common/xdg-app-run.h b/common/xdg-app-run.h
index 0039007..94462f0 100644
--- a/common/xdg-app-run.h
+++ b/common/xdg-app-run.h
@@ -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,