1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
4 This file is part of systemd.
6 Copyright 2013 Lennart Poettering
8 systemd is free software; you can redistribute it and/or modify it
9 under the terms of the GNU Lesser General Public License as published by
10 the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
18 You should have received a copy of the GNU Lesser General Public License
19 along with systemd; If not, see <http://www.gnu.org/licenses/>.
25 #include "bus-kernel.h"
26 #include "bus-internal.h"
30 #include "bus-policy.h"
31 #include "dbus-busname.h"
34 static const UnitActiveState state_translation_table[_BUSNAME_STATE_MAX] = {
35 [BUSNAME_DEAD] = UNIT_INACTIVE,
36 [BUSNAME_MAKING] = UNIT_ACTIVATING,
37 [BUSNAME_REGISTERED] = UNIT_ACTIVE,
38 [BUSNAME_LISTENING] = UNIT_ACTIVE,
39 [BUSNAME_RUNNING] = UNIT_ACTIVE,
40 [BUSNAME_SIGTERM] = UNIT_DEACTIVATING,
41 [BUSNAME_SIGKILL] = UNIT_DEACTIVATING,
42 [BUSNAME_FAILED] = UNIT_FAILED
45 static int busname_dispatch_io(sd_event_source *source, int fd, uint32_t revents, void *userdata);
46 static int busname_dispatch_timer(sd_event_source *source, usec_t usec, void *userdata);
48 static void busname_init(Unit *u) {
49 BusName *n = BUSNAME(u);
52 assert(u->load_state == UNIT_STUB);
58 n->timeout_usec = u->manager->default_timeout_start_usec;
61 static void busname_unwatch_control_pid(BusName *n) {
64 if (n->control_pid <= 0)
67 unit_unwatch_pid(UNIT(n), n->control_pid);
71 static void busname_free_policy(BusName *n) {
76 while ((p = n->policy)) {
77 LIST_REMOVE(policy, n->policy, p);
84 static void busname_close_fd(BusName *n) {
87 n->starter_event_source = sd_event_source_unref(n->starter_event_source);
88 n->starter_fd = safe_close(n->starter_fd);
91 static void busname_done(Unit *u) {
92 BusName *n = BUSNAME(u);
99 busname_free_policy(n);
100 busname_unwatch_control_pid(n);
103 unit_ref_unset(&n->service);
105 n->timer_event_source = sd_event_source_unref(n->timer_event_source);
108 static int busname_arm_timer(BusName *n) {
113 if (n->timeout_usec <= 0) {
114 n->timer_event_source = sd_event_source_unref(n->timer_event_source);
118 if (n->timer_event_source) {
119 r = sd_event_source_set_time(n->timer_event_source, now(CLOCK_MONOTONIC) + n->timeout_usec);
123 return sd_event_source_set_enabled(n->timer_event_source, SD_EVENT_ONESHOT);
126 return sd_event_add_time(
127 UNIT(n)->manager->event,
128 &n->timer_event_source,
130 now(CLOCK_MONOTONIC) + n->timeout_usec, 0,
131 busname_dispatch_timer, n);
134 static int busname_add_default_default_dependencies(BusName *n) {
139 r = unit_add_dependency_by_name(UNIT(n), UNIT_BEFORE, SPECIAL_BUSNAMES_TARGET, NULL, true);
143 if (UNIT(n)->manager->running_as == SYSTEMD_SYSTEM) {
144 r = unit_add_two_dependencies_by_name(UNIT(n), UNIT_AFTER, UNIT_REQUIRES, SPECIAL_SYSINIT_TARGET, NULL, true);
149 return unit_add_two_dependencies_by_name(UNIT(n), UNIT_BEFORE, UNIT_CONFLICTS, SPECIAL_SHUTDOWN_TARGET, NULL, true);
152 static int busname_add_extras(BusName *n) {
159 n->name = unit_name_to_prefix(u->id);
164 if (!u->description) {
165 r = unit_set_description(u, n->name);
171 if (!UNIT_DEREF(n->service)) {
174 r = unit_load_related_unit(u, ".service", &x);
178 unit_ref_set(&n->service, x);
181 r = unit_add_two_dependencies(u, UNIT_BEFORE, UNIT_TRIGGERS, UNIT_DEREF(n->service), true);
186 if (u->default_dependencies) {
187 r = busname_add_default_default_dependencies(n);
195 static int busname_verify(BusName *n) {
200 if (UNIT(n)->load_state != UNIT_LOADED)
203 if (!service_name_is_valid(n->name)) {
204 log_unit_error(UNIT(n)->id, "%s's Name= setting is not a valid service name Refusing.", UNIT(n)->id);
208 e = strjoina(n->name, ".busname");
209 if (!unit_has_name(UNIT(n), e)) {
210 log_unit_error(UNIT(n)->id, "%s's Name= setting doesn't match unit name. Refusing.", UNIT(n)->id);
217 static int busname_load(Unit *u) {
218 BusName *n = BUSNAME(u);
222 assert(u->load_state == UNIT_STUB);
224 r = unit_load_fragment_and_dropin(u);
228 if (u->load_state == UNIT_LOADED) {
229 /* This is a new unit? Then let's add in some extras */
230 r = busname_add_extras(n);
235 return busname_verify(n);
238 static void busname_dump(Unit *u, FILE *f, const char *prefix) {
239 BusName *n = BUSNAME(u);
245 "%sBus Name State: %s\n"
250 prefix, busname_state_to_string(n->state),
251 prefix, busname_result_to_string(n->result),
253 prefix, yes_no(n->activating),
254 prefix, yes_no(n->accept_fd));
256 if (n->control_pid > 0)
258 "%sControl PID: "PID_FMT"\n",
259 prefix, n->control_pid);
262 static void busname_unwatch_fd(BusName *n) {
267 if (!n->starter_event_source)
270 r = sd_event_source_set_enabled(n->starter_event_source, SD_EVENT_OFF);
272 log_unit_debug(UNIT(n)->id, "Failed to disable event source.");
275 static int busname_watch_fd(BusName *n) {
280 if (n->starter_fd < 0)
283 if (n->starter_event_source)
284 r = sd_event_source_set_enabled(n->starter_event_source, SD_EVENT_ON);
286 r = sd_event_add_io(UNIT(n)->manager->event, &n->starter_event_source, n->starter_fd, EPOLLIN, busname_dispatch_io, n);
288 log_unit_warning_errno(UNIT(n)->id, r, "Failed to watch starter fd: %m");
289 busname_unwatch_fd(n);
296 static int busname_open_fd(BusName *n) {
297 _cleanup_free_ char *path = NULL;
302 if (n->starter_fd >= 0)
305 mode = UNIT(n)->manager->running_as == SYSTEMD_SYSTEM ? "system" : "user";
306 n->starter_fd = bus_kernel_open_bus_fd(mode, &path);
307 if (n->starter_fd < 0)
308 return log_unit_warning_errno(UNIT(n)->id, n->starter_fd, "Failed to open %s: %m", path ?: "kdbus");
313 static void busname_set_state(BusName *n, BusNameState state) {
314 BusNameState old_state;
317 old_state = n->state;
320 if (!IN_SET(state, BUSNAME_MAKING, BUSNAME_SIGTERM, BUSNAME_SIGKILL)) {
321 n->timer_event_source = sd_event_source_unref(n->timer_event_source);
322 busname_unwatch_control_pid(n);
325 if (state != BUSNAME_LISTENING)
326 busname_unwatch_fd(n);
328 if (!IN_SET(state, BUSNAME_LISTENING, BUSNAME_MAKING, BUSNAME_REGISTERED, BUSNAME_RUNNING))
331 if (state != old_state)
332 log_unit_debug(UNIT(n)->id, "%s changed %s -> %s",
333 UNIT(n)->id, busname_state_to_string(old_state), busname_state_to_string(state));
335 unit_notify(UNIT(n), state_translation_table[old_state], state_translation_table[state], true);
338 static int busname_coldplug(Unit *u, Hashmap *deferred_work) {
339 BusName *n = BUSNAME(u);
343 assert(n->state == BUSNAME_DEAD);
345 if (n->deserialized_state == n->state)
348 if (IN_SET(n->deserialized_state, BUSNAME_MAKING, BUSNAME_SIGTERM, BUSNAME_SIGKILL)) {
350 if (n->control_pid <= 0)
353 r = unit_watch_pid(UNIT(n), n->control_pid);
357 r = busname_arm_timer(n);
362 if (IN_SET(n->deserialized_state, BUSNAME_MAKING, BUSNAME_LISTENING, BUSNAME_REGISTERED, BUSNAME_RUNNING)) {
363 r = busname_open_fd(n);
368 if (n->deserialized_state == BUSNAME_LISTENING) {
369 r = busname_watch_fd(n);
374 busname_set_state(n, n->deserialized_state);
378 static int busname_make_starter(BusName *n, pid_t *_pid) {
382 r = busname_arm_timer(n);
386 /* We have to resolve the user/group names out-of-process,
387 * hence let's fork here. It's messy, but well, what can we
397 default_signals(SIGNALS_CRASH_HANDLER, SIGNALS_IGNORE, -1);
398 ignore_signals(SIGPIPE, -1);
401 r = bus_kernel_make_starter(n->starter_fd, n->name, n->activating, n->accept_fd, n->policy, n->policy_world);
403 ret = EXIT_MAKE_STARTER;
411 log_error_errno(r, "Failed to create starter connection at step %s: %m", exit_status_to_string(ret, EXIT_STATUS_SYSTEMD));
416 r = unit_watch_pid(UNIT(n), pid);
424 n->timer_event_source = sd_event_source_unref(n->timer_event_source);
428 static void busname_enter_dead(BusName *n, BusNameResult f) {
431 if (f != BUSNAME_SUCCESS)
434 busname_set_state(n, n->result != BUSNAME_SUCCESS ? BUSNAME_FAILED : BUSNAME_DEAD);
437 static void busname_enter_signal(BusName *n, BusNameState state, BusNameResult f) {
438 KillContext kill_context = {};
443 if (f != BUSNAME_SUCCESS)
446 kill_context_init(&kill_context);
448 r = unit_kill_context(UNIT(n),
450 state != BUSNAME_SIGTERM ? KILL_KILL : KILL_TERMINATE,
455 log_unit_warning_errno(UNIT(n)->id, r, "%s failed to kill control process: %m", UNIT(n)->id);
460 r = busname_arm_timer(n);
462 log_unit_warning_errno(UNIT(n)->id, r, "%s failed to arm timer: %m", UNIT(n)->id);
466 busname_set_state(n, state);
467 } else if (state == BUSNAME_SIGTERM)
468 busname_enter_signal(n, BUSNAME_SIGKILL, BUSNAME_SUCCESS);
470 busname_enter_dead(n, BUSNAME_SUCCESS);
475 busname_enter_dead(n, BUSNAME_FAILURE_RESOURCES);
478 static void busname_enter_listening(BusName *n) {
484 r = busname_watch_fd(n);
486 log_unit_warning_errno(UNIT(n)->id, r, "%s failed to watch names: %m", UNIT(n)->id);
490 busname_set_state(n, BUSNAME_LISTENING);
492 busname_set_state(n, BUSNAME_REGISTERED);
497 busname_enter_signal(n, BUSNAME_SIGTERM, BUSNAME_FAILURE_RESOURCES);
500 static void busname_enter_making(BusName *n) {
505 r = busname_open_fd(n);
510 /* If there is a policy, we need to resolve user/group
511 * names, which we can't do from PID1, hence let's
513 busname_unwatch_control_pid(n);
515 r = busname_make_starter(n, &n->control_pid);
517 log_unit_warning_errno(UNIT(n)->id, r, "%s failed to fork 'making' task: %m", UNIT(n)->id);
521 busname_set_state(n, BUSNAME_MAKING);
523 /* If there is no policy, we can do everything
524 * directly from PID 1, hence do so. */
526 r = bus_kernel_make_starter(n->starter_fd, n->name, n->activating, n->accept_fd, NULL, n->policy_world);
528 log_unit_warning_errno(UNIT(n)->id, r, "%s failed to make starter: %m", UNIT(n)->id);
532 busname_enter_listening(n);
538 busname_enter_dead(n, BUSNAME_FAILURE_RESOURCES);
541 static void busname_enter_running(BusName *n) {
542 _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
543 bool pending = false;
553 /* We don't take conenctions anymore if we are supposed to
554 * shut down anyway */
556 if (unit_stop_pending(UNIT(n))) {
557 log_unit_debug(UNIT(n)->id, "Suppressing activation request on %s since unit stop is scheduled.", UNIT(n)->id);
559 /* Flush all queued activation reqeuest by closing and reopening the connection */
560 bus_kernel_drop_one(n->starter_fd);
562 busname_enter_listening(n);
566 /* If there's already a start pending don't bother to do
568 SET_FOREACH(other, UNIT(n)->dependencies[UNIT_TRIGGERS], i)
569 if (unit_active_or_pending(other)) {
575 r = manager_add_job(UNIT(n)->manager, JOB_START, UNIT_DEREF(n->service), JOB_REPLACE, true, &error, NULL);
580 busname_set_state(n, BUSNAME_RUNNING);
584 log_unit_warning(UNIT(n)->id, "%s failed to queue service startup job: %s", UNIT(n)->id, bus_error_message(&error, r));
585 busname_enter_dead(n, BUSNAME_FAILURE_RESOURCES);
588 static int busname_start(Unit *u) {
589 BusName *n = BUSNAME(u);
593 /* We cannot fulfill this request right now, try again later
595 if (IN_SET(n->state, BUSNAME_SIGTERM, BUSNAME_SIGKILL))
599 if (n->state == BUSNAME_MAKING)
602 if (n->activating && UNIT_ISSET(n->service)) {
605 service = SERVICE(UNIT_DEREF(n->service));
607 if (UNIT(service)->load_state != UNIT_LOADED) {
608 log_unit_error(u->id, "Bus service %s not loaded, refusing.", UNIT(service)->id);
613 assert(IN_SET(n->state, BUSNAME_DEAD, BUSNAME_FAILED));
615 n->result = BUSNAME_SUCCESS;
616 busname_enter_making(n);
621 static int busname_stop(Unit *u) {
622 BusName *n = BUSNAME(u);
627 if (IN_SET(n->state, BUSNAME_SIGTERM, BUSNAME_SIGKILL))
630 /* If there's already something running, we go directly into
633 if (n->state == BUSNAME_MAKING) {
634 busname_enter_signal(n, BUSNAME_SIGTERM, BUSNAME_SUCCESS);
638 assert(IN_SET(n->state, BUSNAME_REGISTERED, BUSNAME_LISTENING, BUSNAME_RUNNING));
640 busname_enter_dead(n, BUSNAME_SUCCESS);
644 static int busname_serialize(Unit *u, FILE *f, FDSet *fds) {
645 BusName *n = BUSNAME(u);
651 unit_serialize_item(u, f, "state", busname_state_to_string(n->state));
652 unit_serialize_item(u, f, "result", busname_result_to_string(n->result));
654 if (n->control_pid > 0)
655 unit_serialize_item_format(u, f, "control-pid", PID_FMT, n->control_pid);
657 if (n->starter_fd >= 0) {
660 copy = fdset_put_dup(fds, n->starter_fd);
664 unit_serialize_item_format(u, f, "starter-fd", "%i", copy);
670 static int busname_deserialize_item(Unit *u, const char *key, const char *value, FDSet *fds) {
671 BusName *n = BUSNAME(u);
677 if (streq(key, "state")) {
680 state = busname_state_from_string(value);
682 log_unit_debug(u->id, "Failed to parse state value %s", value);
684 n->deserialized_state = state;
686 } else if (streq(key, "result")) {
689 f = busname_result_from_string(value);
691 log_unit_debug(u->id, "Failed to parse result value %s", value);
692 else if (f != BUSNAME_SUCCESS)
695 } else if (streq(key, "control-pid")) {
698 if (parse_pid(value, &pid) < 0)
699 log_unit_debug(u->id, "Failed to parse control-pid value %s", value);
701 n->control_pid = pid;
702 } else if (streq(key, "starter-fd")) {
705 if (safe_atoi(value, &fd) < 0 || fd < 0 || !fdset_contains(fds, fd))
706 log_unit_debug(u->id, "Failed to parse starter fd value %s", value);
708 safe_close(n->starter_fd);
709 n->starter_fd = fdset_remove(fds, fd);
712 log_unit_debug(u->id, "Unknown serialization key '%s'", key);
717 _pure_ static UnitActiveState busname_active_state(Unit *u) {
720 return state_translation_table[BUSNAME(u)->state];
723 _pure_ static const char *busname_sub_state_to_string(Unit *u) {
726 return busname_state_to_string(BUSNAME(u)->state);
729 static int busname_peek_message(BusName *n) {
730 struct kdbus_cmd_recv cmd_recv = {
731 .size = sizeof(cmd_recv),
732 .flags = KDBUS_RECV_PEEK,
734 struct kdbus_cmd_free cmd_free = {
735 .size = sizeof(cmd_free),
737 const char *comm = NULL;
738 struct kdbus_item *d;
740 size_t start, ps, sz, delta;
745 /* Generate a friendly debug log message about which process
746 * caused triggering of this bus name. This simply peeks the
747 * metadata of the first queued message and logs it. */
751 /* Let's shortcut things a bit, if debug logging is turned off
754 if (log_get_max_level() < LOG_DEBUG)
757 r = ioctl(n->starter_fd, KDBUS_CMD_RECV, &cmd_recv);
759 if (errno == EINTR || errno == EAGAIN)
762 log_unit_error(UNIT(n)->id, "%s: Failed to query activation message: %m", UNIT(n)->id);
766 /* We map as late as possible, and unmap imemdiately after
767 * use. On 32bit address space is scarce and we want to be
768 * able to handle a lot of activator connections at the same
769 * time, and hence shouldn't keep the mmap()s around for
770 * longer than necessary. */
773 start = (cmd_recv.msg.offset / ps) * ps;
774 delta = cmd_recv.msg.offset - start;
775 sz = PAGE_ALIGN(delta + cmd_recv.msg.msg_size);
777 p = mmap(NULL, sz, PROT_READ, MAP_SHARED, n->starter_fd, start);
778 if (p == MAP_FAILED) {
779 log_unit_error(UNIT(n)->id, "%s: Failed to map activation message: %m", UNIT(n)->id);
784 k = (struct kdbus_msg *) ((uint8_t *) p + delta);
785 KDBUS_ITEM_FOREACH(d, k, items) {
788 case KDBUS_ITEM_PIDS:
792 case KDBUS_ITEM_PID_COMM:
799 log_unit_debug(UNIT(n)->id, "%s: Activation triggered by process " PID_FMT " (%s)", UNIT(n)->id, pid, strna(comm));
805 (void) munmap(p, sz);
807 cmd_free.offset = cmd_recv.msg.offset;
808 if (ioctl(n->starter_fd, KDBUS_CMD_FREE, &cmd_free) < 0)
809 log_unit_warning(UNIT(n)->id, "Failed to free peeked message, ignoring: %m");
814 static int busname_dispatch_io(sd_event_source *source, int fd, uint32_t revents, void *userdata) {
815 BusName *n = userdata;
820 if (n->state != BUSNAME_LISTENING)
823 log_unit_debug(UNIT(n)->id, "Activation request on %s", UNIT(n)->id);
825 if (revents != EPOLLIN) {
826 log_unit_error(UNIT(n)->id, "%s: Got unexpected poll event (0x%x) on starter fd.",
827 UNIT(n)->id, revents);
831 busname_peek_message(n);
832 busname_enter_running(n);
836 busname_enter_dead(n, BUSNAME_FAILURE_RESOURCES);
840 static void busname_sigchld_event(Unit *u, pid_t pid, int code, int status) {
841 BusName *n = BUSNAME(u);
847 if (pid != n->control_pid)
852 if (is_clean_exit(code, status, NULL))
854 else if (code == CLD_EXITED)
855 f = BUSNAME_FAILURE_EXIT_CODE;
856 else if (code == CLD_KILLED)
857 f = BUSNAME_FAILURE_SIGNAL;
858 else if (code == CLD_DUMPED)
859 f = BUSNAME_FAILURE_CORE_DUMP;
861 assert_not_reached("Unknown sigchld code");
864 f == BUSNAME_SUCCESS ? LOG_DEBUG : LOG_NOTICE,
865 "%s control process exited, code=%s status=%i",
866 u->id, sigchld_code_to_string(code), status);
868 if (f != BUSNAME_SUCCESS)
874 if (f == BUSNAME_SUCCESS)
875 busname_enter_listening(n);
877 busname_enter_signal(n, BUSNAME_SIGTERM, f);
880 case BUSNAME_SIGTERM:
881 case BUSNAME_SIGKILL:
882 busname_enter_dead(n, f);
886 assert_not_reached("Uh, control process died at wrong time.");
889 /* Notify clients about changed exit status */
890 unit_add_to_dbus_queue(u);
893 static int busname_dispatch_timer(sd_event_source *source, usec_t usec, void *userdata) {
894 BusName *n = BUSNAME(userdata);
897 assert(n->timer_event_source == source);
902 log_unit_warning(UNIT(n)->id, "%s making timed out. Terminating.", UNIT(n)->id);
903 busname_enter_signal(n, BUSNAME_SIGTERM, BUSNAME_FAILURE_TIMEOUT);
906 case BUSNAME_SIGTERM:
907 log_unit_warning(UNIT(n)->id, "%s stopping timed out. Killing.", UNIT(n)->id);
908 busname_enter_signal(n, BUSNAME_SIGKILL, BUSNAME_FAILURE_TIMEOUT);
911 case BUSNAME_SIGKILL:
912 log_unit_warning(UNIT(n)->id, "%s still around after SIGKILL. Ignoring.", UNIT(n)->id);
913 busname_enter_dead(n, BUSNAME_FAILURE_TIMEOUT);
917 assert_not_reached("Timeout at wrong time.");
923 static void busname_reset_failed(Unit *u) {
924 BusName *n = BUSNAME(u);
928 if (n->state == BUSNAME_FAILED)
929 busname_set_state(n, BUSNAME_DEAD);
931 n->result = BUSNAME_SUCCESS;
934 static void busname_trigger_notify(Unit *u, Unit *other) {
935 BusName *n = BUSNAME(u);
941 if (!IN_SET(n->state, BUSNAME_RUNNING, BUSNAME_LISTENING))
944 if (other->load_state != UNIT_LOADED || other->type != UNIT_SERVICE)
949 if (s->state == SERVICE_FAILED && s->result == SERVICE_FAILURE_START_LIMIT)
950 busname_enter_dead(n, BUSNAME_FAILURE_SERVICE_FAILED_PERMANENT);
951 else if (IN_SET(s->state,
952 SERVICE_DEAD, SERVICE_FAILED,
953 SERVICE_STOP, SERVICE_STOP_SIGTERM, SERVICE_STOP_SIGKILL,
954 SERVICE_STOP_POST, SERVICE_FINAL_SIGTERM, SERVICE_FINAL_SIGKILL,
955 SERVICE_AUTO_RESTART))
956 busname_enter_listening(n);
959 static int busname_kill(Unit *u, KillWho who, int signo, sd_bus_error *error) {
960 return unit_kill_common(u, who, signo, -1, BUSNAME(u)->control_pid, error);
963 static int busname_get_timeout(Unit *u, uint64_t *timeout) {
964 BusName *n = BUSNAME(u);
967 if (!n->timer_event_source)
970 r = sd_event_source_get_time(n->timer_event_source, timeout);
977 static bool busname_supported(Manager *m) {
978 static int supported = -1;
982 supported = access("/sys/fs/kdbus", F_OK) >= 0;
987 static const char* const busname_state_table[_BUSNAME_STATE_MAX] = {
988 [BUSNAME_DEAD] = "dead",
989 [BUSNAME_MAKING] = "making",
990 [BUSNAME_REGISTERED] = "registered",
991 [BUSNAME_LISTENING] = "listening",
992 [BUSNAME_RUNNING] = "running",
993 [BUSNAME_SIGTERM] = "sigterm",
994 [BUSNAME_SIGKILL] = "sigkill",
995 [BUSNAME_FAILED] = "failed",
998 DEFINE_STRING_TABLE_LOOKUP(busname_state, BusNameState);
1000 static const char* const busname_result_table[_BUSNAME_RESULT_MAX] = {
1001 [BUSNAME_SUCCESS] = "success",
1002 [BUSNAME_FAILURE_RESOURCES] = "resources",
1003 [BUSNAME_FAILURE_TIMEOUT] = "timeout",
1004 [BUSNAME_FAILURE_EXIT_CODE] = "exit-code",
1005 [BUSNAME_FAILURE_SIGNAL] = "signal",
1006 [BUSNAME_FAILURE_CORE_DUMP] = "core-dump",
1007 [BUSNAME_FAILURE_SERVICE_FAILED_PERMANENT] = "service-failed-permanent",
1010 DEFINE_STRING_TABLE_LOOKUP(busname_result, BusNameResult);
1012 const UnitVTable busname_vtable = {
1013 .object_size = sizeof(BusName),
1019 .private_section = "BusName",
1021 .init = busname_init,
1022 .done = busname_done,
1023 .load = busname_load,
1025 .coldplug = busname_coldplug,
1027 .dump = busname_dump,
1029 .start = busname_start,
1030 .stop = busname_stop,
1032 .kill = busname_kill,
1034 .get_timeout = busname_get_timeout,
1036 .serialize = busname_serialize,
1037 .deserialize_item = busname_deserialize_item,
1039 .active_state = busname_active_state,
1040 .sub_state_to_string = busname_sub_state_to_string,
1042 .sigchld_event = busname_sigchld_event,
1044 .trigger_notify = busname_trigger_notify,
1046 .reset_failed = busname_reset_failed,
1048 .supported = busname_supported,
1050 .bus_interface = "org.freedesktop.systemd1.BusName",
1051 .bus_vtable = bus_busname_vtable,
1053 .status_message_formats = {
1054 .finished_start_job = {
1055 [JOB_DONE] = "Listening on %s.",
1056 [JOB_FAILED] = "Failed to listen on %s.",
1057 [JOB_DEPENDENCY] = "Dependency failed for %s.",
1058 [JOB_TIMEOUT] = "Timed out starting %s.",
1060 .finished_stop_job = {
1061 [JOB_DONE] = "Closed %s.",
1062 [JOB_FAILED] = "Failed stopping %s.",
1063 [JOB_TIMEOUT] = "Timed out stopping %s.",