1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
4 This file is part of systemd.
6 Copyright 2011 Lennart Poettering
8 systemd is free software; you can redistribute it and/or modify it
9 under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 systemd is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with systemd; If not, see <http://www.gnu.org/licenses/>.
27 #include "dbus-common.h"
30 #define BUS_MANAGER_INTERFACE \
31 " <interface name=\"org.freedesktop.login1.Manager\">\n" \
32 " <method name=\"GetSession\">\n" \
33 " <arg name=\"id\" type=\"s\" direction=\"in\"/>\n" \
34 " <arg name=\"session\" type=\"o\" direction=\"out\"/>\n" \
36 " <method name=\"GetUser\">\n" \
37 " <arg name=\"uid\" type=\"u\" direction=\"in\"/>\n" \
38 " <arg name=\"user\" type=\"o\" direction=\"out\"/>\n" \
40 " <method name=\"GetSeat\">\n" \
41 " <arg name=\"id\" type=\"s\" direction=\"in\"/>\n" \
42 " <arg name=\"seat\" type=\"o\" direction=\"out\"/>\n" \
44 " <method name=\"ListSessions\">\n" \
45 " <arg name=\"sessions\" type=\"a(susso)\" direction=\"out\"/>\n" \
47 " <method name=\"ListUsers\">\n" \
48 " <arg name=\"users\" type=\"a(uso)\" direction=\"out\"/>\n" \
50 " <method name=\"ListSeats\">\n" \
51 " <arg name=\"seats\" type=\"a(so)\" direction=\"out\"/>\n" \
53 " <method name=\"CreateSession\">\n" \
54 " <arg name=\"uid\" type=\"u\" direction=\"in\"/>\n" \
55 " <arg name=\"leader\" type=\"u\" direction=\"in\"/>\n" \
56 " <arg name=\"sevice\" type=\"s\" direction=\"in\"/>\n" \
57 " <arg name=\"type\" type=\"s\" direction=\"in\"/>\n" \
58 " <arg name=\"seat\" type=\"s\" direction=\"in\"/>\n" \
59 " <arg name=\"vtnr\" type=\"u\" direction=\"in\"/>\n" \
60 " <arg name=\"tty\" type=\"s\" direction=\"in\"/>\n" \
61 " <arg name=\"display\" type=\"s\" direction=\"in\"/>\n" \
62 " <arg name=\"remote\" type=\"b\" direction=\"in\"/>\n" \
63 " <arg name=\"remote_user\" type=\"s\" direction=\"in\"/>\n" \
64 " <arg name=\"remote_host\" type=\"s\" direction=\"in\"/>\n" \
65 " <arg name=\"controllers\" type=\"as\" direction=\"in\"/>\n" \
66 " <arg name=\"reset_controllers\" type=\"as\" direction=\"in\"/>\n" \
67 " <arg name=\"kill_processes\" type=\"b\" direction=\"in\"/>\n" \
68 " <arg name=\"id\" type=\"s\" direction=\"out\"/>\n" \
69 " <arg name=\"path\" type=\"o\" direction=\"out\"/>\n" \
70 " <arg name=\"runtime_path\" type=\"o\" direction=\"out\"/>\n" \
71 " <arg name=\"fd\" type=\"h\" direction=\"out\"/>\n" \
73 " <method name=\"ActivateSession\">\n" \
74 " <arg name=\"id\" type=\"s\" direction=\"in\"/>\n" \
76 " <method name=\"TerminateSession\">\n" \
77 " <arg name=\"id\" type=\"s\" direction=\"in\"/>\n" \
79 " <method name=\"TerminateUser\">\n" \
80 " <arg name=\"uid\" type=\"u\" direction=\"in\"/>\n" \
82 " <method name=\"TerminateSeat\">\n" \
83 " <arg name=\"id\" type=\"s\" direction=\"in\"/>\n" \
85 " <signal name=\"SessionNew\">\n" \
86 " <arg name=\"id\" type=\"s\"/>\n" \
87 " <arg name=\"path\" type=\"o\"/>\n" \
89 " <signal name=\"SessionRemoved\">\n" \
90 " <arg name=\"id\" type=\"s\"/>\n" \
91 " <arg name=\"path\" type=\"o\"/>\n" \
93 " <signal name=\"UserNew\">\n" \
94 " <arg name=\"uid\" type=\"u\"/>\n" \
95 " <arg name=\"path\" type=\"o\"/>\n" \
97 " <signal name=\"UserRemoved\">\n" \
98 " <arg name=\"uid\" type=\"u\"/>\n" \
99 " <arg name=\"path\" type=\"o\"/>\n" \
101 " <signal name=\"SeatNew\">\n" \
102 " <arg name=\"id\" type=\"s\"/>\n" \
103 " <arg name=\"path\" type=\"o\"/>\n" \
105 " <signal name=\"SeatRemoved\">\n" \
106 " <arg name=\"id\" type=\"s\"/>\n" \
107 " <arg name=\"path\" type=\"o\"/>\n" \
109 " <property name=\"ControlGroupHierarchy\" type=\"s\" access=\"read\"/>\n" \
110 " <property name=\"Controllers\" type=\"as\" access=\"read\"/>\n" \
111 " <property name=\"ResetControllers\" type=\"as\" access=\"read\"/>\n" \
112 " <property name=\"NAutoVTs\" type=\"u\" access=\"read\"/>\n" \
113 " <property name=\"KillOnlyUsers\" type=\"as\" access=\"read\"/>\n" \
114 " <property name=\"KillExcludeUsers\" type=\"as\" access=\"read\"/>\n" \
115 " <property name=\"KillUserProcesses\" type=\"b\" access=\"read\"/>\n" \
116 " <property name=\"IdleHint\" type=\"b\" access=\"read\"/>\n" \
117 " <property name=\"IdleSinceHint\" type=\"t\" access=\"read\"/>\n" \
118 " <property name=\"IdleSinceHintMonotonic\" type=\"t\" access=\"read\"/>\n" \
121 #define INTROSPECTION_BEGIN \
122 DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE \
124 BUS_MANAGER_INTERFACE \
125 BUS_PROPERTIES_INTERFACE \
127 BUS_INTROSPECTABLE_INTERFACE
129 #define INTROSPECTION_END \
132 #define INTERFACES_LIST \
133 BUS_GENERIC_INTERFACES_LIST \
134 "org.freedesktop.login1.Manager\0"
136 static int bus_manager_append_idle_hint(DBusMessageIter *i, const char *property, void *data) {
144 b = manager_get_idle_hint(m, NULL) > 0;
145 if (!dbus_message_iter_append_basic(i, DBUS_TYPE_BOOLEAN, &b))
151 static int bus_manager_append_idle_hint_since(DBusMessageIter *i, const char *property, void *data) {
160 manager_get_idle_hint(m, &t);
161 u = streq(property, "IdleSinceHint") ? t.realtime : t.monotonic;
163 if (!dbus_message_iter_append_basic(i, DBUS_TYPE_UINT64, &u))
169 static int bus_manager_create_session(Manager *m, DBusMessage *message, DBusMessage **_reply) {
170 Session *session = NULL;
172 const char *type, *seat, *tty, *display, *remote_user, *remote_host, *service;
173 uint32_t uid, leader, audit_id = 0;
174 dbus_bool_t remote, kill_processes;
175 char **controllers = NULL, **reset_controllers = NULL;
178 DBusMessageIter iter;
182 int pipe_fds[2] = { -1, -1 };
183 DBusMessage *reply = NULL;
190 if (!dbus_message_iter_init(message, &iter) ||
191 dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_UINT32)
194 dbus_message_iter_get_basic(&iter, &uid);
196 if (!dbus_message_iter_next(&iter) ||
197 dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_UINT32)
200 dbus_message_iter_get_basic(&iter, &leader);
203 !dbus_message_iter_next(&iter) ||
204 dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING)
207 dbus_message_iter_get_basic(&iter, &service);
209 if (!dbus_message_iter_next(&iter) ||
210 dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING)
213 dbus_message_iter_get_basic(&iter, &type);
214 t = session_type_from_string(type);
217 !dbus_message_iter_next(&iter) ||
218 dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING)
221 dbus_message_iter_get_basic(&iter, &seat);
226 s = hashmap_get(m->seats, seat);
231 if (!dbus_message_iter_next(&iter) ||
232 dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_UINT32)
235 dbus_message_iter_get_basic(&iter, &vtnr);
237 if (!dbus_message_iter_next(&iter) ||
238 dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING)
241 dbus_message_iter_get_basic(&iter, &tty);
243 if (tty_is_vc(tty)) {
248 else if (s != m->vtconsole)
251 v = vtnr_from_tty(tty);
254 return v < 0 ? v : -EINVAL;
258 else if (vtnr != (uint32_t) v)
261 } else if (!isempty(tty) && s && seat_is_vtconsole(s))
265 if (seat_is_vtconsole(s)) {
266 if (vtnr <= 0 || vtnr > 63)
274 if (!dbus_message_iter_next(&iter) ||
275 dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING)
278 dbus_message_iter_get_basic(&iter, &display);
280 if (!dbus_message_iter_next(&iter) ||
281 dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_BOOLEAN)
284 dbus_message_iter_get_basic(&iter, &remote);
286 if (!dbus_message_iter_next(&iter) ||
287 dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING)
290 dbus_message_iter_get_basic(&iter, &remote_user);
292 if (!dbus_message_iter_next(&iter) ||
293 dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING)
296 dbus_message_iter_get_basic(&iter, &remote_host);
298 if (!dbus_message_iter_next(&iter) ||
299 dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_ARRAY ||
300 dbus_message_iter_get_element_type(&iter) != DBUS_TYPE_STRING)
303 r = bus_parse_strv_iter(&iter, &controllers);
307 if (!dbus_message_iter_next(&iter) ||
308 dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_ARRAY ||
309 dbus_message_iter_get_element_type(&iter) != DBUS_TYPE_STRING) {
314 r = bus_parse_strv_iter(&iter, &reset_controllers);
318 if (!dbus_message_iter_next(&iter) ||
319 dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_BOOLEAN) {
324 dbus_message_iter_get_basic(&iter, &kill_processes);
326 r = manager_add_user_by_uid(m, uid, &user);
330 audit_session_from_pid(leader, &audit_id);
333 asprintf(&id, "%lu", (unsigned long) audit_id);
340 session = hashmap_get(m->sessions, id);
344 /* Session already exists, client is probably
345 * something like "su" which changes uid but
346 * is still the same audit session */
348 reply = dbus_message_new_method_return(message);
354 /* Create a throw-away fd */
355 if (pipe(pipe_fds) < 0) {
360 close_nointr_nofail(pipe_fds[0]);
363 p = session_bus_path(session);
369 b = dbus_message_append_args(
371 DBUS_TYPE_STRING, &session->id,
372 DBUS_TYPE_OBJECT_PATH, &p,
373 DBUS_TYPE_STRING, &session->user->runtime_path,
374 DBUS_TYPE_UNIX_FD, &pipe_fds[1],
383 close_nointr_nofail(pipe_fds[1]);
392 asprintf(&id, "c%lu", ++m->session_counter);
399 } while (hashmap_get(m->sessions, id));
402 r = manager_add_session(m, user, id, &session);
407 session->leader = leader;
408 session->audit_id = audit_id;
410 session->remote = remote;
411 session->controllers = controllers;
412 session->reset_controllers = reset_controllers;
413 session->kill_processes = kill_processes;
414 session->vtnr = vtnr;
416 controllers = reset_controllers = NULL;
419 session->tty = strdup(tty);
426 if (!isempty(display)) {
427 session->display = strdup(display);
428 if (!session->display) {
434 if (!isempty(remote_user)) {
435 session->remote_user = strdup(remote_user);
436 if (!session->remote_user) {
442 if (!isempty(remote_host)) {
443 session->remote_host = strdup(remote_host);
444 if (!session->remote_host) {
450 if (!isempty(service)) {
451 session->service = strdup(service);
452 if (!session->service) {
458 if (pipe(pipe_fds) < 0) {
463 r = session_set_pipe_fd(session, pipe_fds[0]);
469 r = seat_attach_session(s, session);
474 r = session_start(session);
478 reply = dbus_message_new_method_return(message);
484 p = session_bus_path(session);
490 b = dbus_message_append_args(
492 DBUS_TYPE_STRING, &session->id,
493 DBUS_TYPE_OBJECT_PATH, &p,
494 DBUS_TYPE_STRING, &session->user->runtime_path,
495 DBUS_TYPE_UNIX_FD, &pipe_fds[1],
504 close_nointr_nofail(pipe_fds[1]);
510 strv_free(controllers);
511 strv_free(reset_controllers);
514 session_add_to_gc_queue(session);
517 user_add_to_gc_queue(user);
519 close_pipe(pipe_fds);
522 dbus_message_unref(reply);
527 static DBusHandlerResult manager_message_handler(
528 DBusConnection *connection,
529 DBusMessage *message,
532 Manager *m = userdata;
534 const BusProperty properties[] = {
535 { "org.freedesktop.login1.Manager", "ControlGroupHierarchy", bus_property_append_string, "s", m->cgroup_path },
536 { "org.freedesktop.login1.Manager", "Controllers", bus_property_append_strv, "as", m->controllers },
537 { "org.freedesktop.login1.Manager", "NAutoVTs", bus_property_append_unsigned, "u", &m->n_autovts },
538 { "org.freedesktop.login1.Manager", "KillOnlyUsers", bus_property_append_strv, "as", m->kill_only_users },
539 { "org.freedesktop.login1.Manager", "KillExcludeUsers", bus_property_append_strv, "as", m->kill_exclude_users },
540 { "org.freedesktop.login1.Manager", "KillUserProcesses", bus_property_append_bool, "b", &m->kill_user_processes },
541 { "org.freedesktop.login1.Manager", "IdleHint", bus_manager_append_idle_hint, "b", m },
542 { "org.freedesktop.login1.Manager", "IdleSinceHint", bus_manager_append_idle_hint_since, "t", m },
543 { "org.freedesktop.login1.Manager", "IdleSinceHintMonotonic", bus_manager_append_idle_hint_since, "t", m },
544 { NULL, NULL, NULL, NULL, NULL }
548 DBusMessage *reply = NULL;
555 dbus_error_init(&error);
557 if (dbus_message_is_method_call(message, "org.freedesktop.login1.Manager", "GetSession")) {
563 if (!dbus_message_get_args(
566 DBUS_TYPE_STRING, &name,
568 return bus_send_error_reply(connection, message, &error, -EINVAL);
570 session = hashmap_get(m->sessions, name);
572 return bus_send_error_reply(connection, message, &error, -ENOENT);
574 reply = dbus_message_new_method_return(message);
578 p = session_bus_path(session);
582 b = dbus_message_append_args(
584 DBUS_TYPE_OBJECT_PATH, &p,
591 } else if (dbus_message_is_method_call(message, "org.freedesktop.login1.Manager", "GetUser")) {
597 if (!dbus_message_get_args(
600 DBUS_TYPE_UINT32, &uid,
602 return bus_send_error_reply(connection, message, &error, -EINVAL);
604 user = hashmap_get(m->users, ULONG_TO_PTR((unsigned long) uid));
606 return bus_send_error_reply(connection, message, &error, -ENOENT);
608 reply = dbus_message_new_method_return(message);
612 p = user_bus_path(user);
616 b = dbus_message_append_args(
618 DBUS_TYPE_OBJECT_PATH, &p,
625 } else if (dbus_message_is_method_call(message, "org.freedesktop.login1.Manager", "GetSeat")) {
631 if (!dbus_message_get_args(
634 DBUS_TYPE_STRING, &name,
636 return bus_send_error_reply(connection, message, &error, -EINVAL);
638 seat = hashmap_get(m->seats, name);
640 return bus_send_error_reply(connection, message, &error, -ENOENT);
642 reply = dbus_message_new_method_return(message);
646 p = seat_bus_path(seat);
650 b = dbus_message_append_args(
652 DBUS_TYPE_OBJECT_PATH, &p,
659 } else if (dbus_message_is_method_call(message, "org.freedesktop.login1.Manager", "ListSessions")) {
663 DBusMessageIter iter, sub;
664 const char *empty = "";
666 reply = dbus_message_new_method_return(message);
670 dbus_message_iter_init_append(reply, &iter);
672 if (!dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "(susso)", &sub))
675 HASHMAP_FOREACH(session, m->sessions, i) {
676 DBusMessageIter sub2;
679 if (!dbus_message_iter_open_container(&sub, DBUS_TYPE_STRUCT, NULL, &sub2))
682 uid = session->user->uid;
684 p = session_bus_path(session);
688 if (!dbus_message_iter_append_basic(&sub2, DBUS_TYPE_STRING, &session->id) ||
689 !dbus_message_iter_append_basic(&sub2, DBUS_TYPE_UINT32, &uid) ||
690 !dbus_message_iter_append_basic(&sub2, DBUS_TYPE_STRING, &session->user->name) ||
691 !dbus_message_iter_append_basic(&sub2, DBUS_TYPE_STRING, session->seat ? (const char**) &session->seat->id : &empty) ||
692 !dbus_message_iter_append_basic(&sub2, DBUS_TYPE_OBJECT_PATH, &p)) {
699 if (!dbus_message_iter_close_container(&sub, &sub2))
703 if (!dbus_message_iter_close_container(&iter, &sub))
706 } else if (dbus_message_is_method_call(message, "org.freedesktop.login1.Manager", "ListUsers")) {
710 DBusMessageIter iter, sub;
712 reply = dbus_message_new_method_return(message);
716 dbus_message_iter_init_append(reply, &iter);
718 if (!dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "(uso)", &sub))
721 HASHMAP_FOREACH(user, m->users, i) {
722 DBusMessageIter sub2;
725 if (!dbus_message_iter_open_container(&sub, DBUS_TYPE_STRUCT, NULL, &sub2))
730 p = user_bus_path(user);
734 if (!dbus_message_iter_append_basic(&sub2, DBUS_TYPE_UINT32, &uid) ||
735 !dbus_message_iter_append_basic(&sub2, DBUS_TYPE_STRING, &user->name) ||
736 !dbus_message_iter_append_basic(&sub2, DBUS_TYPE_OBJECT_PATH, &p)) {
743 if (!dbus_message_iter_close_container(&sub, &sub2))
747 if (!dbus_message_iter_close_container(&iter, &sub))
750 } else if (dbus_message_is_method_call(message, "org.freedesktop.login1.Manager", "ListSeats")) {
754 DBusMessageIter iter, sub;
756 reply = dbus_message_new_method_return(message);
760 dbus_message_iter_init_append(reply, &iter);
762 if (!dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "(so)", &sub))
765 HASHMAP_FOREACH(seat, m->seats, i) {
766 DBusMessageIter sub2;
768 if (!dbus_message_iter_open_container(&sub, DBUS_TYPE_STRUCT, NULL, &sub2))
771 p = seat_bus_path(seat);
775 if (!dbus_message_iter_append_basic(&sub2, DBUS_TYPE_STRING, &seat->id) ||
776 !dbus_message_iter_append_basic(&sub2, DBUS_TYPE_OBJECT_PATH, &p)) {
783 if (!dbus_message_iter_close_container(&sub, &sub2))
787 if (!dbus_message_iter_close_container(&iter, &sub))
790 } else if (dbus_message_is_method_call(message, "org.freedesktop.login1.Manager", "CreateSession")) {
792 r = bus_manager_create_session(m, message, &reply);
797 return bus_send_error_reply(connection, message, &error, r);
799 } else if (dbus_message_is_method_call(message, "org.freedesktop.login1.Manager", "ActivateSession")) {
803 if (!dbus_message_get_args(
806 DBUS_TYPE_STRING, &name,
808 return bus_send_error_reply(connection, message, &error, -EINVAL);
810 session = hashmap_get(m->sessions, name);
812 return bus_send_error_reply(connection, message, &error, -ENOENT);
814 r = session_activate(session);
816 return bus_send_error_reply(connection, message, NULL, r);
818 reply = dbus_message_new_method_return(message);
822 } else if (dbus_message_is_method_call(message, "org.freedesktop.login1.Manager", "TerminateSession")) {
826 if (!dbus_message_get_args(
829 DBUS_TYPE_STRING, &name,
831 return bus_send_error_reply(connection, message, &error, -EINVAL);
833 session = hashmap_get(m->sessions, name);
835 return bus_send_error_reply(connection, message, &error, -ENOENT);
837 r = session_stop(session);
839 return bus_send_error_reply(connection, message, NULL, r);
841 reply = dbus_message_new_method_return(message);
845 } else if (dbus_message_is_method_call(message, "org.freedesktop.login1.Manager", "TerminateUser")) {
849 if (!dbus_message_get_args(
852 DBUS_TYPE_UINT32, &uid,
854 return bus_send_error_reply(connection, message, &error, -EINVAL);
856 user = hashmap_get(m->users, ULONG_TO_PTR((unsigned long) uid));
858 return bus_send_error_reply(connection, message, &error, -ENOENT);
862 return bus_send_error_reply(connection, message, NULL, r);
864 reply = dbus_message_new_method_return(message);
868 } else if (dbus_message_is_method_call(message, "org.freedesktop.login1.Manager", "TerminateSeat")) {
872 if (!dbus_message_get_args(
875 DBUS_TYPE_STRING, &name,
877 return bus_send_error_reply(connection, message, &error, -EINVAL);
879 seat = hashmap_get(m->seats, name);
881 return bus_send_error_reply(connection, message, &error, -ENOENT);
883 r = seat_stop_sessions(seat);
885 return bus_send_error_reply(connection, message, NULL, r);
887 reply = dbus_message_new_method_return(message);
891 } else if (dbus_message_is_method_call(message, "org.freedesktop.DBus.Introspectable", "Introspect")) {
892 char *introspection = NULL;
901 if (!(reply = dbus_message_new_method_return(message)))
904 /* We roll our own introspection code here, instead of
905 * relying on bus_default_message_handler() because we
906 * need to generate our introspection string
909 if (!(f = open_memstream(&introspection, &size)))
912 fputs(INTROSPECTION_BEGIN, f);
914 HASHMAP_FOREACH(seat, m->seats, i) {
915 p = bus_path_escape(seat->id);
918 fprintf(f, "<node name=\"seat/%s\"/>", p);
923 HASHMAP_FOREACH(user, m->users, i)
924 fprintf(f, "<node name=\"user/%llu\"/>", (unsigned long long) user->uid);
926 HASHMAP_FOREACH(session, m->sessions, i) {
927 p = bus_path_escape(session->id);
930 fprintf(f, "<node name=\"session/%s\"/>", p);
935 fputs(INTROSPECTION_END, f);
948 if (!dbus_message_append_args(reply, DBUS_TYPE_STRING, &introspection, DBUS_TYPE_INVALID)) {
955 return bus_default_message_handler(connection, message, NULL, INTERFACES_LIST, properties);
958 if (!dbus_connection_send(connection, reply, NULL))
961 dbus_message_unref(reply);
964 return DBUS_HANDLER_RESULT_HANDLED;
968 dbus_message_unref(reply);
970 dbus_error_free(&error);
972 return DBUS_HANDLER_RESULT_NEED_MEMORY;
975 const DBusObjectPathVTable bus_manager_vtable = {
976 .message_function = manager_message_handler
979 DBusHandlerResult bus_message_filter(
980 DBusConnection *connection,
981 DBusMessage *message,
984 Manager *m = userdata;
991 dbus_error_init(&error);
993 if (dbus_message_is_signal(message, "org.freedesktop.systemd1.Agent", "Released")) {
996 if (!dbus_message_get_args(message, &error,
997 DBUS_TYPE_STRING, &cgroup,
999 log_error("Failed to parse Released message: %s", bus_error_message(&error));
1001 manager_cgroup_notify_empty(m, cgroup);
1004 dbus_error_free(&error);
1006 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
1009 int manager_send_changed(Manager *manager, const char *properties) {
1015 m = bus_properties_changed_new("/org/freedesktop/login1", "org.freedesktop.login1.Manager", properties);
1019 if (!dbus_connection_send(manager->bus, m, NULL))
1026 dbus_message_unref(m);