chiark / gitweb /
load-fragment: speed up parsing by using a perfect hash table with configuration...
[elogind.git] / src / dbus-unit.c
1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
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-unit.h"
27 #include "bus-errors.h"
28 #include "dbus-common.h"
29
30 const char bus_unit_interface[] _introspect_("Unit") = BUS_UNIT_INTERFACE;
31
32 #define INVALIDATING_PROPERTIES                 \
33         "LoadState\0"                           \
34         "ActiveState\0"                         \
35         "SubState\0"                            \
36         "InactiveExitTimestamp\0"               \
37         "ActiveEnterTimestamp\0"                \
38         "ActiveExitTimestamp\0"                 \
39         "InactiveEnterTimestamp\0"              \
40         "Job\0"                                 \
41         "NeedDaemonReload\0"
42
43 int bus_unit_append_names(DBusMessageIter *i, const char *property, void *data) {
44         char *t;
45         Iterator j;
46         DBusMessageIter sub;
47         Unit *u = data;
48
49         if (!dbus_message_iter_open_container(i, DBUS_TYPE_ARRAY, "s", &sub))
50                 return -ENOMEM;
51
52         SET_FOREACH(t, u->meta.names, j)
53                 if (!dbus_message_iter_append_basic(&sub, DBUS_TYPE_STRING, &t))
54                         return -ENOMEM;
55
56         if (!dbus_message_iter_close_container(i, &sub))
57                 return -ENOMEM;
58
59         return 0;
60 }
61
62 int bus_unit_append_following(DBusMessageIter *i, const char *property, void *data) {
63         Unit *u = data, *f;
64         const char *d;
65
66         assert(i);
67         assert(property);
68         assert(u);
69
70         f = unit_following(u);
71         d = f ? f->meta.id : "";
72
73         if (!dbus_message_iter_append_basic(i, DBUS_TYPE_STRING, &d))
74                 return -ENOMEM;
75
76         return 0;
77 }
78
79 int bus_unit_append_dependencies(DBusMessageIter *i, const char *property, void *data) {
80         Unit *u;
81         Iterator j;
82         DBusMessageIter sub;
83         Set *s = data;
84
85         if (!dbus_message_iter_open_container(i, DBUS_TYPE_ARRAY, "s", &sub))
86                 return -ENOMEM;
87
88         SET_FOREACH(u, s, j)
89                 if (!dbus_message_iter_append_basic(&sub, DBUS_TYPE_STRING, &u->meta.id))
90                         return -ENOMEM;
91
92         if (!dbus_message_iter_close_container(i, &sub))
93                 return -ENOMEM;
94
95         return 0;
96 }
97
98 int bus_unit_append_description(DBusMessageIter *i, const char *property, void *data) {
99         Unit *u = data;
100         const char *d;
101
102         assert(i);
103         assert(property);
104         assert(u);
105
106         d = unit_description(u);
107
108         if (!dbus_message_iter_append_basic(i, DBUS_TYPE_STRING, &d))
109                 return -ENOMEM;
110
111         return 0;
112 }
113
114 DEFINE_BUS_PROPERTY_APPEND_ENUM(bus_unit_append_load_state, unit_load_state, UnitLoadState);
115
116 int bus_unit_append_active_state(DBusMessageIter *i, const char *property, void *data) {
117         Unit *u = data;
118         const char *state;
119
120         assert(i);
121         assert(property);
122         assert(u);
123
124         state = unit_active_state_to_string(unit_active_state(u));
125
126         if (!dbus_message_iter_append_basic(i, DBUS_TYPE_STRING, &state))
127                 return -ENOMEM;
128
129         return 0;
130 }
131
132 int bus_unit_append_sub_state(DBusMessageIter *i, const char *property, void *data) {
133         Unit *u = data;
134         const char *state;
135
136         assert(i);
137         assert(property);
138         assert(u);
139
140         state = unit_sub_state_to_string(u);
141
142         if (!dbus_message_iter_append_basic(i, DBUS_TYPE_STRING, &state))
143                 return -ENOMEM;
144
145         return 0;
146 }
147
148 int bus_unit_append_file_state(DBusMessageIter *i, const char *property, void *data) {
149         Unit *u = data;
150         const char *state;
151
152         assert(i);
153         assert(property);
154         assert(u);
155
156         state = strempty(unit_file_state_to_string(unit_get_unit_file_state(u)));
157
158         if (!dbus_message_iter_append_basic(i, DBUS_TYPE_STRING, &state))
159                 return -ENOMEM;
160
161         return 0;
162 }
163
164 int bus_unit_append_can_start(DBusMessageIter *i, const char *property, void *data) {
165         Unit *u = data;
166         dbus_bool_t b;
167
168         assert(i);
169         assert(property);
170         assert(u);
171
172         b = unit_can_start(u) &&
173                 !u->meta.refuse_manual_start;
174
175         if (!dbus_message_iter_append_basic(i, DBUS_TYPE_BOOLEAN, &b))
176                 return -ENOMEM;
177
178         return 0;
179 }
180
181 int bus_unit_append_can_stop(DBusMessageIter *i, const char *property, void *data) {
182         Unit *u = data;
183         dbus_bool_t b;
184
185         assert(i);
186         assert(property);
187         assert(u);
188
189         /* On the lower levels we assume that every unit we can start
190          * we can also stop */
191
192         b = unit_can_start(u) &&
193                 !u->meta.refuse_manual_stop;
194
195         if (!dbus_message_iter_append_basic(i, DBUS_TYPE_BOOLEAN, &b))
196                 return -ENOMEM;
197
198         return 0;
199 }
200
201 int bus_unit_append_can_reload(DBusMessageIter *i, const char *property, void *data) {
202         Unit *u = data;
203         dbus_bool_t b;
204
205         assert(i);
206         assert(property);
207         assert(u);
208
209         b = unit_can_reload(u);
210
211         if (!dbus_message_iter_append_basic(i, DBUS_TYPE_BOOLEAN, &b))
212                 return -ENOMEM;
213
214         return 0;
215 }
216
217 int bus_unit_append_can_isolate(DBusMessageIter *i, const char *property, void *data) {
218         Unit *u = data;
219         dbus_bool_t b;
220
221         assert(i);
222         assert(property);
223         assert(u);
224
225         b = unit_can_isolate(u) &&
226                 !u->meta.refuse_manual_start;
227
228         if (!dbus_message_iter_append_basic(i, DBUS_TYPE_BOOLEAN, &b))
229                 return -ENOMEM;
230
231         return 0;
232 }
233
234 int bus_unit_append_job(DBusMessageIter *i, const char *property, void *data) {
235         Unit *u = data;
236         DBusMessageIter sub;
237         char *p;
238
239         assert(i);
240         assert(property);
241         assert(u);
242
243         if (!dbus_message_iter_open_container(i, DBUS_TYPE_STRUCT, NULL, &sub))
244                 return -ENOMEM;
245
246         if (u->meta.job) {
247
248                 if (!(p = job_dbus_path(u->meta.job)))
249                         return -ENOMEM;
250
251                 if (!dbus_message_iter_append_basic(&sub, DBUS_TYPE_UINT32, &u->meta.job->id) ||
252                     !dbus_message_iter_append_basic(&sub, DBUS_TYPE_OBJECT_PATH, &p)) {
253                         free(p);
254                         return -ENOMEM;
255                 }
256         } else {
257                 uint32_t id = 0;
258
259                 /* No job, so let's fill in some placeholder
260                  * data. Since we need to fill in a valid path we
261                  * simple point to ourselves. */
262
263                 if (!(p = unit_dbus_path(u)))
264                         return -ENOMEM;
265
266                 if (!dbus_message_iter_append_basic(&sub, DBUS_TYPE_UINT32, &id) ||
267                     !dbus_message_iter_append_basic(&sub, DBUS_TYPE_OBJECT_PATH, &p)) {
268                         free(p);
269                         return -ENOMEM;
270                 }
271         }
272
273         free(p);
274
275         if (!dbus_message_iter_close_container(i, &sub))
276                 return -ENOMEM;
277
278         return 0;
279 }
280
281 int bus_unit_append_default_cgroup(DBusMessageIter *i, const char *property, void *data) {
282         Unit *u = data;
283         char *t;
284         CGroupBonding *cgb;
285         bool success;
286
287         assert(i);
288         assert(property);
289         assert(u);
290
291         if ((cgb = unit_get_default_cgroup(u))) {
292                 if (!(t = cgroup_bonding_to_string(cgb)))
293                         return -ENOMEM;
294         } else
295                 t = (char*) "";
296
297         success = dbus_message_iter_append_basic(i, DBUS_TYPE_STRING, &t);
298
299         if (cgb)
300                 free(t);
301
302         return success ? 0 : -ENOMEM;
303 }
304
305 int bus_unit_append_cgroups(DBusMessageIter *i, const char *property, void *data) {
306         Unit *u = data;
307         CGroupBonding *cgb;
308         DBusMessageIter sub;
309
310         if (!dbus_message_iter_open_container(i, DBUS_TYPE_ARRAY, "s", &sub))
311                 return -ENOMEM;
312
313         LIST_FOREACH(by_unit, cgb, u->meta.cgroup_bondings) {
314                 char *t;
315                 bool success;
316
317                 if (!(t = cgroup_bonding_to_string(cgb)))
318                         return -ENOMEM;
319
320                 success = dbus_message_iter_append_basic(&sub, DBUS_TYPE_STRING, &t);
321                 free(t);
322
323                 if (!success)
324                         return -ENOMEM;
325         }
326
327         if (!dbus_message_iter_close_container(i, &sub))
328                 return -ENOMEM;
329
330         return 0;
331 }
332
333 int bus_unit_append_need_daemon_reload(DBusMessageIter *i, const char *property, void *data) {
334         Unit *u = data;
335         dbus_bool_t b;
336
337         assert(i);
338         assert(property);
339         assert(u);
340
341         b = unit_need_daemon_reload(u);
342
343         if (!dbus_message_iter_append_basic(i, DBUS_TYPE_BOOLEAN, &b))
344                 return -ENOMEM;
345
346         return 0;
347 }
348
349 int bus_unit_append_load_error(DBusMessageIter *i, const char *property, void *data) {
350         Unit *u = data;
351         const char *name, *message;
352         DBusMessageIter sub;
353
354         assert(i);
355         assert(property);
356         assert(u);
357
358         if (u->meta.load_error != 0) {
359                 name = bus_errno_to_dbus(u->meta.load_error);
360                 message = strempty(strerror(-u->meta.load_error));
361         } else
362                 name = message = "";
363
364         if (!dbus_message_iter_open_container(i, DBUS_TYPE_STRUCT, NULL, &sub) ||
365             !dbus_message_iter_append_basic(&sub, DBUS_TYPE_STRING, &name) ||
366             !dbus_message_iter_append_basic(&sub, DBUS_TYPE_STRING, &message) ||
367             !dbus_message_iter_close_container(i, &sub))
368                 return -ENOMEM;
369
370         return 0;
371 }
372
373 static DBusHandlerResult bus_unit_message_dispatch(Unit *u, DBusConnection *connection, DBusMessage *message) {
374         DBusMessage *reply = NULL;
375         Manager *m = u->meta.manager;
376         DBusError error;
377         JobType job_type = _JOB_TYPE_INVALID;
378         char *path = NULL;
379         bool reload_if_possible = false;
380
381         dbus_error_init(&error);
382
383         if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Unit", "Start"))
384                 job_type = JOB_START;
385         else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Unit", "Stop"))
386                 job_type = JOB_STOP;
387         else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Unit", "Reload"))
388                 job_type = JOB_RELOAD;
389         else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Unit", "Restart"))
390                 job_type = JOB_RESTART;
391         else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Unit", "TryRestart"))
392                 job_type = JOB_TRY_RESTART;
393         else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Unit", "ReloadOrRestart")) {
394                 reload_if_possible = true;
395                 job_type = JOB_RESTART;
396         } else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Unit", "ReloadOrTryRestart")) {
397                 reload_if_possible = true;
398                 job_type = JOB_TRY_RESTART;
399         } else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Unit", "Kill")) {
400                 const char *swho, *smode;
401                 int32_t signo;
402                 KillMode mode;
403                 KillWho who;
404                 int r;
405
406                 if (!dbus_message_get_args(
407                                     message,
408                                     &error,
409                                     DBUS_TYPE_STRING, &swho,
410                                     DBUS_TYPE_STRING, &smode,
411                                     DBUS_TYPE_INT32, &signo,
412                                     DBUS_TYPE_INVALID))
413                         return bus_send_error_reply(connection, message, &error, -EINVAL);
414
415                 if (isempty(swho))
416                         who = KILL_ALL;
417                 else {
418                         who = kill_who_from_string(swho);
419                         if (who < 0)
420                                 return bus_send_error_reply(connection, message, &error, -EINVAL);
421                 }
422
423                 if (isempty(smode))
424                         mode = KILL_CONTROL_GROUP;
425                 else {
426                         mode = kill_mode_from_string(smode);
427                         if (mode < 0)
428                                 return bus_send_error_reply(connection, message, &error, -EINVAL);
429                 }
430
431                 if (signo <= 0 || signo >= _NSIG)
432                         return bus_send_error_reply(connection, message, &error, -EINVAL);
433
434                 if ((r = unit_kill(u, who, mode, signo, &error)) < 0)
435                         return bus_send_error_reply(connection, message, &error, r);
436
437                 if (!(reply = dbus_message_new_method_return(message)))
438                         goto oom;
439
440         } else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Unit", "ResetFailed")) {
441
442                 unit_reset_failed(u);
443
444                 if (!(reply = dbus_message_new_method_return(message)))
445                         goto oom;
446
447         } else if (UNIT_VTABLE(u)->bus_message_handler)
448                 return UNIT_VTABLE(u)->bus_message_handler(u, connection, message);
449         else
450                 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
451
452         if (job_type != _JOB_TYPE_INVALID) {
453                 const char *smode;
454                 JobMode mode;
455                 Job *j;
456                 int r;
457
458                 if ((job_type == JOB_START && u->meta.refuse_manual_start) ||
459                     (job_type == JOB_STOP && u->meta.refuse_manual_stop) ||
460                     ((job_type == JOB_RESTART || job_type == JOB_TRY_RESTART) &&
461                      (u->meta.refuse_manual_start || u->meta.refuse_manual_stop))) {
462                         dbus_set_error(&error, BUS_ERROR_ONLY_BY_DEPENDENCY, "Operation refused, may be requested by dependency only.");
463                         return bus_send_error_reply(connection, message, &error, -EPERM);
464                 }
465
466                 if (!dbus_message_get_args(
467                                     message,
468                                     &error,
469                                     DBUS_TYPE_STRING, &smode,
470                                     DBUS_TYPE_INVALID))
471                         return bus_send_error_reply(connection, message, &error, -EINVAL);
472
473                 if (reload_if_possible && unit_can_reload(u)) {
474                         if (job_type == JOB_RESTART)
475                                 job_type = JOB_RELOAD_OR_START;
476                         else if (job_type == JOB_TRY_RESTART)
477                                 job_type = JOB_RELOAD;
478                 }
479
480                 if ((mode = job_mode_from_string(smode)) == _JOB_MODE_INVALID) {
481                         dbus_set_error(&error, BUS_ERROR_INVALID_JOB_MODE, "Job mode %s is invalid.", smode);
482                         return bus_send_error_reply(connection, message, &error, -EINVAL);
483                 }
484
485                 if ((r = manager_add_job(m, job_type, u, mode, true, &error, &j)) < 0)
486                         return bus_send_error_reply(connection, message, &error, r);
487
488                 if (!(reply = dbus_message_new_method_return(message)))
489                         goto oom;
490
491                 if (!(path = job_dbus_path(j)))
492                         goto oom;
493
494                 if (!dbus_message_append_args(
495                                     reply,
496                                     DBUS_TYPE_OBJECT_PATH, &path,
497                                     DBUS_TYPE_INVALID))
498                         goto oom;
499         }
500
501         if (reply) {
502                 if (!dbus_connection_send(connection, reply, NULL))
503                         goto oom;
504
505                 dbus_message_unref(reply);
506         }
507
508         free(path);
509
510         return DBUS_HANDLER_RESULT_HANDLED;
511
512 oom:
513         free(path);
514
515         if (reply)
516                 dbus_message_unref(reply);
517
518         dbus_error_free(&error);
519
520         return DBUS_HANDLER_RESULT_NEED_MEMORY;
521 }
522
523 static DBusHandlerResult bus_unit_message_handler(DBusConnection *connection, DBusMessage  *message, void *data) {
524         Manager *m = data;
525         Unit *u;
526         int r;
527         DBusMessage *reply;
528
529         assert(connection);
530         assert(message);
531         assert(m);
532
533         if (streq(dbus_message_get_path(message), "/org/freedesktop/systemd1/unit")) {
534                 /* Be nice to gdbus and return introspection data for our mid-level paths */
535
536                 if (dbus_message_is_method_call(message, "org.freedesktop.DBus.Introspectable", "Introspect")) {
537                         char *introspection = NULL;
538                         FILE *f;
539                         Iterator i;
540                         const char *k;
541                         size_t size;
542
543                         if (!(reply = dbus_message_new_method_return(message)))
544                                 goto oom;
545
546                         /* We roll our own introspection code here, instead of
547                          * relying on bus_default_message_handler() because we
548                          * need to generate our introspection string
549                          * dynamically. */
550
551                         if (!(f = open_memstream(&introspection, &size)))
552                                 goto oom;
553
554                         fputs(DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE
555                               "<node>\n", f);
556
557                         fputs(BUS_INTROSPECTABLE_INTERFACE, f);
558                         fputs(BUS_PEER_INTERFACE, f);
559
560                         HASHMAP_FOREACH_KEY(u, k, m->units, i) {
561                                 char *p;
562
563                                 if (k != u->meta.id)
564                                         continue;
565
566                                 if (!(p = bus_path_escape(k))) {
567                                         fclose(f);
568                                         free(introspection);
569                                         goto oom;
570                                 }
571
572                                 fprintf(f, "<node name=\"%s\"/>", p);
573                                 free(p);
574                         }
575
576                         fputs("</node>\n", f);
577
578                         if (ferror(f)) {
579                                 fclose(f);
580                                 free(introspection);
581                                 goto oom;
582                         }
583
584                         fclose(f);
585
586                         if (!introspection)
587                                 goto oom;
588
589                         if (!dbus_message_append_args(reply, DBUS_TYPE_STRING, &introspection, DBUS_TYPE_INVALID)) {
590                                 free(introspection);
591                                 goto oom;
592                         }
593
594                         free(introspection);
595
596                         if (!dbus_connection_send(connection, reply, NULL))
597                                 goto oom;
598
599                         dbus_message_unref(reply);
600
601                         return DBUS_HANDLER_RESULT_HANDLED;
602                 }
603
604                 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
605         }
606
607         if ((r = manager_get_unit_from_dbus_path(m, dbus_message_get_path(message), &u)) < 0) {
608
609                 if (r == -ENOMEM)
610                         return DBUS_HANDLER_RESULT_NEED_MEMORY;
611
612                 if (r == -ENOENT) {
613                         DBusError e;
614
615                         dbus_error_init(&e);
616                         dbus_set_error_const(&e, DBUS_ERROR_UNKNOWN_OBJECT, "Unknown unit");
617                         return bus_send_error_reply(connection, message, &e, r);
618                 }
619
620                 return bus_send_error_reply(connection, message, NULL, r);
621         }
622
623         return bus_unit_message_dispatch(u, connection, message);
624
625 oom:
626         if (reply)
627                 dbus_message_unref(reply);
628
629         return DBUS_HANDLER_RESULT_NEED_MEMORY;
630 }
631
632 const DBusObjectPathVTable bus_unit_vtable = {
633         .message_function = bus_unit_message_handler
634 };
635
636 void bus_unit_send_change_signal(Unit *u) {
637         char *p = NULL;
638         DBusMessage *m = NULL;
639
640         assert(u);
641
642         if (u->meta.in_dbus_queue) {
643                 LIST_REMOVE(Meta, dbus_queue, u->meta.manager->dbus_unit_queue, &u->meta);
644                 u->meta.in_dbus_queue = false;
645         }
646
647         if (!u->meta.id)
648                 return;
649
650         if (!bus_has_subscriber(u->meta.manager)) {
651                 u->meta.sent_dbus_new_signal = true;
652                 return;
653         }
654
655         if (!(p = unit_dbus_path(u)))
656                 goto oom;
657
658         if (u->meta.sent_dbus_new_signal) {
659                 /* Send a properties changed signal. First for the
660                  * specific type, then for the generic unit. The
661                  * clients may rely on this order to get atomic
662                  * behaviour if needed. */
663
664                 if (UNIT_VTABLE(u)->bus_invalidating_properties) {
665
666                         if (!(m = bus_properties_changed_new(p,
667                                                              UNIT_VTABLE(u)->bus_interface,
668                                                              UNIT_VTABLE(u)->bus_invalidating_properties)))
669                                 goto oom;
670
671                         if (bus_broadcast(u->meta.manager, m) < 0)
672                                 goto oom;
673
674                         dbus_message_unref(m);
675                 }
676
677                 if (!(m = bus_properties_changed_new(p, "org.freedesktop.systemd1.Unit", INVALIDATING_PROPERTIES)))
678                         goto oom;
679
680         } else {
681                 /* Send a new signal */
682
683                 if (!(m = dbus_message_new_signal("/org/freedesktop/systemd1", "org.freedesktop.systemd1.Manager", "UnitNew")))
684                         goto oom;
685
686                 if (!dbus_message_append_args(m,
687                                               DBUS_TYPE_STRING, &u->meta.id,
688                                               DBUS_TYPE_OBJECT_PATH, &p,
689                                               DBUS_TYPE_INVALID))
690                         goto oom;
691         }
692
693         if (bus_broadcast(u->meta.manager, m) < 0)
694                 goto oom;
695
696         free(p);
697         dbus_message_unref(m);
698
699         u->meta.sent_dbus_new_signal = true;
700
701         return;
702
703 oom:
704         free(p);
705
706         if (m)
707                 dbus_message_unref(m);
708
709         log_error("Failed to allocate unit change/new signal.");
710 }
711
712 void bus_unit_send_removed_signal(Unit *u) {
713         char *p = NULL;
714         DBusMessage *m = NULL;
715
716         assert(u);
717
718         if (!bus_has_subscriber(u->meta.manager))
719                 return;
720
721         if (!u->meta.sent_dbus_new_signal)
722                 bus_unit_send_change_signal(u);
723
724         if (!u->meta.id)
725                 return;
726
727         if (!(p = unit_dbus_path(u)))
728                 goto oom;
729
730         if (!(m = dbus_message_new_signal("/org/freedesktop/systemd1", "org.freedesktop.systemd1.Manager", "UnitRemoved")))
731                 goto oom;
732
733         if (!dbus_message_append_args(m,
734                                       DBUS_TYPE_STRING, &u->meta.id,
735                                       DBUS_TYPE_OBJECT_PATH, &p,
736                                       DBUS_TYPE_INVALID))
737                 goto oom;
738
739         if (bus_broadcast(u->meta.manager, m) < 0)
740                 goto oom;
741
742         free(p);
743         dbus_message_unref(m);
744
745         return;
746
747 oom:
748         free(p);
749
750         if (m)
751                 dbus_message_unref(m);
752
753         log_error("Failed to allocate unit remove signal.");
754 }