1 /* SPDX-License-Identifier: LGPL-2.1+ */
11 #include "alloc-util.h"
14 #include "capability-util.h"
15 #include "cpu-set-util.h"
16 #include "dbus-execute.h"
17 #include "dbus-util.h"
19 #include "errno-list.h"
24 #include "hexdecoct.h"
27 #include "journal-util.h"
28 #include "mountpoint-util.h"
29 #include "namespace.h"
30 #include "parse-util.h"
31 #include "path-util.h"
32 #include "process-util.h"
33 #include "rlimit-util.h"
35 #include "seccomp-util.h"
37 #include "securebits-util.h"
38 #include "specifier.h"
40 #include "syslog-util.h"
41 #include "unit-printf.h"
42 #include "user-util.h"
45 BUS_DEFINE_PROPERTY_GET_ENUM(bus_property_get_exec_output
, exec_output
, ExecOutput
);
46 static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_exec_input
, exec_input
, ExecInput
);
47 static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_exec_utmp_mode
, exec_utmp_mode
, ExecUtmpMode
);
48 static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_exec_preserve_mode
, exec_preserve_mode
, ExecPreserveMode
);
49 static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_exec_keyring_mode
, exec_keyring_mode
, ExecKeyringMode
);
50 static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_protect_home
, protect_home
, ProtectHome
);
51 static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_protect_system
, protect_system
, ProtectSystem
);
52 static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_personality
, personality
, unsigned long);
53 static BUS_DEFINE_PROPERTY_GET(property_get_ioprio
, "i", ExecContext
, exec_context_get_effective_ioprio
);
54 static BUS_DEFINE_PROPERTY_GET2(property_get_ioprio_class
, "i", ExecContext
, exec_context_get_effective_ioprio
, IOPRIO_PRIO_CLASS
);
55 static BUS_DEFINE_PROPERTY_GET2(property_get_ioprio_priority
, "i", ExecContext
, exec_context_get_effective_ioprio
, IOPRIO_PRIO_DATA
);
56 static BUS_DEFINE_PROPERTY_GET_GLOBAL(property_get_empty_string
, "s", NULL
);
57 static BUS_DEFINE_PROPERTY_GET_REF(property_get_syslog_level
, "i", int, LOG_PRI
);
58 static BUS_DEFINE_PROPERTY_GET_REF(property_get_syslog_facility
, "i", int, LOG_FAC
);
60 static int property_get_environment_files(
63 const char *interface
,
65 sd_bus_message
*reply
,
67 sd_bus_error
*error
) {
69 ExecContext
*c
= userdata
;
77 r
= sd_bus_message_open_container(reply
, 'a', "(sb)");
81 STRV_FOREACH(j
, c
->environment_files
) {
84 r
= sd_bus_message_append(reply
, "(sb)", fn
[0] == '-' ? fn
+ 1 : fn
, fn
[0] == '-');
89 return sd_bus_message_close_container(reply
);
92 static int property_get_oom_score_adjust(
95 const char *interface
,
97 sd_bus_message
*reply
,
99 sd_bus_error
*error
) {
101 ExecContext
*c
= userdata
;
108 if (c
->oom_score_adjust_set
)
109 n
= c
->oom_score_adjust
;
111 _cleanup_free_
char *t
= NULL
;
114 if (read_one_line_file("/proc/self/oom_score_adj", &t
) >= 0)
118 return sd_bus_message_append(reply
, "i", n
);
121 static int property_get_nice(
124 const char *interface
,
125 const char *property
,
126 sd_bus_message
*reply
,
128 sd_bus_error
*error
) {
130 ExecContext
*c
= userdata
;
141 n
= getpriority(PRIO_PROCESS
, 0);
146 return sd_bus_message_append(reply
, "i", n
);
149 static int property_get_cpu_sched_policy(
152 const char *interface
,
153 const char *property
,
154 sd_bus_message
*reply
,
156 sd_bus_error
*error
) {
158 ExecContext
*c
= userdata
;
165 if (c
->cpu_sched_set
)
166 n
= c
->cpu_sched_policy
;
168 n
= sched_getscheduler(0);
173 return sd_bus_message_append(reply
, "i", n
);
176 static int property_get_cpu_sched_priority(
179 const char *interface
,
180 const char *property
,
181 sd_bus_message
*reply
,
183 sd_bus_error
*error
) {
185 ExecContext
*c
= userdata
;
192 if (c
->cpu_sched_set
)
193 n
= c
->cpu_sched_priority
;
195 struct sched_param p
= {};
197 if (sched_getparam(0, &p
) >= 0)
198 n
= p
.sched_priority
;
203 return sd_bus_message_append(reply
, "i", n
);
206 static int property_get_cpu_affinity(
209 const char *interface
,
210 const char *property
,
211 sd_bus_message
*reply
,
213 sd_bus_error
*error
) {
215 ExecContext
*c
= userdata
;
216 _cleanup_free_
uint8_t *array
= NULL
;
223 (void) cpu_set_to_dbus(&c
->cpu_set
, &array
, &allocated
);
224 return sd_bus_message_append_array(reply
, 'y', array
, allocated
);
227 static int property_get_numa_mask(
230 const char *interface
,
231 const char *property
,
232 sd_bus_message
*reply
,
234 sd_bus_error
*error
) {
236 ExecContext
*c
= userdata
;
237 _cleanup_free_
uint8_t *array
= NULL
;
244 (void) cpu_set_to_dbus(&c
->numa_policy
.nodes
, &array
, &allocated
);
246 return sd_bus_message_append_array(reply
, 'y', array
, allocated
);
249 static int property_get_numa_policy(
252 const char *interface
,
253 const char *property
,
254 sd_bus_message
*reply
,
256 sd_bus_error
*error
) {
257 ExecContext
*c
= userdata
;
264 policy
= numa_policy_get_type(&c
->numa_policy
);
266 return sd_bus_message_append_basic(reply
, 'i', &policy
);
269 static int property_get_timer_slack_nsec(
272 const char *interface
,
273 const char *property
,
274 sd_bus_message
*reply
,
276 sd_bus_error
*error
) {
278 ExecContext
*c
= userdata
;
285 if (c
->timer_slack_nsec
!= NSEC_INFINITY
)
286 u
= (uint64_t) c
->timer_slack_nsec
;
288 u
= (uint64_t) prctl(PR_GET_TIMERSLACK
);
290 return sd_bus_message_append(reply
, "t", u
);
293 static int property_get_syscall_filter(
296 const char *interface
,
297 const char *property
,
298 sd_bus_message
*reply
,
300 sd_bus_error
*error
) {
302 ExecContext
*c
= userdata
;
303 _cleanup_strv_free_
char **l
= NULL
;
315 r
= sd_bus_message_open_container(reply
, 'r', "bas");
319 r
= sd_bus_message_append(reply
, "b", c
->syscall_whitelist
);
324 HASHMAP_FOREACH_KEY(val
, id
, c
->syscall_filter
, i
) {
325 _cleanup_free_
char *name
= NULL
;
326 const char *e
= NULL
;
328 int num
= PTR_TO_INT(val
);
330 name
= seccomp_syscall_resolve_num_arch(SCMP_ARCH_NATIVE
, PTR_TO_INT(id
) - 1);
335 e
= errno_to_name(num
);
337 s
= strjoin(name
, ":", e
);
341 r
= asprintf(&s
, "%s:%d", name
, num
);
348 r
= strv_consume(&l
, s
);
356 r
= sd_bus_message_append_strv(reply
, l
);
360 return sd_bus_message_close_container(reply
);
363 static int property_get_syscall_archs(
366 const char *interface
,
367 const char *property
,
368 sd_bus_message
*reply
,
370 sd_bus_error
*error
) {
372 ExecContext
*c
= userdata
;
373 _cleanup_strv_free_
char **l
= NULL
;
386 SET_FOREACH(id
, c
->syscall_archs
, i
) {
389 name
= seccomp_arch_to_string(PTR_TO_UINT32(id
) - 1);
393 r
= strv_extend(&l
, name
);
401 r
= sd_bus_message_append_strv(reply
, l
);
408 static int property_get_selinux_context(
411 const char *interface
,
412 const char *property
,
413 sd_bus_message
*reply
,
415 sd_bus_error
*error
) {
417 ExecContext
*c
= userdata
;
423 return sd_bus_message_append(reply
, "(bs)", c
->selinux_context_ignore
, c
->selinux_context
);
426 static int property_get_apparmor_profile(
429 const char *interface
,
430 const char *property
,
431 sd_bus_message
*reply
,
433 sd_bus_error
*error
) {
435 ExecContext
*c
= userdata
;
441 return sd_bus_message_append(reply
, "(bs)", c
->apparmor_profile_ignore
, c
->apparmor_profile
);
444 static int property_get_smack_process_label(
447 const char *interface
,
448 const char *property
,
449 sd_bus_message
*reply
,
451 sd_bus_error
*error
) {
453 ExecContext
*c
= userdata
;
459 return sd_bus_message_append(reply
, "(bs)", c
->smack_process_label_ignore
, c
->smack_process_label
);
462 static int property_get_address_families(
465 const char *interface
,
466 const char *property
,
467 sd_bus_message
*reply
,
469 sd_bus_error
*error
) {
471 ExecContext
*c
= userdata
;
472 _cleanup_strv_free_
char **l
= NULL
;
481 r
= sd_bus_message_open_container(reply
, 'r', "bas");
485 r
= sd_bus_message_append(reply
, "b", c
->address_families_whitelist
);
489 SET_FOREACH(af
, c
->address_families
, i
) {
492 name
= af_to_name(PTR_TO_INT(af
));
496 r
= strv_extend(&l
, name
);
503 r
= sd_bus_message_append_strv(reply
, l
);
507 return sd_bus_message_close_container(reply
);
510 static int property_get_working_directory(
513 const char *interface
,
514 const char *property
,
515 sd_bus_message
*reply
,
517 sd_bus_error
*error
) {
519 ExecContext
*c
= userdata
;
526 if (c
->working_directory_home
)
529 wd
= c
->working_directory
;
531 if (c
->working_directory_missing_ok
)
532 wd
= strjoina("!", wd
);
534 return sd_bus_message_append(reply
, "s", wd
);
537 static int property_get_stdio_fdname(
540 const char *interface
,
541 const char *property
,
542 sd_bus_message
*reply
,
544 sd_bus_error
*error
) {
546 ExecContext
*c
= userdata
;
554 if (streq(property
, "StandardInputFileDescriptorName"))
555 fileno
= STDIN_FILENO
;
556 else if (streq(property
, "StandardOutputFileDescriptorName"))
557 fileno
= STDOUT_FILENO
;
559 assert(streq(property
, "StandardErrorFileDescriptorName"));
560 fileno
= STDERR_FILENO
;
563 return sd_bus_message_append(reply
, "s", exec_context_fdname(c
, fileno
));
566 static int property_get_input_data(
569 const char *interface
,
570 const char *property
,
571 sd_bus_message
*reply
,
573 sd_bus_error
*error
) {
575 ExecContext
*c
= userdata
;
582 return sd_bus_message_append_array(reply
, 'y', c
->stdin_data
, c
->stdin_data_size
);
585 static int property_get_bind_paths(
588 const char *interface
,
589 const char *property
,
590 sd_bus_message
*reply
,
592 sd_bus_error
*error
) {
594 ExecContext
*c
= userdata
;
604 ro
= strstr(property
, "ReadOnly");
606 r
= sd_bus_message_open_container(reply
, 'a', "(ssbt)");
610 for (i
= 0; i
< c
->n_bind_mounts
; i
++) {
612 if (ro
!= c
->bind_mounts
[i
].read_only
)
615 r
= sd_bus_message_append(
617 c
->bind_mounts
[i
].source
,
618 c
->bind_mounts
[i
].destination
,
619 c
->bind_mounts
[i
].ignore_enoent
,
620 c
->bind_mounts
[i
].recursive
? (uint64_t) MS_REC
: (uint64_t) 0);
625 return sd_bus_message_close_container(reply
);
628 static int property_get_temporary_filesystems(
631 const char *interface
,
632 const char *property
,
633 sd_bus_message
*reply
,
635 sd_bus_error
*error
) {
637 ExecContext
*c
= userdata
;
646 r
= sd_bus_message_open_container(reply
, 'a', "(ss)");
650 for (i
= 0; i
< c
->n_temporary_filesystems
; i
++) {
651 TemporaryFileSystem
*t
= c
->temporary_filesystems
+ i
;
653 r
= sd_bus_message_append(
661 return sd_bus_message_close_container(reply
);
664 static int property_get_log_extra_fields(
667 const char *interface
,
668 const char *property
,
669 sd_bus_message
*reply
,
671 sd_bus_error
*error
) {
673 ExecContext
*c
= userdata
;
682 r
= sd_bus_message_open_container(reply
, 'a', "ay");
686 for (i
= 0; i
< c
->n_log_extra_fields
; i
++) {
687 r
= sd_bus_message_append_array(reply
, 'y', c
->log_extra_fields
[i
].iov_base
, c
->log_extra_fields
[i
].iov_len
);
692 return sd_bus_message_close_container(reply
);
695 const sd_bus_vtable bus_exec_vtable
[] = {
696 SD_BUS_VTABLE_START(0),
697 SD_BUS_PROPERTY("Environment", "as", NULL
, offsetof(ExecContext
, environment
), SD_BUS_VTABLE_PROPERTY_CONST
),
698 SD_BUS_PROPERTY("EnvironmentFiles", "a(sb)", property_get_environment_files
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
699 SD_BUS_PROPERTY("PassEnvironment", "as", NULL
, offsetof(ExecContext
, pass_environment
), SD_BUS_VTABLE_PROPERTY_CONST
),
700 SD_BUS_PROPERTY("UnsetEnvironment", "as", NULL
, offsetof(ExecContext
, unset_environment
), SD_BUS_VTABLE_PROPERTY_CONST
),
701 SD_BUS_PROPERTY("UMask", "u", bus_property_get_mode
, offsetof(ExecContext
, umask
), SD_BUS_VTABLE_PROPERTY_CONST
),
702 SD_BUS_PROPERTY("LimitCPU", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_CPU
]), SD_BUS_VTABLE_PROPERTY_CONST
),
703 SD_BUS_PROPERTY("LimitCPUSoft", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_CPU
]), SD_BUS_VTABLE_PROPERTY_CONST
),
704 SD_BUS_PROPERTY("LimitFSIZE", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_FSIZE
]), SD_BUS_VTABLE_PROPERTY_CONST
),
705 SD_BUS_PROPERTY("LimitFSIZESoft", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_FSIZE
]), SD_BUS_VTABLE_PROPERTY_CONST
),
706 SD_BUS_PROPERTY("LimitDATA", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_DATA
]), SD_BUS_VTABLE_PROPERTY_CONST
),
707 SD_BUS_PROPERTY("LimitDATASoft", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_DATA
]), SD_BUS_VTABLE_PROPERTY_CONST
),
708 SD_BUS_PROPERTY("LimitSTACK", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_STACK
]), SD_BUS_VTABLE_PROPERTY_CONST
),
709 SD_BUS_PROPERTY("LimitSTACKSoft", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_STACK
]), SD_BUS_VTABLE_PROPERTY_CONST
),
710 SD_BUS_PROPERTY("LimitCORE", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_CORE
]), SD_BUS_VTABLE_PROPERTY_CONST
),
711 SD_BUS_PROPERTY("LimitCORESoft", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_CORE
]), SD_BUS_VTABLE_PROPERTY_CONST
),
712 SD_BUS_PROPERTY("LimitRSS", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_RSS
]), SD_BUS_VTABLE_PROPERTY_CONST
),
713 SD_BUS_PROPERTY("LimitRSSSoft", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_RSS
]), SD_BUS_VTABLE_PROPERTY_CONST
),
714 SD_BUS_PROPERTY("LimitNOFILE", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_NOFILE
]), SD_BUS_VTABLE_PROPERTY_CONST
),
715 SD_BUS_PROPERTY("LimitNOFILESoft", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_NOFILE
]), SD_BUS_VTABLE_PROPERTY_CONST
),
716 SD_BUS_PROPERTY("LimitAS", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_AS
]), SD_BUS_VTABLE_PROPERTY_CONST
),
717 SD_BUS_PROPERTY("LimitASSoft", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_AS
]), SD_BUS_VTABLE_PROPERTY_CONST
),
718 SD_BUS_PROPERTY("LimitNPROC", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_NPROC
]), SD_BUS_VTABLE_PROPERTY_CONST
),
719 SD_BUS_PROPERTY("LimitNPROCSoft", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_NPROC
]), SD_BUS_VTABLE_PROPERTY_CONST
),
720 SD_BUS_PROPERTY("LimitMEMLOCK", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_MEMLOCK
]), SD_BUS_VTABLE_PROPERTY_CONST
),
721 SD_BUS_PROPERTY("LimitMEMLOCKSoft", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_MEMLOCK
]), SD_BUS_VTABLE_PROPERTY_CONST
),
722 SD_BUS_PROPERTY("LimitLOCKS", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_LOCKS
]), SD_BUS_VTABLE_PROPERTY_CONST
),
723 SD_BUS_PROPERTY("LimitLOCKSSoft", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_LOCKS
]), SD_BUS_VTABLE_PROPERTY_CONST
),
724 SD_BUS_PROPERTY("LimitSIGPENDING", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_SIGPENDING
]), SD_BUS_VTABLE_PROPERTY_CONST
),
725 SD_BUS_PROPERTY("LimitSIGPENDINGSoft", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_SIGPENDING
]), SD_BUS_VTABLE_PROPERTY_CONST
),
726 SD_BUS_PROPERTY("LimitMSGQUEUE", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_MSGQUEUE
]), SD_BUS_VTABLE_PROPERTY_CONST
),
727 SD_BUS_PROPERTY("LimitMSGQUEUESoft", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_MSGQUEUE
]), SD_BUS_VTABLE_PROPERTY_CONST
),
728 SD_BUS_PROPERTY("LimitNICE", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_NICE
]), SD_BUS_VTABLE_PROPERTY_CONST
),
729 SD_BUS_PROPERTY("LimitNICESoft", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_NICE
]), SD_BUS_VTABLE_PROPERTY_CONST
),
730 SD_BUS_PROPERTY("LimitRTPRIO", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_RTPRIO
]), SD_BUS_VTABLE_PROPERTY_CONST
),
731 SD_BUS_PROPERTY("LimitRTPRIOSoft", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_RTPRIO
]), SD_BUS_VTABLE_PROPERTY_CONST
),
732 SD_BUS_PROPERTY("LimitRTTIME", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_RTTIME
]), SD_BUS_VTABLE_PROPERTY_CONST
),
733 SD_BUS_PROPERTY("LimitRTTIMESoft", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_RTTIME
]), SD_BUS_VTABLE_PROPERTY_CONST
),
734 SD_BUS_PROPERTY("WorkingDirectory", "s", property_get_working_directory
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
735 SD_BUS_PROPERTY("RootDirectory", "s", NULL
, offsetof(ExecContext
, root_directory
), SD_BUS_VTABLE_PROPERTY_CONST
),
736 SD_BUS_PROPERTY("RootImage", "s", NULL
, offsetof(ExecContext
, root_image
), SD_BUS_VTABLE_PROPERTY_CONST
),
737 SD_BUS_PROPERTY("OOMScoreAdjust", "i", property_get_oom_score_adjust
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
738 SD_BUS_PROPERTY("Nice", "i", property_get_nice
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
739 SD_BUS_PROPERTY("IOSchedulingClass", "i", property_get_ioprio_class
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
740 SD_BUS_PROPERTY("IOSchedulingPriority", "i", property_get_ioprio_priority
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
741 SD_BUS_PROPERTY("CPUSchedulingPolicy", "i", property_get_cpu_sched_policy
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
742 SD_BUS_PROPERTY("CPUSchedulingPriority", "i", property_get_cpu_sched_priority
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
743 SD_BUS_PROPERTY("CPUAffinity", "ay", property_get_cpu_affinity
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
744 SD_BUS_PROPERTY("NUMAPolicy", "i", property_get_numa_policy
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
745 SD_BUS_PROPERTY("NUMAMask", "ay", property_get_numa_mask
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
746 SD_BUS_PROPERTY("TimerSlackNSec", "t", property_get_timer_slack_nsec
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
747 SD_BUS_PROPERTY("CPUSchedulingResetOnFork", "b", bus_property_get_bool
, offsetof(ExecContext
, cpu_sched_reset_on_fork
), SD_BUS_VTABLE_PROPERTY_CONST
),
748 SD_BUS_PROPERTY("NonBlocking", "b", bus_property_get_bool
, offsetof(ExecContext
, non_blocking
), SD_BUS_VTABLE_PROPERTY_CONST
),
749 SD_BUS_PROPERTY("StandardInput", "s", property_get_exec_input
, offsetof(ExecContext
, std_input
), SD_BUS_VTABLE_PROPERTY_CONST
),
750 SD_BUS_PROPERTY("StandardInputFileDescriptorName", "s", property_get_stdio_fdname
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
751 SD_BUS_PROPERTY("StandardInputData", "ay", property_get_input_data
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
752 SD_BUS_PROPERTY("StandardOutput", "s", bus_property_get_exec_output
, offsetof(ExecContext
, std_output
), SD_BUS_VTABLE_PROPERTY_CONST
),
753 SD_BUS_PROPERTY("StandardOutputFileDescriptorName", "s", property_get_stdio_fdname
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
754 SD_BUS_PROPERTY("StandardError", "s", bus_property_get_exec_output
, offsetof(ExecContext
, std_error
), SD_BUS_VTABLE_PROPERTY_CONST
),
755 SD_BUS_PROPERTY("StandardErrorFileDescriptorName", "s", property_get_stdio_fdname
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
756 SD_BUS_PROPERTY("TTYPath", "s", NULL
, offsetof(ExecContext
, tty_path
), SD_BUS_VTABLE_PROPERTY_CONST
),
757 SD_BUS_PROPERTY("TTYReset", "b", bus_property_get_bool
, offsetof(ExecContext
, tty_reset
), SD_BUS_VTABLE_PROPERTY_CONST
),
758 SD_BUS_PROPERTY("TTYVHangup", "b", bus_property_get_bool
, offsetof(ExecContext
, tty_vhangup
), SD_BUS_VTABLE_PROPERTY_CONST
),
759 SD_BUS_PROPERTY("TTYVTDisallocate", "b", bus_property_get_bool
, offsetof(ExecContext
, tty_vt_disallocate
), SD_BUS_VTABLE_PROPERTY_CONST
),
760 SD_BUS_PROPERTY("SyslogPriority", "i", bus_property_get_int
, offsetof(ExecContext
, syslog_priority
), SD_BUS_VTABLE_PROPERTY_CONST
),
761 SD_BUS_PROPERTY("SyslogIdentifier", "s", NULL
, offsetof(ExecContext
, syslog_identifier
), SD_BUS_VTABLE_PROPERTY_CONST
),
762 SD_BUS_PROPERTY("SyslogLevelPrefix", "b", bus_property_get_bool
, offsetof(ExecContext
, syslog_level_prefix
), SD_BUS_VTABLE_PROPERTY_CONST
),
763 SD_BUS_PROPERTY("SyslogLevel", "i", property_get_syslog_level
, offsetof(ExecContext
, syslog_priority
), SD_BUS_VTABLE_PROPERTY_CONST
),
764 SD_BUS_PROPERTY("SyslogFacility", "i", property_get_syslog_facility
, offsetof(ExecContext
, syslog_priority
), SD_BUS_VTABLE_PROPERTY_CONST
),
765 SD_BUS_PROPERTY("LogLevelMax", "i", bus_property_get_int
, offsetof(ExecContext
, log_level_max
), SD_BUS_VTABLE_PROPERTY_CONST
),
766 SD_BUS_PROPERTY("LogRateLimitIntervalUSec", "t", bus_property_get_usec
, offsetof(ExecContext
, log_ratelimit_interval_usec
), SD_BUS_VTABLE_PROPERTY_CONST
),
767 SD_BUS_PROPERTY("LogRateLimitBurst", "u", bus_property_get_unsigned
, offsetof(ExecContext
, log_ratelimit_burst
), SD_BUS_VTABLE_PROPERTY_CONST
),
768 SD_BUS_PROPERTY("LogExtraFields", "aay", property_get_log_extra_fields
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
769 SD_BUS_PROPERTY("LogNamespace", "s", NULL
, offsetof(ExecContext
, log_namespace
), SD_BUS_VTABLE_PROPERTY_CONST
),
770 SD_BUS_PROPERTY("SecureBits", "i", bus_property_get_int
, offsetof(ExecContext
, secure_bits
), SD_BUS_VTABLE_PROPERTY_CONST
),
771 SD_BUS_PROPERTY("CapabilityBoundingSet", "t", NULL
, offsetof(ExecContext
, capability_bounding_set
), SD_BUS_VTABLE_PROPERTY_CONST
),
772 SD_BUS_PROPERTY("AmbientCapabilities", "t", NULL
, offsetof(ExecContext
, capability_ambient_set
), SD_BUS_VTABLE_PROPERTY_CONST
),
773 SD_BUS_PROPERTY("User", "s", NULL
, offsetof(ExecContext
, user
), SD_BUS_VTABLE_PROPERTY_CONST
),
774 SD_BUS_PROPERTY("Group", "s", NULL
, offsetof(ExecContext
, group
), SD_BUS_VTABLE_PROPERTY_CONST
),
775 SD_BUS_PROPERTY("DynamicUser", "b", bus_property_get_bool
, offsetof(ExecContext
, dynamic_user
), SD_BUS_VTABLE_PROPERTY_CONST
),
776 SD_BUS_PROPERTY("RemoveIPC", "b", bus_property_get_bool
, offsetof(ExecContext
, remove_ipc
), SD_BUS_VTABLE_PROPERTY_CONST
),
777 SD_BUS_PROPERTY("SupplementaryGroups", "as", NULL
, offsetof(ExecContext
, supplementary_groups
), SD_BUS_VTABLE_PROPERTY_CONST
),
778 SD_BUS_PROPERTY("PAMName", "s", NULL
, offsetof(ExecContext
, pam_name
), SD_BUS_VTABLE_PROPERTY_CONST
),
779 SD_BUS_PROPERTY("ReadWritePaths", "as", NULL
, offsetof(ExecContext
, read_write_paths
), SD_BUS_VTABLE_PROPERTY_CONST
),
780 SD_BUS_PROPERTY("ReadOnlyPaths", "as", NULL
, offsetof(ExecContext
, read_only_paths
), SD_BUS_VTABLE_PROPERTY_CONST
),
781 SD_BUS_PROPERTY("InaccessiblePaths", "as", NULL
, offsetof(ExecContext
, inaccessible_paths
), SD_BUS_VTABLE_PROPERTY_CONST
),
782 SD_BUS_PROPERTY("MountFlags", "t", bus_property_get_ulong
, offsetof(ExecContext
, mount_flags
), SD_BUS_VTABLE_PROPERTY_CONST
),
783 SD_BUS_PROPERTY("PrivateTmp", "b", bus_property_get_bool
, offsetof(ExecContext
, private_tmp
), SD_BUS_VTABLE_PROPERTY_CONST
),
784 SD_BUS_PROPERTY("PrivateDevices", "b", bus_property_get_bool
, offsetof(ExecContext
, private_devices
), SD_BUS_VTABLE_PROPERTY_CONST
),
785 SD_BUS_PROPERTY("ProtectKernelTunables", "b", bus_property_get_bool
, offsetof(ExecContext
, protect_kernel_tunables
), SD_BUS_VTABLE_PROPERTY_CONST
),
786 SD_BUS_PROPERTY("ProtectKernelModules", "b", bus_property_get_bool
, offsetof(ExecContext
, protect_kernel_modules
), SD_BUS_VTABLE_PROPERTY_CONST
),
787 SD_BUS_PROPERTY("ProtectKernelLogs", "b", bus_property_get_bool
, offsetof(ExecContext
, protect_kernel_logs
), SD_BUS_VTABLE_PROPERTY_CONST
),
788 SD_BUS_PROPERTY("ProtectControlGroups", "b", bus_property_get_bool
, offsetof(ExecContext
, protect_control_groups
), SD_BUS_VTABLE_PROPERTY_CONST
),
789 SD_BUS_PROPERTY("PrivateNetwork", "b", bus_property_get_bool
, offsetof(ExecContext
, private_network
), SD_BUS_VTABLE_PROPERTY_CONST
),
790 SD_BUS_PROPERTY("PrivateUsers", "b", bus_property_get_bool
, offsetof(ExecContext
, private_users
), SD_BUS_VTABLE_PROPERTY_CONST
),
791 SD_BUS_PROPERTY("PrivateMounts", "b", bus_property_get_bool
, offsetof(ExecContext
, private_mounts
), SD_BUS_VTABLE_PROPERTY_CONST
),
792 SD_BUS_PROPERTY("ProtectHome", "s", property_get_protect_home
, offsetof(ExecContext
, protect_home
), SD_BUS_VTABLE_PROPERTY_CONST
),
793 SD_BUS_PROPERTY("ProtectSystem", "s", property_get_protect_system
, offsetof(ExecContext
, protect_system
), SD_BUS_VTABLE_PROPERTY_CONST
),
794 SD_BUS_PROPERTY("SameProcessGroup", "b", bus_property_get_bool
, offsetof(ExecContext
, same_pgrp
), SD_BUS_VTABLE_PROPERTY_CONST
),
795 SD_BUS_PROPERTY("UtmpIdentifier", "s", NULL
, offsetof(ExecContext
, utmp_id
), SD_BUS_VTABLE_PROPERTY_CONST
),
796 SD_BUS_PROPERTY("UtmpMode", "s", property_get_exec_utmp_mode
, offsetof(ExecContext
, utmp_mode
), SD_BUS_VTABLE_PROPERTY_CONST
),
797 SD_BUS_PROPERTY("SELinuxContext", "(bs)", property_get_selinux_context
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
798 SD_BUS_PROPERTY("AppArmorProfile", "(bs)", property_get_apparmor_profile
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
799 SD_BUS_PROPERTY("SmackProcessLabel", "(bs)", property_get_smack_process_label
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
800 SD_BUS_PROPERTY("IgnoreSIGPIPE", "b", bus_property_get_bool
, offsetof(ExecContext
, ignore_sigpipe
), SD_BUS_VTABLE_PROPERTY_CONST
),
801 SD_BUS_PROPERTY("NoNewPrivileges", "b", bus_property_get_bool
, offsetof(ExecContext
, no_new_privileges
), SD_BUS_VTABLE_PROPERTY_CONST
),
802 SD_BUS_PROPERTY("SystemCallFilter", "(bas)", property_get_syscall_filter
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
803 SD_BUS_PROPERTY("SystemCallArchitectures", "as", property_get_syscall_archs
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
804 SD_BUS_PROPERTY("SystemCallErrorNumber", "i", bus_property_get_int
, offsetof(ExecContext
, syscall_errno
), SD_BUS_VTABLE_PROPERTY_CONST
),
805 SD_BUS_PROPERTY("Personality", "s", property_get_personality
, offsetof(ExecContext
, personality
), SD_BUS_VTABLE_PROPERTY_CONST
),
806 SD_BUS_PROPERTY("LockPersonality", "b", bus_property_get_bool
, offsetof(ExecContext
, lock_personality
), SD_BUS_VTABLE_PROPERTY_CONST
),
807 SD_BUS_PROPERTY("RestrictAddressFamilies", "(bas)", property_get_address_families
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
808 SD_BUS_PROPERTY("RuntimeDirectoryPreserve", "s", property_get_exec_preserve_mode
, offsetof(ExecContext
, runtime_directory_preserve_mode
), SD_BUS_VTABLE_PROPERTY_CONST
),
809 SD_BUS_PROPERTY("RuntimeDirectoryMode", "u", bus_property_get_mode
, offsetof(ExecContext
, directories
[EXEC_DIRECTORY_RUNTIME
].mode
), SD_BUS_VTABLE_PROPERTY_CONST
),
810 SD_BUS_PROPERTY("RuntimeDirectory", "as", NULL
, offsetof(ExecContext
, directories
[EXEC_DIRECTORY_RUNTIME
].paths
), SD_BUS_VTABLE_PROPERTY_CONST
),
811 SD_BUS_PROPERTY("StateDirectoryMode", "u", bus_property_get_mode
, offsetof(ExecContext
, directories
[EXEC_DIRECTORY_STATE
].mode
), SD_BUS_VTABLE_PROPERTY_CONST
),
812 SD_BUS_PROPERTY("StateDirectory", "as", NULL
, offsetof(ExecContext
, directories
[EXEC_DIRECTORY_STATE
].paths
), SD_BUS_VTABLE_PROPERTY_CONST
),
813 SD_BUS_PROPERTY("CacheDirectoryMode", "u", bus_property_get_mode
, offsetof(ExecContext
, directories
[EXEC_DIRECTORY_CACHE
].mode
), SD_BUS_VTABLE_PROPERTY_CONST
),
814 SD_BUS_PROPERTY("CacheDirectory", "as", NULL
, offsetof(ExecContext
, directories
[EXEC_DIRECTORY_CACHE
].paths
), SD_BUS_VTABLE_PROPERTY_CONST
),
815 SD_BUS_PROPERTY("LogsDirectoryMode", "u", bus_property_get_mode
, offsetof(ExecContext
, directories
[EXEC_DIRECTORY_LOGS
].mode
), SD_BUS_VTABLE_PROPERTY_CONST
),
816 SD_BUS_PROPERTY("LogsDirectory", "as", NULL
, offsetof(ExecContext
, directories
[EXEC_DIRECTORY_LOGS
].paths
), SD_BUS_VTABLE_PROPERTY_CONST
),
817 SD_BUS_PROPERTY("ConfigurationDirectoryMode", "u", bus_property_get_mode
, offsetof(ExecContext
, directories
[EXEC_DIRECTORY_CONFIGURATION
].mode
), SD_BUS_VTABLE_PROPERTY_CONST
),
818 SD_BUS_PROPERTY("ConfigurationDirectory", "as", NULL
, offsetof(ExecContext
, directories
[EXEC_DIRECTORY_CONFIGURATION
].paths
), SD_BUS_VTABLE_PROPERTY_CONST
),
819 SD_BUS_PROPERTY("TimeoutCleanUSec", "t", bus_property_get_usec
, offsetof(ExecContext
, timeout_clean_usec
), SD_BUS_VTABLE_PROPERTY_CONST
),
820 SD_BUS_PROPERTY("MemoryDenyWriteExecute", "b", bus_property_get_bool
, offsetof(ExecContext
, memory_deny_write_execute
), SD_BUS_VTABLE_PROPERTY_CONST
),
821 SD_BUS_PROPERTY("RestrictRealtime", "b", bus_property_get_bool
, offsetof(ExecContext
, restrict_realtime
), SD_BUS_VTABLE_PROPERTY_CONST
),
822 SD_BUS_PROPERTY("RestrictSUIDSGID", "b", bus_property_get_bool
, offsetof(ExecContext
, restrict_suid_sgid
), SD_BUS_VTABLE_PROPERTY_CONST
),
823 SD_BUS_PROPERTY("RestrictNamespaces", "t", bus_property_get_ulong
, offsetof(ExecContext
, restrict_namespaces
), SD_BUS_VTABLE_PROPERTY_CONST
),
824 SD_BUS_PROPERTY("BindPaths", "a(ssbt)", property_get_bind_paths
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
825 SD_BUS_PROPERTY("BindReadOnlyPaths", "a(ssbt)", property_get_bind_paths
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
826 SD_BUS_PROPERTY("TemporaryFileSystem", "a(ss)", property_get_temporary_filesystems
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
827 SD_BUS_PROPERTY("MountAPIVFS", "b", bus_property_get_bool
, offsetof(ExecContext
, mount_apivfs
), SD_BUS_VTABLE_PROPERTY_CONST
),
828 SD_BUS_PROPERTY("KeyringMode", "s", property_get_exec_keyring_mode
, offsetof(ExecContext
, keyring_mode
), SD_BUS_VTABLE_PROPERTY_CONST
),
829 SD_BUS_PROPERTY("ProtectHostname", "b", bus_property_get_bool
, offsetof(ExecContext
, protect_hostname
), SD_BUS_VTABLE_PROPERTY_CONST
),
830 SD_BUS_PROPERTY("NetworkNamespacePath", "s", NULL
, offsetof(ExecContext
, network_namespace_path
), SD_BUS_VTABLE_PROPERTY_CONST
),
832 /* Obsolete/redundant properties: */
833 SD_BUS_PROPERTY("Capabilities", "s", property_get_empty_string
, 0, SD_BUS_VTABLE_PROPERTY_CONST
|SD_BUS_VTABLE_HIDDEN
),
834 SD_BUS_PROPERTY("ReadWriteDirectories", "as", NULL
, offsetof(ExecContext
, read_write_paths
), SD_BUS_VTABLE_PROPERTY_CONST
|SD_BUS_VTABLE_HIDDEN
),
835 SD_BUS_PROPERTY("ReadOnlyDirectories", "as", NULL
, offsetof(ExecContext
, read_only_paths
), SD_BUS_VTABLE_PROPERTY_CONST
|SD_BUS_VTABLE_HIDDEN
),
836 SD_BUS_PROPERTY("InaccessibleDirectories", "as", NULL
, offsetof(ExecContext
, inaccessible_paths
), SD_BUS_VTABLE_PROPERTY_CONST
|SD_BUS_VTABLE_HIDDEN
),
837 SD_BUS_PROPERTY("IOScheduling", "i", property_get_ioprio
, 0, SD_BUS_VTABLE_PROPERTY_CONST
|SD_BUS_VTABLE_HIDDEN
),
842 static int append_exec_command(sd_bus_message
*reply
, ExecCommand
*c
) {
851 r
= sd_bus_message_open_container(reply
, 'r', "sasbttttuii");
855 r
= sd_bus_message_append(reply
, "s", c
->path
);
859 r
= sd_bus_message_append_strv(reply
, c
->argv
);
863 r
= sd_bus_message_append(reply
, "bttttuii",
864 !!(c
->flags
& EXEC_COMMAND_IGNORE_FAILURE
),
865 c
->exec_status
.start_timestamp
.realtime
,
866 c
->exec_status
.start_timestamp
.monotonic
,
867 c
->exec_status
.exit_timestamp
.realtime
,
868 c
->exec_status
.exit_timestamp
.monotonic
,
869 (uint32_t) c
->exec_status
.pid
,
870 (int32_t) c
->exec_status
.code
,
871 (int32_t) c
->exec_status
.status
);
875 return sd_bus_message_close_container(reply
);
878 static int append_exec_ex_command(sd_bus_message
*reply
, ExecCommand
*c
) {
879 _cleanup_strv_free_
char **ex_opts
= NULL
;
888 r
= sd_bus_message_open_container(reply
, 'r', "sasasttttuii");
892 r
= sd_bus_message_append(reply
, "s", c
->path
);
896 r
= sd_bus_message_append_strv(reply
, c
->argv
);
900 r
= exec_command_flags_to_strv(c
->flags
, &ex_opts
);
904 r
= sd_bus_message_append_strv(reply
, ex_opts
);
908 r
= sd_bus_message_append(reply
, "ttttuii",
909 c
->exec_status
.start_timestamp
.realtime
,
910 c
->exec_status
.start_timestamp
.monotonic
,
911 c
->exec_status
.exit_timestamp
.realtime
,
912 c
->exec_status
.exit_timestamp
.monotonic
,
913 (uint32_t) c
->exec_status
.pid
,
914 (int32_t) c
->exec_status
.code
,
915 (int32_t) c
->exec_status
.status
);
919 return sd_bus_message_close_container(reply
);
922 int bus_property_get_exec_command(
925 const char *interface
,
926 const char *property
,
927 sd_bus_message
*reply
,
929 sd_bus_error
*ret_error
) {
931 ExecCommand
*c
= (ExecCommand
*) userdata
;
937 r
= sd_bus_message_open_container(reply
, 'a', "(sasbttttuii)");
941 r
= append_exec_command(reply
, c
);
945 return sd_bus_message_close_container(reply
);
948 int bus_property_get_exec_command_list(
951 const char *interface
,
952 const char *property
,
953 sd_bus_message
*reply
,
955 sd_bus_error
*ret_error
) {
957 ExecCommand
*c
= *(ExecCommand
**) userdata
;
963 r
= sd_bus_message_open_container(reply
, 'a', "(sasbttttuii)");
967 LIST_FOREACH(command
, c
, c
) {
968 r
= append_exec_command(reply
, c
);
973 return sd_bus_message_close_container(reply
);
976 int bus_property_get_exec_ex_command_list(
979 const char *interface
,
980 const char *property
,
981 sd_bus_message
*reply
,
983 sd_bus_error
*ret_error
) {
985 ExecCommand
*c
, *exec_command
= *(ExecCommand
**) userdata
;
991 r
= sd_bus_message_open_container(reply
, 'a', "(sasasttttuii)");
995 LIST_FOREACH(command
, c
, exec_command
) {
996 r
= append_exec_ex_command(reply
, c
);
1001 return sd_bus_message_close_container(reply
);
1004 static char *exec_command_flags_to_exec_chars(ExecCommandFlags flags
) {
1005 return strjoin(FLAGS_SET(flags
, EXEC_COMMAND_IGNORE_FAILURE
) ? "-" : "",
1006 FLAGS_SET(flags
, EXEC_COMMAND_NO_ENV_EXPAND
) ? ":" : "",
1007 FLAGS_SET(flags
, EXEC_COMMAND_FULLY_PRIVILEGED
) ? "+" : "",
1008 FLAGS_SET(flags
, EXEC_COMMAND_NO_SETUID
) ? "!" : "",
1009 FLAGS_SET(flags
, EXEC_COMMAND_AMBIENT_MAGIC
) ? "!!" : "");
1012 int bus_set_transient_exec_command(
1015 ExecCommand
**exec_command
,
1016 sd_bus_message
*message
,
1017 UnitWriteFlags flags
,
1018 sd_bus_error
*error
) {
1019 bool is_ex_prop
= endswith(name
, "Ex");
1023 r
= sd_bus_message_enter_container(message
, 'a', is_ex_prop
? "(sasas)" : "(sasb)");
1027 while ((r
= sd_bus_message_enter_container(message
, 'r', is_ex_prop
? "sasas" : "sasb")) > 0) {
1028 _cleanup_strv_free_
char **argv
= NULL
, **ex_opts
= NULL
;
1032 r
= sd_bus_message_read(message
, "s", &path
);
1036 if (!path_is_absolute(path
))
1037 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Path %s is not absolute.", path
);
1039 r
= sd_bus_message_read_strv(message
, &argv
);
1043 r
= is_ex_prop
? sd_bus_message_read_strv(message
, &ex_opts
) : sd_bus_message_read(message
, "b", &b
);
1047 r
= sd_bus_message_exit_container(message
);
1051 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
1054 c
= new0(ExecCommand
, 1);
1058 c
->path
= strdup(path
);
1064 c
->argv
= TAKE_PTR(argv
);
1067 r
= exec_command_flags_from_strv(ex_opts
, &c
->flags
);
1071 c
->flags
= b
? EXEC_COMMAND_IGNORE_FAILURE
: 0;
1073 path_simplify(c
->path
, false);
1074 exec_command_append_list(exec_command
, c
);
1082 r
= sd_bus_message_exit_container(message
);
1086 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
1087 _cleanup_free_
char *buf
= NULL
;
1088 _cleanup_fclose_
FILE *f
= NULL
;
1093 *exec_command
= exec_command_free_list(*exec_command
);
1095 f
= open_memstream_unlocked(&buf
, &size
);
1099 fprintf(f
, "%s=\n", name
);
1101 LIST_FOREACH(command
, c
, *exec_command
) {
1102 _cleanup_free_
char *a
= NULL
, *exec_chars
= NULL
;
1104 exec_chars
= exec_command_flags_to_exec_chars(c
->flags
);
1108 a
= unit_concat_strv(c
->argv
, UNIT_ESCAPE_C
|UNIT_ESCAPE_SPECIFIERS
);
1112 if (streq_ptr(c
->path
, c
->argv
? c
->argv
[0] : NULL
))
1113 fprintf(f
, "%s=%s%s\n", name
, exec_chars
, a
);
1115 _cleanup_free_
char *t
= NULL
;
1118 p
= unit_escape_setting(c
->path
, UNIT_ESCAPE_C
|UNIT_ESCAPE_SPECIFIERS
, &t
);
1122 fprintf(f
, "%s=%s@%s %s\n", name
, exec_chars
, p
, a
);
1126 r
= fflush_and_check(f
);
1130 unit_write_setting(u
, flags
, name
, buf
);
1136 static int parse_personality(const char *s
, unsigned long *p
) {
1141 v
= personality_from_string(s
);
1142 if (v
== PERSONALITY_INVALID
)
1149 static const char* mount_propagation_flags_to_string_with_check(unsigned long n
) {
1150 if (!IN_SET(n
, 0, MS_SHARED
, MS_PRIVATE
, MS_SLAVE
))
1153 return mount_propagation_flags_to_string(n
);
1156 static BUS_DEFINE_SET_TRANSIENT(nsec
, "t", uint64_t, nsec_t
, NSEC_FMT
);
1157 static BUS_DEFINE_SET_TRANSIENT_IS_VALID(log_level
, "i", int32_t, int, "%" PRIi32
, log_level_is_valid
);
1159 static BUS_DEFINE_SET_TRANSIENT_IS_VALID(errno
, "i", int32_t, int, "%" PRIi32
, errno_is_valid
);
1161 static BUS_DEFINE_SET_TRANSIENT_PARSE(std_input
, ExecInput
, exec_input_from_string
);
1162 static BUS_DEFINE_SET_TRANSIENT_PARSE(std_output
, ExecOutput
, exec_output_from_string
);
1163 static BUS_DEFINE_SET_TRANSIENT_PARSE(utmp_mode
, ExecUtmpMode
, exec_utmp_mode_from_string
);
1164 static BUS_DEFINE_SET_TRANSIENT_PARSE(protect_system
, ProtectSystem
, protect_system_from_string
);
1165 static BUS_DEFINE_SET_TRANSIENT_PARSE(protect_home
, ProtectHome
, protect_home_from_string
);
1166 static BUS_DEFINE_SET_TRANSIENT_PARSE(keyring_mode
, ExecKeyringMode
, exec_keyring_mode_from_string
);
1167 static BUS_DEFINE_SET_TRANSIENT_PARSE(preserve_mode
, ExecPreserveMode
, exec_preserve_mode_from_string
);
1168 static BUS_DEFINE_SET_TRANSIENT_PARSE_PTR(personality
, unsigned long, parse_personality
);
1169 static BUS_DEFINE_SET_TRANSIENT_TO_STRING_ALLOC(secure_bits
, "i", int32_t, int, "%" PRIi32
, secure_bits_to_string_alloc_with_check
);
1170 static BUS_DEFINE_SET_TRANSIENT_TO_STRING_ALLOC(capability
, "t", uint64_t, uint64_t, "%" PRIu64
, capability_set_to_string_alloc
);
1171 static BUS_DEFINE_SET_TRANSIENT_TO_STRING_ALLOC(namespace_flag
, "t", uint64_t, unsigned long, "%" PRIu64
, namespace_flags_to_string
);
1172 static BUS_DEFINE_SET_TRANSIENT_TO_STRING(mount_flags
, "t", uint64_t, unsigned long, "%" PRIu64
, mount_propagation_flags_to_string_with_check
);
1174 int bus_exec_context_set_transient_property(
1178 sd_bus_message
*message
,
1179 UnitWriteFlags flags
,
1180 sd_bus_error
*error
) {
1190 flags
|= UNIT_PRIVATE
;
1192 if (streq(name
, "User"))
1193 return bus_set_transient_user_compat(u
, name
, &c
->user
, message
, flags
, error
);
1195 if (streq(name
, "Group"))
1196 return bus_set_transient_user_compat(u
, name
, &c
->group
, message
, flags
, error
);
1198 if (streq(name
, "TTYPath"))
1199 return bus_set_transient_path(u
, name
, &c
->tty_path
, message
, flags
, error
);
1201 if (streq(name
, "RootImage"))
1202 return bus_set_transient_path(u
, name
, &c
->root_image
, message
, flags
, error
);
1204 if (streq(name
, "RootDirectory"))
1205 return bus_set_transient_path(u
, name
, &c
->root_directory
, message
, flags
, error
);
1207 if (streq(name
, "SyslogIdentifier"))
1208 return bus_set_transient_string(u
, name
, &c
->syslog_identifier
, message
, flags
, error
);
1210 if (streq(name
, "LogLevelMax"))
1211 return bus_set_transient_log_level(u
, name
, &c
->log_level_max
, message
, flags
, error
);
1213 if (streq(name
, "LogRateLimitIntervalUSec"))
1214 return bus_set_transient_usec(u
, name
, &c
->log_ratelimit_interval_usec
, message
, flags
, error
);
1216 if (streq(name
, "LogRateLimitBurst"))
1217 return bus_set_transient_unsigned(u
, name
, &c
->log_ratelimit_burst
, message
, flags
, error
);
1219 if (streq(name
, "Personality"))
1220 return bus_set_transient_personality(u
, name
, &c
->personality
, message
, flags
, error
);
1222 if (streq(name
, "StandardInput"))
1223 return bus_set_transient_std_input(u
, name
, &c
->std_input
, message
, flags
, error
);
1225 if (streq(name
, "StandardOutput"))
1226 return bus_set_transient_std_output(u
, name
, &c
->std_output
, message
, flags
, error
);
1228 if (streq(name
, "StandardError"))
1229 return bus_set_transient_std_output(u
, name
, &c
->std_error
, message
, flags
, error
);
1231 if (streq(name
, "IgnoreSIGPIPE"))
1232 return bus_set_transient_bool(u
, name
, &c
->ignore_sigpipe
, message
, flags
, error
);
1234 if (streq(name
, "TTYVHangup"))
1235 return bus_set_transient_bool(u
, name
, &c
->tty_vhangup
, message
, flags
, error
);
1237 if (streq(name
, "TTYReset"))
1238 return bus_set_transient_bool(u
, name
, &c
->tty_reset
, message
, flags
, error
);
1240 if (streq(name
, "TTYVTDisallocate"))
1241 return bus_set_transient_bool(u
, name
, &c
->tty_vt_disallocate
, message
, flags
, error
);
1243 if (streq(name
, "PrivateTmp"))
1244 return bus_set_transient_bool(u
, name
, &c
->private_tmp
, message
, flags
, error
);
1246 if (streq(name
, "PrivateDevices"))
1247 return bus_set_transient_bool(u
, name
, &c
->private_devices
, message
, flags
, error
);
1249 if (streq(name
, "PrivateMounts"))
1250 return bus_set_transient_bool(u
, name
, &c
->private_mounts
, message
, flags
, error
);
1252 if (streq(name
, "PrivateNetwork"))
1253 return bus_set_transient_bool(u
, name
, &c
->private_network
, message
, flags
, error
);
1255 if (streq(name
, "PrivateUsers"))
1256 return bus_set_transient_bool(u
, name
, &c
->private_users
, message
, flags
, error
);
1258 if (streq(name
, "NoNewPrivileges"))
1259 return bus_set_transient_bool(u
, name
, &c
->no_new_privileges
, message
, flags
, error
);
1261 if (streq(name
, "SyslogLevelPrefix"))
1262 return bus_set_transient_bool(u
, name
, &c
->syslog_level_prefix
, message
, flags
, error
);
1264 if (streq(name
, "MemoryDenyWriteExecute"))
1265 return bus_set_transient_bool(u
, name
, &c
->memory_deny_write_execute
, message
, flags
, error
);
1267 if (streq(name
, "RestrictRealtime"))
1268 return bus_set_transient_bool(u
, name
, &c
->restrict_realtime
, message
, flags
, error
);
1270 if (streq(name
, "RestrictSUIDSGID"))
1271 return bus_set_transient_bool(u
, name
, &c
->restrict_suid_sgid
, message
, flags
, error
);
1273 if (streq(name
, "DynamicUser"))
1274 return bus_set_transient_bool(u
, name
, &c
->dynamic_user
, message
, flags
, error
);
1276 if (streq(name
, "RemoveIPC"))
1277 return bus_set_transient_bool(u
, name
, &c
->remove_ipc
, message
, flags
, error
);
1279 if (streq(name
, "ProtectKernelTunables"))
1280 return bus_set_transient_bool(u
, name
, &c
->protect_kernel_tunables
, message
, flags
, error
);
1282 if (streq(name
, "ProtectKernelModules"))
1283 return bus_set_transient_bool(u
, name
, &c
->protect_kernel_modules
, message
, flags
, error
);
1285 if (streq(name
, "ProtectKernelLogs"))
1286 return bus_set_transient_bool(u
, name
, &c
->protect_kernel_logs
, message
, flags
, error
);
1288 if (streq(name
, "ProtectClock"))
1289 return bus_set_transient_bool(u
, name
, &c
->protect_clock
, message
, flags
, error
);
1291 if (streq(name
, "ProtectControlGroups"))
1292 return bus_set_transient_bool(u
, name
, &c
->protect_control_groups
, message
, flags
, error
);
1294 if (streq(name
, "MountAPIVFS"))
1295 return bus_set_transient_bool(u
, name
, &c
->mount_apivfs
, message
, flags
, error
);
1297 if (streq(name
, "CPUSchedulingResetOnFork"))
1298 return bus_set_transient_bool(u
, name
, &c
->cpu_sched_reset_on_fork
, message
, flags
, error
);
1300 if (streq(name
, "NonBlocking"))
1301 return bus_set_transient_bool(u
, name
, &c
->non_blocking
, message
, flags
, error
);
1303 if (streq(name
, "LockPersonality"))
1304 return bus_set_transient_bool(u
, name
, &c
->lock_personality
, message
, flags
, error
);
1306 if (streq(name
, "ProtectHostname"))
1307 return bus_set_transient_bool(u
, name
, &c
->protect_hostname
, message
, flags
, error
);
1309 if (streq(name
, "UtmpIdentifier"))
1310 return bus_set_transient_string(u
, name
, &c
->utmp_id
, message
, flags
, error
);
1312 if (streq(name
, "UtmpMode"))
1313 return bus_set_transient_utmp_mode(u
, name
, &c
->utmp_mode
, message
, flags
, error
);
1315 if (streq(name
, "PAMName"))
1316 return bus_set_transient_string(u
, name
, &c
->pam_name
, message
, flags
, error
);
1318 if (streq(name
, "TimerSlackNSec"))
1319 return bus_set_transient_nsec(u
, name
, &c
->timer_slack_nsec
, message
, flags
, error
);
1321 if (streq(name
, "ProtectSystem"))
1322 return bus_set_transient_protect_system(u
, name
, &c
->protect_system
, message
, flags
, error
);
1324 if (streq(name
, "ProtectHome"))
1325 return bus_set_transient_protect_home(u
, name
, &c
->protect_home
, message
, flags
, error
);
1327 if (streq(name
, "KeyringMode"))
1328 return bus_set_transient_keyring_mode(u
, name
, &c
->keyring_mode
, message
, flags
, error
);
1330 if (streq(name
, "RuntimeDirectoryPreserve"))
1331 return bus_set_transient_preserve_mode(u
, name
, &c
->runtime_directory_preserve_mode
, message
, flags
, error
);
1333 if (streq(name
, "UMask"))
1334 return bus_set_transient_mode_t(u
, name
, &c
->umask
, message
, flags
, error
);
1336 if (streq(name
, "RuntimeDirectoryMode"))
1337 return bus_set_transient_mode_t(u
, name
, &c
->directories
[EXEC_DIRECTORY_RUNTIME
].mode
, message
, flags
, error
);
1339 if (streq(name
, "StateDirectoryMode"))
1340 return bus_set_transient_mode_t(u
, name
, &c
->directories
[EXEC_DIRECTORY_STATE
].mode
, message
, flags
, error
);
1342 if (streq(name
, "CacheDirectoryMode"))
1343 return bus_set_transient_mode_t(u
, name
, &c
->directories
[EXEC_DIRECTORY_CACHE
].mode
, message
, flags
, error
);
1345 if (streq(name
, "LogsDirectoryMode"))
1346 return bus_set_transient_mode_t(u
, name
, &c
->directories
[EXEC_DIRECTORY_LOGS
].mode
, message
, flags
, error
);
1348 if (streq(name
, "ConfigurationDirectoryMode"))
1349 return bus_set_transient_mode_t(u
, name
, &c
->directories
[EXEC_DIRECTORY_CONFIGURATION
].mode
, message
, flags
, error
);
1351 if (streq(name
, "SELinuxContext"))
1352 return bus_set_transient_string(u
, name
, &c
->selinux_context
, message
, flags
, error
);
1354 if (streq(name
, "SecureBits"))
1355 return bus_set_transient_secure_bits(u
, name
, &c
->secure_bits
, message
, flags
, error
);
1357 if (streq(name
, "CapabilityBoundingSet"))
1358 return bus_set_transient_capability(u
, name
, &c
->capability_bounding_set
, message
, flags
, error
);
1360 if (streq(name
, "AmbientCapabilities"))
1361 return bus_set_transient_capability(u
, name
, &c
->capability_ambient_set
, message
, flags
, error
);
1363 if (streq(name
, "RestrictNamespaces"))
1364 return bus_set_transient_namespace_flag(u
, name
, &c
->restrict_namespaces
, message
, flags
, error
);
1366 if (streq(name
, "MountFlags"))
1367 return bus_set_transient_mount_flags(u
, name
, &c
->mount_flags
, message
, flags
, error
);
1369 if (streq(name
, "NetworkNamespacePath"))
1370 return bus_set_transient_path(u
, name
, &c
->network_namespace_path
, message
, flags
, error
);
1372 if (streq(name
, "SupplementaryGroups")) {
1373 _cleanup_strv_free_
char **l
= NULL
;
1376 r
= sd_bus_message_read_strv(message
, &l
);
1381 if (!isempty(*p
) && !valid_user_group_name_or_id_compat(*p
))
1382 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
,
1383 "Invalid supplementary group names");
1385 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
1386 if (strv_isempty(l
)) {
1387 c
->supplementary_groups
= strv_free(c
->supplementary_groups
);
1388 unit_write_settingf(u
, flags
, name
, "%s=", name
);
1390 _cleanup_free_
char *joined
= NULL
;
1392 r
= strv_extend_strv(&c
->supplementary_groups
, l
, true);
1396 joined
= strv_join(c
->supplementary_groups
, " ");
1400 unit_write_settingf(u
, flags
|UNIT_ESCAPE_SPECIFIERS
, name
, "%s=%s", name
, joined
);
1406 } else if (streq(name
, "SyslogLevel")) {
1409 r
= sd_bus_message_read(message
, "i", &level
);
1413 if (!log_level_is_valid(level
))
1414 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Log level value out of range");
1416 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
1417 c
->syslog_priority
= (c
->syslog_priority
& LOG_FACMASK
) | level
;
1418 unit_write_settingf(u
, flags
, name
, "SyslogLevel=%i", level
);
1423 } else if (streq(name
, "SyslogFacility")) {
1426 r
= sd_bus_message_read(message
, "i", &facility
);
1430 if (!log_facility_unshifted_is_valid(facility
))
1431 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Log facility value out of range");
1433 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
1434 c
->syslog_priority
= (facility
<< 3) | LOG_PRI(c
->syslog_priority
);
1435 unit_write_settingf(u
, flags
, name
, "SyslogFacility=%i", facility
);
1440 } else if (streq(name
, "LogNamespace")) {
1443 r
= sd_bus_message_read(message
, "s", &n
);
1447 if (!isempty(n
) && !log_namespace_name_valid(n
))
1448 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Log namespace name not valid");
1450 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
1453 c
->log_namespace
= mfree(c
->log_namespace
);
1454 unit_write_settingf(u
, flags
, name
, "%s=", name
);
1456 r
= free_and_strdup(&c
->log_namespace
, n
);
1460 unit_write_settingf(u
, flags
, name
, "%s=%s", name
, n
);
1466 } else if (streq(name
, "LogExtraFields")) {
1469 r
= sd_bus_message_enter_container(message
, 'a', "ay");
1474 _cleanup_free_
void *copy
= NULL
;
1480 /* Note that we expect a byte array for each field, instead of a string. That's because on the
1481 * lower-level journal fields can actually contain binary data and are not restricted to text,
1482 * and we should not "lose precision" in our types on the way. That said, I am pretty sure
1483 * actually encoding binary data as unit metadata is not a good idea. Hence we actually refuse
1484 * any actual binary data, and only accept UTF-8. This allows us to eventually lift this
1485 * limitation, should a good, valid usecase arise. */
1487 r
= sd_bus_message_read_array(message
, 'y', &p
, &sz
);
1493 if (memchr(p
, 0, sz
))
1494 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Journal field contains zero byte");
1496 eq
= memchr(p
, '=', sz
);
1498 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Journal field contains no '=' character");
1499 if (!journal_field_valid(p
, eq
- (const char*) p
, false))
1500 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Journal field invalid");
1502 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
1503 t
= reallocarray(c
->log_extra_fields
, c
->n_log_extra_fields
+1, sizeof(struct iovec
));
1506 c
->log_extra_fields
= t
;
1509 copy
= malloc(sz
+ 1);
1513 memcpy(copy
, p
, sz
);
1514 ((uint8_t*) copy
)[sz
] = 0;
1516 if (!utf8_is_valid(copy
))
1517 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Journal field is not valid UTF-8");
1519 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
1520 c
->log_extra_fields
[c
->n_log_extra_fields
++] = IOVEC_MAKE(copy
, sz
);
1521 unit_write_settingf(u
, flags
|UNIT_ESCAPE_SPECIFIERS
|UNIT_ESCAPE_C
, name
, "LogExtraFields=%s", (char*) copy
);
1529 r
= sd_bus_message_exit_container(message
);
1533 if (!UNIT_WRITE_FLAGS_NOOP(flags
) && n
== 0) {
1534 exec_context_free_log_extra_fields(c
);
1535 unit_write_setting(u
, flags
, name
, "LogExtraFields=");
1543 if (streq(name
, "SystemCallErrorNumber"))
1544 return bus_set_transient_errno(u
, name
, &c
->syscall_errno
, message
, flags
, error
);
1546 if (streq(name
, "SystemCallFilter")) {
1548 _cleanup_strv_free_
char **l
= NULL
;
1550 r
= sd_bus_message_enter_container(message
, 'r', "bas");
1554 r
= sd_bus_message_read(message
, "b", &whitelist
);
1558 r
= sd_bus_message_read_strv(message
, &l
);
1562 r
= sd_bus_message_exit_container(message
);
1566 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
1567 _cleanup_free_
char *joined
= NULL
;
1568 SeccompParseFlags invert_flag
= whitelist
? 0 : SECCOMP_PARSE_INVERT
;
1571 if (strv_isempty(l
)) {
1572 c
->syscall_whitelist
= false;
1573 c
->syscall_filter
= hashmap_free(c
->syscall_filter
);
1575 unit_write_settingf(u
, flags
, name
, "SystemCallFilter=");
1579 if (!c
->syscall_filter
) {
1580 c
->syscall_filter
= hashmap_new(NULL
);
1581 if (!c
->syscall_filter
)
1584 c
->syscall_whitelist
= whitelist
;
1586 if (c
->syscall_whitelist
) {
1587 r
= seccomp_parse_syscall_filter("@default",
1590 SECCOMP_PARSE_WHITELIST
| invert_flag
,
1598 STRV_FOREACH(s
, l
) {
1599 _cleanup_free_
char *n
= NULL
;
1602 r
= parse_syscall_and_errno(*s
, &n
, &e
);
1606 r
= seccomp_parse_syscall_filter(n
,
1609 (c
->syscall_whitelist
? SECCOMP_PARSE_WHITELIST
: 0) | invert_flag
,
1616 joined
= strv_join(l
, " ");
1620 unit_write_settingf(u
, flags
, name
, "SystemCallFilter=%s%s", whitelist
? "" : "~", joined
);
1625 } else if (streq(name
, "SystemCallArchitectures")) {
1626 _cleanup_strv_free_
char **l
= NULL
;
1628 r
= sd_bus_message_read_strv(message
, &l
);
1632 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
1633 _cleanup_free_
char *joined
= NULL
;
1635 if (strv_isempty(l
))
1636 c
->syscall_archs
= set_free(c
->syscall_archs
);
1640 r
= set_ensure_allocated(&c
->syscall_archs
, NULL
);
1644 STRV_FOREACH(s
, l
) {
1647 r
= seccomp_arch_from_string(*s
, &a
);
1651 r
= set_put(c
->syscall_archs
, UINT32_TO_PTR(a
+ 1));
1658 joined
= strv_join(l
, " ");
1662 unit_write_settingf(u
, flags
, name
, "%s=%s", name
, joined
);
1667 } else if (streq(name
, "RestrictAddressFamilies")) {
1669 _cleanup_strv_free_
char **l
= NULL
;
1671 r
= sd_bus_message_enter_container(message
, 'r', "bas");
1675 r
= sd_bus_message_read(message
, "b", &whitelist
);
1679 r
= sd_bus_message_read_strv(message
, &l
);
1683 r
= sd_bus_message_exit_container(message
);
1687 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
1688 _cleanup_free_
char *joined
= NULL
;
1691 if (strv_isempty(l
)) {
1692 c
->address_families_whitelist
= false;
1693 c
->address_families
= set_free(c
->address_families
);
1695 unit_write_settingf(u
, flags
, name
, "RestrictAddressFamilies=");
1699 if (!c
->address_families
) {
1700 c
->address_families
= set_new(NULL
);
1701 if (!c
->address_families
)
1704 c
->address_families_whitelist
= whitelist
;
1707 STRV_FOREACH(s
, l
) {
1710 af
= af_from_name(*s
);
1714 if (whitelist
== c
->address_families_whitelist
) {
1715 r
= set_put(c
->address_families
, INT_TO_PTR(af
));
1719 (void) set_remove(c
->address_families
, INT_TO_PTR(af
));
1722 joined
= strv_join(l
, " ");
1726 unit_write_settingf(u
, flags
, name
, "RestrictAddressFamilies=%s%s", whitelist
? "" : "~", joined
);
1732 if (STR_IN_SET(name
, "CPUAffinity", "NUMAMask")) {
1735 bool affinity
= streq(name
, "CPUAffinity");
1736 _cleanup_(cpu_set_reset
) CPUSet set
= {};
1738 r
= sd_bus_message_read_array(message
, 'y', &a
, &n
);
1742 r
= cpu_set_from_dbus(a
, n
, &set
);
1746 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
1748 cpu_set_reset(affinity
? &c
->cpu_set
: &c
->numa_policy
.nodes
);
1749 unit_write_settingf(u
, flags
, name
, "%s=", name
);
1751 _cleanup_free_
char *str
= NULL
;
1753 str
= cpu_set_to_string(&set
);
1757 /* We forego any optimizations here, and always create the structure using
1758 * cpu_set_add_all(), because we don't want to care if the existing size we
1759 * got over dbus is appropriate. */
1760 r
= cpu_set_add_all(affinity
? &c
->cpu_set
: &c
->numa_policy
.nodes
, &set
);
1764 unit_write_settingf(u
, flags
, name
, "%s=%s", name
, str
);
1770 } else if (streq(name
, "NUMAPolicy")) {
1773 r
= sd_bus_message_read(message
, "i", &type
);
1777 if (!mpol_is_valid(type
))
1778 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Invalid NUMAPolicy value: %i", type
);
1780 if (!UNIT_WRITE_FLAGS_NOOP(flags
))
1781 c
->numa_policy
.type
= type
;
1784 } else if (streq(name
, "Nice")) {
1787 r
= sd_bus_message_read(message
, "i", &q
);
1791 if (!nice_is_valid(q
))
1792 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Invalid Nice value: %i", q
);
1794 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
1798 unit_write_settingf(u
, flags
, name
, "Nice=%i", q
);
1803 } else if (streq(name
, "CPUSchedulingPolicy")) {
1806 r
= sd_bus_message_read(message
, "i", &q
);
1810 if (!sched_policy_is_valid(q
))
1811 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Invalid CPU scheduling policy: %i", q
);
1813 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
1814 _cleanup_free_
char *s
= NULL
;
1816 r
= sched_policy_to_string_alloc(q
, &s
);
1820 c
->cpu_sched_policy
= q
;
1821 c
->cpu_sched_priority
= CLAMP(c
->cpu_sched_priority
, sched_get_priority_min(q
), sched_get_priority_max(q
));
1822 c
->cpu_sched_set
= true;
1824 unit_write_settingf(u
, flags
, name
, "CPUSchedulingPolicy=%s", s
);
1829 } else if (streq(name
, "CPUSchedulingPriority")) {
1830 int32_t p
, min
, max
;
1832 r
= sd_bus_message_read(message
, "i", &p
);
1836 min
= sched_get_priority_min(c
->cpu_sched_policy
);
1837 max
= sched_get_priority_max(c
->cpu_sched_policy
);
1838 if (p
< min
|| p
> max
)
1839 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Invalid CPU scheduling priority: %i", p
);
1841 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
1842 c
->cpu_sched_priority
= p
;
1843 c
->cpu_sched_set
= true;
1845 unit_write_settingf(u
, flags
, name
, "CPUSchedulingPriority=%i", p
);
1850 } else if (streq(name
, "IOSchedulingClass")) {
1853 r
= sd_bus_message_read(message
, "i", &q
);
1857 if (!ioprio_class_is_valid(q
))
1858 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Invalid IO scheduling class: %i", q
);
1860 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
1861 _cleanup_free_
char *s
= NULL
;
1863 r
= ioprio_class_to_string_alloc(q
, &s
);
1867 c
->ioprio
= IOPRIO_PRIO_VALUE(q
, IOPRIO_PRIO_DATA(c
->ioprio
));
1868 c
->ioprio_set
= true;
1870 unit_write_settingf(u
, flags
, name
, "IOSchedulingClass=%s", s
);
1875 } else if (streq(name
, "IOSchedulingPriority")) {
1878 r
= sd_bus_message_read(message
, "i", &p
);
1882 if (!ioprio_priority_is_valid(p
))
1883 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Invalid IO scheduling priority: %i", p
);
1885 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
1886 c
->ioprio
= IOPRIO_PRIO_VALUE(IOPRIO_PRIO_CLASS(c
->ioprio
), p
);
1887 c
->ioprio_set
= true;
1889 unit_write_settingf(u
, flags
, name
, "IOSchedulingPriority=%i", p
);
1894 } else if (streq(name
, "WorkingDirectory")) {
1898 r
= sd_bus_message_read(message
, "s", &s
);
1908 if (!isempty(s
) && !streq(s
, "~") && !path_is_absolute(s
))
1909 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "WorkingDirectory= expects an absolute path or '~'");
1911 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
1912 if (streq(s
, "~")) {
1913 c
->working_directory
= mfree(c
->working_directory
);
1914 c
->working_directory_home
= true;
1916 r
= free_and_strdup(&c
->working_directory
, empty_to_null(s
));
1920 c
->working_directory_home
= false;
1923 c
->working_directory_missing_ok
= missing_ok
;
1924 unit_write_settingf(u
, flags
|UNIT_ESCAPE_SPECIFIERS
, name
, "WorkingDirectory=%s%s", missing_ok
? "-" : "", s
);
1929 } else if (STR_IN_SET(name
,
1930 "StandardInputFileDescriptorName", "StandardOutputFileDescriptorName", "StandardErrorFileDescriptorName")) {
1933 r
= sd_bus_message_read(message
, "s", &s
);
1937 if (!isempty(s
) && !fdname_is_valid(s
))
1938 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Invalid file descriptor name");
1940 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
1942 if (streq(name
, "StandardInputFileDescriptorName")) {
1943 r
= free_and_strdup(c
->stdio_fdname
+ STDIN_FILENO
, empty_to_null(s
));
1947 c
->std_input
= EXEC_INPUT_NAMED_FD
;
1948 unit_write_settingf(u
, flags
|UNIT_ESCAPE_SPECIFIERS
, name
, "StandardInput=fd:%s", exec_context_fdname(c
, STDIN_FILENO
));
1950 } else if (streq(name
, "StandardOutputFileDescriptorName")) {
1951 r
= free_and_strdup(c
->stdio_fdname
+ STDOUT_FILENO
, empty_to_null(s
));
1955 c
->std_output
= EXEC_OUTPUT_NAMED_FD
;
1956 unit_write_settingf(u
, flags
|UNIT_ESCAPE_SPECIFIERS
, name
, "StandardOutput=fd:%s", exec_context_fdname(c
, STDOUT_FILENO
));
1959 assert(streq(name
, "StandardErrorFileDescriptorName"));
1961 r
= free_and_strdup(&c
->stdio_fdname
[STDERR_FILENO
], empty_to_null(s
));
1965 c
->std_error
= EXEC_OUTPUT_NAMED_FD
;
1966 unit_write_settingf(u
, flags
|UNIT_ESCAPE_SPECIFIERS
, name
, "StandardError=fd:%s", exec_context_fdname(c
, STDERR_FILENO
));
1972 } else if (STR_IN_SET(name
,
1973 "StandardInputFile",
1974 "StandardOutputFile", "StandardOutputFileToAppend",
1975 "StandardErrorFile", "StandardErrorFileToAppend")) {
1978 r
= sd_bus_message_read(message
, "s", &s
);
1983 if (!path_is_absolute(s
))
1984 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Path %s is not absolute", s
);
1985 if (!path_is_normalized(s
))
1986 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Path %s is not normalized", s
);
1989 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
1991 if (streq(name
, "StandardInputFile")) {
1992 r
= free_and_strdup(&c
->stdio_file
[STDIN_FILENO
], empty_to_null(s
));
1996 c
->std_input
= EXEC_INPUT_FILE
;
1997 unit_write_settingf(u
, flags
|UNIT_ESCAPE_SPECIFIERS
, name
, "StandardInput=file:%s", s
);
1999 } else if (STR_IN_SET(name
, "StandardOutputFile", "StandardOutputFileToAppend")) {
2000 r
= free_and_strdup(&c
->stdio_file
[STDOUT_FILENO
], empty_to_null(s
));
2004 if (streq(name
, "StandardOutputFile")) {
2005 c
->std_output
= EXEC_OUTPUT_FILE
;
2006 unit_write_settingf(u
, flags
|UNIT_ESCAPE_SPECIFIERS
, name
, "StandardOutput=file:%s", s
);
2008 assert(streq(name
, "StandardOutputFileToAppend"));
2009 c
->std_output
= EXEC_OUTPUT_FILE_APPEND
;
2010 unit_write_settingf(u
, flags
|UNIT_ESCAPE_SPECIFIERS
, name
, "StandardOutput=append:%s", s
);
2013 assert(STR_IN_SET(name
, "StandardErrorFile", "StandardErrorFileToAppend"));
2015 r
= free_and_strdup(&c
->stdio_file
[STDERR_FILENO
], empty_to_null(s
));
2019 if (streq(name
, "StandardErrorFile")) {
2020 c
->std_error
= EXEC_OUTPUT_FILE
;
2021 unit_write_settingf(u
, flags
|UNIT_ESCAPE_SPECIFIERS
, name
, "StandardError=file:%s", s
);
2023 assert(streq(name
, "StandardErrorFileToAppend"));
2024 c
->std_error
= EXEC_OUTPUT_FILE_APPEND
;
2025 unit_write_settingf(u
, flags
|UNIT_ESCAPE_SPECIFIERS
, name
, "StandardError=append:%s", s
);
2032 } else if (streq(name
, "StandardInputData")) {
2036 r
= sd_bus_message_read_array(message
, 'y', &p
, &sz
);
2040 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
2041 _cleanup_free_
char *encoded
= NULL
;
2044 c
->stdin_data
= mfree(c
->stdin_data
);
2045 c
->stdin_data_size
= 0;
2047 unit_write_settingf(u
, flags
, name
, "StandardInputData=");
2052 if (c
->stdin_data_size
+ sz
< c
->stdin_data_size
|| /* check for overflow */
2053 c
->stdin_data_size
+ sz
> EXEC_STDIN_DATA_MAX
)
2056 n
= base64mem(p
, sz
, &encoded
);
2060 q
= realloc(c
->stdin_data
, c
->stdin_data_size
+ sz
);
2064 memcpy((uint8_t*) q
+ c
->stdin_data_size
, p
, sz
);
2067 c
->stdin_data_size
+= sz
;
2069 unit_write_settingf(u
, flags
, name
, "StandardInputData=%s", encoded
);
2075 } else if (streq(name
, "Environment")) {
2077 _cleanup_strv_free_
char **l
= NULL
;
2079 r
= sd_bus_message_read_strv(message
, &l
);
2083 if (!strv_env_is_valid(l
))
2084 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Invalid environment block.");
2086 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
2087 if (strv_isempty(l
)) {
2088 c
->environment
= strv_free(c
->environment
);
2089 unit_write_setting(u
, flags
, name
, "Environment=");
2091 _cleanup_free_
char *joined
= NULL
;
2094 joined
= unit_concat_strv(l
, UNIT_ESCAPE_SPECIFIERS
|UNIT_ESCAPE_C
);
2098 e
= strv_env_merge(2, c
->environment
, l
);
2102 strv_free_and_replace(c
->environment
, e
);
2103 unit_write_settingf(u
, flags
, name
, "Environment=%s", joined
);
2109 } else if (streq(name
, "UnsetEnvironment")) {
2111 _cleanup_strv_free_
char **l
= NULL
;
2113 r
= sd_bus_message_read_strv(message
, &l
);
2117 if (!strv_env_name_or_assignment_is_valid(l
))
2118 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Invalid UnsetEnvironment= list.");
2120 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
2121 if (strv_isempty(l
)) {
2122 c
->unset_environment
= strv_free(c
->unset_environment
);
2123 unit_write_setting(u
, flags
, name
, "UnsetEnvironment=");
2125 _cleanup_free_
char *joined
= NULL
;
2128 joined
= unit_concat_strv(l
, UNIT_ESCAPE_SPECIFIERS
|UNIT_ESCAPE_C
);
2132 e
= strv_env_merge(2, c
->unset_environment
, l
);
2136 strv_free_and_replace(c
->unset_environment
, e
);
2137 unit_write_settingf(u
, flags
, name
, "UnsetEnvironment=%s", joined
);
2143 } else if (streq(name
, "OOMScoreAdjust")) {
2146 r
= sd_bus_message_read(message
, "i", &oa
);
2150 if (!oom_score_adjust_is_valid(oa
))
2151 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "OOM score adjust value out of range");
2153 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
2154 c
->oom_score_adjust
= oa
;
2155 c
->oom_score_adjust_set
= true;
2156 unit_write_settingf(u
, flags
, name
, "OOMScoreAdjust=%i", oa
);
2161 } else if (streq(name
, "EnvironmentFiles")) {
2163 _cleanup_free_
char *joined
= NULL
;
2164 _cleanup_fclose_
FILE *f
= NULL
;
2165 _cleanup_strv_free_
char **l
= NULL
;
2169 r
= sd_bus_message_enter_container(message
, 'a', "(sb)");
2173 f
= open_memstream_unlocked(&joined
, &size
);
2177 fputs("EnvironmentFile=\n", f
);
2179 STRV_FOREACH(i
, c
->environment_files
) {
2180 _cleanup_free_
char *q
= NULL
;
2182 q
= specifier_escape(*i
);
2186 fprintf(f
, "EnvironmentFile=%s\n", q
);
2189 while ((r
= sd_bus_message_enter_container(message
, 'r', "sb")) > 0) {
2193 r
= sd_bus_message_read(message
, "sb", &path
, &b
);
2197 r
= sd_bus_message_exit_container(message
);
2201 if (!path_is_absolute(path
))
2202 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Path %s is not absolute.", path
);
2204 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
2205 _cleanup_free_
char *q
= NULL
, *buf
= NULL
;
2207 buf
= strjoin(b
? "-" : "", path
);
2211 q
= specifier_escape(buf
);
2215 fprintf(f
, "EnvironmentFile=%s\n", q
);
2217 r
= strv_consume(&l
, TAKE_PTR(buf
));
2225 r
= sd_bus_message_exit_container(message
);
2229 r
= fflush_and_check(f
);
2233 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
2234 if (strv_isempty(l
)) {
2235 c
->environment_files
= strv_free(c
->environment_files
);
2236 unit_write_setting(u
, flags
, name
, "EnvironmentFile=");
2238 r
= strv_extend_strv(&c
->environment_files
, l
, true);
2242 unit_write_setting(u
, flags
, name
, joined
);
2248 } else if (streq(name
, "PassEnvironment")) {
2250 _cleanup_strv_free_
char **l
= NULL
;
2252 r
= sd_bus_message_read_strv(message
, &l
);
2256 if (!strv_env_name_is_valid(l
))
2257 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Invalid PassEnvironment= block.");
2259 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
2260 if (strv_isempty(l
)) {
2261 c
->pass_environment
= strv_free(c
->pass_environment
);
2262 unit_write_setting(u
, flags
, name
, "PassEnvironment=");
2264 _cleanup_free_
char *joined
= NULL
;
2266 r
= strv_extend_strv(&c
->pass_environment
, l
, true);
2270 /* We write just the new settings out to file, with unresolved specifiers. */
2271 joined
= unit_concat_strv(l
, UNIT_ESCAPE_SPECIFIERS
);
2275 unit_write_settingf(u
, flags
, name
, "PassEnvironment=%s", joined
);
2281 } else if (STR_IN_SET(name
, "ReadWriteDirectories", "ReadOnlyDirectories", "InaccessibleDirectories",
2282 "ReadWritePaths", "ReadOnlyPaths", "InaccessiblePaths")) {
2283 _cleanup_strv_free_
char **l
= NULL
;
2287 r
= sd_bus_message_read_strv(message
, &l
);
2291 STRV_FOREACH(p
, l
) {
2295 offset
= i
[0] == '-';
2296 offset
+= i
[offset
] == '+';
2297 if (!path_is_absolute(i
+ offset
))
2298 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Invalid %s", name
);
2300 path_simplify(i
+ offset
, false);
2303 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
2304 if (STR_IN_SET(name
, "ReadWriteDirectories", "ReadWritePaths"))
2305 dirs
= &c
->read_write_paths
;
2306 else if (STR_IN_SET(name
, "ReadOnlyDirectories", "ReadOnlyPaths"))
2307 dirs
= &c
->read_only_paths
;
2308 else /* "InaccessiblePaths" */
2309 dirs
= &c
->inaccessible_paths
;
2311 if (strv_isempty(l
)) {
2312 *dirs
= strv_free(*dirs
);
2313 unit_write_settingf(u
, flags
, name
, "%s=", name
);
2315 _cleanup_free_
char *joined
= NULL
;
2317 joined
= unit_concat_strv(l
, UNIT_ESCAPE_SPECIFIERS
);
2321 r
= strv_extend_strv(dirs
, l
, true);
2325 unit_write_settingf(u
, flags
, name
, "%s=%s", name
, joined
);
2331 } else if (STR_IN_SET(name
, "RuntimeDirectory", "StateDirectory", "CacheDirectory", "LogsDirectory", "ConfigurationDirectory")) {
2332 _cleanup_strv_free_
char **l
= NULL
;
2335 r
= sd_bus_message_read_strv(message
, &l
);
2339 STRV_FOREACH(p
, l
) {
2340 if (!path_is_normalized(*p
))
2341 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "%s= path is not normalized: %s", name
, *p
);
2343 if (path_is_absolute(*p
))
2344 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "%s= path is absolute: %s", name
, *p
);
2346 if (path_startswith(*p
, "private"))
2347 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "%s= path can't be 'private': %s", name
, *p
);
2350 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
2351 ExecDirectoryType i
;
2354 assert_se((i
= exec_directory_type_from_string(name
)) >= 0);
2355 d
= c
->directories
+ i
;
2357 if (strv_isempty(l
)) {
2358 d
->paths
= strv_free(d
->paths
);
2359 unit_write_settingf(u
, flags
, name
, "%s=", name
);
2361 _cleanup_free_
char *joined
= NULL
;
2363 r
= strv_extend_strv(&d
->paths
, l
, true);
2367 joined
= unit_concat_strv(l
, UNIT_ESCAPE_SPECIFIERS
);
2371 unit_write_settingf(u
, flags
, name
, "%s=%s", name
, joined
);
2377 } else if (STR_IN_SET(name
, "AppArmorProfile", "SmackProcessLabel")) {
2381 r
= sd_bus_message_read(message
, "(bs)", &ignore
, &s
);
2385 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
2389 if (streq(name
, "AppArmorProfile")) {
2390 p
= &c
->apparmor_profile
;
2391 b
= &c
->apparmor_profile_ignore
;
2392 } else { /* "SmackProcessLabel" */
2393 p
= &c
->smack_process_label
;
2394 b
= &c
->smack_process_label_ignore
;
2401 if (free_and_strdup(p
, s
) < 0)
2406 unit_write_settingf(u
, flags
|UNIT_ESCAPE_SPECIFIERS
, name
, "%s=%s%s", name
, ignore
? "-" : "", strempty(s
));
2411 } else if (STR_IN_SET(name
, "BindPaths", "BindReadOnlyPaths")) {
2412 char *source
, *destination
;
2414 uint64_t mount_flags
;
2417 r
= sd_bus_message_enter_container(message
, 'a', "(ssbt)");
2421 while ((r
= sd_bus_message_read(message
, "(ssbt)", &source
, &destination
, &ignore_enoent
, &mount_flags
)) > 0) {
2423 if (!path_is_absolute(source
))
2424 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Source path %s is not absolute.", source
);
2425 if (!path_is_absolute(destination
))
2426 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Destination path %s is not absolute.", destination
);
2427 if (!IN_SET(mount_flags
, 0, MS_REC
))
2428 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Unknown mount flags.");
2430 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
2431 r
= bind_mount_add(&c
->bind_mounts
, &c
->n_bind_mounts
,
2434 .destination
= destination
,
2435 .read_only
= !!strstr(name
, "ReadOnly"),
2436 .recursive
= !!(mount_flags
& MS_REC
),
2437 .ignore_enoent
= ignore_enoent
,
2442 unit_write_settingf(
2443 u
, flags
|UNIT_ESCAPE_SPECIFIERS
, name
,
2446 ignore_enoent
? "-" : "",
2449 (mount_flags
& MS_REC
) ? "rbind" : "norbind");
2457 r
= sd_bus_message_exit_container(message
);
2462 bind_mount_free_many(c
->bind_mounts
, c
->n_bind_mounts
);
2463 c
->bind_mounts
= NULL
;
2464 c
->n_bind_mounts
= 0;
2466 unit_write_settingf(u
, flags
, name
, "%s=", name
);
2471 } else if (streq(name
, "TemporaryFileSystem")) {
2472 const char *path
, *options
;
2475 r
= sd_bus_message_enter_container(message
, 'a', "(ss)");
2479 while ((r
= sd_bus_message_read(message
, "(ss)", &path
, &options
)) > 0) {
2481 if (!path_is_absolute(path
))
2482 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Mount point %s is not absolute.", path
);
2484 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
2485 r
= temporary_filesystem_add(&c
->temporary_filesystems
, &c
->n_temporary_filesystems
, path
, options
);
2489 unit_write_settingf(
2490 u
, flags
|UNIT_ESCAPE_SPECIFIERS
, name
,
2502 r
= sd_bus_message_exit_container(message
);
2507 temporary_filesystem_free_many(c
->temporary_filesystems
, c
->n_temporary_filesystems
);
2508 c
->temporary_filesystems
= NULL
;
2509 c
->n_temporary_filesystems
= 0;
2511 unit_write_settingf(u
, flags
, name
, "%s=", name
);
2516 } else if ((suffix
= startswith(name
, "Limit"))) {
2517 const char *soft
= NULL
;
2520 ri
= rlimit_from_string(suffix
);
2522 soft
= endswith(suffix
, "Soft");
2526 n
= strndupa(suffix
, soft
- suffix
);
2527 ri
= rlimit_from_string(n
);
2529 name
= strjoina("Limit", n
);
2537 r
= sd_bus_message_read(message
, "t", &rl
);
2541 if (rl
== (uint64_t) -1)
2546 if ((uint64_t) x
!= rl
)
2550 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
2551 _cleanup_free_
char *f
= NULL
;
2554 if (c
->rlimit
[ri
]) {
2555 nl
= *c
->rlimit
[ri
];
2562 /* When the resource limit is not initialized yet, then assign the value to both fields */
2563 nl
= (struct rlimit
) {
2568 r
= rlimit_format(&nl
, &f
);
2573 *c
->rlimit
[ri
] = nl
;
2575 c
->rlimit
[ri
] = newdup(struct rlimit
, &nl
, 1);
2580 unit_write_settingf(u
, flags
, name
, "%s=%s", name
, f
);