X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fdbus-common.c;h=dcce10e5525351a43fd7df06fafef8de5ff9a265;hb=51b4af2c2833691976844a13464c1301643043d3;hp=25b718ec026533463341bb382eadbbd3d03e35e8;hpb=a8f11321c209830a35edd0357e8def5d4437d854;p=elogind.git diff --git a/src/dbus-common.c b/src/dbus-common.c index 25b718ec0..dcce10e55 100644 --- a/src/dbus-common.c +++ b/src/dbus-common.c @@ -30,6 +30,7 @@ #include "log.h" #include "dbus-common.h" #include "util.h" +#include "def.h" int bus_check_peercred(DBusConnection *c) { int fd; @@ -57,8 +58,6 @@ int bus_check_peercred(DBusConnection *c) { return 1; } -#define TIMEOUT_USEC (60*USEC_PER_SEC) - static int sync_auth(DBusConnection *bus, DBusError *error) { usec_t begin, tstamp; @@ -71,13 +70,13 @@ static int sync_auth(DBusConnection *bus, DBusError *error) { begin = tstamp = now(CLOCK_MONOTONIC); for (;;) { - if (tstamp > begin + TIMEOUT_USEC) + if (tstamp > begin + DEFAULT_TIMEOUT_USEC) break; if (dbus_connection_get_is_authenticated(bus)) break; - if (!dbus_connection_read_write_dispatch(bus, ((begin + TIMEOUT_USEC - tstamp) + USEC_PER_MSEC - 1) / USEC_PER_MSEC)) + if (!dbus_connection_read_write_dispatch(bus, ((begin + DEFAULT_TIMEOUT_USEC - tstamp) + USEC_PER_MSEC - 1) / USEC_PER_MSEC)) break; tstamp = now(CLOCK_MONOTONIC); @@ -104,8 +103,16 @@ int bus_connect(DBusBusType t, DBusConnection **_bus, bool *private, DBusError * /* If we are root, then let's not go via the bus */ if (geteuid() == 0 && t == DBUS_BUS_SYSTEM) { - if (!(bus = dbus_connection_open_private("unix:abstract=/org/freedesktop/systemd1/private", error))) - return -EIO; + + if (!(bus = dbus_connection_open_private("unix:path=/run/systemd/private", error))) { +#ifndef LEGACY + dbus_error_free(error); + + /* Retry with the pre v21 socket name, to ease upgrades */ + if (!(bus = dbus_connection_open_private("unix:abstract=/org/freedesktop/systemd1/private", error))) +#endif + return -EIO; + } dbus_connection_set_exit_on_disconnect(bus, FALSE);