chiark / gitweb /
bus: do kdbus only if this is enabled on the configure switch
authorLennart Poettering <lennart@poettering.net>
Sat, 30 Nov 2013 19:18:48 +0000 (20:18 +0100)
committerLennart Poettering <lennart@poettering.net>
Sat, 30 Nov 2013 19:18:48 +0000 (20:18 +0100)
Since we want to retain the ability to break kernel ←→ userspace ABI
after the next release, let's not make use by default of kdbus, so that
people with future kernels will not suddenly break with current systemd
versions.

kdbus support is left in all builds but must now be explicitly requested
at runtime (for example via setting $DBUS_SESSION_BUS). Via a configure
switch the old behaviour can be restored. In fact, we change autogen.sh
to do this, so that git builds (which run autogen.sh) get kdbus by
default, but tarball builds (which ue the configure defaults) do not get
it, and hence this stays out of the distros by default.

TODO
autogen.sh
configure.ac
src/core/manager.c
src/libsystemd-bus/sd-bus.c

diff --git a/TODO b/TODO
index 65b11c7b2843edf76c8b240fece3696df9bcf234..e4acb15e9e9db8ceae306756dbd9b17be816b5a6 100644 (file)
--- a/TODO
+++ b/TODO
@@ -129,7 +129,7 @@ Features:
   - support "const" properties as flag
   - add API to clone sd_bus_message objects
   - SD_BUS_COMMENT() macro for inclusion in vtables, syntax inspired by gdbus
-  - unelss configure option is specified refuse connecting and creating kdbus, so that we can break compat
+  - make sd_bus_open_system_container() kdbus aware
   - longer term:
     * priority queues
     * priority inheritance
index 9869c156ae80f668a1edce627e4a6b5cd2930f63..d0a2f3fee2436dc1c0cb81224d6cb1e99db13c9c 100755 (executable)
@@ -54,10 +54,10 @@ args="$args \
 fi
 
 if [ "x$1" = "xc" ]; then
-        ./configure CFLAGS='-g -O0' $args
+        ./configure CFLAGS='-g -O0' --enable-kdbus $args
         make clean
 elif [ "x$1" = "xg" ]; then
-        ./configure CFLAGS='-g -Og' $args
+        ./configure CFLAGS='-g -Og' --enable-kdbus $args
         make clean
 else
         echo
@@ -65,6 +65,6 @@ else
         echo "Initialized build system. For a common configuration please run:"
         echo "----------------------------------------------------------------"
         echo
-        echo "./configure CFLAGS='-g -O0' $args"
+        echo "./configure CFLAGS='-g -O0' --enable-kdbus $args"
         echo
 fi
index 6995e78406a9d7deea0a717e4abeda780473ca66..6ada38af9465166881b2bd890e3703f176f4614f 100644 (file)
@@ -799,6 +799,15 @@ if test "x$enable_multi_seat_x" != "xno"; then
 fi
 AM_CONDITIONAL(ENABLE_MULTI_SEAT_X, [test "$have_multi_seat_x" = "yes"])
 
+# ------------------------------------------------------------------------------
+have_kdbus=no
+AC_ARG_ENABLE(kdbus, AS_HELP_STRING([--enable-kdbus], [do not connect to kdbus by default]))
+if test "x$enable_kdbus" == "xyes"; then
+        AC_DEFINE(ENABLE_KDBUS, 1, [Define if kdbus support is to be enabled])
+        have_kdbus=yes
+fi
+AM_CONDITIONAL(ENABLE_KDBUS, [test "$have_kdbus" = "yes"])
+
 # ------------------------------------------------------------------------------
 AC_ARG_WITH(rc-local-script-path-start,
         AS_HELP_STRING([--with-rc-local-script-path-start=PATH],
@@ -1084,6 +1093,7 @@ AC_MSG_RESULT([
         gudev:                   ${enable_gudev}
         gintrospection:          ${enable_introspection}
         multi-seat-x:            ${have_multi_seat_x}
+        kdbus:                   ${have_kdbus}
         Python:                  ${have_python}
         Python Headers:          ${have_python_devel}
         man pages:               ${have_manpages}
index 7de0b268112af4a05d02ff3b59b2ccc6f08fe819..badf19e9548c91b4f801169d8244e97f406f200f 100644 (file)
@@ -414,6 +414,7 @@ static int manager_setup_kdbus(Manager *m) {
 
         assert(m);
 
+#ifdef ENABLE_KDBUS
         if (m->kdbus_fd >= 0)
                 return 0;
 
@@ -428,6 +429,8 @@ static int manager_setup_kdbus(Manager *m) {
         }
 
         log_info("Successfully set up kdbus on %s", p);
+#endif
+
         return 0;
 }
 
index e224be7056c9a8281b0c24307deeaa07235c01cc..1244ec2f6dd051df9d04a3e434b2e45e5f4fd7b4 100644 (file)
@@ -993,7 +993,11 @@ _public_ int sd_bus_open_system(sd_bus **ret) {
         if (e)
                 r = sd_bus_set_address(b, e);
         else
+#ifdef ENABLE_KDBUS
                 r = sd_bus_set_address(b, "kernel:path=/dev/kdbus/0-system/bus;unix:path=/run/dbus/system_bus_socket");
+#else
+                r = sd_bus_set_address(b, "unix:path=/run/dbus/system_bus_socket");
+#endif
 
         if (r < 0)
                 goto fail;
@@ -1035,13 +1039,22 @@ _public_ int sd_bus_open_user(sd_bus **ret) {
 
                         ee = bus_address_escape(e);
                         if (!ee) {
-                                r = -ENOENT;
+                                r = -ENOMEM;
                                 goto fail;
                         }
 
+#ifdef ENABLE_KDBUS
                         asprintf(&b->address, "kernel:path=/dev/kdbus/%lu-user/bus;unix:path=%s/bus", (unsigned long) getuid(), ee);
-                } else
+#else
+                        b->address = strjoin("unix:path=", ee, "/bus", NULL);
+#endif
+                } else {
+#ifdef ENABLE_KDBUS
                         asprintf(&b->address, "kernel:path=/dev/kdbus/%lu-user/bus", (unsigned long) getuid());
+#else
+                        return -ECONNREFUSED;
+#endif
+                }
 
                 if (!b->address) {
                         r = -ENOMEM;