--- PackageKit-1.1.13/src/pk-dbus.c.orig 2018-12-14 10:05:15.000000000 +0100 +++ PackageKit-1.1.13/src/pk-dbus.c 2020-03-03 11:41:02.148537933 +0100 @@ -28,6 +28,7 @@ #include #ifdef HAVE_SYSTEMD_SD_LOGIN_H + #include #include #endif @@ -218,9 +219,7 @@ gchar * pk_dbus_get_session (PkDbus *dbus, const gchar *sender) { gchar *session = NULL; -#ifndef HAVE_SYSTEMD_SD_LOGIN_H g_autoptr(GError) error = NULL; -#endif guint pid; g_autoptr(GVariant) value = NULL; @@ -249,10 +248,12 @@ pk_dbus_get_session (PkDbus *dbus, const /* get session from systemd or ConsoleKit */ #ifdef HAVE_SYSTEMD_SD_LOGIN_H + if (sd_booted () > 0) { session = pk_dbus_get_session_systemd (pid); if (session == NULL) g_warning ("failed to get session for pid %u", pid); -#else + } else { +#endif /* get session from ConsoleKit */ value = g_dbus_proxy_call_sync (dbus->priv->proxy_session, "GetSessionForUnixProcess", @@ -268,6 +269,8 @@ pk_dbus_get_session (PkDbus *dbus, const goto out; } g_variant_get (value, "(o)", &session); +#ifdef HAVE_SYSTEMD_SD_LOGIN_H + } #endif out: return session;