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