Line data Source code
1 : /* SPDX-License-Identifier: LGPL-2.1+ */
2 :
3 : #include <fcntl.h>
4 :
5 : #include "alloc-util.h"
6 : #include "async.h"
7 : #include "bus-internal.h"
8 : #include "bus-util.h"
9 : #include "dbus-cgroup.h"
10 : #include "dbus-execute.h"
11 : #include "dbus-kill.h"
12 : #include "dbus-manager.h"
13 : #include "dbus-service.h"
14 : #include "dbus-util.h"
15 : #include "exit-status.h"
16 : #include "fd-util.h"
17 : #include "fileio.h"
18 : #include "parse-util.h"
19 : #include "path-util.h"
20 : #include "service.h"
21 : #include "signal-util.h"
22 : #include "string-util.h"
23 : #include "strv.h"
24 : #include "unit.h"
25 :
26 0 : static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_type, service_type, ServiceType);
27 0 : static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_result, service_result, ServiceResult);
28 0 : static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_restart, service_restart, ServiceRestart);
29 0 : static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_notify_access, notify_access, NotifyAccess);
30 0 : static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_emergency_action, emergency_action, EmergencyAction);
31 0 : static BUS_DEFINE_PROPERTY_GET(property_get_timeout_abort_usec, "t", Service, service_timeout_abort_usec);
32 :
33 0 : static int property_get_exit_status_set(
34 : sd_bus *bus,
35 : const char *path,
36 : const char *interface,
37 : const char *property,
38 : sd_bus_message *reply,
39 : void *userdata,
40 : sd_bus_error *error) {
41 :
42 0 : const ExitStatusSet *status_set = userdata;
43 : unsigned n;
44 : Iterator i;
45 : int r;
46 :
47 0 : assert(bus);
48 0 : assert(reply);
49 0 : assert(status_set);
50 :
51 0 : r = sd_bus_message_open_container(reply, 'r', "aiai");
52 0 : if (r < 0)
53 0 : return r;
54 :
55 0 : r = sd_bus_message_open_container(reply, 'a', "i");
56 0 : if (r < 0)
57 0 : return r;
58 :
59 0 : BITMAP_FOREACH(n, &status_set->status, i) {
60 0 : assert(n < 256);
61 :
62 0 : r = sd_bus_message_append_basic(reply, 'i', &n);
63 0 : if (r < 0)
64 0 : return r;
65 : }
66 :
67 0 : r = sd_bus_message_close_container(reply);
68 0 : if (r < 0)
69 0 : return r;
70 :
71 0 : r = sd_bus_message_open_container(reply, 'a', "i");
72 0 : if (r < 0)
73 0 : return r;
74 :
75 0 : BITMAP_FOREACH(n, &status_set->signal, i) {
76 : const char *str;
77 :
78 0 : str = signal_to_string(n);
79 0 : if (!str)
80 0 : continue;
81 :
82 0 : r = sd_bus_message_append_basic(reply, 'i', &n);
83 0 : if (r < 0)
84 0 : return r;
85 : }
86 :
87 0 : r = sd_bus_message_close_container(reply);
88 0 : if (r < 0)
89 0 : return r;
90 :
91 0 : return sd_bus_message_close_container(reply);
92 : }
93 :
94 : const sd_bus_vtable bus_service_vtable[] = {
95 : SD_BUS_VTABLE_START(0),
96 : SD_BUS_PROPERTY("Type", "s", property_get_type, offsetof(Service, type), SD_BUS_VTABLE_PROPERTY_CONST),
97 : SD_BUS_PROPERTY("Restart", "s", property_get_restart, offsetof(Service, restart), SD_BUS_VTABLE_PROPERTY_CONST),
98 : SD_BUS_PROPERTY("PIDFile", "s", NULL, offsetof(Service, pid_file), SD_BUS_VTABLE_PROPERTY_CONST),
99 : SD_BUS_PROPERTY("NotifyAccess", "s", property_get_notify_access, offsetof(Service, notify_access), SD_BUS_VTABLE_PROPERTY_CONST),
100 : SD_BUS_PROPERTY("RestartUSec", "t", bus_property_get_usec, offsetof(Service, restart_usec), SD_BUS_VTABLE_PROPERTY_CONST),
101 : SD_BUS_PROPERTY("TimeoutStartUSec", "t", bus_property_get_usec, offsetof(Service, timeout_start_usec), SD_BUS_VTABLE_PROPERTY_CONST),
102 : SD_BUS_PROPERTY("TimeoutStopUSec", "t", bus_property_get_usec, offsetof(Service, timeout_stop_usec), SD_BUS_VTABLE_PROPERTY_CONST),
103 : SD_BUS_PROPERTY("TimeoutAbortUSec", "t", property_get_timeout_abort_usec, 0, 0),
104 : SD_BUS_PROPERTY("TimeoutCleanUSec", "t", bus_property_get_usec, offsetof(Service, timeout_clean_usec), SD_BUS_VTABLE_PROPERTY_CONST),
105 : SD_BUS_PROPERTY("RuntimeMaxUSec", "t", bus_property_get_usec, offsetof(Service, runtime_max_usec), SD_BUS_VTABLE_PROPERTY_CONST),
106 : SD_BUS_PROPERTY("WatchdogUSec", "t", bus_property_get_usec, offsetof(Service, watchdog_usec), SD_BUS_VTABLE_PROPERTY_CONST),
107 : BUS_PROPERTY_DUAL_TIMESTAMP("WatchdogTimestamp", offsetof(Service, watchdog_timestamp), 0),
108 : SD_BUS_PROPERTY("PermissionsStartOnly", "b", bus_property_get_bool, offsetof(Service, permissions_start_only), SD_BUS_VTABLE_PROPERTY_CONST|SD_BUS_VTABLE_HIDDEN), /* 😷 deprecated */
109 : SD_BUS_PROPERTY("RootDirectoryStartOnly", "b", bus_property_get_bool, offsetof(Service, root_directory_start_only), SD_BUS_VTABLE_PROPERTY_CONST),
110 : SD_BUS_PROPERTY("RemainAfterExit", "b", bus_property_get_bool, offsetof(Service, remain_after_exit), SD_BUS_VTABLE_PROPERTY_CONST),
111 : SD_BUS_PROPERTY("GuessMainPID", "b", bus_property_get_bool, offsetof(Service, guess_main_pid), SD_BUS_VTABLE_PROPERTY_CONST),
112 : SD_BUS_PROPERTY("RestartPreventExitStatus", "(aiai)", property_get_exit_status_set, offsetof(Service, restart_prevent_status), SD_BUS_VTABLE_PROPERTY_CONST),
113 : SD_BUS_PROPERTY("RestartForceExitStatus", "(aiai)", property_get_exit_status_set, offsetof(Service, restart_force_status), SD_BUS_VTABLE_PROPERTY_CONST),
114 : SD_BUS_PROPERTY("SuccessExitStatus", "(aiai)", property_get_exit_status_set, offsetof(Service, success_status), SD_BUS_VTABLE_PROPERTY_CONST),
115 : SD_BUS_PROPERTY("MainPID", "u", bus_property_get_pid, offsetof(Service, main_pid), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
116 : SD_BUS_PROPERTY("ControlPID", "u", bus_property_get_pid, offsetof(Service, control_pid), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
117 : SD_BUS_PROPERTY("BusName", "s", NULL, offsetof(Service, bus_name), SD_BUS_VTABLE_PROPERTY_CONST),
118 : SD_BUS_PROPERTY("FileDescriptorStoreMax", "u", bus_property_get_unsigned, offsetof(Service, n_fd_store_max), SD_BUS_VTABLE_PROPERTY_CONST),
119 : SD_BUS_PROPERTY("NFileDescriptorStore", "u", bus_property_get_unsigned, offsetof(Service, n_fd_store), 0),
120 : SD_BUS_PROPERTY("StatusText", "s", NULL, offsetof(Service, status_text), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
121 : SD_BUS_PROPERTY("StatusErrno", "i", bus_property_get_int, offsetof(Service, status_errno), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
122 : SD_BUS_PROPERTY("Result", "s", property_get_result, offsetof(Service, result), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
123 : SD_BUS_PROPERTY("ReloadResult", "s", property_get_result, offsetof(Service, reload_result), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
124 : SD_BUS_PROPERTY("CleanResult", "s", property_get_result, offsetof(Service, clean_result), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
125 : SD_BUS_PROPERTY("USBFunctionDescriptors", "s", NULL, offsetof(Service, usb_function_descriptors), SD_BUS_VTABLE_PROPERTY_CONST),
126 : SD_BUS_PROPERTY("USBFunctionStrings", "s", NULL, offsetof(Service, usb_function_strings), SD_BUS_VTABLE_PROPERTY_CONST),
127 : SD_BUS_PROPERTY("UID", "u", bus_property_get_uid, offsetof(Unit, ref_uid), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
128 : SD_BUS_PROPERTY("GID", "u", bus_property_get_gid, offsetof(Unit, ref_gid), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
129 : SD_BUS_PROPERTY("NRestarts", "u", bus_property_get_unsigned, offsetof(Service, n_restarts), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
130 : SD_BUS_PROPERTY("OOMPolicy", "s", bus_property_get_oom_policy, offsetof(Service, oom_policy), SD_BUS_VTABLE_PROPERTY_CONST),
131 :
132 : BUS_EXEC_STATUS_VTABLE("ExecMain", offsetof(Service, main_exec_status), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
133 : BUS_EXEC_COMMAND_LIST_VTABLE("ExecCondition", offsetof(Service, exec_command[SERVICE_EXEC_CONDITION]), SD_BUS_VTABLE_PROPERTY_EMITS_INVALIDATION),
134 : BUS_EXEC_COMMAND_LIST_VTABLE("ExecStartPre", offsetof(Service, exec_command[SERVICE_EXEC_START_PRE]), SD_BUS_VTABLE_PROPERTY_EMITS_INVALIDATION),
135 : BUS_EXEC_EX_COMMAND_LIST_VTABLE("ExecStartPreEx", offsetof(Service, exec_command[SERVICE_EXEC_START_PRE]), SD_BUS_VTABLE_PROPERTY_EMITS_INVALIDATION),
136 : BUS_EXEC_COMMAND_LIST_VTABLE("ExecStart", offsetof(Service, exec_command[SERVICE_EXEC_START]), SD_BUS_VTABLE_PROPERTY_EMITS_INVALIDATION),
137 : BUS_EXEC_EX_COMMAND_LIST_VTABLE("ExecStartEx", offsetof(Service, exec_command[SERVICE_EXEC_START]), SD_BUS_VTABLE_PROPERTY_EMITS_INVALIDATION),
138 : BUS_EXEC_COMMAND_LIST_VTABLE("ExecStartPost", offsetof(Service, exec_command[SERVICE_EXEC_START_POST]), SD_BUS_VTABLE_PROPERTY_EMITS_INVALIDATION),
139 : BUS_EXEC_EX_COMMAND_LIST_VTABLE("ExecStartPostEx", offsetof(Service, exec_command[SERVICE_EXEC_START_POST]), SD_BUS_VTABLE_PROPERTY_EMITS_INVALIDATION),
140 : BUS_EXEC_COMMAND_LIST_VTABLE("ExecReload", offsetof(Service, exec_command[SERVICE_EXEC_RELOAD]), SD_BUS_VTABLE_PROPERTY_EMITS_INVALIDATION),
141 : BUS_EXEC_COMMAND_LIST_VTABLE("ExecStop", offsetof(Service, exec_command[SERVICE_EXEC_STOP]), SD_BUS_VTABLE_PROPERTY_EMITS_INVALIDATION),
142 : BUS_EXEC_COMMAND_LIST_VTABLE("ExecStopPost", offsetof(Service, exec_command[SERVICE_EXEC_STOP_POST]), SD_BUS_VTABLE_PROPERTY_EMITS_INVALIDATION),
143 :
144 : /* The following four are obsolete, and thus marked hidden here. They moved into the Unit interface */
145 : SD_BUS_PROPERTY("StartLimitInterval", "t", bus_property_get_usec, offsetof(Unit, start_limit.interval), SD_BUS_VTABLE_PROPERTY_CONST|SD_BUS_VTABLE_HIDDEN),
146 : SD_BUS_PROPERTY("StartLimitBurst", "u", bus_property_get_unsigned, offsetof(Unit, start_limit.burst), SD_BUS_VTABLE_PROPERTY_CONST|SD_BUS_VTABLE_HIDDEN),
147 : SD_BUS_PROPERTY("StartLimitAction", "s", property_get_emergency_action, offsetof(Unit, start_limit_action), SD_BUS_VTABLE_PROPERTY_CONST|SD_BUS_VTABLE_HIDDEN),
148 : SD_BUS_PROPERTY("FailureAction", "s", property_get_emergency_action, offsetof(Unit, failure_action), SD_BUS_VTABLE_PROPERTY_CONST|SD_BUS_VTABLE_HIDDEN),
149 : SD_BUS_PROPERTY("RebootArgument", "s", NULL, offsetof(Unit, reboot_arg), SD_BUS_VTABLE_PROPERTY_CONST|SD_BUS_VTABLE_HIDDEN),
150 : SD_BUS_VTABLE_END
151 : };
152 :
153 0 : static int bus_set_transient_exit_status(
154 : Unit *u,
155 : const char *name,
156 : ExitStatusSet *status_set,
157 : sd_bus_message *message,
158 : UnitWriteFlags flags,
159 : sd_bus_error *error) {
160 :
161 : const int32_t *status, *signal;
162 : size_t n_status, n_signal, i;
163 : int r;
164 :
165 0 : r = sd_bus_message_enter_container(message, 'r', "aiai");
166 0 : if (r < 0)
167 0 : return r;
168 :
169 0 : r = sd_bus_message_read_array(message, 'i', (const void **) &status, &n_status);
170 0 : if (r < 0)
171 0 : return r;
172 :
173 0 : r = sd_bus_message_read_array(message, 'i', (const void **) &signal, &n_signal);
174 0 : if (r < 0)
175 0 : return r;
176 :
177 0 : r = sd_bus_message_exit_container(message);
178 0 : if (r < 0)
179 0 : return r;
180 :
181 0 : n_status /= sizeof(int32_t);
182 0 : n_signal /= sizeof(int32_t);
183 :
184 0 : if (n_status == 0 && n_signal == 0 && !UNIT_WRITE_FLAGS_NOOP(flags)) {
185 0 : exit_status_set_free(status_set);
186 0 : unit_write_settingf(u, flags, name, "%s=", name);
187 0 : return 1;
188 : }
189 :
190 0 : for (i = 0; i < n_status; i++) {
191 0 : if (status[i] < 0 || status[i] > 255)
192 0 : return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid status code in %s: %"PRIi32, name, status[i]);
193 :
194 0 : if (!UNIT_WRITE_FLAGS_NOOP(flags)) {
195 0 : r = bitmap_set(&status_set->status, status[i]);
196 0 : if (r < 0)
197 0 : return r;
198 :
199 0 : unit_write_settingf(u, flags, name, "%s=%"PRIi32, name, status[i]);
200 : }
201 : }
202 :
203 0 : for (i = 0; i < n_signal; i++) {
204 : const char *str;
205 :
206 0 : str = signal_to_string((int) signal[i]);
207 0 : if (!str)
208 0 : return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid signal in %s: %"PRIi32, name, signal[i]);
209 :
210 0 : if (!UNIT_WRITE_FLAGS_NOOP(flags)) {
211 0 : r = bitmap_set(&status_set->signal, signal[i]);
212 0 : if (r < 0)
213 0 : return r;
214 :
215 0 : unit_write_settingf(u, flags, name, "%s=%s", name, str);
216 : }
217 : }
218 :
219 0 : return 1;
220 : }
221 :
222 0 : static int bus_set_transient_std_fd(
223 : Unit *u,
224 : const char *name,
225 : int *p,
226 : bool *b,
227 : sd_bus_message *message,
228 : UnitWriteFlags flags,
229 : sd_bus_error *error) {
230 :
231 : int fd, r;
232 :
233 0 : assert(p);
234 0 : assert(b);
235 :
236 0 : r = sd_bus_message_read(message, "h", &fd);
237 0 : if (r < 0)
238 0 : return r;
239 :
240 0 : if (!UNIT_WRITE_FLAGS_NOOP(flags)) {
241 : int copy;
242 :
243 0 : copy = fcntl(fd, F_DUPFD_CLOEXEC, 3);
244 0 : if (copy < 0)
245 0 : return -errno;
246 :
247 0 : asynchronous_close(*p);
248 0 : *p = copy;
249 0 : *b = true;
250 : }
251 :
252 0 : return 1;
253 : }
254 0 : static BUS_DEFINE_SET_TRANSIENT_PARSE(notify_access, NotifyAccess, notify_access_from_string);
255 0 : static BUS_DEFINE_SET_TRANSIENT_PARSE(service_type, ServiceType, service_type_from_string);
256 0 : static BUS_DEFINE_SET_TRANSIENT_PARSE(service_restart, ServiceRestart, service_restart_from_string);
257 0 : static BUS_DEFINE_SET_TRANSIENT_PARSE(oom_policy, OOMPolicy, oom_policy_from_string);
258 0 : static BUS_DEFINE_SET_TRANSIENT_STRING_WITH_CHECK(bus_name, service_name_is_valid);
259 :
260 0 : static int bus_service_set_transient_property(
261 : Service *s,
262 : const char *name,
263 : sd_bus_message *message,
264 : UnitWriteFlags flags,
265 : sd_bus_error *error) {
266 :
267 0 : Unit *u = UNIT(s);
268 : ServiceExecCommand ci;
269 : int r;
270 :
271 0 : assert(s);
272 0 : assert(name);
273 0 : assert(message);
274 :
275 0 : flags |= UNIT_PRIVATE;
276 :
277 0 : if (streq(name, "PermissionsStartOnly"))
278 0 : return bus_set_transient_bool(u, name, &s->permissions_start_only, message, flags, error);
279 :
280 0 : if (streq(name, "RootDirectoryStartOnly"))
281 0 : return bus_set_transient_bool(u, name, &s->root_directory_start_only, message, flags, error);
282 :
283 0 : if (streq(name, "RemainAfterExit"))
284 0 : return bus_set_transient_bool(u, name, &s->remain_after_exit, message, flags, error);
285 :
286 0 : if (streq(name, "GuessMainPID"))
287 0 : return bus_set_transient_bool(u, name, &s->guess_main_pid, message, flags, error);
288 :
289 0 : if (streq(name, "Type"))
290 0 : return bus_set_transient_service_type(u, name, &s->type, message, flags, error);
291 :
292 0 : if (streq(name, "OOMPolicy"))
293 0 : return bus_set_transient_oom_policy(u, name, &s->oom_policy, message, flags, error);
294 :
295 0 : if (streq(name, "RestartUSec"))
296 0 : return bus_set_transient_usec(u, name, &s->restart_usec, message, flags, error);
297 :
298 0 : if (streq(name, "TimeoutStartUSec")) {
299 0 : r = bus_set_transient_usec(u, name, &s->timeout_start_usec, message, flags, error);
300 0 : if (r >= 0 && !UNIT_WRITE_FLAGS_NOOP(flags))
301 0 : s->start_timeout_defined = true;
302 :
303 0 : return r;
304 : }
305 :
306 0 : if (streq(name, "TimeoutStopUSec"))
307 0 : return bus_set_transient_usec(u, name, &s->timeout_stop_usec, message, flags, error);
308 :
309 0 : if (streq(name, "RuntimeMaxUSec"))
310 0 : return bus_set_transient_usec(u, name, &s->runtime_max_usec, message, flags, error);
311 :
312 0 : if (streq(name, "WatchdogUSec"))
313 0 : return bus_set_transient_usec(u, name, &s->watchdog_usec, message, flags, error);
314 :
315 0 : if (streq(name, "FileDescriptorStoreMax"))
316 0 : return bus_set_transient_unsigned(u, name, &s->n_fd_store_max, message, flags, error);
317 :
318 0 : if (streq(name, "NotifyAccess"))
319 0 : return bus_set_transient_notify_access(u, name, &s->notify_access, message, flags, error);
320 :
321 0 : if (streq(name, "PIDFile")) {
322 0 : _cleanup_free_ char *n = NULL;
323 : const char *v, *e;
324 :
325 0 : r = sd_bus_message_read(message, "s", &v);
326 0 : if (r < 0)
327 0 : return r;
328 :
329 0 : if (!isempty(v)) {
330 0 : n = path_make_absolute(v, u->manager->prefix[EXEC_DIRECTORY_RUNTIME]);
331 0 : if (!n)
332 0 : return -ENOMEM;
333 :
334 0 : path_simplify(n, true);
335 :
336 0 : if (!path_is_normalized(n))
337 0 : return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "PIDFile= path '%s' is not valid", n);
338 :
339 0 : e = path_startswith(n, "/var/run/");
340 0 : if (e) {
341 : char *z;
342 :
343 0 : z = path_join("/run", e);
344 0 : if (!z)
345 0 : return log_oom();
346 :
347 0 : if (!UNIT_WRITE_FLAGS_NOOP(flags))
348 0 : log_unit_notice(u, "Transient unit's PIDFile= property references path below legacy directory /var/run, updating %s → %s; please update client accordingly.", n, z);
349 :
350 0 : free_and_replace(n, z);
351 : }
352 : }
353 :
354 0 : if (!UNIT_WRITE_FLAGS_NOOP(flags)) {
355 0 : free_and_replace(s->pid_file, n);
356 0 : unit_write_settingf(u, flags, name, "%s=%s", name, strempty(s->pid_file));
357 : }
358 :
359 0 : return 1;
360 : }
361 :
362 0 : if (streq(name, "USBFunctionDescriptors"))
363 0 : return bus_set_transient_path(u, name, &s->usb_function_descriptors, message, flags, error);
364 :
365 0 : if (streq(name, "USBFunctionStrings"))
366 0 : return bus_set_transient_path(u, name, &s->usb_function_strings, message, flags, error);
367 :
368 0 : if (streq(name, "BusName"))
369 0 : return bus_set_transient_bus_name(u, name, &s->bus_name, message, flags, error);
370 :
371 0 : if (streq(name, "Restart"))
372 0 : return bus_set_transient_service_restart(u, name, &s->restart, message, flags, error);
373 :
374 0 : if (streq(name, "RestartPreventExitStatus"))
375 0 : return bus_set_transient_exit_status(u, name, &s->restart_prevent_status, message, flags, error);
376 :
377 0 : if (streq(name, "RestartForceExitStatus"))
378 0 : return bus_set_transient_exit_status(u, name, &s->restart_force_status, message, flags, error);
379 :
380 0 : if (streq(name, "SuccessExitStatus"))
381 0 : return bus_set_transient_exit_status(u, name, &s->success_status, message, flags, error);
382 :
383 0 : ci = service_exec_command_from_string(name);
384 0 : ci = (ci >= 0) ? ci : service_exec_ex_command_from_string(name);
385 0 : if (ci >= 0)
386 0 : return bus_set_transient_exec_command(u, name, &s->exec_command[ci], message, flags, error);
387 :
388 0 : if (streq(name, "StandardInputFileDescriptor"))
389 0 : return bus_set_transient_std_fd(u, name, &s->stdin_fd, &s->exec_context.stdio_as_fds, message, flags, error);
390 :
391 0 : if (streq(name, "StandardOutputFileDescriptor"))
392 0 : return bus_set_transient_std_fd(u, name, &s->stdout_fd, &s->exec_context.stdio_as_fds, message, flags, error);
393 :
394 0 : if (streq(name, "StandardErrorFileDescriptor"))
395 0 : return bus_set_transient_std_fd(u, name, &s->stderr_fd, &s->exec_context.stdio_as_fds, message, flags, error);
396 :
397 0 : return 0;
398 : }
399 :
400 0 : int bus_service_set_property(
401 : Unit *u,
402 : const char *name,
403 : sd_bus_message *message,
404 : UnitWriteFlags flags,
405 : sd_bus_error *error) {
406 :
407 0 : Service *s = SERVICE(u);
408 : int r;
409 :
410 0 : assert(s);
411 0 : assert(name);
412 0 : assert(message);
413 :
414 0 : r = bus_cgroup_set_property(u, &s->cgroup_context, name, message, flags, error);
415 0 : if (r != 0)
416 0 : return r;
417 :
418 0 : if (u->transient && u->load_state == UNIT_STUB) {
419 : /* This is a transient unit, let's load a little more */
420 :
421 0 : r = bus_service_set_transient_property(s, name, message, flags, error);
422 0 : if (r != 0)
423 0 : return r;
424 :
425 0 : r = bus_exec_context_set_transient_property(u, &s->exec_context, name, message, flags, error);
426 0 : if (r != 0)
427 0 : return r;
428 :
429 0 : r = bus_kill_context_set_transient_property(u, &s->kill_context, name, message, flags, error);
430 0 : if (r != 0)
431 0 : return r;
432 : }
433 :
434 0 : return 0;
435 : }
436 :
437 0 : int bus_service_commit_properties(Unit *u) {
438 0 : assert(u);
439 :
440 0 : unit_invalidate_cgroup_members_masks(u);
441 0 : unit_realize_cgroup(u);
442 :
443 0 : return 0;
444 : }
|