chiark / gitweb /
systemctl: add --block switch for synchronous starting of units
[elogind.git] / src / dbus-manager.c
1 /*-*- Mode: C; c-basic-offset: 8 -*-*/
2
3 /***
4   This file is part of systemd.
5
6   Copyright 2010 Lennart Poettering
7
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.
12
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.
17
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/>.
20 ***/
21
22 #include <errno.h>
23
24 #include "dbus.h"
25 #include "log.h"
26 #include "dbus-manager.h"
27 #include "strv.h"
28
29 #define INTROSPECTION_BEGIN                                             \
30         DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE                       \
31         "<node>"                                                        \
32         " <interface name=\"org.freedesktop.systemd1.Manager\">"        \
33         "  <method name=\"GetUnit\">"                                   \
34         "   <arg name=\"name\" type=\"s\" direction=\"in\"/>"           \
35         "   <arg name=\"unit\" type=\"o\" direction=\"out\"/>"          \
36         "  </method>"                                                   \
37         "  <method name=\"LoadUnit\">"                                  \
38         "   <arg name=\"name\" type=\"s\" direction=\"in\"/>"           \
39         "   <arg name=\"unit\" type=\"o\" direction=\"out\"/>"          \
40         "  </method>"                                                   \
41         "  <method name=\"GetJob\">"                                    \
42         "   <arg name=\"id\" type=\"u\" direction=\"in\"/>"             \
43         "   <arg name=\"job\" type=\"o\" direction=\"out\"/>"           \
44         "  </method>"                                                   \
45         "  <method name=\"ClearJobs\"/>"                                \
46         "  <method name=\"ListUnits\">"                                 \
47         "   <arg name=\"units\" type=\"a(sssssouso)\" direction=\"out\"/>" \
48         "  </method>"                                                   \
49         "  <method name=\"ListJobs\">"                                  \
50         "   <arg name=\"jobs\" type=\"a(usssoo)\" direction=\"out\"/>"  \
51         "  </method>"                                                   \
52         "  <method name=\"Subscribe\"/>"                                \
53         "  <method name=\"Unsubscribe\"/>"                              \
54         "  <method name=\"Dump\"/>"                                     \
55         "  <method name=\"CreateSnapshot\">"                            \
56         "   <arg name=\"name\" type=\"s\" direction=\"in\"/>"           \
57         "   <arg nane=\"cleanup\" type=\"b\" direction=\"in\"/>"        \
58         "   <arg name=\"unit\" type=\"o\" direction=\"out\"/>"          \
59         "  </method>"                                                   \
60         "  <method name=\"Reload\"/>"                                   \
61         "  <method name=\"Reexecute\"/>"                                \
62         "  <method name=\"Exit\"/>"                                     \
63         "  <method name=\"SetEnvironment\">"                            \
64         "   <arg name=\"names\" type=\"as\" direction=\"in\"/>"         \
65         "  </method>"                                                   \
66         "  <method name=\"UnsetEnvironment\">"                          \
67         "   <arg name=\"names\" type=\"as\" direction=\"in\"/>"         \
68         "  </method>"                                                   \
69         "  <signal name=\"UnitNew\">"                                   \
70         "   <arg name=\"id\" type=\"s\"/>"                              \
71         "   <arg name=\"unit\" type=\"o\"/>"                            \
72         "  </signal>"                                                   \
73         "  <signal name=\"UnitRemoved\">"                               \
74         "   <arg name=\"id\" type=\"s\"/>"                              \
75         "   <arg name=\"unit\" type=\"o\"/>"                            \
76         "  </signal>"                                                   \
77         "  <signal name=\"JobNew\">"                                    \
78         "   <arg name=\"id\" type=\"u\"/>"                              \
79         "   <arg name=\"job\" type=\"o\"/>"                             \
80         "  </signal>"                                                   \
81         "  <signal name=\"JobRemoved\">"                                \
82         "   <arg name=\"id\" type=\"u\"/>"                              \
83         "   <arg name=\"job\" type=\"o\"/>"                             \
84         "   <arg name=\"success\" type=\"b\"/>"                         \
85         "  </signal>"                                                   \
86         "  <property name=\"Version\" type=\"s\" access=\"read\"/>"     \
87         "  <property name=\"RunningAs\" type=\"s\" access=\"read\"/>"   \
88         "  <property name=\"BootTimestamp\" type=\"t\" access=\"read\"/>" \
89         "  <property name=\"LogLevel\" type=\"s\" access=\"read\"/>"    \
90         "  <property name=\"LogTarget\" type=\"s\" access=\"read\"/>"   \
91         "  <property name=\"NNames\" type=\"u\" access=\"read\"/>"      \
92         "  <property name=\"NJobs\" type=\"u\" access=\"read\"/>"       \
93         "  <property name=\"Environment\" type=\"as\" access=\"read\"/>" \
94         " </interface>"                                                 \
95         BUS_PROPERTIES_INTERFACE                                        \
96         BUS_INTROSPECTABLE_INTERFACE
97
98 #define INTROSPECTION_END                                               \
99         "</node>"
100
101 static DEFINE_BUS_PROPERTY_APPEND_ENUM(bus_manager_append_running_as, manager_running_as, ManagerRunningAs);
102
103 static int bus_manager_append_log_target(Manager *m, DBusMessageIter *i, const char *property, void *data) {
104         const char *t;
105
106         assert(m);
107         assert(i);
108         assert(property);
109
110         t = log_target_to_string(log_get_target());
111
112         if (!dbus_message_iter_append_basic(i, DBUS_TYPE_STRING, &t))
113                 return -ENOMEM;
114
115         return 0;
116 }
117
118 static int bus_manager_append_log_level(Manager *m, DBusMessageIter *i, const char *property, void *data) {
119         const char *t;
120
121         assert(m);
122         assert(i);
123         assert(property);
124
125         t = log_level_to_string(log_get_max_level());
126
127         if (!dbus_message_iter_append_basic(i, DBUS_TYPE_STRING, &t))
128                 return -ENOMEM;
129
130         return 0;
131 }
132
133 static int bus_manager_append_n_names(Manager *m, DBusMessageIter *i, const char *property, void *data) {
134         uint32_t u;
135
136         assert(m);
137         assert(i);
138         assert(property);
139
140         u = hashmap_size(m->units);
141
142         if (!dbus_message_iter_append_basic(i, DBUS_TYPE_UINT32, &u))
143                 return -ENOMEM;
144
145         return 0;
146 }
147
148 static int bus_manager_append_n_jobs(Manager *m, DBusMessageIter *i, const char *property, void *data) {
149         uint32_t u;
150
151         assert(m);
152         assert(i);
153         assert(property);
154
155         u = hashmap_size(m->jobs);
156
157         if (!dbus_message_iter_append_basic(i, DBUS_TYPE_UINT32, &u))
158                 return -ENOMEM;
159
160         return 0;
161 }
162
163 static DBusHandlerResult bus_manager_message_handler(DBusConnection  *connection, DBusMessage *message, void *data) {
164         Manager *m = data;
165
166         const BusProperty properties[] = {
167                 { "org.freedesktop.systemd1.Manager", "Version",       bus_property_append_string,    "s", PACKAGE_STRING     },
168                 { "org.freedesktop.systemd1.Manager", "RunningAs",     bus_manager_append_running_as, "s", &m->running_as     },
169                 { "org.freedesktop.systemd1.Manager", "BootTimestamp", bus_property_append_uint64,    "t", &m->boot_timestamp },
170                 { "org.freedesktop.systemd1.Manager", "LogLevel",      bus_manager_append_log_level,  "s", NULL               },
171                 { "org.freedesktop.systemd1.Manager", "LogTarget",     bus_manager_append_log_target, "s", NULL               },
172                 { "org.freedesktop.systemd1.Manager", "NNames",        bus_manager_append_n_names,    "u", NULL               },
173                 { "org.freedesktop.systemd1.Manager", "NJobs",         bus_manager_append_n_jobs,     "u", NULL               },
174                 { "org.freedesktop.systemd1.Manager", "Environment",   bus_property_append_strv,      "as", m->environment   },
175                 { NULL, NULL, NULL, NULL, NULL }
176         };
177
178         int r;
179         DBusError error;
180         DBusMessage *reply = NULL;
181         char * path = NULL;
182
183         assert(connection);
184         assert(message);
185         assert(m);
186
187         dbus_error_init(&error);
188
189         log_debug("Got D-Bus request: %s.%s() on %s",
190                   dbus_message_get_interface(message),
191                   dbus_message_get_member(message),
192                   dbus_message_get_path(message));
193
194         if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Manager", "GetUnit")) {
195                 const char *name;
196                 Unit *u;
197
198                 if (!dbus_message_get_args(
199                                     message,
200                                     &error,
201                                     DBUS_TYPE_STRING, &name,
202                                     DBUS_TYPE_INVALID))
203                         return bus_send_error_reply(m, message, &error, -EINVAL);
204
205                 if (!(u = manager_get_unit(m, name)))
206                         return bus_send_error_reply(m, message, NULL, -ENOENT);
207
208                 if (!(reply = dbus_message_new_method_return(message)))
209                         goto oom;
210
211                 if (!(path = unit_dbus_path(u)))
212                         goto oom;
213
214                 if (!dbus_message_append_args(
215                                     reply,
216                                     DBUS_TYPE_OBJECT_PATH, &path,
217                                     DBUS_TYPE_INVALID))
218                         goto oom;
219
220         } else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Manager", "LoadUnit")) {
221                 const char *name;
222                 Unit *u;
223
224                 if (!dbus_message_get_args(
225                                     message,
226                                     &error,
227                                     DBUS_TYPE_STRING, &name,
228                                     DBUS_TYPE_INVALID))
229                         return bus_send_error_reply(m, message, &error, -EINVAL);
230
231                 if ((r = manager_load_unit(m, name, NULL, &u)) < 0)
232                         return bus_send_error_reply(m, message, NULL, r);
233
234                 if (!(reply = dbus_message_new_method_return(message)))
235                         goto oom;
236
237                 if (!(path = unit_dbus_path(u)))
238                         goto oom;
239
240                 if (!dbus_message_append_args(
241                                     reply,
242                                     DBUS_TYPE_OBJECT_PATH, &path,
243                                     DBUS_TYPE_INVALID))
244                         goto oom;
245
246         } else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Manager", "GetJob")) {
247                 uint32_t id;
248                 Job *j;
249
250                 if (!dbus_message_get_args(
251                                     message,
252                                     &error,
253                                     DBUS_TYPE_UINT32, &id,
254                                     DBUS_TYPE_INVALID))
255                         return bus_send_error_reply(m, message, &error, -EINVAL);
256
257                 if (!(j = manager_get_job(m, id)))
258                         return bus_send_error_reply(m, message, NULL, -ENOENT);
259
260                 if (!(reply = dbus_message_new_method_return(message)))
261                         goto oom;
262
263                 if (!(path = job_dbus_path(j)))
264                         goto oom;
265
266                 if (!dbus_message_append_args(
267                                     reply,
268                                     DBUS_TYPE_OBJECT_PATH, &path,
269                                     DBUS_TYPE_INVALID))
270                         goto oom;
271
272         } else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Manager", "ClearJobs")) {
273
274                 manager_clear_jobs(m);
275
276                 if (!(reply = dbus_message_new_method_return(message)))
277                         goto oom;
278
279         } else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Manager", "ListUnits")) {
280                 DBusMessageIter iter, sub;
281                 Iterator i;
282                 Unit *u;
283                 const char *k;
284
285                 if (!(reply = dbus_message_new_method_return(message)))
286                         goto oom;
287
288                 dbus_message_iter_init_append(reply, &iter);
289
290                 if (!dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "(sssssouso)", &sub))
291                         goto oom;
292
293                 HASHMAP_FOREACH_KEY(u, k, m->units, i) {
294                         char *u_path, *j_path;
295                         const char *description, *load_state, *active_state, *sub_state, *job_type;
296                         DBusMessageIter sub2;
297                         uint32_t job_id;
298
299                         if (k != u->meta.id)
300                                 continue;
301
302                         if (!dbus_message_iter_open_container(&sub, DBUS_TYPE_STRUCT, NULL, &sub2))
303                                 goto oom;
304
305                         description = unit_description(u);
306                         load_state = unit_load_state_to_string(u->meta.load_state);
307                         active_state = unit_active_state_to_string(unit_active_state(u));
308                         sub_state = unit_sub_state_to_string(u);
309
310                         if (!(u_path = unit_dbus_path(u)))
311                                 goto oom;
312
313                         if (u->meta.job) {
314                                 job_id = (uint32_t) u->meta.job->id;
315
316                                 if (!(j_path = job_dbus_path(u->meta.job))) {
317                                         free(u_path);
318                                         goto oom;
319                                 }
320
321                                 job_type = job_type_to_string(u->meta.job->type);
322                         } else {
323                                 job_id = 0;
324                                 j_path = u_path;
325                                 job_type = "";
326                         }
327
328                         if (!dbus_message_iter_append_basic(&sub2, DBUS_TYPE_STRING, &u->meta.id) ||
329                             !dbus_message_iter_append_basic(&sub2, DBUS_TYPE_STRING, &description) ||
330                             !dbus_message_iter_append_basic(&sub2, DBUS_TYPE_STRING, &load_state) ||
331                             !dbus_message_iter_append_basic(&sub2, DBUS_TYPE_STRING, &active_state) ||
332                             !dbus_message_iter_append_basic(&sub2, DBUS_TYPE_STRING, &sub_state) ||
333                             !dbus_message_iter_append_basic(&sub2, DBUS_TYPE_OBJECT_PATH, &u_path) ||
334                             !dbus_message_iter_append_basic(&sub2, DBUS_TYPE_UINT32, &job_id) ||
335                             !dbus_message_iter_append_basic(&sub2, DBUS_TYPE_STRING, &job_type) ||
336                             !dbus_message_iter_append_basic(&sub2, DBUS_TYPE_OBJECT_PATH, &j_path)) {
337                                 free(u_path);
338                                 if (u->meta.job)
339                                         free(j_path);
340                                 goto oom;
341                         }
342
343                         free(u_path);
344                         if (u->meta.job)
345                                 free(j_path);
346
347                         if (!dbus_message_iter_close_container(&sub, &sub2))
348                                 goto oom;
349                 }
350
351                 if (!dbus_message_iter_close_container(&iter, &sub))
352                         goto oom;
353
354         } else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Manager", "ListJobs")) {
355                 DBusMessageIter iter, sub;
356                 Iterator i;
357                 Job *j;
358
359                 if (!(reply = dbus_message_new_method_return(message)))
360                         goto oom;
361
362                 dbus_message_iter_init_append(reply, &iter);
363
364                 if (!dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "(usssoo)", &sub))
365                         goto oom;
366
367                 HASHMAP_FOREACH(j, m->jobs, i) {
368                         char *u_path, *j_path;
369                         const char *state, *type;
370                         uint32_t id;
371                         DBusMessageIter sub2;
372
373                         if (!dbus_message_iter_open_container(&sub, DBUS_TYPE_STRUCT, NULL, &sub2))
374                                 goto oom;
375
376                         id = (uint32_t) j->id;
377                         state = job_state_to_string(j->state);
378                         type = job_type_to_string(j->type);
379
380                         if (!(j_path = job_dbus_path(j)))
381                                 goto oom;
382
383                         if (!(u_path = unit_dbus_path(j->unit))) {
384                                 free(j_path);
385                                 goto oom;
386                         }
387
388                         if (!dbus_message_iter_append_basic(&sub2, DBUS_TYPE_UINT32, &id) ||
389                             !dbus_message_iter_append_basic(&sub2, DBUS_TYPE_STRING, &j->unit->meta.id) ||
390                             !dbus_message_iter_append_basic(&sub2, DBUS_TYPE_STRING, &type) ||
391                             !dbus_message_iter_append_basic(&sub2, DBUS_TYPE_STRING, &state) ||
392                             !dbus_message_iter_append_basic(&sub2, DBUS_TYPE_OBJECT_PATH, &j_path) ||
393                             !dbus_message_iter_append_basic(&sub2, DBUS_TYPE_OBJECT_PATH, &u_path)) {
394                                 free(j_path);
395                                 free(u_path);
396                                 goto oom;
397                         }
398
399                         free(j_path);
400                         free(u_path);
401
402                         if (!dbus_message_iter_close_container(&sub, &sub2))
403                                 goto oom;
404                 }
405
406                 if (!dbus_message_iter_close_container(&iter, &sub))
407                         goto oom;
408
409         } else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Manager", "Subscribe")) {
410                 char *client;
411
412                 if (!(client = strdup(dbus_message_get_sender(message))))
413                         goto oom;
414
415                 r = set_put(m->subscribed, client);
416
417                 if (r < 0)
418                         return bus_send_error_reply(m, message, NULL, r);
419
420                 if (!(reply = dbus_message_new_method_return(message)))
421                         goto oom;
422
423         } else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Manager", "Unsubscribe")) {
424                 char *client;
425
426                 if (!(client = set_remove(m->subscribed, (char*) dbus_message_get_sender(message))))
427                         return bus_send_error_reply(m, message, NULL, -ENOENT);
428
429                 free(client);
430
431                 if (!(reply = dbus_message_new_method_return(message)))
432                         goto oom;
433
434         } else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Manager", "Dump")) {
435                 FILE *f;
436                 char *dump = NULL;
437                 size_t size;
438
439                 if (!(reply = dbus_message_new_method_return(message)))
440                         goto oom;
441
442                 if (!(f = open_memstream(&dump, &size)))
443                         goto oom;
444
445                 manager_dump_units(m, f, NULL);
446                 manager_dump_jobs(m, f, NULL);
447
448                 if (ferror(f)) {
449                         fclose(f);
450                         free(dump);
451                         goto oom;
452                 }
453
454                 fclose(f);
455
456                 if (!dbus_message_append_args(reply, DBUS_TYPE_STRING, &dump, DBUS_TYPE_INVALID)) {
457                         free(dump);
458                         goto oom;
459                 }
460
461                 free(dump);
462         } else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Manager", "CreateSnapshot")) {
463                 const char *name;
464                 dbus_bool_t cleanup;
465                 Snapshot *s;
466
467                 if (!dbus_message_get_args(
468                                     message,
469                                     &error,
470                                     DBUS_TYPE_STRING, &name,
471                                     DBUS_TYPE_BOOLEAN, &cleanup,
472                                     DBUS_TYPE_INVALID))
473                         return bus_send_error_reply(m, message, &error, -EINVAL);
474
475                 if (name && name[0] == 0)
476                         name = NULL;
477
478                 if ((r = snapshot_create(m, name, cleanup, &s)) < 0)
479                         return bus_send_error_reply(m, message, NULL, r);
480
481                 if (!(reply = dbus_message_new_method_return(message)))
482                         goto oom;
483
484                 if (!(path = unit_dbus_path(UNIT(s))))
485                         goto oom;
486
487                 if (!dbus_message_append_args(
488                                     reply,
489                                     DBUS_TYPE_OBJECT_PATH, &path,
490                                     DBUS_TYPE_INVALID))
491                         goto oom;
492
493         } else if (dbus_message_is_method_call(message, "org.freedesktop.DBus.Introspectable", "Introspect")) {
494                 char *introspection = NULL;
495                 FILE *f;
496                 Iterator i;
497                 Unit *u;
498                 Job *j;
499                 const char *k;
500                 size_t size;
501
502                 if (!(reply = dbus_message_new_method_return(message)))
503                         goto oom;
504
505                 /* We roll our own introspection code here, instead of
506                  * relying on bus_default_message_handler() because we
507                  * need to generate our introspection string
508                  * dynamically. */
509
510                 if (!(f = open_memstream(&introspection, &size)))
511                         goto oom;
512
513                 fputs(INTROSPECTION_BEGIN, f);
514
515                 HASHMAP_FOREACH_KEY(u, k, m->units, i) {
516                         char *p;
517
518                         if (k != u->meta.id)
519                                 continue;
520
521                         if (!(p = bus_path_escape(k))) {
522                                 fclose(f);
523                                 free(introspection);
524                                 goto oom;
525                         }
526
527                         fprintf(f, "<node name=\"unit/%s\"/>", p);
528                         free(p);
529                 }
530
531                 HASHMAP_FOREACH(j, m->jobs, i)
532                         fprintf(f, "<node name=\"job/%lu\"/>", (unsigned long) j->id);
533
534                 fputs(INTROSPECTION_END, f);
535
536                 if (ferror(f)) {
537                         fclose(f);
538                         free(introspection);
539                         goto oom;
540                 }
541
542                 fclose(f);
543
544                 if (!introspection)
545                         goto oom;
546
547                 if (!dbus_message_append_args(reply, DBUS_TYPE_STRING, &introspection, DBUS_TYPE_INVALID)) {
548                         free(introspection);
549                         goto oom;
550                 }
551
552                 free(introspection);
553
554         } else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Manager", "Reload")) {
555
556                 assert(!m->queued_message);
557
558                 /* Instead of sending the reply back right away, we
559                  * just remember that we need to and then send it
560                  * after the reload is finished. That way the caller
561                  * knows when the reload finished. */
562
563                 if (!(m->queued_message = dbus_message_new_method_return(message)))
564                         goto oom;
565
566                 m->exit_code = MANAGER_RELOAD;
567
568         } else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Manager", "Reexecute")) {
569
570                 if (!(reply = dbus_message_new_method_return(message)))
571                         goto oom;
572
573                 m->exit_code = MANAGER_REEXECUTE;
574
575         } else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Manager", "Exit")) {
576
577                 if (m->running_as == MANAGER_INIT)
578                         return bus_send_error_reply(m, message, NULL, -ENOTSUP);
579
580                 if (!(reply = dbus_message_new_method_return(message)))
581                         goto oom;
582
583                 m->exit_code = MANAGER_EXIT;
584
585         } else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Manager", "SetEnvironment")) {
586                 char **l = NULL, **e = NULL;
587
588                 if ((r = bus_parse_strv(message, &l)) < 0) {
589                         if (r == -ENOMEM)
590                                 goto oom;
591
592                         return bus_send_error_reply(m, message, NULL, r);
593                 }
594
595                 e = strv_env_merge(m->environment, l, NULL);
596                 strv_free(l);
597
598                 if (!e)
599                         goto oom;
600
601                 if (!(reply = dbus_message_new_method_return(message))) {
602                         strv_free(e);
603                         goto oom;
604                 }
605
606                 strv_free(m->environment);
607                 m->environment = e;
608
609         } else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Manager", "UnsetEnvironment")) {
610                 char **l = NULL, **e = NULL;
611
612                 if ((r = bus_parse_strv(message, &l)) < 0) {
613                         if (r == -ENOMEM)
614                                 goto oom;
615
616                         return bus_send_error_reply(m, message, NULL, r);
617                 }
618
619                 e = strv_env_delete(m->environment, l, NULL);
620                 strv_free(l);
621
622                 if (!e)
623                         goto oom;
624
625                 if (!(reply = dbus_message_new_method_return(message)))
626                         goto oom;
627
628                 strv_free(m->environment);
629                 m->environment = e;
630
631         } else
632                 return bus_default_message_handler(m, message, NULL, properties);
633
634         free(path);
635
636         if (reply) {
637                 if (!dbus_connection_send(connection, reply, NULL))
638                         goto oom;
639
640                 dbus_message_unref(reply);
641         }
642
643         return DBUS_HANDLER_RESULT_HANDLED;
644
645 oom:
646         free(path);
647
648         if (reply)
649                 dbus_message_unref(reply);
650
651         dbus_error_free(&error);
652
653         return DBUS_HANDLER_RESULT_NEED_MEMORY;
654 }
655
656 const DBusObjectPathVTable bus_manager_vtable = {
657         .message_function = bus_manager_message_handler
658 };