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"
29 #include "dbus-busname.h"
33 static const UnitActiveState state_translation_table[_BUSNAME_STATE_MAX] = {
34 [BUSNAME_DEAD] = UNIT_INACTIVE,
35 [BUSNAME_MAKING] = UNIT_ACTIVATING,
36 [BUSNAME_REGISTERED] = UNIT_ACTIVE,
37 [BUSNAME_LISTENING] = UNIT_ACTIVE,
38 [BUSNAME_RUNNING] = UNIT_ACTIVE,
39 [BUSNAME_SIGTERM] = UNIT_DEACTIVATING,
40 [BUSNAME_SIGKILL] = UNIT_DEACTIVATING,
41 [BUSNAME_FAILED] = UNIT_FAILED
44 static int busname_dispatch_io(sd_event_source *source, int fd, uint32_t revents, void *userdata);
45 static int busname_dispatch_timer(sd_event_source *source, usec_t usec, void *userdata);
47 static void busname_init(Unit *u) {
48 BusName *n = BUSNAME(u);
51 assert(u->load_state == UNIT_STUB);
57 n->timeout_usec = u->manager->default_timeout_start_usec;
60 static void busname_unwatch_control_pid(BusName *n) {
63 if (n->control_pid <= 0)
66 unit_unwatch_pid(UNIT(n), n->control_pid);
70 static void busname_free_policy(BusName *n) {
75 while ((p = n->policy)) {
76 LIST_REMOVE(policy, n->policy, p);
83 static void busname_close_fd(BusName *n) {
86 n->starter_event_source = sd_event_source_unref(n->starter_event_source);
87 n->starter_fd = safe_close(n->starter_fd);
90 static void busname_done(Unit *u) {
91 BusName *n = BUSNAME(u);
98 busname_free_policy(n);
99 busname_unwatch_control_pid(n);
102 unit_ref_unset(&n->service);
104 n->timer_event_source = sd_event_source_unref(n->timer_event_source);
107 static int busname_arm_timer(BusName *n) {
112 if (n->timeout_usec <= 0) {
113 n->timer_event_source = sd_event_source_unref(n->timer_event_source);
117 if (n->timer_event_source) {
118 r = sd_event_source_set_time(n->timer_event_source, now(CLOCK_MONOTONIC) + n->timeout_usec);
122 return sd_event_source_set_enabled(n->timer_event_source, SD_EVENT_ONESHOT);
125 return sd_event_add_time(
126 UNIT(n)->manager->event,
127 &n->timer_event_source,
129 now(CLOCK_MONOTONIC) + n->timeout_usec, 0,
130 busname_dispatch_timer, n);
133 static int busname_add_default_default_dependencies(BusName *n) {
138 r = unit_add_dependency_by_name(UNIT(n), UNIT_BEFORE, SPECIAL_BUSNAMES_TARGET, NULL, true);
142 if (UNIT(n)->manager->running_as == SYSTEMD_SYSTEM) {
143 r = unit_add_two_dependencies_by_name(UNIT(n), UNIT_AFTER, UNIT_REQUIRES, SPECIAL_SYSINIT_TARGET, NULL, true);
148 return unit_add_two_dependencies_by_name(UNIT(n), UNIT_BEFORE, UNIT_CONFLICTS, SPECIAL_SHUTDOWN_TARGET, NULL, true);
151 static int busname_add_extras(BusName *n) {
158 n->name = unit_name_to_prefix(u->id);
163 if (!u->description) {
164 r = unit_set_description(u, n->name);
170 if (!UNIT_DEREF(n->service)) {
173 r = unit_load_related_unit(u, ".service", &x);
177 unit_ref_set(&n->service, x);
180 r = unit_add_two_dependencies(u, UNIT_BEFORE, UNIT_TRIGGERS, UNIT_DEREF(n->service), true);
185 if (u->default_dependencies) {
186 r = busname_add_default_default_dependencies(n);
194 static int busname_verify(BusName *n) {
199 if (UNIT(n)->load_state != UNIT_LOADED)
202 if (!service_name_is_valid(n->name)) {
203 log_error_unit(UNIT(n)->id, "%s's Name= setting is not a valid service name Refusing.", UNIT(n)->id);
207 e = strappenda(n->name, ".busname");
208 if (!unit_has_name(UNIT(n), e)) {
209 log_error_unit(UNIT(n)->id, "%s's Name= setting doesn't match unit name. Refusing.", UNIT(n)->id);
216 static int busname_load(Unit *u) {
217 BusName *n = BUSNAME(u);
221 assert(u->load_state == UNIT_STUB);
223 r = unit_load_fragment_and_dropin(u);
227 if (u->load_state == UNIT_LOADED) {
228 /* This is a new unit? Then let's add in some extras */
229 r = busname_add_extras(n);
234 return busname_verify(n);
237 static void busname_dump(Unit *u, FILE *f, const char *prefix) {
238 BusName *n = BUSNAME(u);
244 "%sBus Name State: %s\n"
249 prefix, busname_state_to_string(n->state),
250 prefix, busname_result_to_string(n->result),
252 prefix, yes_no(n->activating),
253 prefix, yes_no(n->accept_fd));
255 if (n->control_pid > 0)
257 "%sControl PID: "PID_FMT"\n",
258 prefix, n->control_pid);
261 static void busname_unwatch_fd(BusName *n) {
266 if (!n->starter_event_source)
269 r = sd_event_source_set_enabled(n->starter_event_source, SD_EVENT_OFF);
271 log_debug_unit(UNIT(n)->id, "Failed to disable event source.");
274 static int busname_watch_fd(BusName *n) {
279 if (n->starter_fd < 0)
282 if (n->starter_event_source)
283 r = sd_event_source_set_enabled(n->starter_event_source, SD_EVENT_ON);
285 r = sd_event_add_io(UNIT(n)->manager->event, &n->starter_event_source, n->starter_fd, EPOLLIN, busname_dispatch_io, n);
287 log_warning_unit(UNIT(n)->id, "Failed to watch starter fd: %s", strerror(-r));
288 busname_unwatch_fd(n);
295 static int busname_open_fd(BusName *n) {
296 _cleanup_free_ char *path = NULL;
301 if (n->starter_fd >= 0)
304 mode = UNIT(n)->manager->running_as == SYSTEMD_SYSTEM ? "system" : "user";
305 n->starter_fd = bus_kernel_open_bus_fd(mode, &path);
306 if (n->starter_fd < 0) {
307 log_warning_unit(UNIT(n)->id, "Failed to open %s: %s", path ?: "kdbus", strerror(-n->starter_fd));
308 return n->starter_fd;
314 static void busname_set_state(BusName *n, BusNameState state) {
315 BusNameState old_state;
318 old_state = n->state;
321 if (!IN_SET(state, BUSNAME_MAKING, BUSNAME_SIGTERM, BUSNAME_SIGKILL)) {
322 n->timer_event_source = sd_event_source_unref(n->timer_event_source);
323 busname_unwatch_control_pid(n);
326 if (state != BUSNAME_LISTENING)
327 busname_unwatch_fd(n);
329 if (!IN_SET(state, BUSNAME_LISTENING, BUSNAME_MAKING, BUSNAME_REGISTERED, BUSNAME_RUNNING))
332 if (state != old_state)
333 log_debug_unit(UNIT(n)->id, "%s changed %s -> %s",
334 UNIT(n)->id, busname_state_to_string(old_state), busname_state_to_string(state));
336 unit_notify(UNIT(n), state_translation_table[old_state], state_translation_table[state], true);
339 static int busname_coldplug(Unit *u) {
340 BusName *n = BUSNAME(u);
344 assert(n->state == BUSNAME_DEAD);
346 if (n->deserialized_state == n->state)
349 if (IN_SET(n->deserialized_state, BUSNAME_MAKING, BUSNAME_SIGTERM, BUSNAME_SIGKILL)) {
351 if (n->control_pid <= 0)
354 r = unit_watch_pid(UNIT(n), n->control_pid);
358 r = busname_arm_timer(n);
363 if (IN_SET(n->deserialized_state, BUSNAME_MAKING, BUSNAME_LISTENING, BUSNAME_REGISTERED, BUSNAME_RUNNING)) {
364 r = busname_open_fd(n);
369 if (n->deserialized_state == BUSNAME_LISTENING) {
370 r = busname_watch_fd(n);
375 busname_set_state(n, n->deserialized_state);
379 static int busname_make_starter(BusName *n, pid_t *_pid) {
383 r = busname_arm_timer(n);
387 /* We have to resolve the user/group names out-of-process,
388 * hence let's fork here. It's messy, but well, what can we
398 default_signals(SIGNALS_CRASH_HANDLER, SIGNALS_IGNORE, -1);
399 ignore_signals(SIGPIPE, -1);
402 r = bus_kernel_make_starter(n->starter_fd, n->name, n->activating, n->accept_fd, n->policy, n->policy_world);
404 ret = EXIT_MAKE_STARTER;
412 log_error("Failed to create starter connection at step %s: %s", exit_status_to_string(ret, EXIT_STATUS_SYSTEMD), strerror(-r));
417 r = unit_watch_pid(UNIT(n), pid);
425 n->timer_event_source = sd_event_source_unref(n->timer_event_source);
429 static void busname_enter_dead(BusName *n, BusNameResult f) {
432 if (f != BUSNAME_SUCCESS)
435 busname_set_state(n, n->result != BUSNAME_SUCCESS ? BUSNAME_FAILED : BUSNAME_DEAD);
438 static void busname_enter_signal(BusName *n, BusNameState state, BusNameResult f) {
439 KillContext kill_context = {};
444 if (f != BUSNAME_SUCCESS)
447 kill_context_init(&kill_context);
449 r = unit_kill_context(UNIT(n),
451 state != BUSNAME_SIGTERM ? KILL_KILL : KILL_TERMINATE,
456 log_warning_unit(UNIT(n)->id, "%s failed to kill control process: %s", UNIT(n)->id, strerror(-r));
461 r = busname_arm_timer(n);
463 log_warning_unit(UNIT(n)->id, "%s failed to arm timer: %s", UNIT(n)->id, strerror(-r));
467 busname_set_state(n, state);
468 } else if (state == BUSNAME_SIGTERM)
469 busname_enter_signal(n, BUSNAME_SIGKILL, BUSNAME_SUCCESS);
471 busname_enter_dead(n, BUSNAME_SUCCESS);
476 busname_enter_dead(n, BUSNAME_FAILURE_RESOURCES);
479 static void busname_enter_listening(BusName *n) {
485 r = busname_watch_fd(n);
487 log_warning_unit(UNIT(n)->id, "%s failed to watch names: %s", UNIT(n)->id, strerror(-r));
491 busname_set_state(n, BUSNAME_LISTENING);
493 busname_set_state(n, BUSNAME_REGISTERED);
498 busname_enter_signal(n, BUSNAME_SIGTERM, BUSNAME_FAILURE_RESOURCES);
501 static void busname_enter_making(BusName *n) {
506 r = busname_open_fd(n);
511 /* If there is a policy, we need to resolve user/group
512 * names, which we can't do from PID1, hence let's
514 busname_unwatch_control_pid(n);
516 r = busname_make_starter(n, &n->control_pid);
518 log_warning_unit(UNIT(n)->id, "%s failed to fork 'making' task: %s", UNIT(n)->id, strerror(-r));
522 busname_set_state(n, BUSNAME_MAKING);
524 /* If there is no policy, we can do everything
525 * directly from PID 1, hence do so. */
527 r = bus_kernel_make_starter(n->starter_fd, n->name, n->activating, n->accept_fd, NULL, n->policy_world);
529 log_warning_unit(UNIT(n)->id, "%s failed to make starter: %s", UNIT(n)->id, strerror(-r));
533 busname_enter_listening(n);
539 busname_enter_dead(n, BUSNAME_FAILURE_RESOURCES);
542 static void busname_enter_running(BusName *n) {
543 _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
544 bool pending = false;
554 /* We don't take conenctions anymore if we are supposed to
555 * shut down anyway */
557 if (unit_stop_pending(UNIT(n))) {
558 log_debug_unit(UNIT(n)->id, "Suppressing activation request on %s since unit stop is scheduled.", UNIT(n)->id);
560 /* Flush all queued activation reqeuest by closing and reopening the connection */
561 bus_kernel_drop_one(n->starter_fd);
563 busname_enter_listening(n);
567 /* If there's already a start pending don't bother to do
569 SET_FOREACH(other, UNIT(n)->dependencies[UNIT_TRIGGERS], i)
570 if (unit_active_or_pending(other)) {
576 r = manager_add_job(UNIT(n)->manager, JOB_START, UNIT_DEREF(n->service), JOB_REPLACE, true, &error, NULL);
581 busname_set_state(n, BUSNAME_RUNNING);
585 log_warning_unit(UNIT(n)->id, "%s failed to queue service startup job: %s", UNIT(n)->id, bus_error_message(&error, r));
586 busname_enter_dead(n, BUSNAME_FAILURE_RESOURCES);
589 static int busname_start(Unit *u) {
590 BusName *n = BUSNAME(u);
594 /* We cannot fulfill this request right now, try again later
596 if (IN_SET(n->state, BUSNAME_SIGTERM, BUSNAME_SIGKILL))
600 if (n->state == BUSNAME_MAKING)
603 if (n->activating && UNIT_ISSET(n->service)) {
606 service = SERVICE(UNIT_DEREF(n->service));
608 if (UNIT(service)->load_state != UNIT_LOADED) {
609 log_error_unit(u->id, "Bus service %s not loaded, refusing.", UNIT(service)->id);
614 assert(IN_SET(n->state, BUSNAME_DEAD, BUSNAME_FAILED));
616 n->result = BUSNAME_SUCCESS;
617 busname_enter_making(n);
622 static int busname_stop(Unit *u) {
623 BusName *n = BUSNAME(u);
628 if (IN_SET(n->state, BUSNAME_SIGTERM, BUSNAME_SIGKILL))
631 /* If there's already something running, we go directly into
634 if (n->state == BUSNAME_MAKING) {
635 busname_enter_signal(n, BUSNAME_SIGTERM, BUSNAME_SUCCESS);
639 assert(IN_SET(n->state, BUSNAME_REGISTERED, BUSNAME_LISTENING, BUSNAME_RUNNING));
641 busname_enter_dead(n, BUSNAME_SUCCESS);
645 static int busname_serialize(Unit *u, FILE *f, FDSet *fds) {
646 BusName *n = BUSNAME(u);
652 unit_serialize_item(u, f, "state", busname_state_to_string(n->state));
653 unit_serialize_item(u, f, "result", busname_result_to_string(n->result));
655 if (n->control_pid > 0)
656 unit_serialize_item_format(u, f, "control-pid", PID_FMT, n->control_pid);
658 if (n->starter_fd >= 0) {
661 copy = fdset_put_dup(fds, n->starter_fd);
665 unit_serialize_item_format(u, f, "starter-fd", "%i", copy);
671 static int busname_deserialize_item(Unit *u, const char *key, const char *value, FDSet *fds) {
672 BusName *n = BUSNAME(u);
678 if (streq(key, "state")) {
681 state = busname_state_from_string(value);
683 log_debug_unit(u->id, "Failed to parse state value %s", value);
685 n->deserialized_state = state;
687 } else if (streq(key, "result")) {
690 f = busname_result_from_string(value);
692 log_debug_unit(u->id, "Failed to parse result value %s", value);
693 else if (f != BUSNAME_SUCCESS)
696 } else if (streq(key, "control-pid")) {
699 if (parse_pid(value, &pid) < 0)
700 log_debug_unit(u->id, "Failed to parse control-pid value %s", value);
702 n->control_pid = pid;
703 } else if (streq(key, "starter-fd")) {
706 if (safe_atoi(value, &fd) < 0 || fd < 0 || !fdset_contains(fds, fd))
707 log_debug_unit(u->id, "Failed to parse starter fd value %s", value);
709 safe_close(n->starter_fd);
710 n->starter_fd = fdset_remove(fds, fd);
713 log_debug_unit(u->id, "Unknown serialization key '%s'", key);
718 _pure_ static UnitActiveState busname_active_state(Unit *u) {
721 return state_translation_table[BUSNAME(u)->state];
724 _pure_ static const char *busname_sub_state_to_string(Unit *u) {
727 return busname_state_to_string(BUSNAME(u)->state);
730 static int busname_peek_message(BusName *n) {
731 struct kdbus_cmd_recv cmd_recv = {
732 .flags = KDBUS_RECV_PEEK,
734 struct kdbus_cmd_free cmd_free = {};
735 const char *comm = NULL;
736 struct kdbus_item *d;
738 size_t start, ps, sz, delta;
743 /* Generate a friendly debug log message about which process
744 * caused triggering of this bus name. This simply peeks the
745 * metadata of the first queued message and logs it. */
749 /* Let's shortcut things a bit, if debug logging is turned off
752 if (log_get_max_level() < LOG_DEBUG)
755 r = ioctl(n->starter_fd, KDBUS_CMD_MSG_RECV, &cmd_recv);
757 if (errno == EINTR || errno == EAGAIN)
760 log_error_unit(UNIT(n)->id, "%s: Failed to query activation message: %m", UNIT(n)->id);
764 /* We map as late as possible, and unmap imemdiately after
765 * use. On 32bit address space is scarce and we want to be
766 * able to handle a lot of activator connections at the same
767 * time, and hence shouldn't keep the mmap()s around for
768 * longer than necessary. */
771 start = (cmd_recv.offset / ps) * ps;
772 delta = cmd_recv.offset - start;
773 sz = PAGE_ALIGN(delta + cmd_recv.msg_size);
775 p = mmap(NULL, sz, PROT_READ, MAP_SHARED, n->starter_fd, start);
776 if (p == MAP_FAILED) {
777 log_error_unit(UNIT(n)->id, "%s: Failed to map activation message: %m", UNIT(n)->id);
782 k = (struct kdbus_msg *) ((uint8_t *) p + delta);
783 KDBUS_ITEM_FOREACH(d, k, items) {
786 case KDBUS_ITEM_PIDS:
790 case KDBUS_ITEM_PID_COMM:
797 log_debug_unit(UNIT(n)->id, "%s: Activation triggered by process " PID_FMT " (%s)", UNIT(n)->id, pid, strna(comm));
803 (void) munmap(p, sz);
805 cmd_free.offset = cmd_recv.offset;
806 if (ioctl(n->starter_fd, KDBUS_CMD_FREE, &cmd_free) < 0)
807 log_warning_unit(UNIT(n)->id, "Failed to free peeked message, ignoring: %m");
812 static int busname_dispatch_io(sd_event_source *source, int fd, uint32_t revents, void *userdata) {
813 BusName *n = userdata;
818 if (n->state != BUSNAME_LISTENING)
821 log_debug_unit(UNIT(n)->id, "Activation request on %s", UNIT(n)->id);
823 if (revents != EPOLLIN) {
824 log_error_unit(UNIT(n)->id, "%s: Got unexpected poll event (0x%x) on starter fd.",
825 UNIT(n)->id, revents);
829 busname_peek_message(n);
830 busname_enter_running(n);
834 busname_enter_dead(n, BUSNAME_FAILURE_RESOURCES);
838 static void busname_sigchld_event(Unit *u, pid_t pid, int code, int status) {
839 BusName *n = BUSNAME(u);
845 if (pid != n->control_pid)
850 if (is_clean_exit(code, status, NULL))
852 else if (code == CLD_EXITED)
853 f = BUSNAME_FAILURE_EXIT_CODE;
854 else if (code == CLD_KILLED)
855 f = BUSNAME_FAILURE_SIGNAL;
856 else if (code == CLD_DUMPED)
857 f = BUSNAME_FAILURE_CORE_DUMP;
859 assert_not_reached("Unknown sigchld code");
861 log_full_unit(f == BUSNAME_SUCCESS ? LOG_DEBUG : LOG_NOTICE,
862 u->id, "%s control process exited, code=%s status=%i",
863 u->id, sigchld_code_to_string(code), status);
865 if (f != BUSNAME_SUCCESS)
871 if (f == BUSNAME_SUCCESS)
872 busname_enter_listening(n);
874 busname_enter_signal(n, BUSNAME_SIGTERM, f);
877 case BUSNAME_SIGTERM:
878 case BUSNAME_SIGKILL:
879 busname_enter_dead(n, f);
883 assert_not_reached("Uh, control process died at wrong time.");
886 /* Notify clients about changed exit status */
887 unit_add_to_dbus_queue(u);
890 static int busname_dispatch_timer(sd_event_source *source, usec_t usec, void *userdata) {
891 BusName *n = BUSNAME(userdata);
894 assert(n->timer_event_source == source);
899 log_warning_unit(UNIT(n)->id, "%s making timed out. Terminating.", UNIT(n)->id);
900 busname_enter_signal(n, BUSNAME_SIGTERM, BUSNAME_FAILURE_TIMEOUT);
903 case BUSNAME_SIGTERM:
904 log_warning_unit(UNIT(n)->id, "%s stopping timed out. Killing.", UNIT(n)->id);
905 busname_enter_signal(n, BUSNAME_SIGKILL, BUSNAME_FAILURE_TIMEOUT);
908 case BUSNAME_SIGKILL:
909 log_warning_unit(UNIT(n)->id, "%s still around after SIGKILL. Ignoring.", UNIT(n)->id);
910 busname_enter_dead(n, BUSNAME_FAILURE_TIMEOUT);
914 assert_not_reached("Timeout at wrong time.");
920 static void busname_reset_failed(Unit *u) {
921 BusName *n = BUSNAME(u);
925 if (n->state == BUSNAME_FAILED)
926 busname_set_state(n, BUSNAME_DEAD);
928 n->result = BUSNAME_SUCCESS;
931 static void busname_trigger_notify(Unit *u, Unit *other) {
932 BusName *n = BUSNAME(u);
938 if (!IN_SET(n->state, BUSNAME_RUNNING, BUSNAME_LISTENING))
941 if (other->load_state != UNIT_LOADED || other->type != UNIT_SERVICE)
946 if (s->state == SERVICE_FAILED && s->result == SERVICE_FAILURE_START_LIMIT)
947 busname_enter_dead(n, BUSNAME_FAILURE_SERVICE_FAILED_PERMANENT);
948 else if (IN_SET(s->state,
949 SERVICE_DEAD, SERVICE_FAILED,
950 SERVICE_STOP, SERVICE_STOP_SIGTERM, SERVICE_STOP_SIGKILL,
951 SERVICE_STOP_POST, SERVICE_FINAL_SIGTERM, SERVICE_FINAL_SIGKILL,
952 SERVICE_AUTO_RESTART))
953 busname_enter_listening(n);
956 static int busname_kill(Unit *u, KillWho who, int signo, sd_bus_error *error) {
957 return unit_kill_common(u, who, signo, -1, BUSNAME(u)->control_pid, error);
960 static int busname_get_timeout(Unit *u, uint64_t *timeout) {
961 BusName *n = BUSNAME(u);
964 if (!n->timer_event_source)
967 r = sd_event_source_get_time(n->timer_event_source, timeout);
974 static const char* const busname_state_table[_BUSNAME_STATE_MAX] = {
975 [BUSNAME_DEAD] = "dead",
976 [BUSNAME_MAKING] = "making",
977 [BUSNAME_REGISTERED] = "registered",
978 [BUSNAME_LISTENING] = "listening",
979 [BUSNAME_RUNNING] = "running",
980 [BUSNAME_SIGTERM] = "sigterm",
981 [BUSNAME_SIGKILL] = "sigkill",
982 [BUSNAME_FAILED] = "failed",
985 DEFINE_STRING_TABLE_LOOKUP(busname_state, BusNameState);
987 static const char* const busname_result_table[_BUSNAME_RESULT_MAX] = {
988 [BUSNAME_SUCCESS] = "success",
989 [BUSNAME_FAILURE_RESOURCES] = "resources",
990 [BUSNAME_FAILURE_TIMEOUT] = "timeout",
991 [BUSNAME_FAILURE_EXIT_CODE] = "exit-code",
992 [BUSNAME_FAILURE_SIGNAL] = "signal",
993 [BUSNAME_FAILURE_CORE_DUMP] = "core-dump",
994 [BUSNAME_FAILURE_SERVICE_FAILED_PERMANENT] = "service-failed-permanent",
997 DEFINE_STRING_TABLE_LOOKUP(busname_result, BusNameResult);
999 const UnitVTable busname_vtable = {
1000 .object_size = sizeof(BusName),
1006 .private_section = "BusName",
1008 .init = busname_init,
1009 .done = busname_done,
1010 .load = busname_load,
1012 .coldplug = busname_coldplug,
1014 .dump = busname_dump,
1016 .start = busname_start,
1017 .stop = busname_stop,
1019 .kill = busname_kill,
1021 .get_timeout = busname_get_timeout,
1023 .serialize = busname_serialize,
1024 .deserialize_item = busname_deserialize_item,
1026 .active_state = busname_active_state,
1027 .sub_state_to_string = busname_sub_state_to_string,
1029 .sigchld_event = busname_sigchld_event,
1031 .trigger_notify = busname_trigger_notify,
1033 .reset_failed = busname_reset_failed,
1035 .bus_interface = "org.freedesktop.systemd1.BusName",
1036 .bus_vtable = bus_busname_vtable,
1038 .status_message_formats = {
1039 .finished_start_job = {
1040 [JOB_DONE] = "Listening on %s.",
1041 [JOB_FAILED] = "Failed to listen on %s.",
1042 [JOB_DEPENDENCY] = "Dependency failed for %s.",
1043 [JOB_TIMEOUT] = "Timed out starting %s.",
1045 .finished_stop_job = {
1046 [JOB_DONE] = "Closed %s.",
1047 [JOB_FAILED] = "Failed stopping %s.",
1048 [JOB_TIMEOUT] = "Timed out stopping %s.",