From: Kay Sievers Date: Wed, 17 Jun 2015 14:37:55 +0000 (+0200) Subject: turn kdbus support into a runtime option X-Git-Tag: v226.4~1^2~271 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=commitdiff_plain;h=7b3cb911e7ddb15cc8f7b1bf0a19c5619b58e23c;hp=25387573767909c96090ad22cccafc72c16542d7 turn kdbus support into a runtime option ./configure --enable/disable-kdbus can be used to set the default behavior regarding kdbus. If no kdbus kernel support is available, dbus-dameon will be used. With --enable-kdbus, the kernel command line option "kdbus=0" can be used to disable kdbus. With --disable-kdbus, the kernel command line option "kdbus=1" is required to enable kdbus support. --- diff --git a/src/libelogind/libelogind.pc.in b/src/libelogind/libelogind.pc.in index e74b02687..81b1d79c3 100644 --- a/src/libelogind/libelogind.pc.in +++ b/src/libelogind/libelogind.pc.in @@ -5,15 +5,14 @@ # the Free Software Foundation; either version 2.1 of the License, or # (at your option) any later version. -# See tmpfiles.d(5) for details - -L /etc/os-release - - - - ../usr/lib/os-release -L /etc/localtime - - - - ../usr/share/zoneinfo/UTC -L+ /etc/mtab - - - - ../proc/self/mounts +g systemd-journal - - +u systemd-bus-proxy - "systemd Bus Proxy" +m4_ifdef(`ENABLE_NETWORKD', +u systemd-network - "systemd Network Management" +)m4_dnl m4_ifdef(`ENABLE_RESOLVED', -L! /etc/resolv.conf - - - - ../run/systemd/resolve/resolv.conf +u systemd-resolve - "systemd Resolver" )m4_dnl -C /etc/nsswitch.conf - - - - -m4_ifdef(`HAVE_PAM', -C /etc/pam.d - - - - +m4_ifdef(`ENABLE_TIMESYNCD', +u systemd-timesync - "systemd Time Synchronization" )m4_dnl diff --git a/src/libelogind/sd-bus/bus-util.c b/src/libelogind/sd-bus/bus-util.c index 96296aa1c..2e4cd572f 100644 --- a/src/libelogind/sd-bus/bus-util.c +++ b/src/libelogind/sd-bus/bus-util.c @@ -545,7 +545,6 @@ int bus_open_system_systemd(sd_bus **_bus) { * directly to the system instance, instead of going via the * bus */ -#ifdef ENABLE_KDBUS r = sd_bus_new(&bus); if (r < 0) return r; @@ -564,7 +563,6 @@ int bus_open_system_systemd(sd_bus **_bus) { } bus = sd_bus_unref(bus); -#endif r = sd_bus_new(&bus); if (r < 0) @@ -598,7 +596,6 @@ int bus_open_user_systemd(sd_bus **_bus) { assert(_bus); -#ifdef ENABLE_KDBUS r = sd_bus_new(&bus); if (r < 0) return r; @@ -616,7 +613,6 @@ int bus_open_user_systemd(sd_bus **_bus) { } bus = sd_bus_unref(bus); -#endif e = secure_getenv("XDG_RUNTIME_DIR"); if (!e) @@ -2049,15 +2045,22 @@ int bus_path_decode_unique(const char *path, const char *prefix, char **ret_send bool is_kdbus_wanted(void) { _cleanup_free_ char *value = NULL; +#ifdef ENABLE_KDBUS + const bool configured = true; +#else + const bool configured = false; +#endif + int r; - if (get_proc_cmdline_key("kdbus", NULL) <= 0) { - r = get_proc_cmdline_key("kdbus=", &value); - if (r <= 0 || parse_boolean(value) != 1) - return false; - } + if (get_proc_cmdline_key("kdbus", NULL) > 0) + return true; + + r = get_proc_cmdline_key("kdbus=", &value); + if (r <= 0) + return configured; - return true; + return parse_boolean(value) == 1; } bool is_kdbus_available(void) { diff --git a/src/libelogind/sd-bus/sd-bus.c b/src/libelogind/sd-bus/sd-bus.c index 57c09d9cb..0c18296e1 100644 --- a/src/libelogind/sd-bus/sd-bus.c +++ b/src/libelogind/sd-bus/sd-bus.c @@ -1236,18 +1236,9 @@ int bus_set_address_user(sd_bus *b) { if (!ee) return -ENOMEM; -#ifdef ENABLE_KDBUS (void) asprintf(&b->address, KERNEL_USER_BUS_ADDRESS_FMT ";" UNIX_USER_BUS_ADDRESS_FMT, getuid(), ee); -#else - (void) asprintf(&b->address, UNIX_USER_BUS_ADDRESS_FMT, ee); -#endif - } else { -#ifdef ENABLE_KDBUS + } else (void) asprintf(&b->address, KERNEL_USER_BUS_ADDRESS_FMT, getuid()); -#else - return -ECONNREFUSED; -#endif - } if (!b->address) return -ENOMEM; @@ -1369,11 +1360,7 @@ int bus_set_address_system_machine(sd_bus *b, const char *machine) { if (!e) return -ENOMEM; -#ifdef ENABLE_KDBUS b->address = strjoin("x-machine-kernel:machine=", e, ";x-machine-unix:machine=", e, NULL); -#else - b->address = strjoin("x-machine-unix:machine=", e, NULL); -#endif if (!b->address) return -ENOMEM; diff --git a/src/login/pam_elogind.c b/src/login/pam_elogind.c index f42da90cd..9554ce606 100644 --- a/src/login/pam_elogind.c +++ b/src/login/pam_elogind.c @@ -177,7 +177,6 @@ static int export_legacy_dbus_address( uid_t uid, const char *runtime) { -#ifdef ENABLE_KDBUS _cleanup_free_ char *s = NULL; int r; @@ -195,7 +194,7 @@ static int export_legacy_dbus_address( pam_syslog(handle, LOG_ERR, "Failed to set bus variable."); return r; } -#endif + return PAM_SUCCESS; } diff --git a/src/shared/def.h b/src/shared/def.h index 9665347a8..ea54e25e2 100644 --- a/src/shared/def.h +++ b/src/shared/def.h @@ -63,13 +63,7 @@ #define UNIX_SYSTEM_BUS_ADDRESS "unix:path=/var/run/dbus/system_bus_socket" #define KERNEL_SYSTEM_BUS_ADDRESS "kernel:path=/sys/fs/kdbus/0-system/bus" - -#ifdef ENABLE_KDBUS -# define DEFAULT_SYSTEM_BUS_ADDRESS KERNEL_SYSTEM_BUS_ADDRESS ";" UNIX_SYSTEM_BUS_ADDRESS -#else -# define DEFAULT_SYSTEM_BUS_ADDRESS UNIX_SYSTEM_BUS_ADDRESS -#endif - +#define DEFAULT_SYSTEM_BUS_ADDRESS KERNEL_SYSTEM_BUS_ADDRESS ";" UNIX_SYSTEM_BUS_ADDRESS #define UNIX_USER_BUS_ADDRESS_FMT "unix:path=%s/bus" #define KERNEL_USER_BUS_ADDRESS_FMT "kernel:path=/sys/fs/kdbus/"UID_FMT"-user/bus" diff --git a/units/systemd-networkd.service.m4.in b/units/systemd-networkd.service.m4.in index 7f216f331..64d9130c2 100644 --- a/units/systemd-networkd.service.m4.in +++ b/units/systemd-networkd.service.m4.in @@ -17,13 +17,11 @@ Before=network.target multi-user.target shutdown.target Conflicts=shutdown.target Wants=network.target -m4_ifdef(`ENABLE_KDBUS', # On kdbus systems we pull in the busname explicitly, because it # carries policy that allows the daemon to acquire its name. Wants=org.freedesktop.network1.busname After=org.freedesktop.network1.busname -)m4_dnl [Service] Type=notify Restart=on-failure