dbus-service.c revision 93ae25e6fd62b2f87c3dd9ad3e81934eecc48057
97a9a944b5887e91042b019776c41d5dd74557aferikabele/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
97a9a944b5887e91042b019776c41d5dd74557aferikabele
97a9a944b5887e91042b019776c41d5dd74557aferikabele/***
a945f35eff8b6a88009ce73de6d4c862ce58de3cslive This file is part of systemd.
a945f35eff8b6a88009ce73de6d4c862ce58de3cslive
a945f35eff8b6a88009ce73de6d4c862ce58de3cslive Copyright 2010 Lennart Poettering
5a58787efeb02a1c3f06569d019ad81fd2efa06end
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.
2e545ce2450a9953665f701bb05350f0d3f26275nd
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.
5a58787efeb02a1c3f06569d019ad81fd2efa06end
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/>.
5a58787efeb02a1c3f06569d019ad81fd2efa06end***/
5a58787efeb02a1c3f06569d019ad81fd2efa06end
5a58787efeb02a1c3f06569d019ad81fd2efa06end#include "strv.h"
3f08db06526d6901aa08c110b5bc7dde6bc39905nd#include "path-util.h"
5a58787efeb02a1c3f06569d019ad81fd2efa06end#include "unit.h"
a63f0ab647ad2ab72efc9bea7a66e24e9ebc5cc2nd#include "service.h"
3b3b7fc78d1f5bfc2769903375050048ff41ff26nd#include "dbus-unit.h"
ad74a0524a06bfe11b7de9e3b4ce7233ab3bd3f7nd#include "dbus-execute.h"
ad74a0524a06bfe11b7de9e3b4ce7233ab3bd3f7nd#include "dbus-kill.h"
e1e8390280254f7f0580d701e583f670643d4f3fnilgun#include "dbus-cgroup.h"
f086b4b402fa9a2fefc7dda85de2a3cc1cd0a654rjung#include "dbus-service.h"
3b3b7fc78d1f5bfc2769903375050048ff41ff26nd#include "bus-util.h"
5a58787efeb02a1c3f06569d019ad81fd2efa06end
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);
5a58787efeb02a1c3f06569d019ad81fd2efa06end
06ba4a61654b3763ad65f52283832ebf058fdf1csliveconst sd_bus_vtable bus_service_vtable[] = {
ced7ef1f8c0df1805da0e87dbc5a1b6282910573nd SD_BUS_VTABLE_START(0),
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),
117c1f888a14e73cdd821dc6c23eb0411144a41cnd SD_BUS_VTABLE_END
117c1f888a14e73cdd821dc6c23eb0411144a41cnd};
87ffb6e33f3cbef3b9bb406cc2d27039fa336eaatrawick
4db28ee269aa06f7c6232e11cd01f58c3349af23noodlstatic int bus_service_set_transient_property(
5a58787efeb02a1c3f06569d019ad81fd2efa06end Service *s,
5a58787efeb02a1c3f06569d019ad81fd2efa06end const char *name,
5a58787efeb02a1c3f06569d019ad81fd2efa06end sd_bus_message *message,
5a58787efeb02a1c3f06569d019ad81fd2efa06end UnitSetPropertiesMode mode,
5a58787efeb02a1c3f06569d019ad81fd2efa06end sd_bus_error *error) {
5a58787efeb02a1c3f06569d019ad81fd2efa06end
654d8eb036bedc99e90e11910ee02d3421417697rbowen int r;
30471a4650391f57975f60bbb6e4a90be7b284bfhumbedooh
5a58787efeb02a1c3f06569d019ad81fd2efa06end assert(s);
5a58787efeb02a1c3f06569d019ad81fd2efa06end assert(name);
5a58787efeb02a1c3f06569d019ad81fd2efa06end assert(message);
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf
8a6d5edcb07aeccca7afba02a17dd6904d6b206ctrawick if (streq(name, "RemainAfterExit")) {
8a6d5edcb07aeccca7afba02a17dd6904d6b206ctrawick int b;
8a6d5edcb07aeccca7afba02a17dd6904d6b206ctrawick
8a6d5edcb07aeccca7afba02a17dd6904d6b206ctrawick r = sd_bus_message_read(message, "b", &b);
06ba4a61654b3763ad65f52283832ebf058fdf1cslive if (r < 0)
654d8eb036bedc99e90e11910ee02d3421417697rbowen return r;
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive if (mode != UNIT_CHECK) {
06ba4a61654b3763ad65f52283832ebf058fdf1cslive s->remain_after_exit = b;
b1b0d8ff12f69d873f28a9bf79dfba6b67b45a4bigalic unit_write_drop_in_private_format(UNIT(s), mode, name, "RemainAfterExit=%s\n", yes_no(b));
97a9a944b5887e91042b019776c41d5dd74557aferikabele }
654d8eb036bedc99e90e11910ee02d3421417697rbowen
92510838f2eb125726e15c5eb4f7a23c7a0396e4slive return 1;
97a9a944b5887e91042b019776c41d5dd74557aferikabele
9b6a3a558cc90ffdaa0b50bd02546ffec424ded7slive } else if (streq(name, "Type")) {
9b6a3a558cc90ffdaa0b50bd02546ffec424ded7slive const char *t;
92510838f2eb125726e15c5eb4f7a23c7a0396e4slive ServiceType k;
92510838f2eb125726e15c5eb4f7a23c7a0396e4slive
ffb01336be79c64046b636e59fa8ddca8ec029edsf r = sd_bus_message_read(message, "s", &t);
8a6d5edcb07aeccca7afba02a17dd6904d6b206ctrawick if (r < 0)
ffb01336be79c64046b636e59fa8ddca8ec029edsf return r;
b244bbf442a0aea3dc397b4d0d751f4716c5891dnd
8a6d5edcb07aeccca7afba02a17dd6904d6b206ctrawick k = service_type_from_string(t);
8a6d5edcb07aeccca7afba02a17dd6904d6b206ctrawick if (k < 0)
8a6d5edcb07aeccca7afba02a17dd6904d6b206ctrawick return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid service type %s", t);
8a6d5edcb07aeccca7afba02a17dd6904d6b206ctrawick
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf if (mode != UNIT_CHECK) {
b244bbf442a0aea3dc397b4d0d751f4716c5891dnd s->type = k;
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf unit_write_drop_in_private_format(UNIT(s), mode, name, "Type=%s\n", service_type_to_string(s->type));
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf }
ffb01336be79c64046b636e59fa8ddca8ec029edsf
b244bbf442a0aea3dc397b4d0d751f4716c5891dnd return 1;
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf
8a6d5edcb07aeccca7afba02a17dd6904d6b206ctrawick } else if (streq(name, "ExecStart")) {
8a6d5edcb07aeccca7afba02a17dd6904d6b206ctrawick unsigned n = 0;
77c77cf89621f21c8e2bbad63058b5eaa5f88d4ajim
8a6d5edcb07aeccca7afba02a17dd6904d6b206ctrawick r = sd_bus_message_enter_container(message, 'a', "(sasb)");
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf if (r < 0)
ced7ef1f8c0df1805da0e87dbc5a1b6282910573nd return r;
8a6d5edcb07aeccca7afba02a17dd6904d6b206ctrawick
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf while ((r = sd_bus_message_enter_container(message, 'r', "sasb")) > 0) {
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf _cleanup_strv_free_ char **argv = NULL;
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf const char *path;
ced7ef1f8c0df1805da0e87dbc5a1b6282910573nd int b;
8a6d5edcb07aeccca7afba02a17dd6904d6b206ctrawick
8a6d5edcb07aeccca7afba02a17dd6904d6b206ctrawick r = sd_bus_message_read(message, "s", &path);
8a6d5edcb07aeccca7afba02a17dd6904d6b206ctrawick if (r < 0)
b244bbf442a0aea3dc397b4d0d751f4716c5891dnd return r;
4a31db3c3a0202003c1b9f87affa7cc143e120e5sf
8a6d5edcb07aeccca7afba02a17dd6904d6b206ctrawick if (!path_is_absolute(path))
b244bbf442a0aea3dc397b4d0d751f4716c5891dnd return sd_bus_error_set_errnof(error, EINVAL, "Path %s is not absolute.", path);
8a6d5edcb07aeccca7afba02a17dd6904d6b206ctrawick
ffb01336be79c64046b636e59fa8ddca8ec029edsf r = sd_bus_message_read_strv(message, &argv);
8a6d5edcb07aeccca7afba02a17dd6904d6b206ctrawick if (r < 0)
92510838f2eb125726e15c5eb4f7a23c7a0396e4slive return r;
92510838f2eb125726e15c5eb4f7a23c7a0396e4slive
97a9a944b5887e91042b019776c41d5dd74557aferikabele r = sd_bus_message_read(message, "b", &b);
92510838f2eb125726e15c5eb4f7a23c7a0396e4slive if (r < 0)
4aa603e6448b99f9371397d439795c91a93637eand return r;
f0fa55ff14fa0bf8fd72d989f6625de6dc3260c8igalic
f0fa55ff14fa0bf8fd72d989f6625de6dc3260c8igalic r = sd_bus_message_exit_container(message);
f0fa55ff14fa0bf8fd72d989f6625de6dc3260c8igalic if (r < 0)
f0fa55ff14fa0bf8fd72d989f6625de6dc3260c8igalic return r;
4aa603e6448b99f9371397d439795c91a93637eand
f0fa55ff14fa0bf8fd72d989f6625de6dc3260c8igalic if (mode != UNIT_CHECK) {
06ba4a61654b3763ad65f52283832ebf058fdf1cslive ExecCommand *c;
e8d485701957d5c6de870111c112e168a894d49and
e8d485701957d5c6de870111c112e168a894d49and c = new0(ExecCommand, 1);
654d8eb036bedc99e90e11910ee02d3421417697rbowen if (!c)
654d8eb036bedc99e90e11910ee02d3421417697rbowen return -ENOMEM;
9b6a3a558cc90ffdaa0b50bd02546ffec424ded7slive
9b6a3a558cc90ffdaa0b50bd02546ffec424ded7slive c->path = strdup(path);
9bcfc3697a91b5215893a7d0206865b13fc72148nd if (!c->path) {
9b6a3a558cc90ffdaa0b50bd02546ffec424ded7slive free(c);
9b6a3a558cc90ffdaa0b50bd02546ffec424ded7slive return -ENOMEM;
06ba4a61654b3763ad65f52283832ebf058fdf1cslive }
4a31db3c3a0202003c1b9f87affa7cc143e120e5sf
9b6a3a558cc90ffdaa0b50bd02546ffec424ded7slive c->argv = argv;
9b6a3a558cc90ffdaa0b50bd02546ffec424ded7slive argv = NULL;
709e3a21ba73b8433462959cd56c773454b34441trawick
709e3a21ba73b8433462959cd56c773454b34441trawick c->ignore = b;
709e3a21ba73b8433462959cd56c773454b34441trawick
709e3a21ba73b8433462959cd56c773454b34441trawick path_kill_slashes(c->path);
709e3a21ba73b8433462959cd56c773454b34441trawick exec_command_append_list(&s->exec_command[SERVICE_EXEC_START], c);
709e3a21ba73b8433462959cd56c773454b34441trawick }
709e3a21ba73b8433462959cd56c773454b34441trawick
5a58787efeb02a1c3f06569d019ad81fd2efa06end n++;
5a58787efeb02a1c3f06569d019ad81fd2efa06end }
3b3b7fc78d1f5bfc2769903375050048ff41ff26nd
ad74a0524a06bfe11b7de9e3b4ce7233ab3bd3f7nd if (r < 0)
ad74a0524a06bfe11b7de9e3b4ce7233ab3bd3f7nd return r;
e1e8390280254f7f0580d701e583f670643d4f3fnilgun
f086b4b402fa9a2fefc7dda85de2a3cc1cd0a654rjung r = sd_bus_message_exit_container(message);
727872d18412fc021f03969b8641810d8896820bhumbedooh if (r < 0)
0d0ba3a410038e179b695446bb149cce6264e0abnd return r;
727872d18412fc021f03969b8641810d8896820bhumbedooh
cc7e1025de9ac63bd4db6fe7f71c158b2cf09fe4humbedooh if (mode != UNIT_CHECK) {
0d0ba3a410038e179b695446bb149cce6264e0abnd _cleanup_free_ char *buf = NULL;
cc7e1025de9ac63bd4db6fe7f71c158b2cf09fe4humbedooh _cleanup_fclose_ FILE *f = NULL;
727872d18412fc021f03969b8641810d8896820bhumbedooh ExecCommand *c;
0d0ba3a410038e179b695446bb149cce6264e0abnd size_t size = 0;
0d0ba3a410038e179b695446bb149cce6264e0abnd
0d0ba3a410038e179b695446bb149cce6264e0abnd if (n == 0) {
ac082aefa89416cbdc9a1836eaf3bed9698201c8humbedooh exec_command_free_list(s->exec_command[SERVICE_EXEC_START]);
0d0ba3a410038e179b695446bb149cce6264e0abnd s->exec_command[SERVICE_EXEC_START] = NULL;
0d0ba3a410038e179b695446bb149cce6264e0abnd }
0d0ba3a410038e179b695446bb149cce6264e0abnd
727872d18412fc021f03969b8641810d8896820bhumbedooh f = open_memstream(&buf, &size);
0d0ba3a410038e179b695446bb149cce6264e0abnd if (!f)
0d0ba3a410038e179b695446bb149cce6264e0abnd return -ENOMEM;
30471a4650391f57975f60bbb6e4a90be7b284bfhumbedooh
07dc96d063d49299da433f84b5c5681da9bbdf68rbowen fputs("ExecStart=\n", f);
af33a4994ae2ff15bc67d19ff1a7feb906745bf8rbowen
0d0ba3a410038e179b695446bb149cce6264e0abnd LIST_FOREACH(command, c, s->exec_command[SERVICE_EXEC_START]) {
7fec19672a491661b2fe4b29f685bc7f4efa64d4nd _cleanup_free_ char *a;
7fec19672a491661b2fe4b29f685bc7f4efa64d4nd
7fec19672a491661b2fe4b29f685bc7f4efa64d4nd a = strv_join_quoted(c->argv);
5a58787efeb02a1c3f06569d019ad81fd2efa06end if (!a)
return -ENOMEM;
fprintf(f, "ExecStart=%s@%s %s\n",
c->ignore ? "-" : "",
c->path,
a);
}
fflush(f);
unit_write_drop_in_private(UNIT(s), mode, name, buf);
}
return 1;
}
return 0;
}
int bus_service_set_property(
Unit *u,
const char *name,
sd_bus_message *message,
UnitSetPropertiesMode mode,
sd_bus_error *error) {
Service *s = SERVICE(u);
int r;
assert(s);
assert(name);
assert(message);
r = bus_cgroup_set_property(u, &s->cgroup_context, name, message, mode, error);
if (r != 0)
return r;
if (u->transient && u->load_state == UNIT_STUB) {
/* This is a transient unit, let's load a little more */
r = bus_service_set_transient_property(s, name, message, mode, error);
if (r != 0)
return r;
r = bus_exec_context_set_transient_property(u, &s->exec_context, name, message, mode, error);
if (r != 0)
return r;
r = bus_kill_context_set_transient_property(u, &s->kill_context, name, message, mode, error);
if (r != 0)
return r;
}
return 0;
}
int bus_service_commit_properties(Unit *u) {
assert(u);
unit_update_cgroup_members_masks(u);
unit_realize_cgroup(u);
return 0;
}