1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
11 #include "alloc-util.h"
12 #include "bus-get-properties.h"
14 #include "capability-util.h"
15 #include "cpu-set-util.h"
16 #include "creds-util.h"
17 #include "dbus-execute.h"
18 #include "dbus-util.h"
20 #include "errno-list.h"
25 #include "hexdecoct.h"
27 #include "ioprio-util.h"
28 #include "journal-file.h"
29 #include "missing_ioprio.h"
30 #include "mountpoint-util.h"
31 #include "namespace.h"
32 #include "parse-util.h"
33 #include "path-util.h"
34 #include "process-util.h"
35 #include "rlimit-util.h"
37 #include "seccomp-util.h"
39 #include "securebits-util.h"
40 #include "specifier.h"
41 #include "stat-util.h"
43 #include "syslog-util.h"
44 #include "unit-printf.h"
45 #include "user-util.h"
48 BUS_DEFINE_PROPERTY_GET_ENUM(bus_property_get_exec_output
, exec_output
, ExecOutput
);
49 static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_exec_input
, exec_input
, ExecInput
);
50 static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_exec_utmp_mode
, exec_utmp_mode
, ExecUtmpMode
);
51 static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_exec_preserve_mode
, exec_preserve_mode
, ExecPreserveMode
);
52 static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_exec_keyring_mode
, exec_keyring_mode
, ExecKeyringMode
);
53 static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_protect_proc
, protect_proc
, ProtectProc
);
54 static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_proc_subset
, proc_subset
, ProcSubset
);
55 static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_protect_home
, protect_home
, ProtectHome
);
56 static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_protect_system
, protect_system
, ProtectSystem
);
57 static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_personality
, personality
, unsigned long);
58 static BUS_DEFINE_PROPERTY_GET(property_get_ioprio
, "i", ExecContext
, exec_context_get_effective_ioprio
);
59 static BUS_DEFINE_PROPERTY_GET(property_get_mount_apivfs
, "b", ExecContext
, exec_context_get_effective_mount_apivfs
);
60 static BUS_DEFINE_PROPERTY_GET2(property_get_ioprio_class
, "i", ExecContext
, exec_context_get_effective_ioprio
, ioprio_prio_class
);
61 static BUS_DEFINE_PROPERTY_GET2(property_get_ioprio_priority
, "i", ExecContext
, exec_context_get_effective_ioprio
, ioprio_prio_data
);
62 static BUS_DEFINE_PROPERTY_GET_GLOBAL(property_get_empty_string
, "s", NULL
);
63 static BUS_DEFINE_PROPERTY_GET_REF(property_get_syslog_level
, "i", int, LOG_PRI
);
64 static BUS_DEFINE_PROPERTY_GET_REF(property_get_syslog_facility
, "i", int, LOG_FAC
);
65 static BUS_DEFINE_PROPERTY_GET(property_get_cpu_affinity_from_numa
, "b", ExecContext
, exec_context_get_cpu_affinity_from_numa
);
67 static int property_get_environment_files(
70 const char *interface
,
72 sd_bus_message
*reply
,
74 sd_bus_error
*error
) {
76 ExecContext
*c
= ASSERT_PTR(userdata
);
82 r
= sd_bus_message_open_container(reply
, 'a', "(sb)");
86 STRV_FOREACH(j
, c
->environment_files
) {
89 r
= sd_bus_message_append(reply
, "(sb)", fn
[0] == '-' ? fn
+ 1 : fn
, fn
[0] == '-');
94 return sd_bus_message_close_container(reply
);
97 static int property_get_oom_score_adjust(
100 const char *interface
,
101 const char *property
,
102 sd_bus_message
*reply
,
104 sd_bus_error
*error
) {
106 ExecContext
*c
= ASSERT_PTR(userdata
);
112 if (c
->oom_score_adjust_set
)
113 n
= c
->oom_score_adjust
;
116 r
= get_oom_score_adjust(&n
);
118 log_debug_errno(r
, "Failed to read /proc/self/oom_score_adj, ignoring: %m");
121 return sd_bus_message_append(reply
, "i", n
);
124 static int property_get_coredump_filter(
127 const char *interface
,
128 const char *property
,
129 sd_bus_message
*reply
,
131 sd_bus_error
*error
) {
133 ExecContext
*c
= ASSERT_PTR(userdata
);
140 if (c
->coredump_filter_set
)
141 n
= c
->coredump_filter
;
143 _cleanup_free_
char *t
= NULL
;
145 n
= COREDUMP_FILTER_MASK_DEFAULT
;
146 r
= read_one_line_file("/proc/self/coredump_filter", &t
);
148 log_debug_errno(r
, "Failed to read /proc/self/coredump_filter, ignoring: %m");
150 r
= safe_atoux64(t
, &n
);
152 log_debug_errno(r
, "Failed to parse \"%s\" from /proc/self/coredump_filter, ignoring: %m", t
);
156 return sd_bus_message_append(reply
, "t", n
);
159 static int property_get_nice(
162 const char *interface
,
163 const char *property
,
164 sd_bus_message
*reply
,
166 sd_bus_error
*error
) {
168 ExecContext
*c
= ASSERT_PTR(userdata
);
178 n
= getpriority(PRIO_PROCESS
, 0);
183 return sd_bus_message_append(reply
, "i", n
);
186 static int property_get_cpu_sched_policy(
189 const char *interface
,
190 const char *property
,
191 sd_bus_message
*reply
,
193 sd_bus_error
*error
) {
195 ExecContext
*c
= ASSERT_PTR(userdata
);
201 if (c
->cpu_sched_set
)
202 n
= c
->cpu_sched_policy
;
204 n
= sched_getscheduler(0);
209 return sd_bus_message_append(reply
, "i", n
);
212 static int property_get_cpu_sched_priority(
215 const char *interface
,
216 const char *property
,
217 sd_bus_message
*reply
,
219 sd_bus_error
*error
) {
221 ExecContext
*c
= ASSERT_PTR(userdata
);
227 if (c
->cpu_sched_set
)
228 n
= c
->cpu_sched_priority
;
230 struct sched_param p
= {};
232 if (sched_getparam(0, &p
) >= 0)
233 n
= p
.sched_priority
;
238 return sd_bus_message_append(reply
, "i", n
);
241 static int property_get_cpu_affinity(
244 const char *interface
,
245 const char *property
,
246 sd_bus_message
*reply
,
248 sd_bus_error
*error
) {
250 ExecContext
*c
= ASSERT_PTR(userdata
);
251 _cleanup_(cpu_set_reset
) CPUSet s
= {};
252 _cleanup_free_
uint8_t *array
= NULL
;
258 if (c
->cpu_affinity_from_numa
) {
261 r
= numa_to_cpu_set(&c
->numa_policy
, &s
);
266 (void) cpu_set_to_dbus(c
->cpu_affinity_from_numa
? &s
: &c
->cpu_set
, &array
, &allocated
);
268 return sd_bus_message_append_array(reply
, 'y', array
, allocated
);
271 static int property_get_numa_mask(
274 const char *interface
,
275 const char *property
,
276 sd_bus_message
*reply
,
278 sd_bus_error
*error
) {
280 ExecContext
*c
= ASSERT_PTR(userdata
);
281 _cleanup_free_
uint8_t *array
= NULL
;
287 (void) cpu_set_to_dbus(&c
->numa_policy
.nodes
, &array
, &allocated
);
289 return sd_bus_message_append_array(reply
, 'y', array
, allocated
);
292 static int property_get_numa_policy(
295 const char *interface
,
296 const char *property
,
297 sd_bus_message
*reply
,
299 sd_bus_error
*error
) {
300 ExecContext
*c
= ASSERT_PTR(userdata
);
306 policy
= numa_policy_get_type(&c
->numa_policy
);
308 return sd_bus_message_append_basic(reply
, 'i', &policy
);
311 static int property_get_timer_slack_nsec(
314 const char *interface
,
315 const char *property
,
316 sd_bus_message
*reply
,
318 sd_bus_error
*error
) {
320 ExecContext
*c
= ASSERT_PTR(userdata
);
326 if (c
->timer_slack_nsec
!= NSEC_INFINITY
)
327 u
= (uint64_t) c
->timer_slack_nsec
;
329 u
= (uint64_t) prctl(PR_GET_TIMERSLACK
);
331 return sd_bus_message_append(reply
, "t", u
);
334 static int property_get_syscall_filter(
337 const char *interface
,
338 const char *property
,
339 sd_bus_message
*reply
,
341 sd_bus_error
*error
) {
343 ExecContext
*c
= ASSERT_PTR(userdata
);
344 _cleanup_strv_free_
char **l
= NULL
;
350 r
= sd_bus_message_open_container(reply
, 'r', "bas");
354 r
= sd_bus_message_append(reply
, "b", c
->syscall_allow_list
);
360 HASHMAP_FOREACH_KEY(val
, id
, c
->syscall_filter
) {
361 _cleanup_free_
char *name
= NULL
;
362 const char *e
= NULL
;
364 int num
= PTR_TO_INT(val
);
366 if (c
->syscall_allow_list
&& num
>= 0)
367 /* syscall with num >= 0 in allow-list is denied. */
370 name
= seccomp_syscall_resolve_num_arch(SCMP_ARCH_NATIVE
, PTR_TO_INT(id
) - 1);
375 e
= seccomp_errno_or_action_to_string(num
);
377 s
= strjoin(name
, ":", e
);
381 r
= asprintf(&s
, "%s:%d", name
, num
);
388 r
= strv_consume(&l
, s
);
396 r
= sd_bus_message_append_strv(reply
, l
);
400 return sd_bus_message_close_container(reply
);
403 static int property_get_syscall_log(
406 const char *interface
,
407 const char *property
,
408 sd_bus_message
*reply
,
410 sd_bus_error
*error
) {
412 ExecContext
*c
= ASSERT_PTR(userdata
);
413 _cleanup_strv_free_
char **l
= NULL
;
419 r
= sd_bus_message_open_container(reply
, 'r', "bas");
423 r
= sd_bus_message_append(reply
, "b", c
->syscall_log_allow_list
);
429 HASHMAP_FOREACH_KEY(val
, id
, c
->syscall_log
) {
432 name
= seccomp_syscall_resolve_num_arch(SCMP_ARCH_NATIVE
, PTR_TO_INT(id
) - 1);
436 r
= strv_consume(&l
, name
);
444 r
= sd_bus_message_append_strv(reply
, l
);
448 return sd_bus_message_close_container(reply
);
451 static int property_get_syscall_archs(
454 const char *interface
,
455 const char *property
,
456 sd_bus_message
*reply
,
458 sd_bus_error
*error
) {
460 ExecContext
*c
= ASSERT_PTR(userdata
);
461 _cleanup_strv_free_
char **l
= NULL
;
469 SET_FOREACH(id
, c
->syscall_archs
) {
472 name
= seccomp_arch_to_string(PTR_TO_UINT32(id
) - 1);
476 r
= strv_extend(&l
, name
);
484 r
= sd_bus_message_append_strv(reply
, l
);
491 static int property_get_selinux_context(
494 const char *interface
,
495 const char *property
,
496 sd_bus_message
*reply
,
498 sd_bus_error
*error
) {
500 ExecContext
*c
= ASSERT_PTR(userdata
);
505 return sd_bus_message_append(reply
, "(bs)", c
->selinux_context_ignore
, c
->selinux_context
);
508 static int property_get_apparmor_profile(
511 const char *interface
,
512 const char *property
,
513 sd_bus_message
*reply
,
515 sd_bus_error
*error
) {
517 ExecContext
*c
= ASSERT_PTR(userdata
);
522 return sd_bus_message_append(reply
, "(bs)", c
->apparmor_profile_ignore
, c
->apparmor_profile
);
525 static int property_get_smack_process_label(
528 const char *interface
,
529 const char *property
,
530 sd_bus_message
*reply
,
532 sd_bus_error
*error
) {
534 ExecContext
*c
= ASSERT_PTR(userdata
);
539 return sd_bus_message_append(reply
, "(bs)", c
->smack_process_label_ignore
, c
->smack_process_label
);
542 static int property_get_address_families(
545 const char *interface
,
546 const char *property
,
547 sd_bus_message
*reply
,
549 sd_bus_error
*error
) {
551 ExecContext
*c
= ASSERT_PTR(userdata
);
552 _cleanup_strv_free_
char **l
= NULL
;
559 r
= sd_bus_message_open_container(reply
, 'r', "bas");
563 r
= sd_bus_message_append(reply
, "b", c
->address_families_allow_list
);
567 SET_FOREACH(af
, c
->address_families
) {
570 name
= af_to_name(PTR_TO_INT(af
));
574 r
= strv_extend(&l
, name
);
581 r
= sd_bus_message_append_strv(reply
, l
);
585 return sd_bus_message_close_container(reply
);
588 static int property_get_working_directory(
591 const char *interface
,
592 const char *property
,
593 sd_bus_message
*reply
,
595 sd_bus_error
*error
) {
597 ExecContext
*c
= ASSERT_PTR(userdata
);
603 if (c
->working_directory_home
)
606 wd
= c
->working_directory
;
608 if (c
->working_directory_missing_ok
)
609 wd
= strjoina("!", wd
);
611 return sd_bus_message_append(reply
, "s", wd
);
614 static int property_get_stdio_fdname(
617 const char *interface
,
618 const char *property
,
619 sd_bus_message
*reply
,
621 sd_bus_error
*error
) {
623 ExecContext
*c
= ASSERT_PTR(userdata
);
630 if (streq(property
, "StandardInputFileDescriptorName"))
631 fileno
= STDIN_FILENO
;
632 else if (streq(property
, "StandardOutputFileDescriptorName"))
633 fileno
= STDOUT_FILENO
;
635 assert(streq(property
, "StandardErrorFileDescriptorName"));
636 fileno
= STDERR_FILENO
;
639 return sd_bus_message_append(reply
, "s", exec_context_fdname(c
, fileno
));
642 static int property_get_input_data(
645 const char *interface
,
646 const char *property
,
647 sd_bus_message
*reply
,
649 sd_bus_error
*error
) {
651 ExecContext
*c
= ASSERT_PTR(userdata
);
657 return sd_bus_message_append_array(reply
, 'y', c
->stdin_data
, c
->stdin_data_size
);
660 static int property_get_restrict_filesystems(
663 const char *interface
,
664 const char *property
,
665 sd_bus_message
*reply
,
667 sd_bus_error
*error
) {
669 ExecContext
*c
= ASSERT_PTR(userdata
);
670 _cleanup_free_
char **l
= NULL
;
676 r
= sd_bus_message_open_container(reply
, 'r', "bas");
680 r
= sd_bus_message_append(reply
, "b", c
->restrict_filesystems_allow_list
);
685 l
= set_get_strv(c
->restrict_filesystems
);
692 r
= sd_bus_message_append_strv(reply
, l
);
696 return sd_bus_message_close_container(reply
);
699 static int property_get_bind_paths(
702 const char *interface
,
703 const char *property
,
704 sd_bus_message
*reply
,
706 sd_bus_error
*error
) {
708 ExecContext
*c
= ASSERT_PTR(userdata
);
716 ro
= strstr(property
, "ReadOnly");
718 r
= sd_bus_message_open_container(reply
, 'a', "(ssbt)");
722 for (size_t i
= 0; i
< c
->n_bind_mounts
; i
++) {
724 if (ro
!= c
->bind_mounts
[i
].read_only
)
727 r
= sd_bus_message_append(
729 c
->bind_mounts
[i
].source
,
730 c
->bind_mounts
[i
].destination
,
731 c
->bind_mounts
[i
].ignore_enoent
,
732 c
->bind_mounts
[i
].recursive
? (uint64_t) MS_REC
: (uint64_t) 0);
737 return sd_bus_message_close_container(reply
);
740 static int property_get_temporary_filesystems(
743 const char *interface
,
744 const char *property
,
745 sd_bus_message
*reply
,
747 sd_bus_error
*error
) {
749 ExecContext
*c
= ASSERT_PTR(userdata
);
756 r
= sd_bus_message_open_container(reply
, 'a', "(ss)");
760 for (unsigned i
= 0; i
< c
->n_temporary_filesystems
; i
++) {
761 TemporaryFileSystem
*t
= c
->temporary_filesystems
+ i
;
763 r
= sd_bus_message_append(
771 return sd_bus_message_close_container(reply
);
774 static int property_get_log_extra_fields(
777 const char *interface
,
778 const char *property
,
779 sd_bus_message
*reply
,
781 sd_bus_error
*error
) {
783 ExecContext
*c
= ASSERT_PTR(userdata
);
790 r
= sd_bus_message_open_container(reply
, 'a', "ay");
794 for (size_t i
= 0; i
< c
->n_log_extra_fields
; i
++) {
795 r
= sd_bus_message_append_array(reply
, 'y', c
->log_extra_fields
[i
].iov_base
, c
->log_extra_fields
[i
].iov_len
);
800 return sd_bus_message_close_container(reply
);
803 static int property_get_set_credential(
806 const char *interface
,
807 const char *property
,
808 sd_bus_message
*reply
,
810 sd_bus_error
*error
) {
812 ExecContext
*c
= ASSERT_PTR(userdata
);
813 ExecSetCredential
*sc
;
820 r
= sd_bus_message_open_container(reply
, 'a', "(say)");
824 HASHMAP_FOREACH(sc
, c
->set_credentials
) {
826 if (sc
->encrypted
!= streq(property
, "SetCredentialEncrypted"))
829 r
= sd_bus_message_open_container(reply
, 'r', "say");
833 r
= sd_bus_message_append(reply
, "s", sc
->id
);
837 r
= sd_bus_message_append_array(reply
, 'y', sc
->data
, sc
->size
);
841 r
= sd_bus_message_close_container(reply
);
846 return sd_bus_message_close_container(reply
);
849 static int property_get_load_credential(
852 const char *interface
,
853 const char *property
,
854 sd_bus_message
*reply
,
856 sd_bus_error
*error
) {
858 ExecContext
*c
= ASSERT_PTR(userdata
);
859 ExecLoadCredential
*lc
;
866 r
= sd_bus_message_open_container(reply
, 'a', "(ss)");
870 HASHMAP_FOREACH(lc
, c
->load_credentials
) {
872 if (lc
->encrypted
!= streq(property
, "LoadCredentialEncrypted"))
875 r
= sd_bus_message_append(reply
, "(ss)", lc
->id
, lc
->path
);
880 return sd_bus_message_close_container(reply
);
883 static int property_get_root_hash(
886 const char *interface
,
887 const char *property
,
888 sd_bus_message
*reply
,
890 sd_bus_error
*error
) {
892 ExecContext
*c
= ASSERT_PTR(userdata
);
898 return sd_bus_message_append_array(reply
, 'y', c
->root_hash
, c
->root_hash_size
);
901 static int property_get_root_hash_sig(
904 const char *interface
,
905 const char *property
,
906 sd_bus_message
*reply
,
908 sd_bus_error
*error
) {
910 ExecContext
*c
= ASSERT_PTR(userdata
);
916 return sd_bus_message_append_array(reply
, 'y', c
->root_hash_sig
, c
->root_hash_sig_size
);
919 static int property_get_root_image_options(
922 const char *interface
,
923 const char *property
,
924 sd_bus_message
*reply
,
926 sd_bus_error
*error
) {
928 ExecContext
*c
= ASSERT_PTR(userdata
);
935 r
= sd_bus_message_open_container(reply
, 'a', "(ss)");
939 LIST_FOREACH(mount_options
, m
, c
->root_image_options
) {
940 r
= sd_bus_message_append(reply
, "(ss)",
941 partition_designator_to_string(m
->partition_designator
),
947 return sd_bus_message_close_container(reply
);
950 static int property_get_mount_images(
953 const char *interface
,
954 const char *property
,
955 sd_bus_message
*reply
,
957 sd_bus_error
*error
) {
959 ExecContext
*c
= ASSERT_PTR(userdata
);
966 r
= sd_bus_message_open_container(reply
, 'a', "(ssba(ss))");
970 for (size_t i
= 0; i
< c
->n_mount_images
; i
++) {
971 r
= sd_bus_message_open_container(reply
, SD_BUS_TYPE_STRUCT
, "ssba(ss)");
974 r
= sd_bus_message_append(
976 c
->mount_images
[i
].source
,
977 c
->mount_images
[i
].destination
,
978 c
->mount_images
[i
].ignore_enoent
);
981 r
= sd_bus_message_open_container(reply
, 'a', "(ss)");
984 LIST_FOREACH(mount_options
, m
, c
->mount_images
[i
].mount_options
) {
985 r
= sd_bus_message_append(reply
, "(ss)",
986 partition_designator_to_string(m
->partition_designator
),
991 r
= sd_bus_message_close_container(reply
);
994 r
= sd_bus_message_close_container(reply
);
999 return sd_bus_message_close_container(reply
);
1002 static int property_get_extension_images(
1005 const char *interface
,
1006 const char *property
,
1007 sd_bus_message
*reply
,
1009 sd_bus_error
*error
) {
1011 ExecContext
*c
= ASSERT_PTR(userdata
);
1018 r
= sd_bus_message_open_container(reply
, 'a', "(sba(ss))");
1022 for (size_t i
= 0; i
< c
->n_extension_images
; i
++) {
1023 r
= sd_bus_message_open_container(reply
, SD_BUS_TYPE_STRUCT
, "sba(ss)");
1026 r
= sd_bus_message_append(
1028 c
->extension_images
[i
].source
,
1029 c
->extension_images
[i
].ignore_enoent
);
1032 r
= sd_bus_message_open_container(reply
, 'a', "(ss)");
1035 LIST_FOREACH(mount_options
, m
, c
->extension_images
[i
].mount_options
) {
1036 r
= sd_bus_message_append(reply
, "(ss)",
1037 partition_designator_to_string(m
->partition_designator
),
1042 r
= sd_bus_message_close_container(reply
);
1045 r
= sd_bus_message_close_container(reply
);
1050 return sd_bus_message_close_container(reply
);
1053 static int bus_property_get_exec_dir(
1056 const char *interface
,
1057 const char *property
,
1058 sd_bus_message
*reply
,
1060 sd_bus_error
*error
) {
1062 ExecDirectory
*d
= ASSERT_PTR(userdata
);
1069 r
= sd_bus_message_open_container(reply
, 'a', "s");
1073 for (size_t i
= 0; i
< d
->n_items
; i
++) {
1074 r
= sd_bus_message_append_basic(reply
, 's', d
->items
[i
].path
);
1079 return sd_bus_message_close_container(reply
);
1082 static int bus_property_get_exec_dir_symlink(
1085 const char *interface
,
1086 const char *property
,
1087 sd_bus_message
*reply
,
1089 sd_bus_error
*error
) {
1091 ExecDirectory
*d
= ASSERT_PTR(userdata
);
1098 r
= sd_bus_message_open_container(reply
, 'a', "(sst)");
1102 for (size_t i
= 0; i
< d
->n_items
; i
++)
1103 STRV_FOREACH(dst
, d
->items
[i
].symlinks
) {
1104 r
= sd_bus_message_append(reply
, "(sst)", d
->items
[i
].path
, *dst
, 0 /* flags, unused for now */);
1109 return sd_bus_message_close_container(reply
);
1112 const sd_bus_vtable bus_exec_vtable
[] = {
1113 SD_BUS_VTABLE_START(0),
1114 SD_BUS_PROPERTY("Environment", "as", NULL
, offsetof(ExecContext
, environment
), SD_BUS_VTABLE_PROPERTY_CONST
),
1115 SD_BUS_PROPERTY("EnvironmentFiles", "a(sb)", property_get_environment_files
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
1116 SD_BUS_PROPERTY("PassEnvironment", "as", NULL
, offsetof(ExecContext
, pass_environment
), SD_BUS_VTABLE_PROPERTY_CONST
),
1117 SD_BUS_PROPERTY("UnsetEnvironment", "as", NULL
, offsetof(ExecContext
, unset_environment
), SD_BUS_VTABLE_PROPERTY_CONST
),
1118 SD_BUS_PROPERTY("UMask", "u", bus_property_get_mode
, offsetof(ExecContext
, umask
), SD_BUS_VTABLE_PROPERTY_CONST
),
1119 SD_BUS_PROPERTY("LimitCPU", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_CPU
]), SD_BUS_VTABLE_PROPERTY_CONST
),
1120 SD_BUS_PROPERTY("LimitCPUSoft", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_CPU
]), SD_BUS_VTABLE_PROPERTY_CONST
),
1121 SD_BUS_PROPERTY("LimitFSIZE", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_FSIZE
]), SD_BUS_VTABLE_PROPERTY_CONST
),
1122 SD_BUS_PROPERTY("LimitFSIZESoft", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_FSIZE
]), SD_BUS_VTABLE_PROPERTY_CONST
),
1123 SD_BUS_PROPERTY("LimitDATA", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_DATA
]), SD_BUS_VTABLE_PROPERTY_CONST
),
1124 SD_BUS_PROPERTY("LimitDATASoft", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_DATA
]), SD_BUS_VTABLE_PROPERTY_CONST
),
1125 SD_BUS_PROPERTY("LimitSTACK", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_STACK
]), SD_BUS_VTABLE_PROPERTY_CONST
),
1126 SD_BUS_PROPERTY("LimitSTACKSoft", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_STACK
]), SD_BUS_VTABLE_PROPERTY_CONST
),
1127 SD_BUS_PROPERTY("LimitCORE", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_CORE
]), SD_BUS_VTABLE_PROPERTY_CONST
),
1128 SD_BUS_PROPERTY("LimitCORESoft", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_CORE
]), SD_BUS_VTABLE_PROPERTY_CONST
),
1129 SD_BUS_PROPERTY("LimitRSS", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_RSS
]), SD_BUS_VTABLE_PROPERTY_CONST
),
1130 SD_BUS_PROPERTY("LimitRSSSoft", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_RSS
]), SD_BUS_VTABLE_PROPERTY_CONST
),
1131 SD_BUS_PROPERTY("LimitNOFILE", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_NOFILE
]), SD_BUS_VTABLE_PROPERTY_CONST
),
1132 SD_BUS_PROPERTY("LimitNOFILESoft", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_NOFILE
]), SD_BUS_VTABLE_PROPERTY_CONST
),
1133 SD_BUS_PROPERTY("LimitAS", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_AS
]), SD_BUS_VTABLE_PROPERTY_CONST
),
1134 SD_BUS_PROPERTY("LimitASSoft", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_AS
]), SD_BUS_VTABLE_PROPERTY_CONST
),
1135 SD_BUS_PROPERTY("LimitNPROC", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_NPROC
]), SD_BUS_VTABLE_PROPERTY_CONST
),
1136 SD_BUS_PROPERTY("LimitNPROCSoft", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_NPROC
]), SD_BUS_VTABLE_PROPERTY_CONST
),
1137 SD_BUS_PROPERTY("LimitMEMLOCK", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_MEMLOCK
]), SD_BUS_VTABLE_PROPERTY_CONST
),
1138 SD_BUS_PROPERTY("LimitMEMLOCKSoft", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_MEMLOCK
]), SD_BUS_VTABLE_PROPERTY_CONST
),
1139 SD_BUS_PROPERTY("LimitLOCKS", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_LOCKS
]), SD_BUS_VTABLE_PROPERTY_CONST
),
1140 SD_BUS_PROPERTY("LimitLOCKSSoft", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_LOCKS
]), SD_BUS_VTABLE_PROPERTY_CONST
),
1141 SD_BUS_PROPERTY("LimitSIGPENDING", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_SIGPENDING
]), SD_BUS_VTABLE_PROPERTY_CONST
),
1142 SD_BUS_PROPERTY("LimitSIGPENDINGSoft", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_SIGPENDING
]), SD_BUS_VTABLE_PROPERTY_CONST
),
1143 SD_BUS_PROPERTY("LimitMSGQUEUE", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_MSGQUEUE
]), SD_BUS_VTABLE_PROPERTY_CONST
),
1144 SD_BUS_PROPERTY("LimitMSGQUEUESoft", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_MSGQUEUE
]), SD_BUS_VTABLE_PROPERTY_CONST
),
1145 SD_BUS_PROPERTY("LimitNICE", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_NICE
]), SD_BUS_VTABLE_PROPERTY_CONST
),
1146 SD_BUS_PROPERTY("LimitNICESoft", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_NICE
]), SD_BUS_VTABLE_PROPERTY_CONST
),
1147 SD_BUS_PROPERTY("LimitRTPRIO", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_RTPRIO
]), SD_BUS_VTABLE_PROPERTY_CONST
),
1148 SD_BUS_PROPERTY("LimitRTPRIOSoft", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_RTPRIO
]), SD_BUS_VTABLE_PROPERTY_CONST
),
1149 SD_BUS_PROPERTY("LimitRTTIME", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_RTTIME
]), SD_BUS_VTABLE_PROPERTY_CONST
),
1150 SD_BUS_PROPERTY("LimitRTTIMESoft", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_RTTIME
]), SD_BUS_VTABLE_PROPERTY_CONST
),
1151 SD_BUS_PROPERTY("WorkingDirectory", "s", property_get_working_directory
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
1152 SD_BUS_PROPERTY("RootDirectory", "s", NULL
, offsetof(ExecContext
, root_directory
), SD_BUS_VTABLE_PROPERTY_CONST
),
1153 SD_BUS_PROPERTY("RootImage", "s", NULL
, offsetof(ExecContext
, root_image
), SD_BUS_VTABLE_PROPERTY_CONST
),
1154 SD_BUS_PROPERTY("RootImageOptions", "a(ss)", property_get_root_image_options
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
1155 SD_BUS_PROPERTY("RootHash", "ay", property_get_root_hash
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
1156 SD_BUS_PROPERTY("RootHashPath", "s", NULL
, offsetof(ExecContext
, root_hash_path
), SD_BUS_VTABLE_PROPERTY_CONST
),
1157 SD_BUS_PROPERTY("RootHashSignature", "ay", property_get_root_hash_sig
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
1158 SD_BUS_PROPERTY("RootHashSignaturePath", "s", NULL
, offsetof(ExecContext
, root_hash_sig_path
), SD_BUS_VTABLE_PROPERTY_CONST
),
1159 SD_BUS_PROPERTY("RootVerity", "s", NULL
, offsetof(ExecContext
, root_verity
), SD_BUS_VTABLE_PROPERTY_CONST
),
1160 SD_BUS_PROPERTY("ExtensionDirectories", "as", NULL
, offsetof(ExecContext
, extension_directories
), SD_BUS_VTABLE_PROPERTY_CONST
),
1161 SD_BUS_PROPERTY("ExtensionImages", "a(sba(ss))", property_get_extension_images
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
1162 SD_BUS_PROPERTY("MountImages", "a(ssba(ss))", property_get_mount_images
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
1163 SD_BUS_PROPERTY("OOMScoreAdjust", "i", property_get_oom_score_adjust
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
1164 SD_BUS_PROPERTY("CoredumpFilter", "t", property_get_coredump_filter
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
1165 SD_BUS_PROPERTY("Nice", "i", property_get_nice
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
1166 SD_BUS_PROPERTY("IOSchedulingClass", "i", property_get_ioprio_class
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
1167 SD_BUS_PROPERTY("IOSchedulingPriority", "i", property_get_ioprio_priority
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
1168 SD_BUS_PROPERTY("CPUSchedulingPolicy", "i", property_get_cpu_sched_policy
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
1169 SD_BUS_PROPERTY("CPUSchedulingPriority", "i", property_get_cpu_sched_priority
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
1170 SD_BUS_PROPERTY("CPUAffinity", "ay", property_get_cpu_affinity
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
1171 SD_BUS_PROPERTY("CPUAffinityFromNUMA", "b", property_get_cpu_affinity_from_numa
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
1172 SD_BUS_PROPERTY("NUMAPolicy", "i", property_get_numa_policy
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
1173 SD_BUS_PROPERTY("NUMAMask", "ay", property_get_numa_mask
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
1174 SD_BUS_PROPERTY("TimerSlackNSec", "t", property_get_timer_slack_nsec
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
1175 SD_BUS_PROPERTY("CPUSchedulingResetOnFork", "b", bus_property_get_bool
, offsetof(ExecContext
, cpu_sched_reset_on_fork
), SD_BUS_VTABLE_PROPERTY_CONST
),
1176 SD_BUS_PROPERTY("NonBlocking", "b", bus_property_get_bool
, offsetof(ExecContext
, non_blocking
), SD_BUS_VTABLE_PROPERTY_CONST
),
1177 SD_BUS_PROPERTY("StandardInput", "s", property_get_exec_input
, offsetof(ExecContext
, std_input
), SD_BUS_VTABLE_PROPERTY_CONST
),
1178 SD_BUS_PROPERTY("StandardInputFileDescriptorName", "s", property_get_stdio_fdname
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
1179 SD_BUS_PROPERTY("StandardInputData", "ay", property_get_input_data
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
1180 SD_BUS_PROPERTY("StandardOutput", "s", bus_property_get_exec_output
, offsetof(ExecContext
, std_output
), SD_BUS_VTABLE_PROPERTY_CONST
),
1181 SD_BUS_PROPERTY("StandardOutputFileDescriptorName", "s", property_get_stdio_fdname
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
1182 SD_BUS_PROPERTY("StandardError", "s", bus_property_get_exec_output
, offsetof(ExecContext
, std_error
), SD_BUS_VTABLE_PROPERTY_CONST
),
1183 SD_BUS_PROPERTY("StandardErrorFileDescriptorName", "s", property_get_stdio_fdname
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
1184 SD_BUS_PROPERTY("TTYPath", "s", NULL
, offsetof(ExecContext
, tty_path
), SD_BUS_VTABLE_PROPERTY_CONST
),
1185 SD_BUS_PROPERTY("TTYReset", "b", bus_property_get_bool
, offsetof(ExecContext
, tty_reset
), SD_BUS_VTABLE_PROPERTY_CONST
),
1186 SD_BUS_PROPERTY("TTYVHangup", "b", bus_property_get_bool
, offsetof(ExecContext
, tty_vhangup
), SD_BUS_VTABLE_PROPERTY_CONST
),
1187 SD_BUS_PROPERTY("TTYVTDisallocate", "b", bus_property_get_bool
, offsetof(ExecContext
, tty_vt_disallocate
), SD_BUS_VTABLE_PROPERTY_CONST
),
1188 SD_BUS_PROPERTY("TTYRows", "q", bus_property_get_unsigned
, offsetof(ExecContext
, tty_rows
), SD_BUS_VTABLE_PROPERTY_CONST
),
1189 SD_BUS_PROPERTY("TTYColumns", "q", bus_property_get_unsigned
, offsetof(ExecContext
, tty_cols
), SD_BUS_VTABLE_PROPERTY_CONST
),
1190 SD_BUS_PROPERTY("SyslogPriority", "i", bus_property_get_int
, offsetof(ExecContext
, syslog_priority
), SD_BUS_VTABLE_PROPERTY_CONST
),
1191 SD_BUS_PROPERTY("SyslogIdentifier", "s", NULL
, offsetof(ExecContext
, syslog_identifier
), SD_BUS_VTABLE_PROPERTY_CONST
),
1192 SD_BUS_PROPERTY("SyslogLevelPrefix", "b", bus_property_get_bool
, offsetof(ExecContext
, syslog_level_prefix
), SD_BUS_VTABLE_PROPERTY_CONST
),
1193 SD_BUS_PROPERTY("SyslogLevel", "i", property_get_syslog_level
, offsetof(ExecContext
, syslog_priority
), SD_BUS_VTABLE_PROPERTY_CONST
),
1194 SD_BUS_PROPERTY("SyslogFacility", "i", property_get_syslog_facility
, offsetof(ExecContext
, syslog_priority
), SD_BUS_VTABLE_PROPERTY_CONST
),
1195 SD_BUS_PROPERTY("LogLevelMax", "i", bus_property_get_int
, offsetof(ExecContext
, log_level_max
), SD_BUS_VTABLE_PROPERTY_CONST
),
1196 SD_BUS_PROPERTY("LogRateLimitIntervalUSec", "t", bus_property_get_usec
, offsetof(ExecContext
, log_ratelimit_interval_usec
), SD_BUS_VTABLE_PROPERTY_CONST
),
1197 SD_BUS_PROPERTY("LogRateLimitBurst", "u", bus_property_get_unsigned
, offsetof(ExecContext
, log_ratelimit_burst
), SD_BUS_VTABLE_PROPERTY_CONST
),
1198 SD_BUS_PROPERTY("LogExtraFields", "aay", property_get_log_extra_fields
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
1199 SD_BUS_PROPERTY("LogNamespace", "s", NULL
, offsetof(ExecContext
, log_namespace
), SD_BUS_VTABLE_PROPERTY_CONST
),
1200 SD_BUS_PROPERTY("SecureBits", "i", bus_property_get_int
, offsetof(ExecContext
, secure_bits
), SD_BUS_VTABLE_PROPERTY_CONST
),
1201 SD_BUS_PROPERTY("CapabilityBoundingSet", "t", NULL
, offsetof(ExecContext
, capability_bounding_set
), SD_BUS_VTABLE_PROPERTY_CONST
),
1202 SD_BUS_PROPERTY("AmbientCapabilities", "t", NULL
, offsetof(ExecContext
, capability_ambient_set
), SD_BUS_VTABLE_PROPERTY_CONST
),
1203 SD_BUS_PROPERTY("User", "s", NULL
, offsetof(ExecContext
, user
), SD_BUS_VTABLE_PROPERTY_CONST
),
1204 SD_BUS_PROPERTY("Group", "s", NULL
, offsetof(ExecContext
, group
), SD_BUS_VTABLE_PROPERTY_CONST
),
1205 SD_BUS_PROPERTY("DynamicUser", "b", bus_property_get_bool
, offsetof(ExecContext
, dynamic_user
), SD_BUS_VTABLE_PROPERTY_CONST
),
1206 SD_BUS_PROPERTY("RemoveIPC", "b", bus_property_get_bool
, offsetof(ExecContext
, remove_ipc
), SD_BUS_VTABLE_PROPERTY_CONST
),
1207 SD_BUS_PROPERTY("SetCredential", "a(say)", property_get_set_credential
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
1208 SD_BUS_PROPERTY("SetCredentialEncrypted", "a(say)", property_get_set_credential
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
1209 SD_BUS_PROPERTY("LoadCredential", "a(ss)", property_get_load_credential
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
1210 SD_BUS_PROPERTY("LoadCredentialEncrypted", "a(ss)", property_get_load_credential
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
1211 SD_BUS_PROPERTY("SupplementaryGroups", "as", NULL
, offsetof(ExecContext
, supplementary_groups
), SD_BUS_VTABLE_PROPERTY_CONST
),
1212 SD_BUS_PROPERTY("PAMName", "s", NULL
, offsetof(ExecContext
, pam_name
), SD_BUS_VTABLE_PROPERTY_CONST
),
1213 SD_BUS_PROPERTY("ReadWritePaths", "as", NULL
, offsetof(ExecContext
, read_write_paths
), SD_BUS_VTABLE_PROPERTY_CONST
),
1214 SD_BUS_PROPERTY("ReadOnlyPaths", "as", NULL
, offsetof(ExecContext
, read_only_paths
), SD_BUS_VTABLE_PROPERTY_CONST
),
1215 SD_BUS_PROPERTY("InaccessiblePaths", "as", NULL
, offsetof(ExecContext
, inaccessible_paths
), SD_BUS_VTABLE_PROPERTY_CONST
),
1216 SD_BUS_PROPERTY("ExecPaths", "as", NULL
, offsetof(ExecContext
, exec_paths
), SD_BUS_VTABLE_PROPERTY_CONST
),
1217 SD_BUS_PROPERTY("NoExecPaths", "as", NULL
, offsetof(ExecContext
, no_exec_paths
), SD_BUS_VTABLE_PROPERTY_CONST
),
1218 SD_BUS_PROPERTY("ExecSearchPath", "as", NULL
, offsetof(ExecContext
, exec_search_path
), SD_BUS_VTABLE_PROPERTY_CONST
),
1219 SD_BUS_PROPERTY("MountFlags", "t", bus_property_get_ulong
, offsetof(ExecContext
, mount_flags
), SD_BUS_VTABLE_PROPERTY_CONST
),
1220 SD_BUS_PROPERTY("PrivateTmp", "b", bus_property_get_bool
, offsetof(ExecContext
, private_tmp
), SD_BUS_VTABLE_PROPERTY_CONST
),
1221 SD_BUS_PROPERTY("PrivateDevices", "b", bus_property_get_bool
, offsetof(ExecContext
, private_devices
), SD_BUS_VTABLE_PROPERTY_CONST
),
1222 SD_BUS_PROPERTY("ProtectClock", "b", bus_property_get_bool
, offsetof(ExecContext
, protect_clock
), SD_BUS_VTABLE_PROPERTY_CONST
),
1223 SD_BUS_PROPERTY("ProtectKernelTunables", "b", bus_property_get_bool
, offsetof(ExecContext
, protect_kernel_tunables
), SD_BUS_VTABLE_PROPERTY_CONST
),
1224 SD_BUS_PROPERTY("ProtectKernelModules", "b", bus_property_get_bool
, offsetof(ExecContext
, protect_kernel_modules
), SD_BUS_VTABLE_PROPERTY_CONST
),
1225 SD_BUS_PROPERTY("ProtectKernelLogs", "b", bus_property_get_bool
, offsetof(ExecContext
, protect_kernel_logs
), SD_BUS_VTABLE_PROPERTY_CONST
),
1226 SD_BUS_PROPERTY("ProtectControlGroups", "b", bus_property_get_bool
, offsetof(ExecContext
, protect_control_groups
), SD_BUS_VTABLE_PROPERTY_CONST
),
1227 SD_BUS_PROPERTY("PrivateNetwork", "b", bus_property_get_bool
, offsetof(ExecContext
, private_network
), SD_BUS_VTABLE_PROPERTY_CONST
),
1228 SD_BUS_PROPERTY("PrivateUsers", "b", bus_property_get_bool
, offsetof(ExecContext
, private_users
), SD_BUS_VTABLE_PROPERTY_CONST
),
1229 SD_BUS_PROPERTY("PrivateMounts", "b", bus_property_get_bool
, offsetof(ExecContext
, private_mounts
), SD_BUS_VTABLE_PROPERTY_CONST
),
1230 SD_BUS_PROPERTY("PrivateIPC", "b", bus_property_get_bool
, offsetof(ExecContext
, private_ipc
), SD_BUS_VTABLE_PROPERTY_CONST
),
1231 SD_BUS_PROPERTY("ProtectHome", "s", property_get_protect_home
, offsetof(ExecContext
, protect_home
), SD_BUS_VTABLE_PROPERTY_CONST
),
1232 SD_BUS_PROPERTY("ProtectSystem", "s", property_get_protect_system
, offsetof(ExecContext
, protect_system
), SD_BUS_VTABLE_PROPERTY_CONST
),
1233 SD_BUS_PROPERTY("SameProcessGroup", "b", bus_property_get_bool
, offsetof(ExecContext
, same_pgrp
), SD_BUS_VTABLE_PROPERTY_CONST
),
1234 SD_BUS_PROPERTY("UtmpIdentifier", "s", NULL
, offsetof(ExecContext
, utmp_id
), SD_BUS_VTABLE_PROPERTY_CONST
),
1235 SD_BUS_PROPERTY("UtmpMode", "s", property_get_exec_utmp_mode
, offsetof(ExecContext
, utmp_mode
), SD_BUS_VTABLE_PROPERTY_CONST
),
1236 SD_BUS_PROPERTY("SELinuxContext", "(bs)", property_get_selinux_context
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
1237 SD_BUS_PROPERTY("AppArmorProfile", "(bs)", property_get_apparmor_profile
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
1238 SD_BUS_PROPERTY("SmackProcessLabel", "(bs)", property_get_smack_process_label
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
1239 SD_BUS_PROPERTY("IgnoreSIGPIPE", "b", bus_property_get_bool
, offsetof(ExecContext
, ignore_sigpipe
), SD_BUS_VTABLE_PROPERTY_CONST
),
1240 SD_BUS_PROPERTY("NoNewPrivileges", "b", bus_property_get_bool
, offsetof(ExecContext
, no_new_privileges
), SD_BUS_VTABLE_PROPERTY_CONST
),
1241 SD_BUS_PROPERTY("SystemCallFilter", "(bas)", property_get_syscall_filter
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
1242 SD_BUS_PROPERTY("SystemCallArchitectures", "as", property_get_syscall_archs
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
1243 SD_BUS_PROPERTY("SystemCallErrorNumber", "i", bus_property_get_int
, offsetof(ExecContext
, syscall_errno
), SD_BUS_VTABLE_PROPERTY_CONST
),
1244 SD_BUS_PROPERTY("SystemCallLog", "(bas)", property_get_syscall_log
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
1245 SD_BUS_PROPERTY("Personality", "s", property_get_personality
, offsetof(ExecContext
, personality
), SD_BUS_VTABLE_PROPERTY_CONST
),
1246 SD_BUS_PROPERTY("LockPersonality", "b", bus_property_get_bool
, offsetof(ExecContext
, lock_personality
), SD_BUS_VTABLE_PROPERTY_CONST
),
1247 SD_BUS_PROPERTY("RestrictAddressFamilies", "(bas)", property_get_address_families
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
1248 SD_BUS_PROPERTY("RuntimeDirectorySymlink", "a(sst)", bus_property_get_exec_dir_symlink
, offsetof(ExecContext
, directories
[EXEC_DIRECTORY_RUNTIME
]), SD_BUS_VTABLE_PROPERTY_CONST
),
1249 SD_BUS_PROPERTY("RuntimeDirectoryPreserve", "s", property_get_exec_preserve_mode
, offsetof(ExecContext
, runtime_directory_preserve_mode
), SD_BUS_VTABLE_PROPERTY_CONST
),
1250 SD_BUS_PROPERTY("RuntimeDirectoryMode", "u", bus_property_get_mode
, offsetof(ExecContext
, directories
[EXEC_DIRECTORY_RUNTIME
].mode
), SD_BUS_VTABLE_PROPERTY_CONST
),
1251 SD_BUS_PROPERTY("RuntimeDirectory", "as", bus_property_get_exec_dir
, offsetof(ExecContext
, directories
[EXEC_DIRECTORY_RUNTIME
]), SD_BUS_VTABLE_PROPERTY_CONST
),
1252 SD_BUS_PROPERTY("StateDirectorySymlink", "a(sst)", bus_property_get_exec_dir_symlink
, offsetof(ExecContext
, directories
[EXEC_DIRECTORY_STATE
]), SD_BUS_VTABLE_PROPERTY_CONST
),
1253 SD_BUS_PROPERTY("StateDirectoryMode", "u", bus_property_get_mode
, offsetof(ExecContext
, directories
[EXEC_DIRECTORY_STATE
].mode
), SD_BUS_VTABLE_PROPERTY_CONST
),
1254 SD_BUS_PROPERTY("StateDirectory", "as", bus_property_get_exec_dir
, offsetof(ExecContext
, directories
[EXEC_DIRECTORY_STATE
]), SD_BUS_VTABLE_PROPERTY_CONST
),
1255 SD_BUS_PROPERTY("CacheDirectorySymlink", "a(sst)", bus_property_get_exec_dir_symlink
, offsetof(ExecContext
, directories
[EXEC_DIRECTORY_CACHE
]), SD_BUS_VTABLE_PROPERTY_CONST
),
1256 SD_BUS_PROPERTY("CacheDirectoryMode", "u", bus_property_get_mode
, offsetof(ExecContext
, directories
[EXEC_DIRECTORY_CACHE
].mode
), SD_BUS_VTABLE_PROPERTY_CONST
),
1257 SD_BUS_PROPERTY("CacheDirectory", "as", bus_property_get_exec_dir
, offsetof(ExecContext
, directories
[EXEC_DIRECTORY_CACHE
]), SD_BUS_VTABLE_PROPERTY_CONST
),
1258 SD_BUS_PROPERTY("LogsDirectorySymlink", "a(sst)", bus_property_get_exec_dir_symlink
, offsetof(ExecContext
, directories
[EXEC_DIRECTORY_LOGS
]), SD_BUS_VTABLE_PROPERTY_CONST
),
1259 SD_BUS_PROPERTY("LogsDirectoryMode", "u", bus_property_get_mode
, offsetof(ExecContext
, directories
[EXEC_DIRECTORY_LOGS
].mode
), SD_BUS_VTABLE_PROPERTY_CONST
),
1260 SD_BUS_PROPERTY("LogsDirectory", "as", bus_property_get_exec_dir
, offsetof(ExecContext
, directories
[EXEC_DIRECTORY_LOGS
]), SD_BUS_VTABLE_PROPERTY_CONST
),
1261 SD_BUS_PROPERTY("ConfigurationDirectoryMode", "u", bus_property_get_mode
, offsetof(ExecContext
, directories
[EXEC_DIRECTORY_CONFIGURATION
].mode
), SD_BUS_VTABLE_PROPERTY_CONST
),
1262 SD_BUS_PROPERTY("ConfigurationDirectory", "as", bus_property_get_exec_dir
, offsetof(ExecContext
, directories
[EXEC_DIRECTORY_CONFIGURATION
]), SD_BUS_VTABLE_PROPERTY_CONST
),
1263 SD_BUS_PROPERTY("TimeoutCleanUSec", "t", bus_property_get_usec
, offsetof(ExecContext
, timeout_clean_usec
), SD_BUS_VTABLE_PROPERTY_CONST
),
1264 SD_BUS_PROPERTY("MemoryDenyWriteExecute", "b", bus_property_get_bool
, offsetof(ExecContext
, memory_deny_write_execute
), SD_BUS_VTABLE_PROPERTY_CONST
),
1265 SD_BUS_PROPERTY("RestrictRealtime", "b", bus_property_get_bool
, offsetof(ExecContext
, restrict_realtime
), SD_BUS_VTABLE_PROPERTY_CONST
),
1266 SD_BUS_PROPERTY("RestrictSUIDSGID", "b", bus_property_get_bool
, offsetof(ExecContext
, restrict_suid_sgid
), SD_BUS_VTABLE_PROPERTY_CONST
),
1267 SD_BUS_PROPERTY("RestrictNamespaces", "t", bus_property_get_ulong
, offsetof(ExecContext
, restrict_namespaces
), SD_BUS_VTABLE_PROPERTY_CONST
),
1268 SD_BUS_PROPERTY("RestrictFileSystems", "(bas)", property_get_restrict_filesystems
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
1269 SD_BUS_PROPERTY("BindPaths", "a(ssbt)", property_get_bind_paths
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
1270 SD_BUS_PROPERTY("BindReadOnlyPaths", "a(ssbt)", property_get_bind_paths
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
1271 SD_BUS_PROPERTY("TemporaryFileSystem", "a(ss)", property_get_temporary_filesystems
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
1272 SD_BUS_PROPERTY("MountAPIVFS", "b", property_get_mount_apivfs
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
1273 SD_BUS_PROPERTY("KeyringMode", "s", property_get_exec_keyring_mode
, offsetof(ExecContext
, keyring_mode
), SD_BUS_VTABLE_PROPERTY_CONST
),
1274 SD_BUS_PROPERTY("ProtectProc", "s", property_get_protect_proc
, offsetof(ExecContext
, protect_proc
), SD_BUS_VTABLE_PROPERTY_CONST
),
1275 SD_BUS_PROPERTY("ProcSubset", "s", property_get_proc_subset
, offsetof(ExecContext
, proc_subset
), SD_BUS_VTABLE_PROPERTY_CONST
),
1276 SD_BUS_PROPERTY("ProtectHostname", "b", bus_property_get_bool
, offsetof(ExecContext
, protect_hostname
), SD_BUS_VTABLE_PROPERTY_CONST
),
1277 SD_BUS_PROPERTY("NetworkNamespacePath", "s", NULL
, offsetof(ExecContext
, network_namespace_path
), SD_BUS_VTABLE_PROPERTY_CONST
),
1278 SD_BUS_PROPERTY("IPCNamespacePath", "s", NULL
, offsetof(ExecContext
, ipc_namespace_path
), SD_BUS_VTABLE_PROPERTY_CONST
),
1280 /* Obsolete/redundant properties: */
1281 SD_BUS_PROPERTY("Capabilities", "s", property_get_empty_string
, 0, SD_BUS_VTABLE_PROPERTY_CONST
|SD_BUS_VTABLE_HIDDEN
),
1282 SD_BUS_PROPERTY("ReadWriteDirectories", "as", NULL
, offsetof(ExecContext
, read_write_paths
), SD_BUS_VTABLE_PROPERTY_CONST
|SD_BUS_VTABLE_HIDDEN
),
1283 SD_BUS_PROPERTY("ReadOnlyDirectories", "as", NULL
, offsetof(ExecContext
, read_only_paths
), SD_BUS_VTABLE_PROPERTY_CONST
|SD_BUS_VTABLE_HIDDEN
),
1284 SD_BUS_PROPERTY("InaccessibleDirectories", "as", NULL
, offsetof(ExecContext
, inaccessible_paths
), SD_BUS_VTABLE_PROPERTY_CONST
|SD_BUS_VTABLE_HIDDEN
),
1285 SD_BUS_PROPERTY("IOScheduling", "i", property_get_ioprio
, 0, SD_BUS_VTABLE_PROPERTY_CONST
|SD_BUS_VTABLE_HIDDEN
),
1290 static int append_exec_command(sd_bus_message
*reply
, ExecCommand
*c
) {
1299 r
= sd_bus_message_open_container(reply
, 'r', "sasbttttuii");
1303 r
= sd_bus_message_append(reply
, "s", c
->path
);
1307 r
= sd_bus_message_append_strv(reply
, c
->argv
);
1311 r
= sd_bus_message_append(reply
, "bttttuii",
1312 !!(c
->flags
& EXEC_COMMAND_IGNORE_FAILURE
),
1313 c
->exec_status
.start_timestamp
.realtime
,
1314 c
->exec_status
.start_timestamp
.monotonic
,
1315 c
->exec_status
.exit_timestamp
.realtime
,
1316 c
->exec_status
.exit_timestamp
.monotonic
,
1317 (uint32_t) c
->exec_status
.pid
,
1318 (int32_t) c
->exec_status
.code
,
1319 (int32_t) c
->exec_status
.status
);
1323 return sd_bus_message_close_container(reply
);
1326 static int append_exec_ex_command(sd_bus_message
*reply
, ExecCommand
*c
) {
1327 _cleanup_strv_free_
char **ex_opts
= NULL
;
1336 r
= sd_bus_message_open_container(reply
, 'r', "sasasttttuii");
1340 r
= sd_bus_message_append(reply
, "s", c
->path
);
1344 r
= sd_bus_message_append_strv(reply
, c
->argv
);
1348 r
= exec_command_flags_to_strv(c
->flags
, &ex_opts
);
1352 r
= sd_bus_message_append_strv(reply
, ex_opts
);
1356 r
= sd_bus_message_append(reply
, "ttttuii",
1357 c
->exec_status
.start_timestamp
.realtime
,
1358 c
->exec_status
.start_timestamp
.monotonic
,
1359 c
->exec_status
.exit_timestamp
.realtime
,
1360 c
->exec_status
.exit_timestamp
.monotonic
,
1361 (uint32_t) c
->exec_status
.pid
,
1362 (int32_t) c
->exec_status
.code
,
1363 (int32_t) c
->exec_status
.status
);
1367 return sd_bus_message_close_container(reply
);
1370 int bus_property_get_exec_command(
1373 const char *interface
,
1374 const char *property
,
1375 sd_bus_message
*reply
,
1377 sd_bus_error
*ret_error
) {
1379 ExecCommand
*c
= (ExecCommand
*) userdata
;
1385 r
= sd_bus_message_open_container(reply
, 'a', "(sasbttttuii)");
1389 r
= append_exec_command(reply
, c
);
1393 return sd_bus_message_close_container(reply
);
1396 int bus_property_get_exec_command_list(
1399 const char *interface
,
1400 const char *property
,
1401 sd_bus_message
*reply
,
1403 sd_bus_error
*ret_error
) {
1405 ExecCommand
*exec_command
= *(ExecCommand
**) userdata
;
1411 r
= sd_bus_message_open_container(reply
, 'a', "(sasbttttuii)");
1415 LIST_FOREACH(command
, c
, exec_command
) {
1416 r
= append_exec_command(reply
, c
);
1421 return sd_bus_message_close_container(reply
);
1424 int bus_property_get_exec_ex_command_list(
1427 const char *interface
,
1428 const char *property
,
1429 sd_bus_message
*reply
,
1431 sd_bus_error
*ret_error
) {
1433 ExecCommand
*exec_command
= *(ExecCommand
**) userdata
;
1439 r
= sd_bus_message_open_container(reply
, 'a', "(sasasttttuii)");
1443 LIST_FOREACH(command
, c
, exec_command
) {
1444 r
= append_exec_ex_command(reply
, c
);
1449 return sd_bus_message_close_container(reply
);
1452 static char *exec_command_flags_to_exec_chars(ExecCommandFlags flags
) {
1453 return strjoin(FLAGS_SET(flags
, EXEC_COMMAND_IGNORE_FAILURE
) ? "-" : "",
1454 FLAGS_SET(flags
, EXEC_COMMAND_NO_ENV_EXPAND
) ? ":" : "",
1455 FLAGS_SET(flags
, EXEC_COMMAND_FULLY_PRIVILEGED
) ? "+" : "",
1456 FLAGS_SET(flags
, EXEC_COMMAND_NO_SETUID
) ? "!" : "",
1457 FLAGS_SET(flags
, EXEC_COMMAND_AMBIENT_MAGIC
) ? "!!" : "");
1460 int bus_set_transient_exec_command(
1463 ExecCommand
**exec_command
,
1464 sd_bus_message
*message
,
1465 UnitWriteFlags flags
,
1466 sd_bus_error
*error
) {
1467 bool is_ex_prop
= endswith(name
, "Ex");
1471 r
= sd_bus_message_enter_container(message
, 'a', is_ex_prop
? "(sasas)" : "(sasb)");
1475 while ((r
= sd_bus_message_enter_container(message
, 'r', is_ex_prop
? "sasas" : "sasb")) > 0) {
1476 _cleanup_strv_free_
char **argv
= NULL
, **ex_opts
= NULL
;
1480 r
= sd_bus_message_read(message
, "s", &path
);
1484 if (!path_is_absolute(path
) && !filename_is_valid(path
))
1485 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
,
1486 "\"%s\" is neither a valid executable name nor an absolute path",
1489 r
= sd_bus_message_read_strv(message
, &argv
);
1493 if (strv_isempty(argv
))
1494 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
,
1495 "\"%s\" argv cannot be empty", name
);
1497 r
= is_ex_prop
? sd_bus_message_read_strv(message
, &ex_opts
) : sd_bus_message_read(message
, "b", &b
);
1501 r
= sd_bus_message_exit_container(message
);
1505 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
1508 c
= new0(ExecCommand
, 1);
1512 c
->path
= strdup(path
);
1518 c
->argv
= TAKE_PTR(argv
);
1521 r
= exec_command_flags_from_strv(ex_opts
, &c
->flags
);
1525 c
->flags
= b
? EXEC_COMMAND_IGNORE_FAILURE
: 0;
1527 path_simplify(c
->path
);
1528 exec_command_append_list(exec_command
, c
);
1536 r
= sd_bus_message_exit_container(message
);
1540 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
1541 _cleanup_free_
char *buf
= NULL
;
1542 _cleanup_fclose_
FILE *f
= NULL
;
1546 *exec_command
= exec_command_free_list(*exec_command
);
1548 f
= open_memstream_unlocked(&buf
, &size
);
1552 fprintf(f
, "%s=\n", name
);
1554 LIST_FOREACH(command
, c
, *exec_command
) {
1555 _cleanup_free_
char *a
= NULL
, *exec_chars
= NULL
;
1557 exec_chars
= exec_command_flags_to_exec_chars(c
->flags
);
1561 a
= unit_concat_strv(c
->argv
, UNIT_ESCAPE_SPECIFIERS
|UNIT_ESCAPE_EXEC_SYNTAX
);
1565 if (streq_ptr(c
->path
, c
->argv
? c
->argv
[0] : NULL
))
1566 fprintf(f
, "%s=%s%s\n", name
, exec_chars
, a
);
1568 _cleanup_free_
char *t
= NULL
;
1571 p
= unit_escape_setting(c
->path
,
1572 UNIT_ESCAPE_SPECIFIERS
|UNIT_ESCAPE_EXEC_SYNTAX
, &t
);
1576 fprintf(f
, "%s=%s@%s %s\n", name
, exec_chars
, p
, a
);
1580 r
= fflush_and_check(f
);
1584 unit_write_setting(u
, flags
, name
, buf
);
1590 static int parse_personality(const char *s
, unsigned long *p
) {
1595 v
= personality_from_string(s
);
1596 if (v
== PERSONALITY_INVALID
)
1603 static const char* mount_propagation_flags_to_string_with_check(unsigned long n
) {
1604 if (!IN_SET(n
, 0, MS_SHARED
, MS_PRIVATE
, MS_SLAVE
))
1607 return mount_propagation_flags_to_string(n
);
1610 static BUS_DEFINE_SET_TRANSIENT(nsec
, "t", uint64_t, nsec_t
, NSEC_FMT
);
1611 static BUS_DEFINE_SET_TRANSIENT_IS_VALID(log_level
, "i", int32_t, int, "%" PRIi32
, log_level_is_valid
);
1613 static BUS_DEFINE_SET_TRANSIENT_IS_VALID(errno
, "i", int32_t, int, "%" PRIi32
, seccomp_errno_or_action_is_valid
);
1615 static BUS_DEFINE_SET_TRANSIENT_PARSE(std_input
, ExecInput
, exec_input_from_string
);
1616 static BUS_DEFINE_SET_TRANSIENT_PARSE(std_output
, ExecOutput
, exec_output_from_string
);
1617 static BUS_DEFINE_SET_TRANSIENT_PARSE(utmp_mode
, ExecUtmpMode
, exec_utmp_mode_from_string
);
1618 static BUS_DEFINE_SET_TRANSIENT_PARSE(protect_system
, ProtectSystem
, protect_system_from_string
);
1619 static BUS_DEFINE_SET_TRANSIENT_PARSE(protect_home
, ProtectHome
, protect_home_from_string
);
1620 static BUS_DEFINE_SET_TRANSIENT_PARSE(keyring_mode
, ExecKeyringMode
, exec_keyring_mode_from_string
);
1621 static BUS_DEFINE_SET_TRANSIENT_PARSE(protect_proc
, ProtectProc
, protect_proc_from_string
);
1622 static BUS_DEFINE_SET_TRANSIENT_PARSE(proc_subset
, ProcSubset
, proc_subset_from_string
);
1623 static BUS_DEFINE_SET_TRANSIENT_PARSE(preserve_mode
, ExecPreserveMode
, exec_preserve_mode_from_string
);
1624 static BUS_DEFINE_SET_TRANSIENT_PARSE_PTR(personality
, unsigned long, parse_personality
);
1625 static BUS_DEFINE_SET_TRANSIENT_TO_STRING_ALLOC(secure_bits
, "i", int32_t, int, "%" PRIi32
, secure_bits_to_string_alloc_with_check
);
1626 static BUS_DEFINE_SET_TRANSIENT_TO_STRING_ALLOC(capability
, "t", uint64_t, uint64_t, "%" PRIu64
, capability_set_to_string_alloc
);
1627 static BUS_DEFINE_SET_TRANSIENT_TO_STRING_ALLOC(namespace_flag
, "t", uint64_t, unsigned long, "%" PRIu64
, namespace_flags_to_string
);
1628 static BUS_DEFINE_SET_TRANSIENT_TO_STRING(mount_flags
, "t", uint64_t, unsigned long, "%" PRIu64
, mount_propagation_flags_to_string_with_check
);
1630 int bus_exec_context_set_transient_property(
1634 sd_bus_message
*message
,
1635 UnitWriteFlags flags
,
1636 sd_bus_error
*error
) {
1646 flags
|= UNIT_PRIVATE
;
1648 if (streq(name
, "User"))
1649 return bus_set_transient_user_relaxed(u
, name
, &c
->user
, message
, flags
, error
);
1651 if (streq(name
, "Group"))
1652 return bus_set_transient_user_relaxed(u
, name
, &c
->group
, message
, flags
, error
);
1654 if (streq(name
, "TTYPath"))
1655 return bus_set_transient_path(u
, name
, &c
->tty_path
, message
, flags
, error
);
1657 if (streq(name
, "RootImage"))
1658 return bus_set_transient_path(u
, name
, &c
->root_image
, message
, flags
, error
);
1660 if (streq(name
, "RootImageOptions")) {
1661 _cleanup_(mount_options_free_allp
) MountOptions
*options
= NULL
;
1662 _cleanup_free_
char *format_str
= NULL
;
1664 r
= bus_read_mount_options(message
, error
, &options
, &format_str
, " ");
1668 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
1670 LIST_JOIN(mount_options
, c
->root_image_options
, options
);
1671 unit_write_settingf(
1672 u
, flags
|UNIT_ESCAPE_SPECIFIERS
, name
,
1677 c
->root_image_options
= mount_options_free_all(c
->root_image_options
);
1678 unit_write_settingf(u
, flags
, name
, "%s=", name
);
1685 if (streq(name
, "RootHash")) {
1686 const void *roothash_decoded
;
1687 size_t roothash_decoded_size
;
1689 r
= sd_bus_message_read_array(message
, 'y', &roothash_decoded
, &roothash_decoded_size
);
1693 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
1694 _cleanup_free_
char *encoded
= NULL
;
1696 if (roothash_decoded_size
== 0) {
1697 c
->root_hash_path
= mfree(c
->root_hash_path
);
1698 c
->root_hash
= mfree(c
->root_hash
);
1699 c
->root_hash_size
= 0;
1701 unit_write_settingf(u
, flags
, name
, "RootHash=");
1703 _cleanup_free_
void *p
= NULL
;
1705 encoded
= hexmem(roothash_decoded
, roothash_decoded_size
);
1709 p
= memdup(roothash_decoded
, roothash_decoded_size
);
1713 free_and_replace(c
->root_hash
, p
);
1714 c
->root_hash_size
= roothash_decoded_size
;
1715 c
->root_hash_path
= mfree(c
->root_hash_path
);
1717 unit_write_settingf(u
, flags
, name
, "RootHash=%s", encoded
);
1724 if (streq(name
, "RootHashPath")) {
1725 c
->root_hash_size
= 0;
1726 c
->root_hash
= mfree(c
->root_hash
);
1728 return bus_set_transient_path(u
, "RootHash", &c
->root_hash_path
, message
, flags
, error
);
1731 if (streq(name
, "RootHashSignature")) {
1732 const void *roothash_sig_decoded
;
1733 size_t roothash_sig_decoded_size
;
1735 r
= sd_bus_message_read_array(message
, 'y', &roothash_sig_decoded
, &roothash_sig_decoded_size
);
1739 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
1740 _cleanup_free_
char *encoded
= NULL
;
1742 if (roothash_sig_decoded_size
== 0) {
1743 c
->root_hash_sig_path
= mfree(c
->root_hash_sig_path
);
1744 c
->root_hash_sig
= mfree(c
->root_hash_sig
);
1745 c
->root_hash_sig_size
= 0;
1747 unit_write_settingf(u
, flags
, name
, "RootHashSignature=");
1749 _cleanup_free_
void *p
= NULL
;
1752 len
= base64mem(roothash_sig_decoded
, roothash_sig_decoded_size
, &encoded
);
1756 p
= memdup(roothash_sig_decoded
, roothash_sig_decoded_size
);
1760 free_and_replace(c
->root_hash_sig
, p
);
1761 c
->root_hash_sig_size
= roothash_sig_decoded_size
;
1762 c
->root_hash_sig_path
= mfree(c
->root_hash_sig_path
);
1764 unit_write_settingf(u
, flags
, name
, "RootHashSignature=base64:%s", encoded
);
1771 if (streq(name
, "RootHashSignaturePath")) {
1772 c
->root_hash_sig_size
= 0;
1773 c
->root_hash_sig
= mfree(c
->root_hash_sig
);
1775 return bus_set_transient_path(u
, "RootHashSignature", &c
->root_hash_sig_path
, message
, flags
, error
);
1778 if (streq(name
, "RootVerity"))
1779 return bus_set_transient_path(u
, name
, &c
->root_verity
, message
, flags
, error
);
1781 if (streq(name
, "RootDirectory"))
1782 return bus_set_transient_path(u
, name
, &c
->root_directory
, message
, flags
, error
);
1784 if (streq(name
, "SyslogIdentifier"))
1785 return bus_set_transient_string(u
, name
, &c
->syslog_identifier
, message
, flags
, error
);
1787 if (streq(name
, "LogLevelMax"))
1788 return bus_set_transient_log_level(u
, name
, &c
->log_level_max
, message
, flags
, error
);
1790 if (streq(name
, "LogRateLimitIntervalUSec"))
1791 return bus_set_transient_usec(u
, name
, &c
->log_ratelimit_interval_usec
, message
, flags
, error
);
1793 if (streq(name
, "LogRateLimitBurst"))
1794 return bus_set_transient_unsigned(u
, name
, &c
->log_ratelimit_burst
, message
, flags
, error
);
1796 if (streq(name
, "Personality"))
1797 return bus_set_transient_personality(u
, name
, &c
->personality
, message
, flags
, error
);
1799 if (streq(name
, "StandardInput"))
1800 return bus_set_transient_std_input(u
, name
, &c
->std_input
, message
, flags
, error
);
1802 if (streq(name
, "StandardOutput"))
1803 return bus_set_transient_std_output(u
, name
, &c
->std_output
, message
, flags
, error
);
1805 if (streq(name
, "StandardError"))
1806 return bus_set_transient_std_output(u
, name
, &c
->std_error
, message
, flags
, error
);
1808 if (streq(name
, "IgnoreSIGPIPE"))
1809 return bus_set_transient_bool(u
, name
, &c
->ignore_sigpipe
, message
, flags
, error
);
1811 if (streq(name
, "TTYVHangup"))
1812 return bus_set_transient_bool(u
, name
, &c
->tty_vhangup
, message
, flags
, error
);
1814 if (streq(name
, "TTYReset"))
1815 return bus_set_transient_bool(u
, name
, &c
->tty_reset
, message
, flags
, error
);
1817 if (streq(name
, "TTYVTDisallocate"))
1818 return bus_set_transient_bool(u
, name
, &c
->tty_vt_disallocate
, message
, flags
, error
);
1820 if (streq(name
, "TTYRows"))
1821 return bus_set_transient_unsigned(u
, name
, &c
->tty_rows
, message
, flags
, error
);
1823 if (streq(name
, "TTYColumns"))
1824 return bus_set_transient_unsigned(u
, name
, &c
->tty_cols
, message
, flags
, error
);
1826 if (streq(name
, "PrivateTmp"))
1827 return bus_set_transient_bool(u
, name
, &c
->private_tmp
, message
, flags
, error
);
1829 if (streq(name
, "PrivateDevices"))
1830 return bus_set_transient_bool(u
, name
, &c
->private_devices
, message
, flags
, error
);
1832 if (streq(name
, "PrivateMounts"))
1833 return bus_set_transient_bool(u
, name
, &c
->private_mounts
, message
, flags
, error
);
1835 if (streq(name
, "PrivateNetwork"))
1836 return bus_set_transient_bool(u
, name
, &c
->private_network
, message
, flags
, error
);
1838 if (streq(name
, "PrivateIPC"))
1839 return bus_set_transient_bool(u
, name
, &c
->private_ipc
, message
, flags
, error
);
1841 if (streq(name
, "PrivateUsers"))
1842 return bus_set_transient_bool(u
, name
, &c
->private_users
, message
, flags
, error
);
1844 if (streq(name
, "NoNewPrivileges"))
1845 return bus_set_transient_bool(u
, name
, &c
->no_new_privileges
, message
, flags
, error
);
1847 if (streq(name
, "SyslogLevelPrefix"))
1848 return bus_set_transient_bool(u
, name
, &c
->syslog_level_prefix
, message
, flags
, error
);
1850 if (streq(name
, "MemoryDenyWriteExecute"))
1851 return bus_set_transient_bool(u
, name
, &c
->memory_deny_write_execute
, message
, flags
, error
);
1853 if (streq(name
, "RestrictRealtime"))
1854 return bus_set_transient_bool(u
, name
, &c
->restrict_realtime
, message
, flags
, error
);
1856 if (streq(name
, "RestrictSUIDSGID"))
1857 return bus_set_transient_bool(u
, name
, &c
->restrict_suid_sgid
, message
, flags
, error
);
1859 if (streq(name
, "DynamicUser"))
1860 return bus_set_transient_bool(u
, name
, &c
->dynamic_user
, message
, flags
, error
);
1862 if (streq(name
, "RemoveIPC"))
1863 return bus_set_transient_bool(u
, name
, &c
->remove_ipc
, message
, flags
, error
);
1865 if (streq(name
, "ProtectKernelTunables"))
1866 return bus_set_transient_bool(u
, name
, &c
->protect_kernel_tunables
, message
, flags
, error
);
1868 if (streq(name
, "ProtectKernelModules"))
1869 return bus_set_transient_bool(u
, name
, &c
->protect_kernel_modules
, message
, flags
, error
);
1871 if (streq(name
, "ProtectKernelLogs"))
1872 return bus_set_transient_bool(u
, name
, &c
->protect_kernel_logs
, message
, flags
, error
);
1874 if (streq(name
, "ProtectClock"))
1875 return bus_set_transient_bool(u
, name
, &c
->protect_clock
, message
, flags
, error
);
1877 if (streq(name
, "ProtectControlGroups"))
1878 return bus_set_transient_bool(u
, name
, &c
->protect_control_groups
, message
, flags
, error
);
1880 if (streq(name
, "CPUSchedulingResetOnFork"))
1881 return bus_set_transient_bool(u
, name
, &c
->cpu_sched_reset_on_fork
, message
, flags
, error
);
1883 if (streq(name
, "NonBlocking"))
1884 return bus_set_transient_bool(u
, name
, &c
->non_blocking
, message
, flags
, error
);
1886 if (streq(name
, "LockPersonality"))
1887 return bus_set_transient_bool(u
, name
, &c
->lock_personality
, message
, flags
, error
);
1889 if (streq(name
, "ProtectHostname"))
1890 return bus_set_transient_bool(u
, name
, &c
->protect_hostname
, message
, flags
, error
);
1892 if (streq(name
, "UtmpIdentifier"))
1893 return bus_set_transient_string(u
, name
, &c
->utmp_id
, message
, flags
, error
);
1895 if (streq(name
, "UtmpMode"))
1896 return bus_set_transient_utmp_mode(u
, name
, &c
->utmp_mode
, message
, flags
, error
);
1898 if (streq(name
, "PAMName"))
1899 return bus_set_transient_string(u
, name
, &c
->pam_name
, message
, flags
, error
);
1901 if (streq(name
, "TimerSlackNSec"))
1902 return bus_set_transient_nsec(u
, name
, &c
->timer_slack_nsec
, message
, flags
, error
);
1904 if (streq(name
, "ProtectSystem"))
1905 return bus_set_transient_protect_system(u
, name
, &c
->protect_system
, message
, flags
, error
);
1907 if (streq(name
, "ProtectHome"))
1908 return bus_set_transient_protect_home(u
, name
, &c
->protect_home
, message
, flags
, error
);
1910 if (streq(name
, "KeyringMode"))
1911 return bus_set_transient_keyring_mode(u
, name
, &c
->keyring_mode
, message
, flags
, error
);
1913 if (streq(name
, "ProtectProc"))
1914 return bus_set_transient_protect_proc(u
, name
, &c
->protect_proc
, message
, flags
, error
);
1916 if (streq(name
, "ProcSubset"))
1917 return bus_set_transient_proc_subset(u
, name
, &c
->proc_subset
, message
, flags
, error
);
1919 if (streq(name
, "RuntimeDirectoryPreserve"))
1920 return bus_set_transient_preserve_mode(u
, name
, &c
->runtime_directory_preserve_mode
, message
, flags
, error
);
1922 if (streq(name
, "UMask"))
1923 return bus_set_transient_mode_t(u
, name
, &c
->umask
, message
, flags
, error
);
1925 if (streq(name
, "RuntimeDirectoryMode"))
1926 return bus_set_transient_mode_t(u
, name
, &c
->directories
[EXEC_DIRECTORY_RUNTIME
].mode
, message
, flags
, error
);
1928 if (streq(name
, "StateDirectoryMode"))
1929 return bus_set_transient_mode_t(u
, name
, &c
->directories
[EXEC_DIRECTORY_STATE
].mode
, message
, flags
, error
);
1931 if (streq(name
, "CacheDirectoryMode"))
1932 return bus_set_transient_mode_t(u
, name
, &c
->directories
[EXEC_DIRECTORY_CACHE
].mode
, message
, flags
, error
);
1934 if (streq(name
, "LogsDirectoryMode"))
1935 return bus_set_transient_mode_t(u
, name
, &c
->directories
[EXEC_DIRECTORY_LOGS
].mode
, message
, flags
, error
);
1937 if (streq(name
, "ConfigurationDirectoryMode"))
1938 return bus_set_transient_mode_t(u
, name
, &c
->directories
[EXEC_DIRECTORY_CONFIGURATION
].mode
, message
, flags
, error
);
1940 if (streq(name
, "SELinuxContext"))
1941 return bus_set_transient_string(u
, name
, &c
->selinux_context
, message
, flags
, error
);
1943 if (streq(name
, "SecureBits"))
1944 return bus_set_transient_secure_bits(u
, name
, &c
->secure_bits
, message
, flags
, error
);
1946 if (streq(name
, "CapabilityBoundingSet"))
1947 return bus_set_transient_capability(u
, name
, &c
->capability_bounding_set
, message
, flags
, error
);
1949 if (streq(name
, "AmbientCapabilities"))
1950 return bus_set_transient_capability(u
, name
, &c
->capability_ambient_set
, message
, flags
, error
);
1952 if (streq(name
, "RestrictNamespaces"))
1953 return bus_set_transient_namespace_flag(u
, name
, &c
->restrict_namespaces
, message
, flags
, error
);
1955 if (streq(name
, "RestrictFileSystems")) {
1957 _cleanup_strv_free_
char **l
= NULL
;
1959 r
= sd_bus_message_enter_container(message
, 'r', "bas");
1963 r
= sd_bus_message_read(message
, "b", &allow_list
);
1967 r
= sd_bus_message_read_strv(message
, &l
);
1971 r
= sd_bus_message_exit_container(message
);
1975 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
1976 _cleanup_free_
char *joined
= NULL
;
1977 FilesystemParseFlags invert_flag
= allow_list
? 0 : FILESYSTEM_PARSE_INVERT
;
1979 if (strv_isempty(l
)) {
1980 c
->restrict_filesystems_allow_list
= false;
1981 c
->restrict_filesystems
= set_free(c
->restrict_filesystems
);
1983 unit_write_setting(u
, flags
, name
, "RestrictFileSystems=");
1987 if (!c
->restrict_filesystems
)
1988 c
->restrict_filesystems_allow_list
= allow_list
;
1990 STRV_FOREACH(s
, l
) {
1991 r
= lsm_bpf_parse_filesystem(
1993 &c
->restrict_filesystems
,
1994 FILESYSTEM_PARSE_LOG
|
1995 (invert_flag
? FILESYSTEM_PARSE_INVERT
: 0)|
1996 (c
->restrict_filesystems_allow_list
? FILESYSTEM_PARSE_ALLOW_LIST
: 0),
2002 joined
= strv_join(l
, " ");
2006 unit_write_settingf(u
, flags
, name
, "%s=%s%s", name
, allow_list
? "" : "~", joined
);
2012 if (streq(name
, "MountFlags"))
2013 return bus_set_transient_mount_flags(u
, name
, &c
->mount_flags
, message
, flags
, error
);
2015 if (streq(name
, "NetworkNamespacePath"))
2016 return bus_set_transient_path(u
, name
, &c
->network_namespace_path
, message
, flags
, error
);
2018 if (streq(name
, "IPCNamespacePath"))
2019 return bus_set_transient_path(u
, name
, &c
->ipc_namespace_path
, message
, flags
, error
);
2021 if (streq(name
, "SupplementaryGroups")) {
2022 _cleanup_strv_free_
char **l
= NULL
;
2024 r
= sd_bus_message_read_strv(message
, &l
);
2029 if (!isempty(*p
) && !valid_user_group_name(*p
, VALID_USER_ALLOW_NUMERIC
|VALID_USER_RELAX
|VALID_USER_WARN
))
2030 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
,
2031 "Invalid supplementary group names");
2033 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
2034 if (strv_isempty(l
)) {
2035 c
->supplementary_groups
= strv_free(c
->supplementary_groups
);
2036 unit_write_settingf(u
, flags
, name
, "%s=", name
);
2038 _cleanup_free_
char *joined
= NULL
;
2040 r
= strv_extend_strv(&c
->supplementary_groups
, l
, true);
2044 joined
= strv_join(c
->supplementary_groups
, " ");
2048 unit_write_settingf(u
, flags
|UNIT_ESCAPE_SPECIFIERS
, name
, "%s=%s", name
, joined
);
2054 } else if (STR_IN_SET(name
, "SetCredential", "SetCredentialEncrypted")) {
2055 bool isempty
= true;
2057 r
= sd_bus_message_enter_container(message
, 'a', "(say)");
2066 r
= sd_bus_message_enter_container(message
, 'r', "say");
2072 r
= sd_bus_message_read(message
, "s", &id
);
2076 r
= sd_bus_message_read_array(message
, 'y', &p
, &sz
);
2080 r
= sd_bus_message_exit_container(message
);
2084 if (!credential_name_valid(id
))
2085 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Credential ID is invalid: %s", id
);
2089 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
2090 _cleanup_free_
char *a
= NULL
, *b
= NULL
;
2091 _cleanup_free_
void *copy
= NULL
;
2092 ExecSetCredential
*old
;
2094 copy
= memdup(p
, sz
);
2098 old
= hashmap_get(c
->set_credentials
, id
);
2100 free_and_replace(old
->data
, copy
);
2102 old
->encrypted
= streq(name
, "SetCredentialEncrypted");
2104 _cleanup_(exec_set_credential_freep
) ExecSetCredential
*sc
= NULL
;
2106 sc
= new(ExecSetCredential
, 1);
2110 *sc
= (ExecSetCredential
) {
2112 .data
= TAKE_PTR(copy
),
2114 .encrypted
= streq(name
, "SetCredentialEncrypted"),
2120 r
= hashmap_ensure_put(&c
->set_credentials
, &exec_set_credential_hash_ops
, sc
->id
, sc
);
2127 a
= specifier_escape(id
);
2131 b
= cescape_length(p
, sz
);
2135 (void) unit_write_settingf(u
, flags
, name
, "%s=%s:%s", name
, a
, b
);
2139 r
= sd_bus_message_exit_container(message
);
2143 if (!UNIT_WRITE_FLAGS_NOOP(flags
) && isempty
) {
2144 c
->set_credentials
= hashmap_free(c
->set_credentials
);
2145 (void) unit_write_settingf(u
, flags
, name
, "%s=", name
);
2150 } else if (STR_IN_SET(name
, "LoadCredential", "LoadCredentialEncrypted")) {
2151 bool isempty
= true;
2153 r
= sd_bus_message_enter_container(message
, 'a', "(ss)");
2158 const char *id
, *source
;
2160 r
= sd_bus_message_read(message
, "(ss)", &id
, &source
);
2166 if (!credential_name_valid(id
))
2167 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Credential ID is invalid: %s", id
);
2169 if (!(path_is_absolute(source
) ? path_is_normalized(source
) : credential_name_valid(source
)))
2170 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Credential source is invalid: %s", source
);
2174 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
2175 _cleanup_free_
char *copy
= NULL
;
2176 ExecLoadCredential
*old
;
2178 copy
= strdup(source
);
2182 old
= hashmap_get(c
->load_credentials
, id
);
2184 free_and_replace(old
->path
, copy
);
2185 old
->encrypted
= streq(name
, "LoadCredentialEncrypted");
2187 _cleanup_(exec_load_credential_freep
) ExecLoadCredential
*lc
= NULL
;
2189 lc
= new(ExecLoadCredential
, 1);
2193 *lc
= (ExecLoadCredential
) {
2195 .path
= TAKE_PTR(copy
),
2196 .encrypted
= streq(name
, "LoadCredentialEncrypted"),
2202 r
= hashmap_ensure_put(&c
->load_credentials
, &exec_load_credential_hash_ops
, lc
->id
, lc
);
2209 (void) unit_write_settingf(u
, flags
|UNIT_ESCAPE_SPECIFIERS
, name
, "%s=%s:%s", name
, id
, source
);
2213 r
= sd_bus_message_exit_container(message
);
2217 if (!UNIT_WRITE_FLAGS_NOOP(flags
) && isempty
) {
2218 c
->load_credentials
= hashmap_free(c
->load_credentials
);
2219 (void) unit_write_settingf(u
, flags
, name
, "%s=", name
);
2224 } else if (streq(name
, "SyslogLevel")) {
2227 r
= sd_bus_message_read(message
, "i", &level
);
2231 if (!log_level_is_valid(level
))
2232 return sd_bus_error_set(error
, SD_BUS_ERROR_INVALID_ARGS
, "Log level value out of range");
2234 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
2235 c
->syslog_priority
= (c
->syslog_priority
& LOG_FACMASK
) | level
;
2236 unit_write_settingf(u
, flags
, name
, "SyslogLevel=%i", level
);
2241 } else if (streq(name
, "SyslogFacility")) {
2244 r
= sd_bus_message_read(message
, "i", &facility
);
2248 if (!log_facility_unshifted_is_valid(facility
))
2249 return sd_bus_error_set(error
, SD_BUS_ERROR_INVALID_ARGS
, "Log facility value out of range");
2251 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
2252 c
->syslog_priority
= (facility
<< 3) | LOG_PRI(c
->syslog_priority
);
2253 unit_write_settingf(u
, flags
, name
, "SyslogFacility=%i", facility
);
2258 } else if (streq(name
, "LogNamespace")) {
2261 r
= sd_bus_message_read(message
, "s", &n
);
2265 if (!isempty(n
) && !log_namespace_name_valid(n
))
2266 return sd_bus_error_set(error
, SD_BUS_ERROR_INVALID_ARGS
, "Log namespace name not valid");
2268 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
2271 c
->log_namespace
= mfree(c
->log_namespace
);
2272 unit_write_settingf(u
, flags
, name
, "%s=", name
);
2274 r
= free_and_strdup(&c
->log_namespace
, n
);
2278 unit_write_settingf(u
, flags
, name
, "%s=%s", name
, n
);
2284 } else if (streq(name
, "LogExtraFields")) {
2287 r
= sd_bus_message_enter_container(message
, 'a', "ay");
2292 _cleanup_free_
void *copy
= NULL
;
2298 /* Note that we expect a byte array for each field, instead of a string. That's because on the
2299 * lower-level journal fields can actually contain binary data and are not restricted to text,
2300 * and we should not "lose precision" in our types on the way. That said, I am pretty sure
2301 * actually encoding binary data as unit metadata is not a good idea. Hence we actually refuse
2302 * any actual binary data, and only accept UTF-8. This allows us to eventually lift this
2303 * limitation, should a good, valid usecase arise. */
2305 r
= sd_bus_message_read_array(message
, 'y', &p
, &sz
);
2311 if (memchr(p
, 0, sz
))
2312 return sd_bus_error_set(error
, SD_BUS_ERROR_INVALID_ARGS
, "Journal field contains zero byte");
2314 eq
= memchr(p
, '=', sz
);
2316 return sd_bus_error_set(error
, SD_BUS_ERROR_INVALID_ARGS
, "Journal field contains no '=' character");
2317 if (!journal_field_valid(p
, eq
- (const char*) p
, false))
2318 return sd_bus_error_set(error
, SD_BUS_ERROR_INVALID_ARGS
, "Journal field invalid");
2320 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
2321 t
= reallocarray(c
->log_extra_fields
, c
->n_log_extra_fields
+1, sizeof(struct iovec
));
2324 c
->log_extra_fields
= t
;
2327 copy
= malloc(sz
+ 1);
2331 memcpy(copy
, p
, sz
);
2332 ((uint8_t*) copy
)[sz
] = 0;
2334 if (!utf8_is_valid(copy
))
2335 return sd_bus_error_set(error
, SD_BUS_ERROR_INVALID_ARGS
, "Journal field is not valid UTF-8");
2337 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
2338 c
->log_extra_fields
[c
->n_log_extra_fields
++] = IOVEC_MAKE(copy
, sz
);
2339 unit_write_settingf(u
, flags
|UNIT_ESCAPE_SPECIFIERS
|UNIT_ESCAPE_C
, name
, "LogExtraFields=%s", (char*) copy
);
2347 r
= sd_bus_message_exit_container(message
);
2351 if (!UNIT_WRITE_FLAGS_NOOP(flags
) && n
== 0) {
2352 exec_context_free_log_extra_fields(c
);
2353 unit_write_setting(u
, flags
, name
, "LogExtraFields=");
2361 if (streq(name
, "SystemCallErrorNumber"))
2362 return bus_set_transient_errno(u
, name
, &c
->syscall_errno
, message
, flags
, error
);
2364 if (streq(name
, "SystemCallFilter")) {
2366 _cleanup_strv_free_
char **l
= NULL
;
2368 r
= sd_bus_message_enter_container(message
, 'r', "bas");
2372 r
= sd_bus_message_read(message
, "b", &allow_list
);
2376 r
= sd_bus_message_read_strv(message
, &l
);
2380 r
= sd_bus_message_exit_container(message
);
2384 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
2385 _cleanup_free_
char *joined
= NULL
;
2386 SeccompParseFlags invert_flag
= allow_list
? 0 : SECCOMP_PARSE_INVERT
;
2388 if (strv_isempty(l
)) {
2389 c
->syscall_allow_list
= false;
2390 c
->syscall_filter
= hashmap_free(c
->syscall_filter
);
2392 unit_write_settingf(u
, flags
, name
, "SystemCallFilter=");
2396 if (!c
->syscall_filter
) {
2397 c
->syscall_filter
= hashmap_new(NULL
);
2398 if (!c
->syscall_filter
)
2401 c
->syscall_allow_list
= allow_list
;
2403 if (c
->syscall_allow_list
) {
2404 r
= seccomp_parse_syscall_filter("@default",
2407 SECCOMP_PARSE_PERMISSIVE
|
2408 SECCOMP_PARSE_ALLOW_LIST
,
2416 STRV_FOREACH(s
, l
) {
2417 _cleanup_free_
char *n
= NULL
;
2420 r
= parse_syscall_and_errno(*s
, &n
, &e
);
2424 if (allow_list
&& e
>= 0)
2427 r
= seccomp_parse_syscall_filter(n
,
2430 SECCOMP_PARSE_LOG
| SECCOMP_PARSE_PERMISSIVE
|
2432 (c
->syscall_allow_list
? SECCOMP_PARSE_ALLOW_LIST
: 0),
2439 joined
= strv_join(l
, " ");
2443 unit_write_settingf(u
, flags
, name
, "SystemCallFilter=%s%s", allow_list
? "" : "~", joined
);
2448 } else if (streq(name
, "SystemCallLog")) {
2450 _cleanup_strv_free_
char **l
= NULL
;
2452 r
= sd_bus_message_enter_container(message
, 'r', "bas");
2456 r
= sd_bus_message_read(message
, "b", &allow_list
);
2460 r
= sd_bus_message_read_strv(message
, &l
);
2464 r
= sd_bus_message_exit_container(message
);
2468 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
2469 _cleanup_free_
char *joined
= NULL
;
2470 SeccompParseFlags invert_flag
= allow_list
? 0 : SECCOMP_PARSE_INVERT
;
2472 if (strv_isempty(l
)) {
2473 c
->syscall_log_allow_list
= false;
2474 c
->syscall_log
= hashmap_free(c
->syscall_log
);
2476 unit_write_settingf(u
, flags
, name
, "SystemCallLog=");
2480 if (!c
->syscall_log
) {
2481 c
->syscall_log
= hashmap_new(NULL
);
2482 if (!c
->syscall_log
)
2485 c
->syscall_log_allow_list
= allow_list
;
2488 STRV_FOREACH(s
, l
) {
2489 r
= seccomp_parse_syscall_filter(*s
,
2490 -1, /* errno not used */
2492 SECCOMP_PARSE_LOG
| SECCOMP_PARSE_PERMISSIVE
|
2494 (c
->syscall_log_allow_list
? SECCOMP_PARSE_ALLOW_LIST
: 0),
2501 joined
= strv_join(l
, " ");
2505 unit_write_settingf(u
, flags
, name
, "SystemCallLog=%s%s", allow_list
? "" : "~", joined
);
2510 } else if (streq(name
, "SystemCallArchitectures")) {
2511 _cleanup_strv_free_
char **l
= NULL
;
2513 r
= sd_bus_message_read_strv(message
, &l
);
2517 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
2518 _cleanup_free_
char *joined
= NULL
;
2520 if (strv_isempty(l
))
2521 c
->syscall_archs
= set_free(c
->syscall_archs
);
2523 STRV_FOREACH(s
, l
) {
2526 r
= seccomp_arch_from_string(*s
, &a
);
2530 r
= set_ensure_put(&c
->syscall_archs
, NULL
, UINT32_TO_PTR(a
+ 1));
2535 joined
= strv_join(l
, " ");
2539 unit_write_settingf(u
, flags
, name
, "%s=%s", name
, joined
);
2544 } else if (streq(name
, "RestrictAddressFamilies")) {
2545 _cleanup_strv_free_
char **l
= NULL
;
2548 r
= sd_bus_message_enter_container(message
, 'r', "bas");
2552 r
= sd_bus_message_read(message
, "b", &allow_list
);
2556 r
= sd_bus_message_read_strv(message
, &l
);
2560 r
= sd_bus_message_exit_container(message
);
2564 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
2565 _cleanup_free_
char *joined
= NULL
;
2567 if (strv_isempty(l
)) {
2568 c
->address_families_allow_list
= allow_list
;
2569 c
->address_families
= set_free(c
->address_families
);
2571 unit_write_settingf(u
, flags
, name
, "RestrictAddressFamilies=%s",
2572 allow_list
? "none" : "");
2576 if (!c
->address_families
) {
2577 c
->address_families
= set_new(NULL
);
2578 if (!c
->address_families
)
2581 c
->address_families_allow_list
= allow_list
;
2584 STRV_FOREACH(s
, l
) {
2587 af
= af_from_name(*s
);
2591 if (allow_list
== c
->address_families_allow_list
) {
2592 r
= set_put(c
->address_families
, INT_TO_PTR(af
));
2596 set_remove(c
->address_families
, INT_TO_PTR(af
));
2599 joined
= strv_join(l
, " ");
2603 unit_write_settingf(u
, flags
, name
, "RestrictAddressFamilies=%s%s", allow_list
? "" : "~", joined
);
2609 if (STR_IN_SET(name
, "CPUAffinity", "NUMAMask")) {
2612 bool affinity
= streq(name
, "CPUAffinity");
2613 _cleanup_(cpu_set_reset
) CPUSet set
= {};
2615 r
= sd_bus_message_read_array(message
, 'y', &a
, &n
);
2619 r
= cpu_set_from_dbus(a
, n
, &set
);
2623 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
2625 cpu_set_reset(affinity
? &c
->cpu_set
: &c
->numa_policy
.nodes
);
2626 unit_write_settingf(u
, flags
, name
, "%s=", name
);
2628 _cleanup_free_
char *str
= NULL
;
2630 str
= cpu_set_to_string(&set
);
2634 /* We forego any optimizations here, and always create the structure using
2635 * cpu_set_add_all(), because we don't want to care if the existing size we
2636 * got over dbus is appropriate. */
2637 r
= cpu_set_add_all(affinity
? &c
->cpu_set
: &c
->numa_policy
.nodes
, &set
);
2641 unit_write_settingf(u
, flags
, name
, "%s=%s", name
, str
);
2647 } else if (streq(name
, "CPUAffinityFromNUMA")) {
2650 r
= sd_bus_message_read_basic(message
, 'b', &q
);
2654 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
2655 c
->cpu_affinity_from_numa
= q
;
2656 unit_write_settingf(u
, flags
, name
, "%s=%s", "CPUAffinity", "numa");
2661 } else if (streq(name
, "NUMAPolicy")) {
2664 r
= sd_bus_message_read(message
, "i", &type
);
2668 if (!mpol_is_valid(type
))
2669 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Invalid NUMAPolicy value: %i", type
);
2671 if (!UNIT_WRITE_FLAGS_NOOP(flags
))
2672 c
->numa_policy
.type
= type
;
2676 } else if (streq(name
, "Nice")) {
2679 r
= sd_bus_message_read(message
, "i", &q
);
2683 if (!nice_is_valid(q
))
2684 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Invalid Nice value: %i", q
);
2686 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
2690 unit_write_settingf(u
, flags
, name
, "Nice=%i", q
);
2695 } else if (streq(name
, "CPUSchedulingPolicy")) {
2698 r
= sd_bus_message_read(message
, "i", &q
);
2702 if (!sched_policy_is_valid(q
))
2703 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Invalid CPU scheduling policy: %i", q
);
2705 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
2706 _cleanup_free_
char *s
= NULL
;
2708 r
= sched_policy_to_string_alloc(q
, &s
);
2712 c
->cpu_sched_policy
= q
;
2713 c
->cpu_sched_priority
= CLAMP(c
->cpu_sched_priority
, sched_get_priority_min(q
), sched_get_priority_max(q
));
2714 c
->cpu_sched_set
= true;
2716 unit_write_settingf(u
, flags
, name
, "CPUSchedulingPolicy=%s", s
);
2721 } else if (streq(name
, "CPUSchedulingPriority")) {
2722 int32_t p
, min
, max
;
2724 r
= sd_bus_message_read(message
, "i", &p
);
2728 min
= sched_get_priority_min(c
->cpu_sched_policy
);
2729 max
= sched_get_priority_max(c
->cpu_sched_policy
);
2730 if (p
< min
|| p
> max
)
2731 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Invalid CPU scheduling priority: %i", p
);
2733 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
2734 c
->cpu_sched_priority
= p
;
2735 c
->cpu_sched_set
= true;
2737 unit_write_settingf(u
, flags
, name
, "CPUSchedulingPriority=%i", p
);
2742 } else if (streq(name
, "IOSchedulingClass")) {
2745 r
= sd_bus_message_read(message
, "i", &q
);
2749 if (!ioprio_class_is_valid(q
))
2750 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Invalid IO scheduling class: %i", q
);
2752 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
2753 _cleanup_free_
char *s
= NULL
;
2755 r
= ioprio_class_to_string_alloc(q
, &s
);
2759 c
->ioprio
= ioprio_normalize(ioprio_prio_value(q
, ioprio_prio_data(c
->ioprio
)));
2760 c
->ioprio_set
= true;
2762 unit_write_settingf(u
, flags
, name
, "IOSchedulingClass=%s", s
);
2767 } else if (streq(name
, "IOSchedulingPriority")) {
2770 r
= sd_bus_message_read(message
, "i", &p
);
2774 if (!ioprio_priority_is_valid(p
))
2775 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Invalid IO scheduling priority: %i", p
);
2777 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
2778 c
->ioprio
= ioprio_normalize(ioprio_prio_value(ioprio_prio_class(c
->ioprio
), p
));
2779 c
->ioprio_set
= true;
2781 unit_write_settingf(u
, flags
, name
, "IOSchedulingPriority=%i", p
);
2786 } else if (streq(name
, "MountAPIVFS")) {
2789 r
= bus_set_transient_bool(u
, name
, &b
, message
, flags
, error
);
2793 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
2794 c
->mount_apivfs
= b
;
2795 c
->mount_apivfs_set
= true;
2800 } else if (streq(name
, "WorkingDirectory")) {
2804 r
= sd_bus_message_read(message
, "s", &s
);
2814 if (!isempty(s
) && !streq(s
, "~") && !path_is_absolute(s
))
2815 return sd_bus_error_set(error
, SD_BUS_ERROR_INVALID_ARGS
, "WorkingDirectory= expects an absolute path or '~'");
2817 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
2818 if (streq(s
, "~")) {
2819 c
->working_directory
= mfree(c
->working_directory
);
2820 c
->working_directory_home
= true;
2822 r
= free_and_strdup(&c
->working_directory
, empty_to_null(s
));
2826 c
->working_directory_home
= false;
2829 c
->working_directory_missing_ok
= missing_ok
;
2830 unit_write_settingf(u
, flags
|UNIT_ESCAPE_SPECIFIERS
, name
, "WorkingDirectory=%s%s", missing_ok
? "-" : "", s
);
2835 } else if (STR_IN_SET(name
,
2836 "StandardInputFileDescriptorName", "StandardOutputFileDescriptorName", "StandardErrorFileDescriptorName")) {
2839 r
= sd_bus_message_read(message
, "s", &s
);
2843 if (!isempty(s
) && !fdname_is_valid(s
))
2844 return sd_bus_error_set(error
, SD_BUS_ERROR_INVALID_ARGS
, "Invalid file descriptor name");
2846 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
2848 if (streq(name
, "StandardInputFileDescriptorName")) {
2849 r
= free_and_strdup(c
->stdio_fdname
+ STDIN_FILENO
, empty_to_null(s
));
2853 c
->std_input
= EXEC_INPUT_NAMED_FD
;
2854 unit_write_settingf(u
, flags
|UNIT_ESCAPE_SPECIFIERS
, name
, "StandardInput=fd:%s", exec_context_fdname(c
, STDIN_FILENO
));
2856 } else if (streq(name
, "StandardOutputFileDescriptorName")) {
2857 r
= free_and_strdup(c
->stdio_fdname
+ STDOUT_FILENO
, empty_to_null(s
));
2861 c
->std_output
= EXEC_OUTPUT_NAMED_FD
;
2862 unit_write_settingf(u
, flags
|UNIT_ESCAPE_SPECIFIERS
, name
, "StandardOutput=fd:%s", exec_context_fdname(c
, STDOUT_FILENO
));
2865 assert(streq(name
, "StandardErrorFileDescriptorName"));
2867 r
= free_and_strdup(&c
->stdio_fdname
[STDERR_FILENO
], empty_to_null(s
));
2871 c
->std_error
= EXEC_OUTPUT_NAMED_FD
;
2872 unit_write_settingf(u
, flags
|UNIT_ESCAPE_SPECIFIERS
, name
, "StandardError=fd:%s", exec_context_fdname(c
, STDERR_FILENO
));
2878 } else if (STR_IN_SET(name
,
2879 "StandardInputFile",
2880 "StandardOutputFile", "StandardOutputFileToAppend", "StandardOutputFileToTruncate",
2881 "StandardErrorFile", "StandardErrorFileToAppend", "StandardErrorFileToTruncate")) {
2884 r
= sd_bus_message_read(message
, "s", &s
);
2889 if (!path_is_absolute(s
))
2890 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Path %s is not absolute", s
);
2891 if (!path_is_normalized(s
))
2892 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Path %s is not normalized", s
);
2895 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
2897 if (streq(name
, "StandardInputFile")) {
2898 r
= free_and_strdup(&c
->stdio_file
[STDIN_FILENO
], empty_to_null(s
));
2902 c
->std_input
= EXEC_INPUT_FILE
;
2903 unit_write_settingf(u
, flags
|UNIT_ESCAPE_SPECIFIERS
, name
, "StandardInput=file:%s", s
);
2905 } else if (STR_IN_SET(name
, "StandardOutputFile", "StandardOutputFileToAppend", "StandardOutputFileToTruncate")) {
2906 r
= free_and_strdup(&c
->stdio_file
[STDOUT_FILENO
], empty_to_null(s
));
2910 if (streq(name
, "StandardOutputFile")) {
2911 c
->std_output
= EXEC_OUTPUT_FILE
;
2912 unit_write_settingf(u
, flags
|UNIT_ESCAPE_SPECIFIERS
, name
, "StandardOutput=file:%s", s
);
2913 } else if (streq(name
, "StandardOutputFileToAppend")) {
2914 c
->std_output
= EXEC_OUTPUT_FILE_APPEND
;
2915 unit_write_settingf(u
, flags
|UNIT_ESCAPE_SPECIFIERS
, name
, "StandardOutput=append:%s", s
);
2917 assert(streq(name
, "StandardOutputFileToTruncate"));
2918 c
->std_output
= EXEC_OUTPUT_FILE_TRUNCATE
;
2919 unit_write_settingf(u
, flags
|UNIT_ESCAPE_SPECIFIERS
, name
, "StandardOutput=truncate:%s", s
);
2922 assert(STR_IN_SET(name
, "StandardErrorFile", "StandardErrorFileToAppend", "StandardErrorFileToTruncate"));
2924 r
= free_and_strdup(&c
->stdio_file
[STDERR_FILENO
], empty_to_null(s
));
2928 if (streq(name
, "StandardErrorFile")) {
2929 c
->std_error
= EXEC_OUTPUT_FILE
;
2930 unit_write_settingf(u
, flags
|UNIT_ESCAPE_SPECIFIERS
, name
, "StandardError=file:%s", s
);
2931 } else if (streq(name
, "StandardErrorFileToAppend")) {
2932 c
->std_error
= EXEC_OUTPUT_FILE_APPEND
;
2933 unit_write_settingf(u
, flags
|UNIT_ESCAPE_SPECIFIERS
, name
, "StandardError=append:%s", s
);
2935 assert(streq(name
, "StandardErrorFileToTruncate"));
2936 c
->std_error
= EXEC_OUTPUT_FILE_TRUNCATE
;
2937 unit_write_settingf(u
, flags
|UNIT_ESCAPE_SPECIFIERS
, name
, "StandardError=truncate:%s", s
);
2944 } else if (streq(name
, "StandardInputData")) {
2948 r
= sd_bus_message_read_array(message
, 'y', &p
, &sz
);
2952 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
2953 _cleanup_free_
char *encoded
= NULL
;
2956 c
->stdin_data
= mfree(c
->stdin_data
);
2957 c
->stdin_data_size
= 0;
2959 unit_write_settingf(u
, flags
, name
, "StandardInputData=");
2964 if (c
->stdin_data_size
+ sz
< c
->stdin_data_size
|| /* check for overflow */
2965 c
->stdin_data_size
+ sz
> EXEC_STDIN_DATA_MAX
)
2968 n
= base64mem(p
, sz
, &encoded
);
2972 q
= realloc(c
->stdin_data
, c
->stdin_data_size
+ sz
);
2976 memcpy((uint8_t*) q
+ c
->stdin_data_size
, p
, sz
);
2979 c
->stdin_data_size
+= sz
;
2981 unit_write_settingf(u
, flags
, name
, "StandardInputData=%s", encoded
);
2987 } else if (streq(name
, "Environment")) {
2989 _cleanup_strv_free_
char **l
= NULL
;
2991 r
= sd_bus_message_read_strv(message
, &l
);
2995 if (!strv_env_is_valid(l
))
2996 return sd_bus_error_set(error
, SD_BUS_ERROR_INVALID_ARGS
, "Invalid environment block.");
2998 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
2999 if (strv_isempty(l
)) {
3000 c
->environment
= strv_free(c
->environment
);
3001 unit_write_setting(u
, flags
, name
, "Environment=");
3003 _cleanup_free_
char *joined
= NULL
;
3006 joined
= unit_concat_strv(l
, UNIT_ESCAPE_SPECIFIERS
|UNIT_ESCAPE_C
);
3010 e
= strv_env_merge(c
->environment
, l
);
3014 strv_free_and_replace(c
->environment
, e
);
3015 unit_write_settingf(u
, flags
, name
, "Environment=%s", joined
);
3021 } else if (streq(name
, "UnsetEnvironment")) {
3023 _cleanup_strv_free_
char **l
= NULL
;
3025 r
= sd_bus_message_read_strv(message
, &l
);
3029 if (!strv_env_name_or_assignment_is_valid(l
))
3030 return sd_bus_error_set(error
, SD_BUS_ERROR_INVALID_ARGS
, "Invalid UnsetEnvironment= list.");
3032 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
3033 if (strv_isempty(l
)) {
3034 c
->unset_environment
= strv_free(c
->unset_environment
);
3035 unit_write_setting(u
, flags
, name
, "UnsetEnvironment=");
3037 _cleanup_free_
char *joined
= NULL
;
3040 joined
= unit_concat_strv(l
, UNIT_ESCAPE_SPECIFIERS
|UNIT_ESCAPE_C
);
3044 e
= strv_env_merge(c
->unset_environment
, l
);
3048 strv_free_and_replace(c
->unset_environment
, e
);
3049 unit_write_settingf(u
, flags
, name
, "UnsetEnvironment=%s", joined
);
3055 } else if (streq(name
, "OOMScoreAdjust")) {
3058 r
= sd_bus_message_read(message
, "i", &oa
);
3062 if (!oom_score_adjust_is_valid(oa
))
3063 return sd_bus_error_set(error
, SD_BUS_ERROR_INVALID_ARGS
, "OOM score adjust value out of range");
3065 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
3066 c
->oom_score_adjust
= oa
;
3067 c
->oom_score_adjust_set
= true;
3068 unit_write_settingf(u
, flags
, name
, "OOMScoreAdjust=%i", oa
);
3073 } else if (streq(name
, "CoredumpFilter")) {
3076 r
= sd_bus_message_read(message
, "t", &f
);
3080 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
3081 c
->coredump_filter
= f
;
3082 c
->coredump_filter_set
= true;
3083 unit_write_settingf(u
, flags
, name
, "CoredumpFilter=0x%"PRIx64
, f
);
3088 } else if (streq(name
, "EnvironmentFiles")) {
3090 _cleanup_free_
char *joined
= NULL
;
3091 _cleanup_fclose_
FILE *f
= NULL
;
3092 _cleanup_strv_free_
char **l
= NULL
;
3095 r
= sd_bus_message_enter_container(message
, 'a', "(sb)");
3099 f
= open_memstream_unlocked(&joined
, &size
);
3103 fputs("EnvironmentFile=\n", f
);
3105 STRV_FOREACH(i
, c
->environment_files
) {
3106 _cleanup_free_
char *q
= NULL
;
3108 q
= specifier_escape(*i
);
3112 fprintf(f
, "EnvironmentFile=%s\n", q
);
3115 while ((r
= sd_bus_message_enter_container(message
, 'r', "sb")) > 0) {
3119 r
= sd_bus_message_read(message
, "sb", &path
, &b
);
3123 r
= sd_bus_message_exit_container(message
);
3127 if (!path_is_absolute(path
))
3128 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Path %s is not absolute.", path
);
3130 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
3131 _cleanup_free_
char *q
= NULL
, *buf
= NULL
;
3133 buf
= strjoin(b
? "-" : "", path
);
3137 q
= specifier_escape(buf
);
3141 fprintf(f
, "EnvironmentFile=%s\n", q
);
3143 r
= strv_consume(&l
, TAKE_PTR(buf
));
3151 r
= sd_bus_message_exit_container(message
);
3155 r
= fflush_and_check(f
);
3159 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
3160 if (strv_isempty(l
)) {
3161 c
->environment_files
= strv_free(c
->environment_files
);
3162 unit_write_setting(u
, flags
, name
, "EnvironmentFile=");
3164 r
= strv_extend_strv(&c
->environment_files
, l
, true);
3168 unit_write_setting(u
, flags
, name
, joined
);
3174 } else if (streq(name
, "PassEnvironment")) {
3176 _cleanup_strv_free_
char **l
= NULL
;
3178 r
= sd_bus_message_read_strv(message
, &l
);
3182 if (!strv_env_name_is_valid(l
))
3183 return sd_bus_error_set(error
, SD_BUS_ERROR_INVALID_ARGS
, "Invalid PassEnvironment= block.");
3185 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
3186 if (strv_isempty(l
)) {
3187 c
->pass_environment
= strv_free(c
->pass_environment
);
3188 unit_write_setting(u
, flags
, name
, "PassEnvironment=");
3190 _cleanup_free_
char *joined
= NULL
;
3192 r
= strv_extend_strv(&c
->pass_environment
, l
, true);
3196 /* We write just the new settings out to file, with unresolved specifiers. */
3197 joined
= unit_concat_strv(l
, UNIT_ESCAPE_SPECIFIERS
);
3201 unit_write_settingf(u
, flags
, name
, "PassEnvironment=%s", joined
);
3207 } else if (STR_IN_SET(name
, "ReadWriteDirectories", "ReadOnlyDirectories", "InaccessibleDirectories",
3208 "ReadWritePaths", "ReadOnlyPaths", "InaccessiblePaths", "ExecPaths", "NoExecPaths",
3209 "ExtensionDirectories")) {
3210 _cleanup_strv_free_
char **l
= NULL
;
3213 r
= sd_bus_message_read_strv(message
, &l
);
3217 STRV_FOREACH(p
, l
) {
3221 offset
= i
[0] == '-';
3222 offset
+= i
[offset
] == '+';
3223 if (!path_is_absolute(i
+ offset
))
3224 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Invalid %s", name
);
3226 path_simplify(i
+ offset
);
3229 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
3230 if (STR_IN_SET(name
, "ReadWriteDirectories", "ReadWritePaths"))
3231 dirs
= &c
->read_write_paths
;
3232 else if (STR_IN_SET(name
, "ReadOnlyDirectories", "ReadOnlyPaths"))
3233 dirs
= &c
->read_only_paths
;
3234 else if (streq(name
, "ExecPaths"))
3235 dirs
= &c
->exec_paths
;
3236 else if (streq(name
, "NoExecPaths"))
3237 dirs
= &c
->no_exec_paths
;
3238 else if (streq(name
, "ExtensionDirectories"))
3239 dirs
= &c
->extension_directories
;
3240 else /* "InaccessiblePaths" */
3241 dirs
= &c
->inaccessible_paths
;
3243 if (strv_isempty(l
)) {
3244 *dirs
= strv_free(*dirs
);
3245 unit_write_settingf(u
, flags
, name
, "%s=", name
);
3247 _cleanup_free_
char *joined
= NULL
;
3249 joined
= unit_concat_strv(l
, UNIT_ESCAPE_SPECIFIERS
);
3253 r
= strv_extend_strv(dirs
, l
, true);
3257 unit_write_settingf(u
, flags
, name
, "%s=%s", name
, joined
);
3263 } else if (streq(name
, "ExecSearchPath")) {
3264 _cleanup_strv_free_
char **l
= NULL
;
3266 r
= sd_bus_message_read_strv(message
, &l
);
3271 if (!path_is_absolute(*p
) || !path_is_normalized(*p
) || strchr(*p
, ':'))
3272 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Invalid %s", name
);
3274 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
3275 if (strv_isempty(l
)) {
3276 c
->exec_search_path
= strv_free(c
->exec_search_path
);
3277 unit_write_settingf(u
, flags
|UNIT_ESCAPE_SPECIFIERS
, name
, "ExecSearchPath=");
3279 _cleanup_free_
char *joined
= NULL
;
3280 r
= strv_extend_strv(&c
->exec_search_path
, l
, true);
3283 joined
= strv_join(c
->exec_search_path
, ":");
3286 unit_write_settingf(u
, flags
|UNIT_ESCAPE_SPECIFIERS
, name
, "ExecSearchPath=%s", joined
);
3292 } else if (STR_IN_SET(name
, "RuntimeDirectory", "StateDirectory", "CacheDirectory", "LogsDirectory", "ConfigurationDirectory")) {
3293 _cleanup_strv_free_
char **l
= NULL
;
3295 r
= sd_bus_message_read_strv(message
, &l
);
3299 STRV_FOREACH(p
, l
) {
3300 if (!path_is_normalized(*p
))
3301 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "%s= path is not normalized: %s", name
, *p
);
3303 if (path_is_absolute(*p
))
3304 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "%s= path is absolute: %s", name
, *p
);
3306 if (path_startswith(*p
, "private"))
3307 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "%s= path can't be 'private': %s", name
, *p
);
3310 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
3311 ExecDirectoryType i
;
3314 assert_se((i
= exec_directory_type_from_string(name
)) >= 0);
3315 d
= c
->directories
+ i
;
3317 if (strv_isempty(l
)) {
3318 exec_directory_done(d
);
3319 unit_write_settingf(u
, flags
, name
, "%s=", name
);
3321 _cleanup_free_
char *joined
= NULL
;
3323 STRV_FOREACH(source
, l
) {
3324 r
= exec_directory_add(&d
->items
, &d
->n_items
, *source
, NULL
);
3329 joined
= unit_concat_strv(l
, UNIT_ESCAPE_SPECIFIERS
);
3333 unit_write_settingf(u
, flags
, name
, "%s=%s", name
, joined
);
3339 } else if (STR_IN_SET(name
, "AppArmorProfile", "SmackProcessLabel")) {
3343 r
= sd_bus_message_read(message
, "(bs)", &ignore
, &s
);
3347 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
3351 if (streq(name
, "AppArmorProfile")) {
3352 p
= &c
->apparmor_profile
;
3353 b
= &c
->apparmor_profile_ignore
;
3354 } else { /* "SmackProcessLabel" */
3355 p
= &c
->smack_process_label
;
3356 b
= &c
->smack_process_label_ignore
;
3363 if (free_and_strdup(p
, s
) < 0)
3368 unit_write_settingf(u
, flags
|UNIT_ESCAPE_SPECIFIERS
, name
, "%s=%s%s", name
, ignore
? "-" : "", strempty(s
));
3373 } else if (STR_IN_SET(name
, "BindPaths", "BindReadOnlyPaths")) {
3374 char *source
, *destination
;
3376 uint64_t mount_flags
;
3379 r
= sd_bus_message_enter_container(message
, 'a', "(ssbt)");
3383 while ((r
= sd_bus_message_read(message
, "(ssbt)", &source
, &destination
, &ignore_enoent
, &mount_flags
)) > 0) {
3385 if (!path_is_absolute(source
))
3386 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Source path %s is not absolute.", source
);
3387 if (!path_is_absolute(destination
))
3388 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Destination path %s is not absolute.", destination
);
3389 if (!IN_SET(mount_flags
, 0, MS_REC
))
3390 return sd_bus_error_set(error
, SD_BUS_ERROR_INVALID_ARGS
, "Unknown mount flags.");
3392 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
3393 r
= bind_mount_add(&c
->bind_mounts
, &c
->n_bind_mounts
,
3396 .destination
= destination
,
3397 .read_only
= !!strstr(name
, "ReadOnly"),
3398 .recursive
= !!(mount_flags
& MS_REC
),
3399 .ignore_enoent
= ignore_enoent
,
3404 unit_write_settingf(
3405 u
, flags
|UNIT_ESCAPE_SPECIFIERS
, name
,
3408 ignore_enoent
? "-" : "",
3411 (mount_flags
& MS_REC
) ? "rbind" : "norbind");
3419 r
= sd_bus_message_exit_container(message
);
3424 bind_mount_free_many(c
->bind_mounts
, c
->n_bind_mounts
);
3425 c
->bind_mounts
= NULL
;
3426 c
->n_bind_mounts
= 0;
3428 unit_write_settingf(u
, flags
, name
, "%s=", name
);
3433 } else if (streq(name
, "TemporaryFileSystem")) {
3434 const char *path
, *options
;
3437 r
= sd_bus_message_enter_container(message
, 'a', "(ss)");
3441 while ((r
= sd_bus_message_read(message
, "(ss)", &path
, &options
)) > 0) {
3443 if (!path_is_absolute(path
))
3444 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Mount point %s is not absolute.", path
);
3446 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
3447 r
= temporary_filesystem_add(&c
->temporary_filesystems
, &c
->n_temporary_filesystems
, path
, options
);
3451 unit_write_settingf(
3452 u
, flags
|UNIT_ESCAPE_SPECIFIERS
, name
,
3464 r
= sd_bus_message_exit_container(message
);
3469 temporary_filesystem_free_many(c
->temporary_filesystems
, c
->n_temporary_filesystems
);
3470 c
->temporary_filesystems
= NULL
;
3471 c
->n_temporary_filesystems
= 0;
3473 unit_write_settingf(u
, flags
, name
, "%s=", name
);
3478 } else if ((suffix
= startswith(name
, "Limit"))) {
3479 const char *soft
= NULL
;
3482 ri
= rlimit_from_string(suffix
);
3484 soft
= endswith(suffix
, "Soft");
3488 n
= strndupa_safe(suffix
, soft
- suffix
);
3489 ri
= rlimit_from_string(n
);
3491 name
= strjoina("Limit", n
);
3499 r
= sd_bus_message_read(message
, "t", &rl
);
3503 if (rl
== UINT64_MAX
)
3508 if ((uint64_t) x
!= rl
)
3512 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
3513 _cleanup_free_
char *f
= NULL
;
3516 if (c
->rlimit
[ri
]) {
3517 nl
= *c
->rlimit
[ri
];
3524 /* When the resource limit is not initialized yet, then assign the value to both fields */
3525 nl
= (struct rlimit
) {
3530 r
= rlimit_format(&nl
, &f
);
3535 *c
->rlimit
[ri
] = nl
;
3537 c
->rlimit
[ri
] = newdup(struct rlimit
, &nl
, 1);
3542 unit_write_settingf(u
, flags
, name
, "%s=%s", name
, f
);
3548 } else if (streq(name
, "MountImages")) {
3549 _cleanup_free_
char *format_str
= NULL
;
3550 MountImage
*mount_images
= NULL
;
3551 size_t n_mount_images
= 0;
3552 char *source
, *destination
;
3555 r
= sd_bus_message_enter_container(message
, 'a', "(ssba(ss))");
3560 _cleanup_(mount_options_free_allp
) MountOptions
*options
= NULL
;
3561 _cleanup_free_
char *source_escaped
= NULL
, *destination_escaped
= NULL
;
3564 r
= sd_bus_message_enter_container(message
, 'r', "ssba(ss)");
3568 r
= sd_bus_message_read(message
, "ssb", &source
, &destination
, &permissive
);
3572 if (!path_is_absolute(source
))
3573 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Source path %s is not absolute.", source
);
3574 if (!path_is_normalized(source
))
3575 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Source path %s is not normalized.", source
);
3576 if (!path_is_absolute(destination
))
3577 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Destination path %s is not absolute.", destination
);
3578 if (!path_is_normalized(destination
))
3579 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Destination path %s is not normalized.", destination
);
3581 /* Need to store them in the unit with the escapes, so that they can be parsed again */
3582 source_escaped
= shell_escape(source
, ":");
3583 if (!source_escaped
)
3585 destination_escaped
= shell_escape(destination
, ":");
3586 if (!destination_escaped
)
3589 tuple
= strjoin(format_str
,
3590 format_str
? " " : "",
3591 permissive
? "-" : "",
3594 destination_escaped
);
3597 free_and_replace(format_str
, tuple
);
3599 r
= bus_read_mount_options(message
, error
, &options
, &format_str
, ":");
3603 r
= sd_bus_message_exit_container(message
);
3607 r
= mount_image_add(&mount_images
, &n_mount_images
,
3610 .destination
= destination
,
3611 .mount_options
= options
,
3612 .ignore_enoent
= permissive
,
3613 .type
= MOUNT_IMAGE_DISCRETE
,
3621 r
= sd_bus_message_exit_container(message
);
3625 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
3626 if (n_mount_images
== 0) {
3627 c
->mount_images
= mount_image_free_many(c
->mount_images
, &c
->n_mount_images
);
3629 unit_write_settingf(u
, flags
, name
, "%s=", name
);
3631 for (size_t i
= 0; i
< n_mount_images
; ++i
) {
3632 r
= mount_image_add(&c
->mount_images
, &c
->n_mount_images
, &mount_images
[i
]);
3637 unit_write_settingf(u
, flags
|UNIT_ESCAPE_C
|UNIT_ESCAPE_SPECIFIERS
,
3645 mount_images
= mount_image_free_many(mount_images
, &n_mount_images
);
3648 } else if (streq(name
, "ExtensionImages")) {
3649 _cleanup_free_
char *format_str
= NULL
;
3650 MountImage
*extension_images
= NULL
;
3651 size_t n_extension_images
= 0;
3653 r
= sd_bus_message_enter_container(message
, 'a', "(sba(ss))");
3658 _cleanup_(mount_options_free_allp
) MountOptions
*options
= NULL
;
3659 _cleanup_free_
char *source_escaped
= NULL
;
3660 char *source
, *tuple
;
3663 r
= sd_bus_message_enter_container(message
, 'r', "sba(ss)");
3667 r
= sd_bus_message_read(message
, "sb", &source
, &permissive
);
3671 if (!path_is_absolute(source
))
3672 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Source path %s is not absolute.", source
);
3673 if (!path_is_normalized(source
))
3674 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Source path %s is not normalized.", source
);
3676 /* Need to store them in the unit with the escapes, so that they can be parsed again */
3677 source_escaped
= shell_escape(source
, ":");
3678 if (!source_escaped
)
3681 tuple
= strjoin(format_str
,
3682 format_str
? " " : "",
3683 permissive
? "-" : "",
3687 free_and_replace(format_str
, tuple
);
3689 r
= bus_read_mount_options(message
, error
, &options
, &format_str
, ":");
3693 r
= sd_bus_message_exit_container(message
);
3697 r
= mount_image_add(&extension_images
, &n_extension_images
,
3700 .mount_options
= options
,
3701 .ignore_enoent
= permissive
,
3702 .type
= MOUNT_IMAGE_EXTENSION
,
3710 r
= sd_bus_message_exit_container(message
);
3714 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
3715 if (n_extension_images
== 0) {
3716 c
->extension_images
= mount_image_free_many(c
->extension_images
, &c
->n_extension_images
);
3718 unit_write_settingf(u
, flags
, name
, "%s=", name
);
3720 for (size_t i
= 0; i
< n_extension_images
; ++i
) {
3721 r
= mount_image_add(&c
->extension_images
, &c
->n_extension_images
, &extension_images
[i
]);
3726 unit_write_settingf(u
, flags
|UNIT_ESCAPE_C
|UNIT_ESCAPE_SPECIFIERS
,
3734 extension_images
= mount_image_free_many(extension_images
, &n_extension_images
);
3738 } else if (STR_IN_SET(name
, "StateDirectorySymlink", "RuntimeDirectorySymlink", "CacheDirectorySymlink", "LogsDirectorySymlink")) {
3739 char *source
, *destination
;
3740 ExecDirectory
*directory
;
3741 uint64_t symlink_flags
; /* No flags for now, reserved for future uses. */
3742 ExecDirectoryType i
;
3744 assert_se((i
= exec_directory_type_symlink_from_string(name
)) >= 0);
3745 directory
= c
->directories
+ i
;
3747 r
= sd_bus_message_enter_container(message
, 'a', "(sst)");
3751 while ((r
= sd_bus_message_read(message
, "(sst)", &source
, &destination
, &symlink_flags
)) > 0) {
3752 if (!path_is_valid(source
))
3753 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Source path %s is not valid.", source
);
3754 if (path_is_absolute(source
))
3755 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Source path %s is absolute.", source
);
3756 if (!path_is_normalized(source
))
3757 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Source path %s is not normalized.", source
);
3758 if (!path_is_valid(destination
))
3759 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Destination path %s is not valid.", destination
);
3760 if (path_is_absolute(destination
))
3761 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Destination path %s is absolute.", destination
);
3762 if (!path_is_normalized(destination
))
3763 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Destination path %s is not normalized.", destination
);
3764 if (symlink_flags
!= 0)
3765 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Flags must be zero.");
3767 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
3768 _cleanup_free_
char *destination_escaped
= NULL
, *source_escaped
= NULL
;
3769 ExecDirectoryItem
*item
= NULL
;
3771 /* Adding new directories is supported from both *DirectorySymlink methods and the
3772 * older ones, so try to find an existing configuration first and create it if it's
3774 for (size_t j
= 0; j
< directory
->n_items
; ++j
)
3775 if (path_equal(source
, directory
->items
[j
].path
)) {
3776 item
= &directory
->items
[j
];
3781 r
= strv_extend(&item
->symlinks
, destination
);
3783 r
= exec_directory_add(&directory
->items
, &directory
->n_items
, source
, STRV_MAKE(destination
));
3787 /* Need to store them in the unit with the escapes, so that they can be parsed again */
3788 source_escaped
= xescape(source
, ":");
3789 destination_escaped
= xescape(destination
, ":");
3790 if (!source_escaped
|| !destination_escaped
)
3793 unit_write_settingf(
3794 u
, flags
|UNIT_ESCAPE_SPECIFIERS
, exec_directory_type_to_string(i
),
3796 exec_directory_type_to_string(i
),
3798 destination_escaped
);
3804 r
= sd_bus_message_exit_container(message
);