Commit 1a9bc224 authored by Thomas Haller's avatar Thomas Haller

build: cleanup build defines for session-tracking

- always define the SESSION_TRACKING_* defines to replace
  "#ifdef" with "#if".

- drop defining the consolekit database path CKDB_PATH in
  config.h. The path was not customizable via configure/meson.

- fix meson build to enable consolekit support for session tracking
  without also enabling logind/elogind session tracking.
  logind/elogind is mutually exclusive, but consolekit session tracking
  goes together just fine.
parent 3b5f8c91
/* Define if building universal (internal helper macro) */
#mesondefine AC_APPLE_UNIVERSAL_BUILD
/* Path to ConsoleKit database */
#mesondefine CKDB_PATH
/* Define to path of dhclient binary */
#mesondefine DHCLIENT_PATH
......
......@@ -444,6 +444,8 @@ fi
if test "$have_systemd_logind" = "yes"; then
AC_DEFINE([SESSION_TRACKING_SYSTEMD], 1, [Define to 1 if libsystemd-login is available])
session_tracking="$session_tracking, systemd-logind"
else
AC_DEFINE([SESSION_TRACKING_SYSTEMD], 0, [Define to 1 if libsystemd-login is available])
fi
if test "$use_elogind" = "yes" -a "$have_systemd_logind" = "yes"; then
......@@ -460,12 +462,15 @@ fi
if test "$have_elogind" = "yes"; then
AC_DEFINE([SESSION_TRACKING_ELOGIND], 1, [Define to 1 if libelogin is available])
session_tracking="$session_tracking, elogind"
else
AC_DEFINE([SESSION_TRACKING_ELOGIND], 0, [Define to 1 if libelogin is available])
fi
if test "$use_consolekit" = "yes"; then
AC_DEFINE([SESSION_TRACKING_CONSOLEKIT], 1, [Define to 1 if ConsoleKit is available])
AC_DEFINE([CKDB_PATH], "/var/run/ConsoleKit/database", [Path to ConsoleKit database])
session_tracking="$session_tracking, consolekit"
else
AC_DEFINE([SESSION_TRACKING_CONSOLEKIT], 0, [Define to 1 if ConsoleKit is available])
fi
session_tracking="$(printf '%s' "${session_tracking}" | sed 's/^, //')"
......
......@@ -347,32 +347,31 @@ config_h.set_quoted('NM_CONFIG_DEFAULT_LOGGING_BACKEND', config_logging_backend_
session_tracking = get_option('session_tracking')
session_trackers = []
enable_session_tracking = (session_tracking != 'no')
enable_consolekit = get_option('consolekit')
if enable_session_tracking
if session_tracking == 'systemd'
logind_dep = libsystemd_dep
if not logind_dep.found()
logind_dep = dependency('libsystemd-login', required: false)
assert(logind_dep.found(), 'You must have libsystemd or libsystemd-login installed to build with systemd-logind support')
endif
session_trackers += 'systemd-logind'
config_h.set('SESSION_TRACKING_SYSTEMD', true)
else
logind_dep = libelogind_dep
assert(logind_dep.found() and libelogind_dep.version().version_compare('>= 229'), 'You must have libelogind installed to build with elogind support.')
session_trackers += 'elogind'
config_h.set('SESSION_TRACKING_ELOGIND', true)
if session_tracking == 'systemd'
logind_dep = libsystemd_dep
if not logind_dep.found()
logind_dep = dependency('libsystemd-login', required: false)
assert(logind_dep.found(), 'You must have libsystemd or libsystemd-login installed to build with systemd-logind support')
endif
session_trackers += 'systemd-logind'
config_h.set10('SESSION_TRACKING_SYSTEMD', true)
config_h.set10('SESSION_TRACKING_ELOGIND', false)
elif session_tracking == 'elogind'
logind_dep = libelogind_dep
assert(logind_dep.found() and libelogind_dep.version().version_compare('>= 229'), 'You must have libelogind installed to build with elogind support.')
session_trackers += 'elogind'
config_h.set10('SESSION_TRACKING_SYSTEMD', false)
config_h.set10('SESSION_TRACKING_ELOGIND', true)
else
logind_dep = dependency('', required:false)
endif
if enable_consolekit
session_trackers += 'consolekit'
config_h.set_quoted('CKDB_PATH', '/var/run/ConsoleKit/database')
config_h.set('SESSION_TRACKING_CONSOLEKIT', enable_consolekit)
endif
session_tracking_consolekit = get_option('session_tracking_consolekit')
if session_tracking_consolekit
session_trackers += 'consolekit'
endif
config_h.set10('SESSION_TRACKING_CONSOLEKIT', session_tracking_consolekit)
hostname_persist = get_option('hostname_persist')
config_h.set('HOSTNAME_PERSIST_SUSE', (hostname_persist == 'suse'))
......@@ -396,7 +395,7 @@ if enable_suspend_resume
system_inhibit_dep = libelogind_dep
suspend_resume = 'elogind'
config_h.set('SUSPEND_RESUME_ELOGIND', true)
elif enable_consolekit
elif session_tracking_consolekit
suspend_resume = 'consolekit'
config_h.set('SUSPEND_RESUME_CONSOLEKIT', true)
else
......
......@@ -13,7 +13,7 @@ option('dnssec_trigger', type: 'array', value: ['dnssec-trigger-script', '/usr/l
# platform
option('dist_version', type: 'string', value: '', description: 'Define the NM\'s distribution version string')
option('consolekit', type: 'boolean', value: true, description: 'Support consolekit session tracking')
option('session_tracking_consolekit', type: 'boolean', value: true, description: 'Support consolekit session tracking')
option('session_tracking', type: 'combo', choices: ['systemd', 'elogind', 'no'], value: 'systemd', description: 'Compatibility option to choose one session tracking module')
option('suspend_resume', type: 'boolean', value: true, description: 'Build NetworkManager with specific suspend/resume support')
option('polkit', type: 'combo', choices: ['yes', 'no', 'disabled'], value: 'yes', description: 'set default value for auth-polkit configuration option. This value can be overwritten by NM configuration. \'disabled\' compiles NM without any support')
......
......@@ -146,12 +146,10 @@ sources = files(
deps = [
dl_dep,
libndp_dep,
# FIXME: Some files use introspection/dbus* headers, so
# this dependency might be needed
#libnmdbus_dep,
libudev_dep,
nm_core_dep,
shared_n_acd_dep
shared_n_acd_dep,
logind_dep,
]
if enable_concheck
......@@ -170,10 +168,6 @@ if enable_selinux
deps += selinux_dep
endif
if enable_session_tracking
deps += logind_dep
endif
libnetwork_manager = static_library(
nm_name,
sources: sources,
......
......@@ -28,24 +28,26 @@
#include <string.h>
#include <sys/stat.h>
#if defined (SESSION_TRACKING_SYSTEMD) && defined (SESSION_TRACKING_ELOGIND)
#if SESSION_TRACKING_SYSTEMD && SESSION_TRACKING_ELOGIND
#error Cannot build both systemd-logind and elogind support
#endif
#ifdef SESSION_TRACKING_SYSTEMD
#if SESSION_TRACKING_SYSTEMD
#include <systemd/sd-login.h>
#define LOGIND_NAME "systemd-logind"
#endif
#ifdef SESSION_TRACKING_ELOGIND
#if SESSION_TRACKING_ELOGIND
#include <elogind/sd-login.h>
#define LOGIND_NAME "elogind"
/* Re-Use SESSION_TRACKING_SYSTEMD as elogind substitutes systemd-login */
#define SESSION_TRACKING_SYSTEMD 1
#endif
#include "NetworkManagerUtils.h"
#define SESSION_TRACKING_XLOGIND (SESSION_TRACKING_SYSTEMD || SESSION_TRACKING_ELOGIND)
#define CKDB_PATH "/var/run/ConsoleKit/database"
/*****************************************************************************/
enum {
......@@ -58,14 +60,14 @@ static guint signals[LAST_SIGNAL] = { 0 };
struct _NMSessionMonitor {
GObject parent;
#ifdef SESSION_TRACKING_SYSTEMD
#if SESSION_TRACKING_XLOGIND
struct {
sd_login_monitor *monitor;
guint watch;
} sd;
#endif
#ifdef SESSION_TRACKING_CONSOLEKIT
#if SESSION_TRACKING_CONSOLEKIT
struct {
GFileMonitor *monitor;
GHashTable *cache;
......@@ -85,7 +87,7 @@ G_DEFINE_TYPE (NMSessionMonitor, nm_session_monitor, G_TYPE_OBJECT);
/*****************************************************************************/
#ifdef SESSION_TRACKING_SYSTEMD
#if SESSION_TRACKING_XLOGIND
static gboolean
st_sd_session_exists (NMSessionMonitor *monitor, uid_t uid, gboolean active)
{
......@@ -143,11 +145,11 @@ st_sd_finalize (NMSessionMonitor *monitor)
}
nm_clear_g_source (&monitor->sd.watch);
}
#endif /* SESSION_TRACKING_SYSTEMD */
#endif /* SESSION_TRACKING_XLOGIND */
/*****************************************************************************/
#ifdef SESSION_TRACKING_CONSOLEKIT
#if SESSION_TRACKING_CONSOLEKIT
typedef struct {
gboolean active;
} CkSession;
......@@ -352,12 +354,12 @@ nm_session_monitor_session_exists (NMSessionMonitor *self,
{
g_return_val_if_fail (NM_IS_SESSION_MONITOR (self), FALSE);
#ifdef SESSION_TRACKING_SYSTEMD
#if SESSION_TRACKING_XLOGIND
if (st_sd_session_exists (self, uid, active))
return TRUE;
#endif
#ifdef SESSION_TRACKING_CONSOLEKIT
#if SESSION_TRACKING_CONSOLEKIT
if (ck_session_exists (self, uid, active))
return TRUE;
#endif
......@@ -370,12 +372,12 @@ nm_session_monitor_session_exists (NMSessionMonitor *self,
static void
nm_session_monitor_init (NMSessionMonitor *monitor)
{
#ifdef SESSION_TRACKING_SYSTEMD
#if SESSION_TRACKING_XLOGIND
st_sd_init (monitor);
_LOGD ("using "LOGIND_NAME" session tracking");
#endif
#ifdef SESSION_TRACKING_CONSOLEKIT
#if SESSION_TRACKING_CONSOLEKIT
ck_init (monitor);
_LOGD ("using ConsoleKit session tracking");
#endif
......@@ -384,11 +386,11 @@ nm_session_monitor_init (NMSessionMonitor *monitor)
static void
finalize (GObject *object)
{
#ifdef SESSION_TRACKING_SYSTEMD
#if SESSION_TRACKING_XLOGIND
st_sd_finalize (NM_SESSION_MONITOR (object));
#endif
#ifdef SESSION_TRACKING_CONSOLEKIT
#if SESSION_TRACKING_CONSOLEKIT
ck_finalize (NM_SESSION_MONITOR (object));
#endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment