dbus-service.c revision 93ae25e6fd62b2f87c3dd9ad3e81934eecc48057
97a9a944b5887e91042b019776c41d5dd74557aferikabele/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
a945f35eff8b6a88009ce73de6d4c862ce58de3cslive This file is part of systemd.
a945f35eff8b6a88009ce73de6d4c862ce58de3cslive Copyright 2010 Lennart Poettering
5a58787efeb02a1c3f06569d019ad81fd2efa06end systemd is free software; you can redistribute it and/or modify it
5a58787efeb02a1c3f06569d019ad81fd2efa06end under the terms of the GNU Lesser General Public License as published by
5a58787efeb02a1c3f06569d019ad81fd2efa06end the Free Software Foundation; either version 2.1 of the License, or
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen (at your option) any later version.
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen systemd is distributed in the hope that it will be useful, but
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen WITHOUT ANY WARRANTY; without even the implied warranty of
5a58787efeb02a1c3f06569d019ad81fd2efa06end MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
5a58787efeb02a1c3f06569d019ad81fd2efa06end Lesser General Public License for more details.
af33a4994ae2ff15bc67d19ff1a7feb906745bf8rbowen You should have received a copy of the GNU Lesser General Public License
3f08db06526d6901aa08c110b5bc7dde6bc39905nd along with systemd; If not, see <http://www.gnu.org/licenses/>.
5a58787efeb02a1c3f06569d019ad81fd2efa06endstatic BUS_DEFINE_PROPERTY_GET_ENUM(property_get_type, service_type, ServiceType);
5a58787efeb02a1c3f06569d019ad81fd2efa06endstatic BUS_DEFINE_PROPERTY_GET_ENUM(property_get_result, service_result, ServiceResult);
5a58787efeb02a1c3f06569d019ad81fd2efa06endstatic BUS_DEFINE_PROPERTY_GET_ENUM(property_get_restart, service_restart, ServiceRestart);
5a58787efeb02a1c3f06569d019ad81fd2efa06endstatic BUS_DEFINE_PROPERTY_GET_ENUM(property_get_notify_access, notify_access, NotifyAccess);
5a58787efeb02a1c3f06569d019ad81fd2efa06endstatic BUS_DEFINE_PROPERTY_GET_ENUM(property_get_start_limit_action, start_limit_action, StartLimitAction);
9b6a3a558cc90ffdaa0b50bd02546ffec424ded7slive SD_BUS_PROPERTY("Type", "s", property_get_type, offsetof(Service, type), SD_BUS_VTABLE_PROPERTY_CONST),
ced7ef1f8c0df1805da0e87dbc5a1b6282910573nd SD_BUS_PROPERTY("Restart", "s", property_get_restart, offsetof(Service, restart), SD_BUS_VTABLE_PROPERTY_CONST),
b21197dc8e6b8c764fdcc24d4bae8b0eebb6bc4end SD_BUS_PROPERTY("PIDFile", "s", NULL, offsetof(Service, pid_file), SD_BUS_VTABLE_PROPERTY_CONST),
9b6a3a558cc90ffdaa0b50bd02546ffec424ded7slive SD_BUS_PROPERTY("NotifyAccess", "s", property_get_notify_access, offsetof(Service, notify_access), SD_BUS_VTABLE_PROPERTY_CONST),
9b6a3a558cc90ffdaa0b50bd02546ffec424ded7slive SD_BUS_PROPERTY("RestartUSec", "t", bus_property_get_usec, offsetof(Service, restart_usec), SD_BUS_VTABLE_PROPERTY_CONST),
9b6a3a558cc90ffdaa0b50bd02546ffec424ded7slive SD_BUS_PROPERTY("TimeoutStartUSec", "t", bus_property_get_usec, offsetof(Service, timeout_start_usec), SD_BUS_VTABLE_PROPERTY_CONST),
97a9a944b5887e91042b019776c41d5dd74557aferikabele SD_BUS_PROPERTY("TimeoutStopUSec", "t", bus_property_get_usec, offsetof(Service, timeout_stop_usec), SD_BUS_VTABLE_PROPERTY_CONST),
f8396ed8364b56ec8adeaa49cac35a929758a29eslive SD_BUS_PROPERTY("WatchdogUSec", "t", bus_property_get_usec, offsetof(Service, watchdog_usec), SD_BUS_VTABLE_PROPERTY_CONST),
ffb01336be79c64046b636e59fa8ddca8ec029edsf BUS_PROPERTY_DUAL_TIMESTAMP("WatchdogTimestamp", offsetof(Service, watchdog_timestamp), 0),
f8396ed8364b56ec8adeaa49cac35a929758a29eslive SD_BUS_PROPERTY("StartLimitInterval", "t", bus_property_get_usec, offsetof(Service, start_limit.interval), SD_BUS_VTABLE_PROPERTY_CONST),
f8396ed8364b56ec8adeaa49cac35a929758a29eslive SD_BUS_PROPERTY("StartLimitBurst", "u", bus_property_get_unsigned, offsetof(Service, start_limit.burst), SD_BUS_VTABLE_PROPERTY_CONST),
5a58787efeb02a1c3f06569d019ad81fd2efa06end SD_BUS_PROPERTY("StartLimitAction", "s", property_get_start_limit_action, offsetof(Service, start_limit_action), SD_BUS_VTABLE_PROPERTY_CONST),
5a58787efeb02a1c3f06569d019ad81fd2efa06end SD_BUS_PROPERTY("RebootArgument", "s", NULL, offsetof(Service, reboot_arg), SD_BUS_VTABLE_PROPERTY_CONST),
5a58787efeb02a1c3f06569d019ad81fd2efa06end SD_BUS_PROPERTY("FailureAction", "s", property_get_start_limit_action, offsetof(Service, failure_action), SD_BUS_VTABLE_PROPERTY_CONST),
5a58787efeb02a1c3f06569d019ad81fd2efa06end SD_BUS_PROPERTY("PermissionsStartOnly", "b", bus_property_get_bool, offsetof(Service, permissions_start_only), SD_BUS_VTABLE_PROPERTY_CONST),
deeee6bb6fd94c0ba5f3730b58abd9d299c89ccdnd SD_BUS_PROPERTY("RootDirectoryStartOnly", "b", bus_property_get_bool, offsetof(Service, root_directory_start_only), SD_BUS_VTABLE_PROPERTY_CONST),
4db28ee269aa06f7c6232e11cd01f58c3349af23noodl SD_BUS_PROPERTY("RemainAfterExit", "b", bus_property_get_bool, offsetof(Service, remain_after_exit), SD_BUS_VTABLE_PROPERTY_CONST),
117c1f888a14e73cdd821dc6c23eb0411144a41cnd SD_BUS_PROPERTY("GuessMainPID", "b", bus_property_get_bool, offsetof(Service, guess_main_pid), SD_BUS_VTABLE_PROPERTY_CONST),
117c1f888a14e73cdd821dc6c23eb0411144a41cnd SD_BUS_PROPERTY("MainPID", "u", bus_property_get_pid, offsetof(Service, main_pid), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
4a31db3c3a0202003c1b9f87affa7cc143e120e5sf SD_BUS_PROPERTY("ControlPID", "u", bus_property_get_pid, offsetof(Service, control_pid), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
117c1f888a14e73cdd821dc6c23eb0411144a41cnd SD_BUS_PROPERTY("BusName", "s", NULL, offsetof(Service, bus_name), SD_BUS_VTABLE_PROPERTY_CONST),
ffb01336be79c64046b636e59fa8ddca8ec029edsf SD_BUS_PROPERTY("StatusText", "s", NULL, offsetof(Service, status_text), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
117c1f888a14e73cdd821dc6c23eb0411144a41cnd SD_BUS_PROPERTY("Result", "s", property_get_result, offsetof(Service, result), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
117c1f888a14e73cdd821dc6c23eb0411144a41cnd BUS_EXEC_STATUS_VTABLE("ExecMain", offsetof(Service, main_exec_status), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
117c1f888a14e73cdd821dc6c23eb0411144a41cnd BUS_EXEC_COMMAND_LIST_VTABLE("ExecStartPre", offsetof(Service, exec_command[SERVICE_EXEC_START_PRE]), SD_BUS_VTABLE_PROPERTY_EMITS_INVALIDATION),
2bc7f1cf720973a67f8ff7a8d523e40569ae5b6cnd BUS_EXEC_COMMAND_LIST_VTABLE("ExecStart", offsetof(Service, exec_command[SERVICE_EXEC_START]), SD_BUS_VTABLE_PROPERTY_EMITS_INVALIDATION),
117c1f888a14e73cdd821dc6c23eb0411144a41cnd BUS_EXEC_COMMAND_LIST_VTABLE("ExecStartPost", offsetof(Service, exec_command[SERVICE_EXEC_START_POST]), SD_BUS_VTABLE_PROPERTY_EMITS_INVALIDATION),
117c1f888a14e73cdd821dc6c23eb0411144a41cnd BUS_EXEC_COMMAND_LIST_VTABLE("ExecReload", offsetof(Service, exec_command[SERVICE_EXEC_RELOAD]), SD_BUS_VTABLE_PROPERTY_EMITS_INVALIDATION),
117c1f888a14e73cdd821dc6c23eb0411144a41cnd BUS_EXEC_COMMAND_LIST_VTABLE("ExecStop", offsetof(Service, exec_command[SERVICE_EXEC_STOP]), SD_BUS_VTABLE_PROPERTY_EMITS_INVALIDATION),
117c1f888a14e73cdd821dc6c23eb0411144a41cnd BUS_EXEC_COMMAND_LIST_VTABLE("ExecStopPost", offsetof(Service, exec_command[SERVICE_EXEC_STOP_POST]), SD_BUS_VTABLE_PROPERTY_EMITS_INVALIDATION),
5a58787efeb02a1c3f06569d019ad81fd2efa06end const char *name,
b1b0d8ff12f69d873f28a9bf79dfba6b67b45a4bigalic unit_write_drop_in_private_format(UNIT(s), mode, name, "RemainAfterExit=%s\n", yes_no(b));
9b6a3a558cc90ffdaa0b50bd02546ffec424ded7slive const char *t;
8a6d5edcb07aeccca7afba02a17dd6904d6b206ctrawick return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid service type %s", t);
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf unit_write_drop_in_private_format(UNIT(s), mode, name, "Type=%s\n", service_type_to_string(s->type));
8a6d5edcb07aeccca7afba02a17dd6904d6b206ctrawick unsigned n = 0;
8a6d5edcb07aeccca7afba02a17dd6904d6b206ctrawick r = sd_bus_message_enter_container(message, 'a', "(sasb)");
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf if (r < 0)
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf while ((r = sd_bus_message_enter_container(message, 'r', "sasb")) > 0) {
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf const char *path;
b244bbf442a0aea3dc397b4d0d751f4716c5891dnd return sd_bus_error_set_errnof(error, EINVAL, "Path %s is not absolute.", path);
9bcfc3697a91b5215893a7d0206865b13fc72148nd if (!c->path) {
709e3a21ba73b8433462959cd56c773454b34441trawick exec_command_append_list(&s->exec_command[SERVICE_EXEC_START], c);
ad74a0524a06bfe11b7de9e3b4ce7233ab3bd3f7nd if (r < 0)
0d0ba3a410038e179b695446bb149cce6264e0abnd if (n == 0) {
ac082aefa89416cbdc9a1836eaf3bed9698201c8humbedooh exec_command_free_list(s->exec_command[SERVICE_EXEC_START]);
0d0ba3a410038e179b695446bb149cce6264e0abnd LIST_FOREACH(command, c, s->exec_command[SERVICE_EXEC_START]) {
return -ENOMEM;
c->path,
fflush(f);
Unit *u,
const char *name,
assert(s);
assert(u);