mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2025-12-31 20:36:25 +00:00
build: make polkit optional again for sysprof-cli
This commit is contained in:
@ -71,6 +71,12 @@ config_h.set('HAVE_EXECINFO_H', cc.has_header('execinfo.h'))
|
||||
config_h.set('HAVE_STRLCPY', cc.has_function('strlcpy'))
|
||||
config_h.set('HAVE_REALLOCARRAY', cc.has_function('reallocarray'))
|
||||
|
||||
polkit_agent_dep = dependency('polkit-agent-1', required: false)
|
||||
polkit_dep = dependency('polkit-gobject-1', version: polkit_req_version, required: false)
|
||||
|
||||
config_h.set10('HAVE_POLKIT_AGENT', polkit_agent_dep.found())
|
||||
config_h.set10('HAVE_POLKIT', polkit_dep.found())
|
||||
|
||||
if get_option('libunwind')
|
||||
libunwind_dep = dependency('libunwind-generic', required: false)
|
||||
config_h.set('ENABLE_LIBUNWIND', libunwind_dep.found())
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#ifdef HAVE_POLKIT
|
||||
#if HAVE_POLKIT
|
||||
# ifndef HAVE_POLKIT_AUTOPTR
|
||||
# include <polkit/polkit.h>
|
||||
|
||||
|
||||
@ -22,14 +22,14 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#ifdef HAVE_POLKIT
|
||||
#if HAVE_POLKIT
|
||||
# include <polkit/polkit.h>
|
||||
#endif
|
||||
|
||||
#include "sysprof-polkit-private.h"
|
||||
#include "sysprof-backport-autocleanups.h"
|
||||
|
||||
#ifdef HAVE_POLKIT
|
||||
#if HAVE_POLKIT
|
||||
typedef struct
|
||||
{
|
||||
const gchar *policy;
|
||||
@ -137,7 +137,7 @@ _sysprof_polkit_authorize_for_bus_async (GDBusConnection *bus,
|
||||
gpointer user_data)
|
||||
{
|
||||
g_autoptr(GTask) task = NULL;
|
||||
#ifdef HAVE_POLKIT
|
||||
#if HAVE_POLKIT
|
||||
const gchar *bus_name;
|
||||
Authorize *auth;
|
||||
#endif
|
||||
@ -149,7 +149,7 @@ _sysprof_polkit_authorize_for_bus_async (GDBusConnection *bus,
|
||||
task = g_task_new (NULL, cancellable, callback, user_data);
|
||||
g_task_set_source_tag (task, _sysprof_polkit_authorize_for_bus_async);
|
||||
|
||||
#ifdef HAVE_POLKIT
|
||||
#if HAVE_POLKIT
|
||||
bus_name = g_dbus_connection_get_unique_name (bus);
|
||||
|
||||
auth = g_slice_new0 (Authorize);
|
||||
|
||||
@ -7,9 +7,7 @@ tools_deps = [
|
||||
|
||||
tools_cflags = [ '-DSYSPROF_COMPILATION ']
|
||||
|
||||
if get_option('libsysprof') and host_machine.system() == 'linux'
|
||||
polkit_agent_dep = dependency('polkit-agent-1')
|
||||
polkit_dep = dependency('polkit-gobject-1', version: polkit_req_version, required: false)
|
||||
if get_option('libsysprof')
|
||||
sysprof_cli = executable('sysprof-cli', 'sysprof-cli.c',
|
||||
dependencies: tools_deps + [libsysprof_dep, polkit_dep, polkit_agent_dep],
|
||||
c_args: tools_cflags,
|
||||
|
||||
@ -25,16 +25,19 @@
|
||||
#include <glib-unix.h>
|
||||
#include <glib/gi18n.h>
|
||||
#include <glib/gstdio.h>
|
||||
#include <polkit/polkit.h>
|
||||
#define POLKIT_AGENT_I_KNOW_API_IS_SUBJECT_TO_CHANGE
|
||||
#include <polkitagent/polkitagent.h>
|
||||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/eventfd.h>
|
||||
#include <sys/types.h>
|
||||
#include <signal.h>
|
||||
#include <sysprof.h>
|
||||
|
||||
#if HAVE_POLKIT && HAVE_POLKIT_AGENT
|
||||
# define POLKIT_AGENT_I_KNOW_API_IS_SUBJECT_TO_CHANGE
|
||||
# include <polkit/polkit.h>
|
||||
# include <polkitagent/polkitagent.h>
|
||||
# define USE_POLKIT
|
||||
#endif
|
||||
|
||||
#include "sysprof-capture-util-private.h"
|
||||
|
||||
static GMainLoop *main_loop;
|
||||
@ -184,10 +187,13 @@ gint
|
||||
main (gint argc,
|
||||
gchar *argv[])
|
||||
{
|
||||
g_auto(GStrv) child_argv = NULL;
|
||||
g_auto(GStrv) envs = NULL;
|
||||
#ifdef USE_POLKIT
|
||||
PolkitAgentListener *polkit = NULL;
|
||||
PolkitSubject *subject = NULL;
|
||||
#endif
|
||||
|
||||
g_auto(GStrv) child_argv = NULL;
|
||||
g_auto(GStrv) envs = NULL;
|
||||
SysprofCaptureWriter *writer;
|
||||
SysprofSource *source;
|
||||
GMainContext *main_context;
|
||||
@ -317,6 +323,7 @@ Examples:\n\
|
||||
|
||||
main_loop = g_main_loop_new (NULL, FALSE);
|
||||
|
||||
#ifdef USE_POLKIT
|
||||
/* Start polkit agent so that we can elevate privileges from a TTY */
|
||||
if (g_getenv ("DESKTOP_SESSION") == NULL &&
|
||||
(subject = polkit_unix_process_new_for_owner (getpid (), 0, -1)))
|
||||
@ -338,6 +345,7 @@ Examples:\n\
|
||||
pkerror->message);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
profiler = sysprof_local_profiler_new ();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user