mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2025-12-31 20:36:25 +00:00
proc: authorize before starting source
This commit is contained in:
@ -53,6 +53,7 @@ struct _SysprofProcSource
|
||||
SysprofCaptureWriter *writer;
|
||||
GArray *pids;
|
||||
SysprofMountinfo *mountinfo;
|
||||
guint is_ready : 1;
|
||||
};
|
||||
|
||||
static void source_iface_init (SysprofSourceInterface *iface);
|
||||
@ -301,6 +302,47 @@ sysprof_proc_source_add_pid (SysprofSource *source,
|
||||
g_array_append_val (self->pids, pid);
|
||||
}
|
||||
|
||||
static void
|
||||
sysprof_proc_source_auth_cb (GObject *object,
|
||||
GAsyncResult *result,
|
||||
gpointer user_data)
|
||||
{
|
||||
SysprofHelpers *helpers = (SysprofHelpers *)object;
|
||||
g_autoptr(SysprofProcSource) self = user_data;
|
||||
g_autoptr(GError) error = NULL;
|
||||
|
||||
g_assert (SYSPROF_IS_HELPERS (helpers));
|
||||
g_assert (G_IS_ASYNC_RESULT (result));
|
||||
g_assert (SYSPROF_IS_PROC_SOURCE (self));
|
||||
|
||||
if (!sysprof_helpers_authorize_finish (helpers, result, &error))
|
||||
{
|
||||
sysprof_source_emit_failed (SYSPROF_SOURCE (self), error);
|
||||
}
|
||||
else
|
||||
{
|
||||
self->is_ready = TRUE;
|
||||
sysprof_source_emit_ready (SYSPROF_SOURCE (self));
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
sysprof_proc_source_prepare (SysprofSource *source)
|
||||
{
|
||||
g_assert (SYSPROF_IS_PROC_SOURCE (source));
|
||||
|
||||
sysprof_helpers_authorize_async (sysprof_helpers_get_default (),
|
||||
NULL,
|
||||
sysprof_proc_source_auth_cb,
|
||||
g_object_ref (source));
|
||||
}
|
||||
|
||||
static gboolean
|
||||
sysprof_proc_source_get_is_ready (SysprofSource *source)
|
||||
{
|
||||
return SYSPROF_PROC_SOURCE (source)->is_ready;
|
||||
}
|
||||
|
||||
static void
|
||||
source_iface_init (SysprofSourceInterface *iface)
|
||||
{
|
||||
@ -308,6 +350,8 @@ source_iface_init (SysprofSourceInterface *iface)
|
||||
iface->start = sysprof_proc_source_start;
|
||||
iface->stop = sysprof_proc_source_stop;
|
||||
iface->add_pid = sysprof_proc_source_add_pid;
|
||||
iface->prepare = sysprof_proc_source_prepare;
|
||||
iface->get_is_ready = sysprof_proc_source_get_is_ready;
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
Reference in New Issue
Block a user