chiark / gitweb /
Fix service file to match installed elogind binary location
[elogind.git] / src / login / logind-seat-dbus.c
index 5c535ba0ec41682fb743c7fb28eb8994983167de..f934a5326a2edc11ef237b85215a17522f895d2b 100644 (file)
@@ -1,5 +1,3 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
 /***
   This file is part of systemd.
 
 #include <errno.h>
 #include <string.h>
 
-#include "logind.h"
+#include "alloc-util.h"
+#include "bus-common-errors.h"
+#include "bus-label.h"
+#include "bus-util.h"
 #include "logind-seat.h"
-#include "dbus-common.h"
+#include "logind.h"
+#include "strv.h"
+#include "user-util.h"
 #include "util.h"
 
-#define BUS_SEAT_INTERFACE \
-        " <interface name=\"org.freedesktop.login1.Seat\">\n"           \
-        "  <method name=\"Terminate\"/>\n"                              \
-        "  <method name=\"ActivateSession\">\n"                         \
-        "   <arg name=\"id\" type=\"s\"/>\n"                            \
-        "  </method>\n"                                                 \
-        "  <property name=\"Id\" type=\"s\" access=\"read\"/>\n"        \
-        "  <property name=\"ActiveSession\" type=\"so\" access=\"read\"/>\n" \
-        "  <property name=\"CanMultiSession\" type=\"b\" access=\"read\"/>\n" \
-        "  <property name=\"CanTTY\" type=\"b\" access=\"read\"/>\n" \
-        "  <property name=\"CanGraphical\" type=\"b\" access=\"read\"/>\n" \
-        "  <property name=\"Sessions\" type=\"a(so)\" access=\"read\"/>\n" \
-        "  <property name=\"IdleHint\" type=\"b\" access=\"read\"/>\n"  \
-        "  <property name=\"IdleSinceHint\" type=\"t\" access=\"read\"/>\n" \
-        "  <property name=\"IdleSinceHintMonotonic\" type=\"t\" access=\"read\"/>\n" \
-        " </interface>\n"                                               \
-
-#define INTROSPECTION                                                   \
-        DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE                       \
-        "<node>\n"                                                      \
-        BUS_SEAT_INTERFACE                                              \
-        BUS_PROPERTIES_INTERFACE                                        \
-        BUS_PEER_INTERFACE                                              \
-        BUS_INTROSPECTABLE_INTERFACE                                    \
-        "</node>\n"
-
-#define INTERFACES_LIST                              \
-        BUS_GENERIC_INTERFACES_LIST                  \
-        "org.freedesktop.login1.Seat\0"
-
-static int bus_seat_append_active(DBusMessageIter *i, const char *property, void *data) {
-        DBusMessageIter sub;
-        Seat *s = data;
-        const char *id, *path;
+static int property_get_active_session(
+                sd_bus *bus,
+                const char *path,
+                const char *interface,
+                const char *property,
+                sd_bus_message *reply,
+                void *userdata,
+                sd_bus_error *error) {
+
         _cleanup_free_ char *p = NULL;
+        Seat *s = userdata;
 
-        assert(i);
-        assert(property);
+        assert(bus);
+        assert(reply);
         assert(s);
 
-        if (!dbus_message_iter_open_container(i, DBUS_TYPE_STRUCT, NULL, &sub))
+        p = s->active ? session_bus_path(s->active) : strdup("/");
+        if (!p)
                 return -ENOMEM;
 
-        if (s->active) {
-                id = s->active->id;
-                path = p = session_bus_path(s->active);
+        return sd_bus_message_append(reply, "(so)", s->active ? s->active->id : "", p);
+}
 
-                if (!p)
-                        return -ENOMEM;
-        } else {
-                id = "";
-                path = "/";
-        }
+static int property_get_can_multi_session(
+                sd_bus *bus,
+                const char *path,
+                const char *interface,
+                const char *property,
+                sd_bus_message *reply,
+                void *userdata,
+                sd_bus_error *error) {
 
-        if (!dbus_message_iter_append_basic(&sub, DBUS_TYPE_STRING, &id) ||
-            !dbus_message_iter_append_basic(&sub, DBUS_TYPE_OBJECT_PATH, &path))
-                return -ENOMEM;
+        Seat *s = userdata;
 
-        if (!dbus_message_iter_close_container(i, &sub))
-                return -ENOMEM;
+        assert(bus);
+        assert(reply);
+        assert(s);
+
+        return sd_bus_message_append(reply, "b", seat_can_multi_session(s));
+}
+
+static int property_get_can_tty(
+                sd_bus *bus,
+                const char *path,
+                const char *interface,
+                const char *property,
+                sd_bus_message *reply,
+                void *userdata,
+                sd_bus_error *error) {
 
-        return 0;
+        Seat *s = userdata;
+
+        assert(bus);
+        assert(reply);
+        assert(s);
+
+        return sd_bus_message_append(reply, "b", seat_can_tty(s));
+}
+
+static int property_get_can_graphical(
+                sd_bus *bus,
+                const char *path,
+                const char *interface,
+                const char *property,
+                sd_bus_message *reply,
+                void *userdata,
+                sd_bus_error *error) {
+
+        Seat *s = userdata;
+
+        assert(bus);
+        assert(reply);
+        assert(s);
+
+        return sd_bus_message_append(reply, "b", seat_can_graphical(s));
 }
 
-static int bus_seat_append_sessions(DBusMessageIter *i, const char *property, void *data) {
-        DBusMessageIter sub, sub2;
-        Seat *s = data;
+static int property_get_sessions(
+                sd_bus *bus,
+                const char *path,
+                const char *interface,
+                const char *property,
+                sd_bus_message *reply,
+                void *userdata,
+                sd_bus_error *error) {
+
+        Seat *s = userdata;
         Session *session;
+        int r;
 
-        assert(i);
-        assert(property);
+        assert(bus);
+        assert(reply);
         assert(s);
 
-        if (!dbus_message_iter_open_container(i, DBUS_TYPE_ARRAY, "(so)", &sub))
-                return -ENOMEM;
+        r = sd_bus_message_open_container(reply, 'a', "(so)");
+        if (r < 0)
+                return r;
 
         LIST_FOREACH(sessions_by_seat, session, s->sessions) {
                 _cleanup_free_ char *p = NULL;
 
-                if (!dbus_message_iter_open_container(&sub, DBUS_TYPE_STRUCT, NULL, &sub2))
-                        return -ENOMEM;
-
                 p = session_bus_path(session);
                 if (!p)
                         return -ENOMEM;
 
-                if (!dbus_message_iter_append_basic(&sub2, DBUS_TYPE_STRING, &session->id) ||
-                    !dbus_message_iter_append_basic(&sub2, DBUS_TYPE_OBJECT_PATH, &p))
-                        return -ENOMEM;
+                r = sd_bus_message_append(reply, "(so)", session->id, p);
+                if (r < 0)
+                        return r;
 
-                if (!dbus_message_iter_close_container(&sub, &sub2))
-                        return -ENOMEM;
         }
 
-        if (!dbus_message_iter_close_container(i, &sub))
-                return -ENOMEM;
+        r = sd_bus_message_close_container(reply);
+        if (r < 0)
+                return r;
 
-        return 0;
+        return 1;
 }
 
-static int bus_seat_append_can_multi_session(DBusMessageIter *i, const char *property, void *data) {
-        Seat *s = data;
-        dbus_bool_t b;
-
-        assert(i);
-        assert(property);
-        assert(s);
+static int property_get_idle_hint(
+                sd_bus *bus,
+                const char *path,
+                const char *interface,
+                const char *property,
+                sd_bus_message *reply,
+                void *userdata,
+                sd_bus_error *error) {
 
-        b = seat_can_multi_session(s);
+        Seat *s = userdata;
 
-        if (!dbus_message_iter_append_basic(i, DBUS_TYPE_BOOLEAN, &b))
-                return -ENOMEM;
+        assert(bus);
+        assert(reply);
+        assert(s);
 
-        return 0;
+        return sd_bus_message_append(reply, "b", seat_get_idle_hint(s, NULL) > 0);
 }
 
-static int bus_seat_append_can_tty(DBusMessageIter *i, const char *property, void *data) {
-        Seat *s = data;
-        dbus_bool_t b;
+static int property_get_idle_since_hint(
+                sd_bus *bus,
+                const char *path,
+                const char *interface,
+                const char *property,
+                sd_bus_message *reply,
+                void *userdata,
+                sd_bus_error *error) {
+
+        Seat *s = userdata;
+        dual_timestamp t;
+        uint64_t u;
+        int r;
 
-        assert(i);
-        assert(property);
+        assert(bus);
+        assert(reply);
         assert(s);
 
-        b = seat_can_tty(s);
+        r = seat_get_idle_hint(s, &t);
+        if (r < 0)
+                return r;
 
-        if (!dbus_message_iter_append_basic(i, DBUS_TYPE_BOOLEAN, &b))
-                return -ENOMEM;
+        u = streq(property, "IdleSinceHint") ? t.realtime : t.monotonic;
 
-        return 0;
+        return sd_bus_message_append(reply, "t", u);
 }
 
-static int bus_seat_append_can_graphical(DBusMessageIter *i, const char *property, void *data) {
-        Seat *s = data;
-        dbus_bool_t b;
+int bus_seat_method_terminate(sd_bus_message *message, void *userdata, sd_bus_error *error) {
+        Seat *s = userdata;
+        int r;
 
-        assert(i);
-        assert(property);
+        assert(message);
         assert(s);
 
-        b = seat_can_graphical(s);
-
-        if (!dbus_message_iter_append_basic(i, DBUS_TYPE_BOOLEAN, &b))
-                return -ENOMEM;
-
-        return 0;
+        r = bus_verify_polkit_async(
+                        message,
+                        CAP_KILL,
+                        "org.freedesktop.login1.manage",
+                        NULL,
+                        false,
+                        UID_INVALID,
+                        &s->manager->polkit_registry,
+                        error);
+        if (r < 0)
+                return r;
+        if (r == 0)
+                return 1; /* Will call us back */
+
+        r = seat_stop_sessions(s, true);
+        if (r < 0)
+                return r;
+
+        return sd_bus_reply_method_return(message, NULL);
 }
 
-static int bus_seat_append_idle_hint(DBusMessageIter *i, const char *property, void *data) {
-        Seat *s = data;
-        dbus_bool_t b;
+static int method_activate_session(sd_bus_message *message, void *userdata, sd_bus_error *error) {
+        Seat *s = userdata;
+        const char *name;
+        Session *session;
+        int r;
 
-        assert(i);
-        assert(property);
+        assert(message);
         assert(s);
 
-        b = seat_get_idle_hint(s, NULL) > 0;
-        if (!dbus_message_iter_append_basic(i, DBUS_TYPE_BOOLEAN, &b))
-                return -ENOMEM;
+        r = sd_bus_message_read(message, "s", &name);
+        if (r < 0)
+                return r;
+
+        session = hashmap_get(s->manager->sessions, name);
+        if (!session)
+                return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_SESSION, "No session '%s' known", name);
 
-        return 0;
+        if (session->seat != s)
+                return sd_bus_error_setf(error, BUS_ERROR_SESSION_NOT_ON_SEAT, "Session %s not on seat %s", name, s->id);
+
+        r = session_activate(session);
+        if (r < 0)
+                return r;
+
+        return sd_bus_reply_method_return(message, NULL);
 }
 
-static int bus_seat_append_idle_hint_since(DBusMessageIter *i, const char *property, void *data) {
-        Seat *s = data;
-        dual_timestamp t;
-        uint64_t k;
+static int method_switch_to(sd_bus_message *message, void *userdata, sd_bus_error *error) {
+        Seat *s = userdata;
+        unsigned int to;
+        int r;
 
-        assert(i);
-        assert(property);
+        assert(message);
         assert(s);
 
-        seat_get_idle_hint(s, &t);
-        k = streq(property, "IdleSinceHint") ? t.realtime : t.monotonic;
+        r = sd_bus_message_read(message, "u", &to);
+        if (r < 0)
+                return r;
 
-        if (!dbus_message_iter_append_basic(i, DBUS_TYPE_UINT64, &k))
-                return -ENOMEM;
+        if (to <= 0)
+                return -EINVAL;
+
+        r = seat_switch_to(s, to);
+        if (r < 0)
+                return r;
 
-        return 0;
+        return sd_bus_reply_method_return(message, NULL);
 }
 
-static int get_seat_for_path(Manager *m, const char *path, Seat **_s) {
-        Seat *s;
-        char *id;
+static int method_switch_to_next(sd_bus_message *message, void *userdata, sd_bus_error *error) {
+        Seat *s = userdata;
+        int r;
 
-        assert(m);
-        assert(path);
-        assert(_s);
+        assert(message);
+        assert(s);
 
-        if (!startswith(path, "/org/freedesktop/login1/seat/"))
-                return -EINVAL;
+        r = seat_switch_to_next(s);
+        if (r < 0)
+                return r;
 
-        id = bus_path_unescape(path + 29);
-        if (!id)
-                return -ENOMEM;
+        return sd_bus_reply_method_return(message, NULL);
+}
 
-        s = hashmap_get(m->seats, id);
-        free(id);
+static int method_switch_to_previous(sd_bus_message *message, void *userdata, sd_bus_error *error) {
+        Seat *s = userdata;
+        int r;
+
+        assert(message);
+        assert(s);
 
-        if (!s)
-                return -ENOENT;
+        r = seat_switch_to_previous(s);
+        if (r < 0)
+                return r;
 
-        *_s = s;
-        return 0;
+        return sd_bus_reply_method_return(message, NULL);
 }
 
-static const BusProperty bus_login_seat_properties[] = {
-        { "Id",                     bus_property_append_string,      "s", offsetof(Seat, id), true },
-        { "ActiveSession",          bus_seat_append_active,       "(so)", 0 },
-        { "CanMultiSession",        bus_seat_append_can_multi_session, "b", 0 },
-        { "CanTTY",                 bus_seat_append_can_tty,         "b", 0 },
-        { "CanGraphical",           bus_seat_append_can_graphical,   "b", 0 },
-        { "Sessions",               bus_seat_append_sessions,    "a(so)", 0 },
-        { "IdleHint",               bus_seat_append_idle_hint,       "b", 0 },
-        { "IdleSinceHint",          bus_seat_append_idle_hint_since, "t", 0 },
-        { "IdleSinceHintMonotonic", bus_seat_append_idle_hint_since, "t", 0 },
-        { NULL, }
+const sd_bus_vtable seat_vtable[] = {
+        SD_BUS_VTABLE_START(0),
+
+        SD_BUS_PROPERTY("Id", "s", NULL, offsetof(Seat, id), SD_BUS_VTABLE_PROPERTY_CONST),
+        SD_BUS_PROPERTY("ActiveSession", "(so)", property_get_active_session, 0, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
+        SD_BUS_PROPERTY("CanMultiSession", "b", property_get_can_multi_session, 0, SD_BUS_VTABLE_PROPERTY_CONST),
+        SD_BUS_PROPERTY("CanTTY", "b", property_get_can_tty, 0, SD_BUS_VTABLE_PROPERTY_CONST),
+        SD_BUS_PROPERTY("CanGraphical", "b", property_get_can_graphical, 0, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
+        SD_BUS_PROPERTY("Sessions", "a(so)", property_get_sessions, 0, 0),
+        SD_BUS_PROPERTY("IdleHint", "b", property_get_idle_hint, 0, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
+        SD_BUS_PROPERTY("IdleSinceHint", "t", property_get_idle_since_hint, 0, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
+        SD_BUS_PROPERTY("IdleSinceHintMonotonic", "t", property_get_idle_since_hint, 0, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
+
+        SD_BUS_METHOD("Terminate", NULL, NULL, bus_seat_method_terminate, SD_BUS_VTABLE_UNPRIVILEGED),
+        SD_BUS_METHOD("ActivateSession", "s", NULL, method_activate_session, SD_BUS_VTABLE_UNPRIVILEGED),
+        SD_BUS_METHOD("SwitchTo", "u", NULL, method_switch_to, SD_BUS_VTABLE_UNPRIVILEGED),
+        SD_BUS_METHOD("SwitchToNext", NULL, NULL, method_switch_to_next, SD_BUS_VTABLE_UNPRIVILEGED),
+        SD_BUS_METHOD("SwitchToPrevious", NULL, NULL, method_switch_to_previous, SD_BUS_VTABLE_UNPRIVILEGED),
+
+        SD_BUS_VTABLE_END
 };
 
-static DBusHandlerResult seat_message_dispatch(
-                Seat *s,
-                DBusConnection *connection,
-                DBusMessage *message) {
-
-        DBusError error;
-        _cleanup_dbus_message_unref_ DBusMessage *reply = NULL;
+int seat_object_find(sd_bus *bus, const char *path, const char *interface, void *userdata, void **found, sd_bus_error *error) {
+        Manager *m = userdata;
+        Seat *seat;
         int r;
 
-        assert(s);
-        assert(connection);
-        assert(message);
+        assert(bus);
+        assert(path);
+        assert(interface);
+        assert(found);
+        assert(m);
 
-        dbus_error_init(&error);
+        if (streq(path, "/org/freedesktop/login1/seat/self")) {
+                _cleanup_(sd_bus_creds_unrefp) sd_bus_creds *creds = NULL;
+                sd_bus_message *message;
+                Session *session;
+                const char *name;
 
-        if (dbus_message_is_method_call(message, "org.freedesktop.login1.Seat", "Terminate")) {
+                message = sd_bus_get_current_message(bus);
+                if (!message)
+                        return 0;
 
-                r = seat_stop_sessions(s);
+                r = sd_bus_query_sender_creds(message, SD_BUS_CREDS_SESSION|SD_BUS_CREDS_AUGMENT, &creds);
                 if (r < 0)
-                        return bus_send_error_reply(connection, message, NULL, r);
+                        return r;
 
-                reply = dbus_message_new_method_return(message);
-                if (!reply)
-                        goto oom;
+                r = sd_bus_creds_get_session(creds, &name);
+                if (r < 0)
+                        return r;
 
-        } else if (dbus_message_is_method_call(message, "org.freedesktop.login1.Seat", "ActivateSession")) {
-                const char *name;
-                Session *session;
+                session = hashmap_get(m->sessions, name);
+                if (!session)
+                        return 0;
 
-                if (!dbus_message_get_args(
-                                    message,
-                                    &error,
-                                    DBUS_TYPE_STRING, &name,
-                                    DBUS_TYPE_INVALID))
-                        return bus_send_error_reply(connection, message, &error, -EINVAL);
+                seat = session->seat;
+        } else {
+                _cleanup_free_ char *e = NULL;
+                const char *p;
 
-                session = hashmap_get(s->manager->sessions, name);
-                if (!session || session->seat != s)
-                        return bus_send_error_reply(connection, message, &error, -ENOENT);
+                p = startswith(path, "/org/freedesktop/login1/seat/");
+                if (!p)
+                        return 0;
 
-                r = session_activate(session);
-                if (r < 0)
-                        return bus_send_error_reply(connection, message, NULL, r);
+                e = bus_label_unescape(p);
+                if (!e)
+                        return -ENOMEM;
 
-                reply = dbus_message_new_method_return(message);
-                if (!reply)
-                        goto oom;
-        } else {
-                const BusBoundProperties bps[] = {
-                        { "org.freedesktop.login1.Seat", bus_login_seat_properties, s },
-                        { NULL, }
-                };
-                return bus_default_message_handler(connection, message, INTROSPECTION, INTERFACES_LIST, bps);
+                seat = hashmap_get(m->seats, e);
         }
 
-        if (reply) {
-                if (!bus_maybe_send_reply(connection, message, reply))
-                        goto oom;
-        }
+        if (!seat)
+                return 0;
 
-        return DBUS_HANDLER_RESULT_HANDLED;
+        *found = seat;
+        return 1;
+}
 
-oom:
-        dbus_error_free(&error);
+char *seat_bus_path(Seat *s) {
+        _cleanup_free_ char *t = NULL;
 
-        return DBUS_HANDLER_RESULT_NEED_MEMORY;
-}
+        assert(s);
 
-static DBusHandlerResult seat_message_handler(
-                DBusConnection *connection,
-                DBusMessage *message,
-                void *userdata) {
+        t = bus_label_escape(s->id);
+        if (!t)
+                return NULL;
 
+        return strappend("/org/freedesktop/login1/seat/", t);
+}
+
+int seat_node_enumerator(sd_bus *bus, const char *path, void *userdata, char ***nodes, sd_bus_error *error) {
+        _cleanup_strv_free_ char **l = NULL;
+        sd_bus_message *message;
         Manager *m = userdata;
-        Seat *s;
+        Seat *seat;
+        Iterator i;
         int r;
 
-        r = get_seat_for_path(m, dbus_message_get_path(message), &s);
-        if (r < 0) {
-
-                if (r == -ENOMEM)
-                        return DBUS_HANDLER_RESULT_NEED_MEMORY;
+        assert(bus);
+        assert(path);
+        assert(nodes);
 
-                if (r == -ENOENT) {
-                        DBusError e;
+        HASHMAP_FOREACH(seat, m->seats, i) {
+                char *p;
 
-                        dbus_error_init(&e);
-                        dbus_set_error_const(&e, DBUS_ERROR_UNKNOWN_OBJECT, "Unknown seat");
-                        return bus_send_error_reply(connection, message, &e, r);
-                }
+                p = seat_bus_path(seat);
+                if (!p)
+                        return -ENOMEM;
 
-                return bus_send_error_reply(connection, message, NULL, r);
+                r = strv_consume(&l, p);
+                if (r < 0)
+                        return r;
         }
 
-        return seat_message_dispatch(s, connection, message);
-}
-
-const DBusObjectPathVTable bus_seat_vtable = {
-        .message_function = seat_message_handler
-};
-
-char *seat_bus_path(Seat *s) {
-        _cleanup_free_ char *t;
+        message = sd_bus_get_current_message(bus);
+        if (message) {
+                _cleanup_(sd_bus_creds_unrefp) sd_bus_creds *creds = NULL;
+                const char *name;
+                Session *session;
 
-        assert(s);
+                r = sd_bus_query_sender_creds(message, SD_BUS_CREDS_SESSION|SD_BUS_CREDS_AUGMENT, &creds);
+                if (r >= 0) {
+                        r = sd_bus_creds_get_session(creds, &name);
+                        if (r >= 0) {
+                                session = hashmap_get(m->sessions, name);
+                                if (session && session->seat) {
+                                        r = strv_extend(&l, "/org/freedesktop/login1/seat/self");
+                                        if (r < 0)
+                                                return r;
+                                }
+                        }
+                }
+        }
 
-        t = bus_path_escape(s->id);
-        if (!t)
-                return NULL;
+        *nodes = l;
+        l = NULL;
 
-        return strappend("/org/freedesktop/login1/seat/", t);
+        return 1;
 }
 
 int seat_send_signal(Seat *s, bool new_seat) {
-        _cleanup_dbus_message_unref_ DBusMessage *m = NULL;
         _cleanup_free_ char *p = NULL;
 
         assert(s);
 
-        m = dbus_message_new_signal("/org/freedesktop/login1",
-                                    "org.freedesktop.login1.Manager",
-                                    new_seat ? "SeatNew" : "SeatRemoved");
-        if (!m)
-                return -ENOMEM;
-
         p = seat_bus_path(s);
         if (!p)
                 return -ENOMEM;
 
-        if (!dbus_message_append_args(
-                            m,
-                            DBUS_TYPE_STRING, &s->id,
-                            DBUS_TYPE_OBJECT_PATH, &p,
-                            DBUS_TYPE_INVALID))
-                return -ENOMEM;
-
-        if (!dbus_connection_send(s->manager->bus, m, NULL))
-                return -ENOMEM;
-
-        return 0;
+        return sd_bus_emit_signal(
+                        s->manager->bus,
+                        "/org/freedesktop/login1",
+                        "org.freedesktop.login1.Manager",
+                        new_seat ? "SeatNew" : "SeatRemoved",
+                        "so", s->id, p);
 }
 
-int seat_send_changed(Seat *s, const char *properties) {
-        _cleanup_dbus_message_unref_ DBusMessage *m = NULL;
+int seat_send_changed(Seat *s, const char *properties, ...) {
         _cleanup_free_ char *p = NULL;
+        char **l;
 
         assert(s);
 
@@ -401,12 +468,7 @@ int seat_send_changed(Seat *s, const char *properties) {
         if (!p)
                 return -ENOMEM;
 
-        m = bus_properties_changed_new(p, "org.freedesktop.login1.Seat", properties);
-        if (!m)
-                return -ENOMEM;
-
-        if (!dbus_connection_send(s->manager->bus, m, NULL))
-                return -ENOMEM;
+        l = strv_from_stdarg_alloca(properties);
 
-        return 0;
+        return sd_bus_emit_properties_changed_strv(s->manager->bus, p, "org.freedesktop.login1.Seat", l);
 }