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 "dbus-execute.h"
17 #include "dbus-util.h"
19 #include "errno-list.h"
24 #include "hexdecoct.h"
27 #include "journal-file.h"
28 #include "mountpoint-util.h"
29 #include "namespace.h"
30 #include "parse-util.h"
31 #include "path-util.h"
32 #include "process-util.h"
33 #include "rlimit-util.h"
35 #include "seccomp-util.h"
37 #include "securebits-util.h"
38 #include "specifier.h"
40 #include "syslog-util.h"
41 #include "unit-printf.h"
42 #include "user-util.h"
45 BUS_DEFINE_PROPERTY_GET_ENUM(bus_property_get_exec_output
, exec_output
, ExecOutput
);
46 static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_exec_input
, exec_input
, ExecInput
);
47 static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_exec_utmp_mode
, exec_utmp_mode
, ExecUtmpMode
);
48 static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_exec_preserve_mode
, exec_preserve_mode
, ExecPreserveMode
);
49 static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_exec_keyring_mode
, exec_keyring_mode
, ExecKeyringMode
);
50 static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_protect_proc
, protect_proc
, ProtectProc
);
51 static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_proc_subset
, proc_subset
, ProcSubset
);
52 static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_protect_home
, protect_home
, ProtectHome
);
53 static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_protect_system
, protect_system
, ProtectSystem
);
54 static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_personality
, personality
, unsigned long);
55 static BUS_DEFINE_PROPERTY_GET(property_get_ioprio
, "i", ExecContext
, exec_context_get_effective_ioprio
);
56 static BUS_DEFINE_PROPERTY_GET(property_get_mount_apivfs
, "b", ExecContext
, exec_context_get_effective_mount_apivfs
);
57 static BUS_DEFINE_PROPERTY_GET2(property_get_ioprio_class
, "i", ExecContext
, exec_context_get_effective_ioprio
, IOPRIO_PRIO_CLASS
);
58 static BUS_DEFINE_PROPERTY_GET2(property_get_ioprio_priority
, "i", ExecContext
, exec_context_get_effective_ioprio
, IOPRIO_PRIO_DATA
);
59 static BUS_DEFINE_PROPERTY_GET_GLOBAL(property_get_empty_string
, "s", NULL
);
60 static BUS_DEFINE_PROPERTY_GET_REF(property_get_syslog_level
, "i", int, LOG_PRI
);
61 static BUS_DEFINE_PROPERTY_GET_REF(property_get_syslog_facility
, "i", int, LOG_FAC
);
62 static BUS_DEFINE_PROPERTY_GET(property_get_cpu_affinity_from_numa
, "b", ExecContext
, exec_context_get_cpu_affinity_from_numa
);
64 static int property_get_environment_files(
67 const char *interface
,
69 sd_bus_message
*reply
,
71 sd_bus_error
*error
) {
73 ExecContext
*c
= userdata
;
81 r
= sd_bus_message_open_container(reply
, 'a', "(sb)");
85 STRV_FOREACH(j
, c
->environment_files
) {
88 r
= sd_bus_message_append(reply
, "(sb)", fn
[0] == '-' ? fn
+ 1 : fn
, fn
[0] == '-');
93 return sd_bus_message_close_container(reply
);
96 static int property_get_oom_score_adjust(
99 const char *interface
,
100 const char *property
,
101 sd_bus_message
*reply
,
103 sd_bus_error
*error
) {
105 ExecContext
*c
= userdata
;
113 if (c
->oom_score_adjust_set
)
114 n
= c
->oom_score_adjust
;
116 _cleanup_free_
char *t
= NULL
;
119 r
= read_one_line_file("/proc/self/oom_score_adj", &t
);
121 log_debug_errno(r
, "Failed to read /proc/self/oom_score_adj, ignoring: %m");
123 r
= safe_atoi32(t
, &n
);
125 log_debug_errno(r
, "Failed to parse \"%s\" from /proc/self/oom_score_adj, ignoring: %m", t
);
129 return sd_bus_message_append(reply
, "i", n
);
132 static int property_get_coredump_filter(
135 const char *interface
,
136 const char *property
,
137 sd_bus_message
*reply
,
139 sd_bus_error
*error
) {
141 ExecContext
*c
= userdata
;
149 if (c
->coredump_filter_set
)
150 n
= c
->coredump_filter
;
152 _cleanup_free_
char *t
= NULL
;
154 n
= COREDUMP_FILTER_MASK_DEFAULT
;
155 r
= read_one_line_file("/proc/self/coredump_filter", &t
);
157 log_debug_errno(r
, "Failed to read /proc/self/coredump_filter, ignoring: %m");
159 r
= safe_atoux64(t
, &n
);
161 log_debug_errno(r
, "Failed to parse \"%s\" from /proc/self/coredump_filter, ignoring: %m", t
);
165 return sd_bus_message_append(reply
, "t", n
);
168 static int property_get_nice(
171 const char *interface
,
172 const char *property
,
173 sd_bus_message
*reply
,
175 sd_bus_error
*error
) {
177 ExecContext
*c
= userdata
;
188 n
= getpriority(PRIO_PROCESS
, 0);
193 return sd_bus_message_append(reply
, "i", n
);
196 static int property_get_cpu_sched_policy(
199 const char *interface
,
200 const char *property
,
201 sd_bus_message
*reply
,
203 sd_bus_error
*error
) {
205 ExecContext
*c
= userdata
;
212 if (c
->cpu_sched_set
)
213 n
= c
->cpu_sched_policy
;
215 n
= sched_getscheduler(0);
220 return sd_bus_message_append(reply
, "i", n
);
223 static int property_get_cpu_sched_priority(
226 const char *interface
,
227 const char *property
,
228 sd_bus_message
*reply
,
230 sd_bus_error
*error
) {
232 ExecContext
*c
= userdata
;
239 if (c
->cpu_sched_set
)
240 n
= c
->cpu_sched_priority
;
242 struct sched_param p
= {};
244 if (sched_getparam(0, &p
) >= 0)
245 n
= p
.sched_priority
;
250 return sd_bus_message_append(reply
, "i", n
);
253 static int property_get_cpu_affinity(
256 const char *interface
,
257 const char *property
,
258 sd_bus_message
*reply
,
260 sd_bus_error
*error
) {
262 ExecContext
*c
= userdata
;
263 _cleanup_(cpu_set_reset
) CPUSet s
= {};
264 _cleanup_free_
uint8_t *array
= NULL
;
271 if (c
->cpu_affinity_from_numa
) {
274 r
= numa_to_cpu_set(&c
->numa_policy
, &s
);
279 (void) cpu_set_to_dbus(c
->cpu_affinity_from_numa
? &s
: &c
->cpu_set
, &array
, &allocated
);
281 return sd_bus_message_append_array(reply
, 'y', array
, allocated
);
284 static int property_get_numa_mask(
287 const char *interface
,
288 const char *property
,
289 sd_bus_message
*reply
,
291 sd_bus_error
*error
) {
293 ExecContext
*c
= userdata
;
294 _cleanup_free_
uint8_t *array
= NULL
;
301 (void) cpu_set_to_dbus(&c
->numa_policy
.nodes
, &array
, &allocated
);
303 return sd_bus_message_append_array(reply
, 'y', array
, allocated
);
306 static int property_get_numa_policy(
309 const char *interface
,
310 const char *property
,
311 sd_bus_message
*reply
,
313 sd_bus_error
*error
) {
314 ExecContext
*c
= userdata
;
321 policy
= numa_policy_get_type(&c
->numa_policy
);
323 return sd_bus_message_append_basic(reply
, 'i', &policy
);
326 static int property_get_timer_slack_nsec(
329 const char *interface
,
330 const char *property
,
331 sd_bus_message
*reply
,
333 sd_bus_error
*error
) {
335 ExecContext
*c
= userdata
;
342 if (c
->timer_slack_nsec
!= NSEC_INFINITY
)
343 u
= (uint64_t) c
->timer_slack_nsec
;
345 u
= (uint64_t) prctl(PR_GET_TIMERSLACK
);
347 return sd_bus_message_append(reply
, "t", u
);
350 static int property_get_syscall_filter(
353 const char *interface
,
354 const char *property
,
355 sd_bus_message
*reply
,
357 sd_bus_error
*error
) {
359 ExecContext
*c
= userdata
;
360 _cleanup_strv_free_
char **l
= NULL
;
371 r
= sd_bus_message_open_container(reply
, 'r', "bas");
375 r
= sd_bus_message_append(reply
, "b", c
->syscall_allow_list
);
380 HASHMAP_FOREACH_KEY(val
, id
, c
->syscall_filter
) {
381 _cleanup_free_
char *name
= NULL
;
382 const char *e
= NULL
;
384 int num
= PTR_TO_INT(val
);
386 name
= seccomp_syscall_resolve_num_arch(SCMP_ARCH_NATIVE
, PTR_TO_INT(id
) - 1);
391 e
= seccomp_errno_or_action_to_string(num
);
393 s
= strjoin(name
, ":", e
);
397 r
= asprintf(&s
, "%s:%d", name
, num
);
404 r
= strv_consume(&l
, s
);
412 r
= sd_bus_message_append_strv(reply
, l
);
416 return sd_bus_message_close_container(reply
);
419 static int property_get_syscall_log(
422 const char *interface
,
423 const char *property
,
424 sd_bus_message
*reply
,
426 sd_bus_error
*error
) {
428 ExecContext
*c
= userdata
;
429 _cleanup_strv_free_
char **l
= NULL
;
440 r
= sd_bus_message_open_container(reply
, 'r', "bas");
444 r
= sd_bus_message_append(reply
, "b", c
->syscall_log_allow_list
);
449 HASHMAP_FOREACH_KEY(val
, id
, c
->syscall_log
) {
452 name
= seccomp_syscall_resolve_num_arch(SCMP_ARCH_NATIVE
, PTR_TO_INT(id
) - 1);
456 r
= strv_consume(&l
, name
);
464 r
= sd_bus_message_append_strv(reply
, l
);
468 return sd_bus_message_close_container(reply
);
471 static int property_get_syscall_archs(
474 const char *interface
,
475 const char *property
,
476 sd_bus_message
*reply
,
478 sd_bus_error
*error
) {
480 ExecContext
*c
= userdata
;
481 _cleanup_strv_free_
char **l
= NULL
;
493 SET_FOREACH(id
, c
->syscall_archs
) {
496 name
= seccomp_arch_to_string(PTR_TO_UINT32(id
) - 1);
500 r
= strv_extend(&l
, name
);
508 r
= sd_bus_message_append_strv(reply
, l
);
515 static int property_get_selinux_context(
518 const char *interface
,
519 const char *property
,
520 sd_bus_message
*reply
,
522 sd_bus_error
*error
) {
524 ExecContext
*c
= userdata
;
530 return sd_bus_message_append(reply
, "(bs)", c
->selinux_context_ignore
, c
->selinux_context
);
533 static int property_get_apparmor_profile(
536 const char *interface
,
537 const char *property
,
538 sd_bus_message
*reply
,
540 sd_bus_error
*error
) {
542 ExecContext
*c
= userdata
;
548 return sd_bus_message_append(reply
, "(bs)", c
->apparmor_profile_ignore
, c
->apparmor_profile
);
551 static int property_get_smack_process_label(
554 const char *interface
,
555 const char *property
,
556 sd_bus_message
*reply
,
558 sd_bus_error
*error
) {
560 ExecContext
*c
= userdata
;
566 return sd_bus_message_append(reply
, "(bs)", c
->smack_process_label_ignore
, c
->smack_process_label
);
569 static int property_get_address_families(
572 const char *interface
,
573 const char *property
,
574 sd_bus_message
*reply
,
576 sd_bus_error
*error
) {
578 ExecContext
*c
= userdata
;
579 _cleanup_strv_free_
char **l
= NULL
;
587 r
= sd_bus_message_open_container(reply
, 'r', "bas");
591 r
= sd_bus_message_append(reply
, "b", c
->address_families_allow_list
);
595 SET_FOREACH(af
, c
->address_families
) {
598 name
= af_to_name(PTR_TO_INT(af
));
602 r
= strv_extend(&l
, name
);
609 r
= sd_bus_message_append_strv(reply
, l
);
613 return sd_bus_message_close_container(reply
);
616 static int property_get_working_directory(
619 const char *interface
,
620 const char *property
,
621 sd_bus_message
*reply
,
623 sd_bus_error
*error
) {
625 ExecContext
*c
= userdata
;
632 if (c
->working_directory_home
)
635 wd
= c
->working_directory
;
637 if (c
->working_directory_missing_ok
)
638 wd
= strjoina("!", wd
);
640 return sd_bus_message_append(reply
, "s", wd
);
643 static int property_get_stdio_fdname(
646 const char *interface
,
647 const char *property
,
648 sd_bus_message
*reply
,
650 sd_bus_error
*error
) {
652 ExecContext
*c
= userdata
;
660 if (streq(property
, "StandardInputFileDescriptorName"))
661 fileno
= STDIN_FILENO
;
662 else if (streq(property
, "StandardOutputFileDescriptorName"))
663 fileno
= STDOUT_FILENO
;
665 assert(streq(property
, "StandardErrorFileDescriptorName"));
666 fileno
= STDERR_FILENO
;
669 return sd_bus_message_append(reply
, "s", exec_context_fdname(c
, fileno
));
672 static int property_get_input_data(
675 const char *interface
,
676 const char *property
,
677 sd_bus_message
*reply
,
679 sd_bus_error
*error
) {
681 ExecContext
*c
= userdata
;
688 return sd_bus_message_append_array(reply
, 'y', c
->stdin_data
, c
->stdin_data_size
);
691 static int property_get_bind_paths(
694 const char *interface
,
695 const char *property
,
696 sd_bus_message
*reply
,
698 sd_bus_error
*error
) {
700 ExecContext
*c
= userdata
;
709 ro
= strstr(property
, "ReadOnly");
711 r
= sd_bus_message_open_container(reply
, 'a', "(ssbt)");
715 for (size_t i
= 0; i
< c
->n_bind_mounts
; i
++) {
717 if (ro
!= c
->bind_mounts
[i
].read_only
)
720 r
= sd_bus_message_append(
722 c
->bind_mounts
[i
].source
,
723 c
->bind_mounts
[i
].destination
,
724 c
->bind_mounts
[i
].ignore_enoent
,
725 c
->bind_mounts
[i
].recursive
? (uint64_t) MS_REC
: (uint64_t) 0);
730 return sd_bus_message_close_container(reply
);
733 static int property_get_temporary_filesystems(
736 const char *interface
,
737 const char *property
,
738 sd_bus_message
*reply
,
740 sd_bus_error
*error
) {
742 ExecContext
*c
= userdata
;
750 r
= sd_bus_message_open_container(reply
, 'a', "(ss)");
754 for (unsigned i
= 0; i
< c
->n_temporary_filesystems
; i
++) {
755 TemporaryFileSystem
*t
= c
->temporary_filesystems
+ i
;
757 r
= sd_bus_message_append(
765 return sd_bus_message_close_container(reply
);
768 static int property_get_log_extra_fields(
771 const char *interface
,
772 const char *property
,
773 sd_bus_message
*reply
,
775 sd_bus_error
*error
) {
777 ExecContext
*c
= userdata
;
785 r
= sd_bus_message_open_container(reply
, 'a', "ay");
789 for (size_t i
= 0; i
< c
->n_log_extra_fields
; i
++) {
790 r
= sd_bus_message_append_array(reply
, 'y', c
->log_extra_fields
[i
].iov_base
, c
->log_extra_fields
[i
].iov_len
);
795 return sd_bus_message_close_container(reply
);
798 static int property_get_set_credential(
801 const char *interface
,
802 const char *property
,
803 sd_bus_message
*reply
,
805 sd_bus_error
*error
) {
807 ExecContext
*c
= userdata
;
808 ExecSetCredential
*sc
;
816 r
= sd_bus_message_open_container(reply
, 'a', "(say)");
820 HASHMAP_FOREACH(sc
, c
->set_credentials
) {
822 r
= sd_bus_message_open_container(reply
, 'r', "say");
826 r
= sd_bus_message_append(reply
, "s", sc
->id
);
830 r
= sd_bus_message_append_array(reply
, 'y', sc
->data
, sc
->size
);
834 r
= sd_bus_message_close_container(reply
);
839 return sd_bus_message_close_container(reply
);
842 static int property_get_load_credential(
845 const char *interface
,
846 const char *property
,
847 sd_bus_message
*reply
,
849 sd_bus_error
*error
) {
851 ExecContext
*c
= userdata
;
860 r
= sd_bus_message_open_container(reply
, 'a', "(ss)");
864 STRV_FOREACH_PAIR(i
, j
, c
->load_credentials
) {
865 r
= sd_bus_message_append(reply
, "(ss)", *i
, *j
);
870 return sd_bus_message_close_container(reply
);
873 static int property_get_root_hash(
876 const char *interface
,
877 const char *property
,
878 sd_bus_message
*reply
,
880 sd_bus_error
*error
) {
882 ExecContext
*c
= userdata
;
889 return sd_bus_message_append_array(reply
, 'y', c
->root_hash
, c
->root_hash_size
);
892 static int property_get_root_hash_sig(
895 const char *interface
,
896 const char *property
,
897 sd_bus_message
*reply
,
899 sd_bus_error
*error
) {
901 ExecContext
*c
= userdata
;
908 return sd_bus_message_append_array(reply
, 'y', c
->root_hash_sig
, c
->root_hash_sig_size
);
911 static int property_get_root_image_options(
914 const char *interface
,
915 const char *property
,
916 sd_bus_message
*reply
,
918 sd_bus_error
*error
) {
920 ExecContext
*c
= userdata
;
929 r
= sd_bus_message_open_container(reply
, 'a', "(ss)");
933 LIST_FOREACH(mount_options
, m
, c
->root_image_options
) {
934 r
= sd_bus_message_append(reply
, "(ss)",
935 partition_designator_to_string(m
->partition_designator
),
941 return sd_bus_message_close_container(reply
);
944 static int property_get_mount_images(
947 const char *interface
,
948 const char *property
,
949 sd_bus_message
*reply
,
951 sd_bus_error
*error
) {
953 ExecContext
*c
= userdata
;
961 r
= sd_bus_message_open_container(reply
, 'a', "(ssba(ss))");
965 for (size_t i
= 0; i
< c
->n_mount_images
; i
++) {
968 r
= sd_bus_message_open_container(reply
, SD_BUS_TYPE_STRUCT
, "ssba(ss)");
971 r
= sd_bus_message_append(
973 c
->mount_images
[i
].source
,
974 c
->mount_images
[i
].destination
,
975 c
->mount_images
[i
].ignore_enoent
);
978 r
= sd_bus_message_open_container(reply
, 'a', "(ss)");
981 LIST_FOREACH(mount_options
, m
, c
->mount_images
[i
].mount_options
) {
982 r
= sd_bus_message_append(reply
, "(ss)",
983 partition_designator_to_string(m
->partition_designator
),
988 r
= sd_bus_message_close_container(reply
);
991 r
= sd_bus_message_close_container(reply
);
996 return sd_bus_message_close_container(reply
);
999 static int property_get_extension_images(
1002 const char *interface
,
1003 const char *property
,
1004 sd_bus_message
*reply
,
1006 sd_bus_error
*error
) {
1008 ExecContext
*c
= userdata
;
1016 r
= sd_bus_message_open_container(reply
, 'a', "(sba(ss))");
1020 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 const sd_bus_vtable bus_exec_vtable
[] = {
1054 SD_BUS_VTABLE_START(0),
1055 SD_BUS_PROPERTY("Environment", "as", NULL
, offsetof(ExecContext
, environment
), SD_BUS_VTABLE_PROPERTY_CONST
),
1056 SD_BUS_PROPERTY("EnvironmentFiles", "a(sb)", property_get_environment_files
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
1057 SD_BUS_PROPERTY("PassEnvironment", "as", NULL
, offsetof(ExecContext
, pass_environment
), SD_BUS_VTABLE_PROPERTY_CONST
),
1058 SD_BUS_PROPERTY("UnsetEnvironment", "as", NULL
, offsetof(ExecContext
, unset_environment
), SD_BUS_VTABLE_PROPERTY_CONST
),
1059 SD_BUS_PROPERTY("UMask", "u", bus_property_get_mode
, offsetof(ExecContext
, umask
), SD_BUS_VTABLE_PROPERTY_CONST
),
1060 SD_BUS_PROPERTY("LimitCPU", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_CPU
]), SD_BUS_VTABLE_PROPERTY_CONST
),
1061 SD_BUS_PROPERTY("LimitCPUSoft", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_CPU
]), SD_BUS_VTABLE_PROPERTY_CONST
),
1062 SD_BUS_PROPERTY("LimitFSIZE", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_FSIZE
]), SD_BUS_VTABLE_PROPERTY_CONST
),
1063 SD_BUS_PROPERTY("LimitFSIZESoft", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_FSIZE
]), SD_BUS_VTABLE_PROPERTY_CONST
),
1064 SD_BUS_PROPERTY("LimitDATA", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_DATA
]), SD_BUS_VTABLE_PROPERTY_CONST
),
1065 SD_BUS_PROPERTY("LimitDATASoft", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_DATA
]), SD_BUS_VTABLE_PROPERTY_CONST
),
1066 SD_BUS_PROPERTY("LimitSTACK", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_STACK
]), SD_BUS_VTABLE_PROPERTY_CONST
),
1067 SD_BUS_PROPERTY("LimitSTACKSoft", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_STACK
]), SD_BUS_VTABLE_PROPERTY_CONST
),
1068 SD_BUS_PROPERTY("LimitCORE", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_CORE
]), SD_BUS_VTABLE_PROPERTY_CONST
),
1069 SD_BUS_PROPERTY("LimitCORESoft", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_CORE
]), SD_BUS_VTABLE_PROPERTY_CONST
),
1070 SD_BUS_PROPERTY("LimitRSS", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_RSS
]), SD_BUS_VTABLE_PROPERTY_CONST
),
1071 SD_BUS_PROPERTY("LimitRSSSoft", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_RSS
]), SD_BUS_VTABLE_PROPERTY_CONST
),
1072 SD_BUS_PROPERTY("LimitNOFILE", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_NOFILE
]), SD_BUS_VTABLE_PROPERTY_CONST
),
1073 SD_BUS_PROPERTY("LimitNOFILESoft", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_NOFILE
]), SD_BUS_VTABLE_PROPERTY_CONST
),
1074 SD_BUS_PROPERTY("LimitAS", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_AS
]), SD_BUS_VTABLE_PROPERTY_CONST
),
1075 SD_BUS_PROPERTY("LimitASSoft", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_AS
]), SD_BUS_VTABLE_PROPERTY_CONST
),
1076 SD_BUS_PROPERTY("LimitNPROC", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_NPROC
]), SD_BUS_VTABLE_PROPERTY_CONST
),
1077 SD_BUS_PROPERTY("LimitNPROCSoft", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_NPROC
]), SD_BUS_VTABLE_PROPERTY_CONST
),
1078 SD_BUS_PROPERTY("LimitMEMLOCK", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_MEMLOCK
]), SD_BUS_VTABLE_PROPERTY_CONST
),
1079 SD_BUS_PROPERTY("LimitMEMLOCKSoft", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_MEMLOCK
]), SD_BUS_VTABLE_PROPERTY_CONST
),
1080 SD_BUS_PROPERTY("LimitLOCKS", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_LOCKS
]), SD_BUS_VTABLE_PROPERTY_CONST
),
1081 SD_BUS_PROPERTY("LimitLOCKSSoft", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_LOCKS
]), SD_BUS_VTABLE_PROPERTY_CONST
),
1082 SD_BUS_PROPERTY("LimitSIGPENDING", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_SIGPENDING
]), SD_BUS_VTABLE_PROPERTY_CONST
),
1083 SD_BUS_PROPERTY("LimitSIGPENDINGSoft", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_SIGPENDING
]), SD_BUS_VTABLE_PROPERTY_CONST
),
1084 SD_BUS_PROPERTY("LimitMSGQUEUE", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_MSGQUEUE
]), SD_BUS_VTABLE_PROPERTY_CONST
),
1085 SD_BUS_PROPERTY("LimitMSGQUEUESoft", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_MSGQUEUE
]), SD_BUS_VTABLE_PROPERTY_CONST
),
1086 SD_BUS_PROPERTY("LimitNICE", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_NICE
]), SD_BUS_VTABLE_PROPERTY_CONST
),
1087 SD_BUS_PROPERTY("LimitNICESoft", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_NICE
]), SD_BUS_VTABLE_PROPERTY_CONST
),
1088 SD_BUS_PROPERTY("LimitRTPRIO", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_RTPRIO
]), SD_BUS_VTABLE_PROPERTY_CONST
),
1089 SD_BUS_PROPERTY("LimitRTPRIOSoft", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_RTPRIO
]), SD_BUS_VTABLE_PROPERTY_CONST
),
1090 SD_BUS_PROPERTY("LimitRTTIME", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_RTTIME
]), SD_BUS_VTABLE_PROPERTY_CONST
),
1091 SD_BUS_PROPERTY("LimitRTTIMESoft", "t", bus_property_get_rlimit
, offsetof(ExecContext
, rlimit
[RLIMIT_RTTIME
]), SD_BUS_VTABLE_PROPERTY_CONST
),
1092 SD_BUS_PROPERTY("WorkingDirectory", "s", property_get_working_directory
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
1093 SD_BUS_PROPERTY("RootDirectory", "s", NULL
, offsetof(ExecContext
, root_directory
), SD_BUS_VTABLE_PROPERTY_CONST
),
1094 SD_BUS_PROPERTY("RootImage", "s", NULL
, offsetof(ExecContext
, root_image
), SD_BUS_VTABLE_PROPERTY_CONST
),
1095 SD_BUS_PROPERTY("RootImageOptions", "a(ss)", property_get_root_image_options
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
1096 SD_BUS_PROPERTY("RootHash", "ay", property_get_root_hash
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
1097 SD_BUS_PROPERTY("RootHashPath", "s", NULL
, offsetof(ExecContext
, root_hash_path
), SD_BUS_VTABLE_PROPERTY_CONST
),
1098 SD_BUS_PROPERTY("RootHashSignature", "ay", property_get_root_hash_sig
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
1099 SD_BUS_PROPERTY("RootHashSignaturePath", "s", NULL
, offsetof(ExecContext
, root_hash_sig_path
), SD_BUS_VTABLE_PROPERTY_CONST
),
1100 SD_BUS_PROPERTY("RootVerity", "s", NULL
, offsetof(ExecContext
, root_verity
), SD_BUS_VTABLE_PROPERTY_CONST
),
1101 SD_BUS_PROPERTY("ExtensionImages", "a(sba(ss))", property_get_extension_images
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
1102 SD_BUS_PROPERTY("MountImages", "a(ssba(ss))", property_get_mount_images
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
1103 SD_BUS_PROPERTY("OOMScoreAdjust", "i", property_get_oom_score_adjust
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
1104 SD_BUS_PROPERTY("CoredumpFilter", "t", property_get_coredump_filter
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
1105 SD_BUS_PROPERTY("Nice", "i", property_get_nice
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
1106 SD_BUS_PROPERTY("IOSchedulingClass", "i", property_get_ioprio_class
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
1107 SD_BUS_PROPERTY("IOSchedulingPriority", "i", property_get_ioprio_priority
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
1108 SD_BUS_PROPERTY("CPUSchedulingPolicy", "i", property_get_cpu_sched_policy
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
1109 SD_BUS_PROPERTY("CPUSchedulingPriority", "i", property_get_cpu_sched_priority
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
1110 SD_BUS_PROPERTY("CPUAffinity", "ay", property_get_cpu_affinity
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
1111 SD_BUS_PROPERTY("CPUAffinityFromNUMA", "b", property_get_cpu_affinity_from_numa
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
1112 SD_BUS_PROPERTY("NUMAPolicy", "i", property_get_numa_policy
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
1113 SD_BUS_PROPERTY("NUMAMask", "ay", property_get_numa_mask
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
1114 SD_BUS_PROPERTY("TimerSlackNSec", "t", property_get_timer_slack_nsec
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
1115 SD_BUS_PROPERTY("CPUSchedulingResetOnFork", "b", bus_property_get_bool
, offsetof(ExecContext
, cpu_sched_reset_on_fork
), SD_BUS_VTABLE_PROPERTY_CONST
),
1116 SD_BUS_PROPERTY("NonBlocking", "b", bus_property_get_bool
, offsetof(ExecContext
, non_blocking
), SD_BUS_VTABLE_PROPERTY_CONST
),
1117 SD_BUS_PROPERTY("StandardInput", "s", property_get_exec_input
, offsetof(ExecContext
, std_input
), SD_BUS_VTABLE_PROPERTY_CONST
),
1118 SD_BUS_PROPERTY("StandardInputFileDescriptorName", "s", property_get_stdio_fdname
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
1119 SD_BUS_PROPERTY("StandardInputData", "ay", property_get_input_data
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
1120 SD_BUS_PROPERTY("StandardOutput", "s", bus_property_get_exec_output
, offsetof(ExecContext
, std_output
), SD_BUS_VTABLE_PROPERTY_CONST
),
1121 SD_BUS_PROPERTY("StandardOutputFileDescriptorName", "s", property_get_stdio_fdname
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
1122 SD_BUS_PROPERTY("StandardError", "s", bus_property_get_exec_output
, offsetof(ExecContext
, std_error
), SD_BUS_VTABLE_PROPERTY_CONST
),
1123 SD_BUS_PROPERTY("StandardErrorFileDescriptorName", "s", property_get_stdio_fdname
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
1124 SD_BUS_PROPERTY("TTYPath", "s", NULL
, offsetof(ExecContext
, tty_path
), SD_BUS_VTABLE_PROPERTY_CONST
),
1125 SD_BUS_PROPERTY("TTYReset", "b", bus_property_get_bool
, offsetof(ExecContext
, tty_reset
), SD_BUS_VTABLE_PROPERTY_CONST
),
1126 SD_BUS_PROPERTY("TTYVHangup", "b", bus_property_get_bool
, offsetof(ExecContext
, tty_vhangup
), SD_BUS_VTABLE_PROPERTY_CONST
),
1127 SD_BUS_PROPERTY("TTYVTDisallocate", "b", bus_property_get_bool
, offsetof(ExecContext
, tty_vt_disallocate
), SD_BUS_VTABLE_PROPERTY_CONST
),
1128 SD_BUS_PROPERTY("SyslogPriority", "i", bus_property_get_int
, offsetof(ExecContext
, syslog_priority
), SD_BUS_VTABLE_PROPERTY_CONST
),
1129 SD_BUS_PROPERTY("SyslogIdentifier", "s", NULL
, offsetof(ExecContext
, syslog_identifier
), SD_BUS_VTABLE_PROPERTY_CONST
),
1130 SD_BUS_PROPERTY("SyslogLevelPrefix", "b", bus_property_get_bool
, offsetof(ExecContext
, syslog_level_prefix
), SD_BUS_VTABLE_PROPERTY_CONST
),
1131 SD_BUS_PROPERTY("SyslogLevel", "i", property_get_syslog_level
, offsetof(ExecContext
, syslog_priority
), SD_BUS_VTABLE_PROPERTY_CONST
),
1132 SD_BUS_PROPERTY("SyslogFacility", "i", property_get_syslog_facility
, offsetof(ExecContext
, syslog_priority
), SD_BUS_VTABLE_PROPERTY_CONST
),
1133 SD_BUS_PROPERTY("LogLevelMax", "i", bus_property_get_int
, offsetof(ExecContext
, log_level_max
), SD_BUS_VTABLE_PROPERTY_CONST
),
1134 SD_BUS_PROPERTY("LogRateLimitIntervalUSec", "t", bus_property_get_usec
, offsetof(ExecContext
, log_ratelimit_interval_usec
), SD_BUS_VTABLE_PROPERTY_CONST
),
1135 SD_BUS_PROPERTY("LogRateLimitBurst", "u", bus_property_get_unsigned
, offsetof(ExecContext
, log_ratelimit_burst
), SD_BUS_VTABLE_PROPERTY_CONST
),
1136 SD_BUS_PROPERTY("LogExtraFields", "aay", property_get_log_extra_fields
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
1137 SD_BUS_PROPERTY("LogNamespace", "s", NULL
, offsetof(ExecContext
, log_namespace
), SD_BUS_VTABLE_PROPERTY_CONST
),
1138 SD_BUS_PROPERTY("SecureBits", "i", bus_property_get_int
, offsetof(ExecContext
, secure_bits
), SD_BUS_VTABLE_PROPERTY_CONST
),
1139 SD_BUS_PROPERTY("CapabilityBoundingSet", "t", NULL
, offsetof(ExecContext
, capability_bounding_set
), SD_BUS_VTABLE_PROPERTY_CONST
),
1140 SD_BUS_PROPERTY("AmbientCapabilities", "t", NULL
, offsetof(ExecContext
, capability_ambient_set
), SD_BUS_VTABLE_PROPERTY_CONST
),
1141 SD_BUS_PROPERTY("User", "s", NULL
, offsetof(ExecContext
, user
), SD_BUS_VTABLE_PROPERTY_CONST
),
1142 SD_BUS_PROPERTY("Group", "s", NULL
, offsetof(ExecContext
, group
), SD_BUS_VTABLE_PROPERTY_CONST
),
1143 SD_BUS_PROPERTY("DynamicUser", "b", bus_property_get_bool
, offsetof(ExecContext
, dynamic_user
), SD_BUS_VTABLE_PROPERTY_CONST
),
1144 SD_BUS_PROPERTY("RemoveIPC", "b", bus_property_get_bool
, offsetof(ExecContext
, remove_ipc
), SD_BUS_VTABLE_PROPERTY_CONST
),
1145 SD_BUS_PROPERTY("SetCredential", "a(say)", property_get_set_credential
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
1146 SD_BUS_PROPERTY("LoadCredential", "a(ss)", property_get_load_credential
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
1147 SD_BUS_PROPERTY("SupplementaryGroups", "as", NULL
, offsetof(ExecContext
, supplementary_groups
), SD_BUS_VTABLE_PROPERTY_CONST
),
1148 SD_BUS_PROPERTY("PAMName", "s", NULL
, offsetof(ExecContext
, pam_name
), SD_BUS_VTABLE_PROPERTY_CONST
),
1149 SD_BUS_PROPERTY("ReadWritePaths", "as", NULL
, offsetof(ExecContext
, read_write_paths
), SD_BUS_VTABLE_PROPERTY_CONST
),
1150 SD_BUS_PROPERTY("ReadOnlyPaths", "as", NULL
, offsetof(ExecContext
, read_only_paths
), SD_BUS_VTABLE_PROPERTY_CONST
),
1151 SD_BUS_PROPERTY("InaccessiblePaths", "as", NULL
, offsetof(ExecContext
, inaccessible_paths
), SD_BUS_VTABLE_PROPERTY_CONST
),
1152 SD_BUS_PROPERTY("ExecPaths", "as", NULL
, offsetof(ExecContext
, exec_paths
), SD_BUS_VTABLE_PROPERTY_CONST
),
1153 SD_BUS_PROPERTY("NoExecPaths", "as", NULL
, offsetof(ExecContext
, no_exec_paths
), SD_BUS_VTABLE_PROPERTY_CONST
),
1154 SD_BUS_PROPERTY("MountFlags", "t", bus_property_get_ulong
, offsetof(ExecContext
, mount_flags
), SD_BUS_VTABLE_PROPERTY_CONST
),
1155 SD_BUS_PROPERTY("PrivateTmp", "b", bus_property_get_bool
, offsetof(ExecContext
, private_tmp
), SD_BUS_VTABLE_PROPERTY_CONST
),
1156 SD_BUS_PROPERTY("PrivateDevices", "b", bus_property_get_bool
, offsetof(ExecContext
, private_devices
), SD_BUS_VTABLE_PROPERTY_CONST
),
1157 SD_BUS_PROPERTY("ProtectClock", "b", bus_property_get_bool
, offsetof(ExecContext
, protect_clock
), SD_BUS_VTABLE_PROPERTY_CONST
),
1158 SD_BUS_PROPERTY("ProtectKernelTunables", "b", bus_property_get_bool
, offsetof(ExecContext
, protect_kernel_tunables
), SD_BUS_VTABLE_PROPERTY_CONST
),
1159 SD_BUS_PROPERTY("ProtectKernelModules", "b", bus_property_get_bool
, offsetof(ExecContext
, protect_kernel_modules
), SD_BUS_VTABLE_PROPERTY_CONST
),
1160 SD_BUS_PROPERTY("ProtectKernelLogs", "b", bus_property_get_bool
, offsetof(ExecContext
, protect_kernel_logs
), SD_BUS_VTABLE_PROPERTY_CONST
),
1161 SD_BUS_PROPERTY("ProtectControlGroups", "b", bus_property_get_bool
, offsetof(ExecContext
, protect_control_groups
), SD_BUS_VTABLE_PROPERTY_CONST
),
1162 SD_BUS_PROPERTY("PrivateNetwork", "b", bus_property_get_bool
, offsetof(ExecContext
, private_network
), SD_BUS_VTABLE_PROPERTY_CONST
),
1163 SD_BUS_PROPERTY("PrivateUsers", "b", bus_property_get_bool
, offsetof(ExecContext
, private_users
), SD_BUS_VTABLE_PROPERTY_CONST
),
1164 SD_BUS_PROPERTY("PrivateMounts", "b", bus_property_get_bool
, offsetof(ExecContext
, private_mounts
), SD_BUS_VTABLE_PROPERTY_CONST
),
1165 SD_BUS_PROPERTY("PrivateIPC", "b", bus_property_get_bool
, offsetof(ExecContext
, private_ipc
), SD_BUS_VTABLE_PROPERTY_CONST
),
1166 SD_BUS_PROPERTY("ProtectHome", "s", property_get_protect_home
, offsetof(ExecContext
, protect_home
), SD_BUS_VTABLE_PROPERTY_CONST
),
1167 SD_BUS_PROPERTY("ProtectSystem", "s", property_get_protect_system
, offsetof(ExecContext
, protect_system
), SD_BUS_VTABLE_PROPERTY_CONST
),
1168 SD_BUS_PROPERTY("SameProcessGroup", "b", bus_property_get_bool
, offsetof(ExecContext
, same_pgrp
), SD_BUS_VTABLE_PROPERTY_CONST
),
1169 SD_BUS_PROPERTY("UtmpIdentifier", "s", NULL
, offsetof(ExecContext
, utmp_id
), SD_BUS_VTABLE_PROPERTY_CONST
),
1170 SD_BUS_PROPERTY("UtmpMode", "s", property_get_exec_utmp_mode
, offsetof(ExecContext
, utmp_mode
), SD_BUS_VTABLE_PROPERTY_CONST
),
1171 SD_BUS_PROPERTY("SELinuxContext", "(bs)", property_get_selinux_context
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
1172 SD_BUS_PROPERTY("AppArmorProfile", "(bs)", property_get_apparmor_profile
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
1173 SD_BUS_PROPERTY("SmackProcessLabel", "(bs)", property_get_smack_process_label
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
1174 SD_BUS_PROPERTY("IgnoreSIGPIPE", "b", bus_property_get_bool
, offsetof(ExecContext
, ignore_sigpipe
), SD_BUS_VTABLE_PROPERTY_CONST
),
1175 SD_BUS_PROPERTY("NoNewPrivileges", "b", bus_property_get_bool
, offsetof(ExecContext
, no_new_privileges
), SD_BUS_VTABLE_PROPERTY_CONST
),
1176 SD_BUS_PROPERTY("SystemCallFilter", "(bas)", property_get_syscall_filter
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
1177 SD_BUS_PROPERTY("SystemCallArchitectures", "as", property_get_syscall_archs
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
1178 SD_BUS_PROPERTY("SystemCallErrorNumber", "i", bus_property_get_int
, offsetof(ExecContext
, syscall_errno
), SD_BUS_VTABLE_PROPERTY_CONST
),
1179 SD_BUS_PROPERTY("SystemCallLog", "(bas)", property_get_syscall_log
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
1180 SD_BUS_PROPERTY("Personality", "s", property_get_personality
, offsetof(ExecContext
, personality
), SD_BUS_VTABLE_PROPERTY_CONST
),
1181 SD_BUS_PROPERTY("LockPersonality", "b", bus_property_get_bool
, offsetof(ExecContext
, lock_personality
), SD_BUS_VTABLE_PROPERTY_CONST
),
1182 SD_BUS_PROPERTY("RestrictAddressFamilies", "(bas)", property_get_address_families
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
1183 SD_BUS_PROPERTY("RuntimeDirectoryPreserve", "s", property_get_exec_preserve_mode
, offsetof(ExecContext
, runtime_directory_preserve_mode
), SD_BUS_VTABLE_PROPERTY_CONST
),
1184 SD_BUS_PROPERTY("RuntimeDirectoryMode", "u", bus_property_get_mode
, offsetof(ExecContext
, directories
[EXEC_DIRECTORY_RUNTIME
].mode
), SD_BUS_VTABLE_PROPERTY_CONST
),
1185 SD_BUS_PROPERTY("RuntimeDirectory", "as", NULL
, offsetof(ExecContext
, directories
[EXEC_DIRECTORY_RUNTIME
].paths
), SD_BUS_VTABLE_PROPERTY_CONST
),
1186 SD_BUS_PROPERTY("StateDirectoryMode", "u", bus_property_get_mode
, offsetof(ExecContext
, directories
[EXEC_DIRECTORY_STATE
].mode
), SD_BUS_VTABLE_PROPERTY_CONST
),
1187 SD_BUS_PROPERTY("StateDirectory", "as", NULL
, offsetof(ExecContext
, directories
[EXEC_DIRECTORY_STATE
].paths
), SD_BUS_VTABLE_PROPERTY_CONST
),
1188 SD_BUS_PROPERTY("CacheDirectoryMode", "u", bus_property_get_mode
, offsetof(ExecContext
, directories
[EXEC_DIRECTORY_CACHE
].mode
), SD_BUS_VTABLE_PROPERTY_CONST
),
1189 SD_BUS_PROPERTY("CacheDirectory", "as", NULL
, offsetof(ExecContext
, directories
[EXEC_DIRECTORY_CACHE
].paths
), SD_BUS_VTABLE_PROPERTY_CONST
),
1190 SD_BUS_PROPERTY("LogsDirectoryMode", "u", bus_property_get_mode
, offsetof(ExecContext
, directories
[EXEC_DIRECTORY_LOGS
].mode
), SD_BUS_VTABLE_PROPERTY_CONST
),
1191 SD_BUS_PROPERTY("LogsDirectory", "as", NULL
, offsetof(ExecContext
, directories
[EXEC_DIRECTORY_LOGS
].paths
), SD_BUS_VTABLE_PROPERTY_CONST
),
1192 SD_BUS_PROPERTY("ConfigurationDirectoryMode", "u", bus_property_get_mode
, offsetof(ExecContext
, directories
[EXEC_DIRECTORY_CONFIGURATION
].mode
), SD_BUS_VTABLE_PROPERTY_CONST
),
1193 SD_BUS_PROPERTY("ConfigurationDirectory", "as", NULL
, offsetof(ExecContext
, directories
[EXEC_DIRECTORY_CONFIGURATION
].paths
), SD_BUS_VTABLE_PROPERTY_CONST
),
1194 SD_BUS_PROPERTY("TimeoutCleanUSec", "t", bus_property_get_usec
, offsetof(ExecContext
, timeout_clean_usec
), SD_BUS_VTABLE_PROPERTY_CONST
),
1195 SD_BUS_PROPERTY("MemoryDenyWriteExecute", "b", bus_property_get_bool
, offsetof(ExecContext
, memory_deny_write_execute
), SD_BUS_VTABLE_PROPERTY_CONST
),
1196 SD_BUS_PROPERTY("RestrictRealtime", "b", bus_property_get_bool
, offsetof(ExecContext
, restrict_realtime
), SD_BUS_VTABLE_PROPERTY_CONST
),
1197 SD_BUS_PROPERTY("RestrictSUIDSGID", "b", bus_property_get_bool
, offsetof(ExecContext
, restrict_suid_sgid
), SD_BUS_VTABLE_PROPERTY_CONST
),
1198 SD_BUS_PROPERTY("RestrictNamespaces", "t", bus_property_get_ulong
, offsetof(ExecContext
, restrict_namespaces
), SD_BUS_VTABLE_PROPERTY_CONST
),
1199 SD_BUS_PROPERTY("BindPaths", "a(ssbt)", property_get_bind_paths
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
1200 SD_BUS_PROPERTY("BindReadOnlyPaths", "a(ssbt)", property_get_bind_paths
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
1201 SD_BUS_PROPERTY("TemporaryFileSystem", "a(ss)", property_get_temporary_filesystems
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
1202 SD_BUS_PROPERTY("MountAPIVFS", "b", property_get_mount_apivfs
, 0, SD_BUS_VTABLE_PROPERTY_CONST
),
1203 SD_BUS_PROPERTY("KeyringMode", "s", property_get_exec_keyring_mode
, offsetof(ExecContext
, keyring_mode
), SD_BUS_VTABLE_PROPERTY_CONST
),
1204 SD_BUS_PROPERTY("ProtectProc", "s", property_get_protect_proc
, offsetof(ExecContext
, protect_proc
), SD_BUS_VTABLE_PROPERTY_CONST
),
1205 SD_BUS_PROPERTY("ProcSubset", "s", property_get_proc_subset
, offsetof(ExecContext
, proc_subset
), SD_BUS_VTABLE_PROPERTY_CONST
),
1206 SD_BUS_PROPERTY("ProtectHostname", "b", bus_property_get_bool
, offsetof(ExecContext
, protect_hostname
), SD_BUS_VTABLE_PROPERTY_CONST
),
1207 SD_BUS_PROPERTY("NetworkNamespacePath", "s", NULL
, offsetof(ExecContext
, network_namespace_path
), SD_BUS_VTABLE_PROPERTY_CONST
),
1208 SD_BUS_PROPERTY("IPCNamespacePath", "s", NULL
, offsetof(ExecContext
, ipc_namespace_path
), SD_BUS_VTABLE_PROPERTY_CONST
),
1210 /* Obsolete/redundant properties: */
1211 SD_BUS_PROPERTY("Capabilities", "s", property_get_empty_string
, 0, SD_BUS_VTABLE_PROPERTY_CONST
|SD_BUS_VTABLE_HIDDEN
),
1212 SD_BUS_PROPERTY("ReadWriteDirectories", "as", NULL
, offsetof(ExecContext
, read_write_paths
), SD_BUS_VTABLE_PROPERTY_CONST
|SD_BUS_VTABLE_HIDDEN
),
1213 SD_BUS_PROPERTY("ReadOnlyDirectories", "as", NULL
, offsetof(ExecContext
, read_only_paths
), SD_BUS_VTABLE_PROPERTY_CONST
|SD_BUS_VTABLE_HIDDEN
),
1214 SD_BUS_PROPERTY("InaccessibleDirectories", "as", NULL
, offsetof(ExecContext
, inaccessible_paths
), SD_BUS_VTABLE_PROPERTY_CONST
|SD_BUS_VTABLE_HIDDEN
),
1215 SD_BUS_PROPERTY("IOScheduling", "i", property_get_ioprio
, 0, SD_BUS_VTABLE_PROPERTY_CONST
|SD_BUS_VTABLE_HIDDEN
),
1220 static int append_exec_command(sd_bus_message
*reply
, ExecCommand
*c
) {
1229 r
= sd_bus_message_open_container(reply
, 'r', "sasbttttuii");
1233 r
= sd_bus_message_append(reply
, "s", c
->path
);
1237 r
= sd_bus_message_append_strv(reply
, c
->argv
);
1241 r
= sd_bus_message_append(reply
, "bttttuii",
1242 !!(c
->flags
& EXEC_COMMAND_IGNORE_FAILURE
),
1243 c
->exec_status
.start_timestamp
.realtime
,
1244 c
->exec_status
.start_timestamp
.monotonic
,
1245 c
->exec_status
.exit_timestamp
.realtime
,
1246 c
->exec_status
.exit_timestamp
.monotonic
,
1247 (uint32_t) c
->exec_status
.pid
,
1248 (int32_t) c
->exec_status
.code
,
1249 (int32_t) c
->exec_status
.status
);
1253 return sd_bus_message_close_container(reply
);
1256 static int append_exec_ex_command(sd_bus_message
*reply
, ExecCommand
*c
) {
1257 _cleanup_strv_free_
char **ex_opts
= NULL
;
1266 r
= sd_bus_message_open_container(reply
, 'r', "sasasttttuii");
1270 r
= sd_bus_message_append(reply
, "s", c
->path
);
1274 r
= sd_bus_message_append_strv(reply
, c
->argv
);
1278 r
= exec_command_flags_to_strv(c
->flags
, &ex_opts
);
1282 r
= sd_bus_message_append_strv(reply
, ex_opts
);
1286 r
= sd_bus_message_append(reply
, "ttttuii",
1287 c
->exec_status
.start_timestamp
.realtime
,
1288 c
->exec_status
.start_timestamp
.monotonic
,
1289 c
->exec_status
.exit_timestamp
.realtime
,
1290 c
->exec_status
.exit_timestamp
.monotonic
,
1291 (uint32_t) c
->exec_status
.pid
,
1292 (int32_t) c
->exec_status
.code
,
1293 (int32_t) c
->exec_status
.status
);
1297 return sd_bus_message_close_container(reply
);
1300 int bus_property_get_exec_command(
1303 const char *interface
,
1304 const char *property
,
1305 sd_bus_message
*reply
,
1307 sd_bus_error
*ret_error
) {
1309 ExecCommand
*c
= (ExecCommand
*) userdata
;
1315 r
= sd_bus_message_open_container(reply
, 'a', "(sasbttttuii)");
1319 r
= append_exec_command(reply
, c
);
1323 return sd_bus_message_close_container(reply
);
1326 int bus_property_get_exec_command_list(
1329 const char *interface
,
1330 const char *property
,
1331 sd_bus_message
*reply
,
1333 sd_bus_error
*ret_error
) {
1335 ExecCommand
*c
= *(ExecCommand
**) userdata
;
1341 r
= sd_bus_message_open_container(reply
, 'a', "(sasbttttuii)");
1345 LIST_FOREACH(command
, c
, c
) {
1346 r
= append_exec_command(reply
, c
);
1351 return sd_bus_message_close_container(reply
);
1354 int bus_property_get_exec_ex_command_list(
1357 const char *interface
,
1358 const char *property
,
1359 sd_bus_message
*reply
,
1361 sd_bus_error
*ret_error
) {
1363 ExecCommand
*c
, *exec_command
= *(ExecCommand
**) userdata
;
1369 r
= sd_bus_message_open_container(reply
, 'a', "(sasasttttuii)");
1373 LIST_FOREACH(command
, c
, exec_command
) {
1374 r
= append_exec_ex_command(reply
, c
);
1379 return sd_bus_message_close_container(reply
);
1382 static char *exec_command_flags_to_exec_chars(ExecCommandFlags flags
) {
1383 return strjoin(FLAGS_SET(flags
, EXEC_COMMAND_IGNORE_FAILURE
) ? "-" : "",
1384 FLAGS_SET(flags
, EXEC_COMMAND_NO_ENV_EXPAND
) ? ":" : "",
1385 FLAGS_SET(flags
, EXEC_COMMAND_FULLY_PRIVILEGED
) ? "+" : "",
1386 FLAGS_SET(flags
, EXEC_COMMAND_NO_SETUID
) ? "!" : "",
1387 FLAGS_SET(flags
, EXEC_COMMAND_AMBIENT_MAGIC
) ? "!!" : "");
1390 int bus_set_transient_exec_command(
1393 ExecCommand
**exec_command
,
1394 sd_bus_message
*message
,
1395 UnitWriteFlags flags
,
1396 sd_bus_error
*error
) {
1397 bool is_ex_prop
= endswith(name
, "Ex");
1401 r
= sd_bus_message_enter_container(message
, 'a', is_ex_prop
? "(sasas)" : "(sasb)");
1405 while ((r
= sd_bus_message_enter_container(message
, 'r', is_ex_prop
? "sasas" : "sasb")) > 0) {
1406 _cleanup_strv_free_
char **argv
= NULL
, **ex_opts
= NULL
;
1410 r
= sd_bus_message_read(message
, "s", &path
);
1414 if (!path_is_absolute(path
) && !filename_is_valid(path
))
1415 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
,
1416 "\"%s\" is neither a valid executable name nor an absolute path",
1419 r
= sd_bus_message_read_strv(message
, &argv
);
1423 r
= is_ex_prop
? sd_bus_message_read_strv(message
, &ex_opts
) : sd_bus_message_read(message
, "b", &b
);
1427 r
= sd_bus_message_exit_container(message
);
1431 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
1434 c
= new0(ExecCommand
, 1);
1438 c
->path
= strdup(path
);
1444 c
->argv
= TAKE_PTR(argv
);
1447 r
= exec_command_flags_from_strv(ex_opts
, &c
->flags
);
1451 c
->flags
= b
? EXEC_COMMAND_IGNORE_FAILURE
: 0;
1453 path_simplify(c
->path
, false);
1454 exec_command_append_list(exec_command
, c
);
1462 r
= sd_bus_message_exit_container(message
);
1466 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
1467 _cleanup_free_
char *buf
= NULL
;
1468 _cleanup_fclose_
FILE *f
= NULL
;
1473 *exec_command
= exec_command_free_list(*exec_command
);
1475 f
= open_memstream_unlocked(&buf
, &size
);
1479 fprintf(f
, "%s=\n", name
);
1481 LIST_FOREACH(command
, c
, *exec_command
) {
1482 _cleanup_free_
char *a
= NULL
, *exec_chars
= NULL
;
1484 exec_chars
= exec_command_flags_to_exec_chars(c
->flags
);
1488 a
= unit_concat_strv(c
->argv
, UNIT_ESCAPE_C
|UNIT_ESCAPE_SPECIFIERS
);
1492 if (streq_ptr(c
->path
, c
->argv
? c
->argv
[0] : NULL
))
1493 fprintf(f
, "%s=%s%s\n", name
, exec_chars
, a
);
1495 _cleanup_free_
char *t
= NULL
;
1498 p
= unit_escape_setting(c
->path
, UNIT_ESCAPE_C
|UNIT_ESCAPE_SPECIFIERS
, &t
);
1502 fprintf(f
, "%s=%s@%s %s\n", name
, exec_chars
, p
, a
);
1506 r
= fflush_and_check(f
);
1510 unit_write_setting(u
, flags
, name
, buf
);
1516 static int parse_personality(const char *s
, unsigned long *p
) {
1521 v
= personality_from_string(s
);
1522 if (v
== PERSONALITY_INVALID
)
1529 static const char* mount_propagation_flags_to_string_with_check(unsigned long n
) {
1530 if (!IN_SET(n
, 0, MS_SHARED
, MS_PRIVATE
, MS_SLAVE
))
1533 return mount_propagation_flags_to_string(n
);
1536 static BUS_DEFINE_SET_TRANSIENT(nsec
, "t", uint64_t, nsec_t
, NSEC_FMT
);
1537 static BUS_DEFINE_SET_TRANSIENT_IS_VALID(log_level
, "i", int32_t, int, "%" PRIi32
, log_level_is_valid
);
1539 static BUS_DEFINE_SET_TRANSIENT_IS_VALID(errno
, "i", int32_t, int, "%" PRIi32
, seccomp_errno_or_action_is_valid
);
1541 static BUS_DEFINE_SET_TRANSIENT_PARSE(std_input
, ExecInput
, exec_input_from_string
);
1542 static BUS_DEFINE_SET_TRANSIENT_PARSE(std_output
, ExecOutput
, exec_output_from_string
);
1543 static BUS_DEFINE_SET_TRANSIENT_PARSE(utmp_mode
, ExecUtmpMode
, exec_utmp_mode_from_string
);
1544 static BUS_DEFINE_SET_TRANSIENT_PARSE(protect_system
, ProtectSystem
, protect_system_from_string
);
1545 static BUS_DEFINE_SET_TRANSIENT_PARSE(protect_home
, ProtectHome
, protect_home_from_string
);
1546 static BUS_DEFINE_SET_TRANSIENT_PARSE(keyring_mode
, ExecKeyringMode
, exec_keyring_mode_from_string
);
1547 static BUS_DEFINE_SET_TRANSIENT_PARSE(protect_proc
, ProtectProc
, protect_proc_from_string
);
1548 static BUS_DEFINE_SET_TRANSIENT_PARSE(proc_subset
, ProcSubset
, proc_subset_from_string
);
1549 static BUS_DEFINE_SET_TRANSIENT_PARSE(preserve_mode
, ExecPreserveMode
, exec_preserve_mode_from_string
);
1550 static BUS_DEFINE_SET_TRANSIENT_PARSE_PTR(personality
, unsigned long, parse_personality
);
1551 static BUS_DEFINE_SET_TRANSIENT_TO_STRING_ALLOC(secure_bits
, "i", int32_t, int, "%" PRIi32
, secure_bits_to_string_alloc_with_check
);
1552 static BUS_DEFINE_SET_TRANSIENT_TO_STRING_ALLOC(capability
, "t", uint64_t, uint64_t, "%" PRIu64
, capability_set_to_string_alloc
);
1553 static BUS_DEFINE_SET_TRANSIENT_TO_STRING_ALLOC(namespace_flag
, "t", uint64_t, unsigned long, "%" PRIu64
, namespace_flags_to_string
);
1554 static BUS_DEFINE_SET_TRANSIENT_TO_STRING(mount_flags
, "t", uint64_t, unsigned long, "%" PRIu64
, mount_propagation_flags_to_string_with_check
);
1556 int bus_exec_context_set_transient_property(
1560 sd_bus_message
*message
,
1561 UnitWriteFlags flags
,
1562 sd_bus_error
*error
) {
1572 flags
|= UNIT_PRIVATE
;
1574 if (streq(name
, "User"))
1575 return bus_set_transient_user_relaxed(u
, name
, &c
->user
, message
, flags
, error
);
1577 if (streq(name
, "Group"))
1578 return bus_set_transient_user_relaxed(u
, name
, &c
->group
, message
, flags
, error
);
1580 if (streq(name
, "TTYPath"))
1581 return bus_set_transient_path(u
, name
, &c
->tty_path
, message
, flags
, error
);
1583 if (streq(name
, "RootImage"))
1584 return bus_set_transient_path(u
, name
, &c
->root_image
, message
, flags
, error
);
1586 if (streq(name
, "RootImageOptions")) {
1587 _cleanup_(mount_options_free_allp
) MountOptions
*options
= NULL
;
1588 _cleanup_free_
char *format_str
= NULL
;
1590 r
= bus_read_mount_options(message
, error
, &options
, &format_str
, " ");
1594 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
1595 if (LIST_IS_EMPTY(options
)) {
1596 c
->root_image_options
= mount_options_free_all(c
->root_image_options
);
1597 unit_write_settingf(u
, flags
, name
, "%s=", name
);
1599 LIST_JOIN(mount_options
, c
->root_image_options
, options
);
1600 unit_write_settingf(
1601 u
, flags
|UNIT_ESCAPE_SPECIFIERS
, name
,
1611 if (streq(name
, "RootHash")) {
1612 const void *roothash_decoded
;
1613 size_t roothash_decoded_size
;
1615 r
= sd_bus_message_read_array(message
, 'y', &roothash_decoded
, &roothash_decoded_size
);
1619 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
1620 _cleanup_free_
char *encoded
= NULL
;
1622 if (roothash_decoded_size
== 0) {
1623 c
->root_hash_path
= mfree(c
->root_hash_path
);
1624 c
->root_hash
= mfree(c
->root_hash
);
1625 c
->root_hash_size
= 0;
1627 unit_write_settingf(u
, flags
, name
, "RootHash=");
1629 _cleanup_free_
void *p
;
1631 encoded
= hexmem(roothash_decoded
, roothash_decoded_size
);
1635 p
= memdup(roothash_decoded
, roothash_decoded_size
);
1639 free_and_replace(c
->root_hash
, p
);
1640 c
->root_hash_size
= roothash_decoded_size
;
1641 c
->root_hash_path
= mfree(c
->root_hash_path
);
1643 unit_write_settingf(u
, flags
, name
, "RootHash=%s", encoded
);
1650 if (streq(name
, "RootHashPath")) {
1651 c
->root_hash_size
= 0;
1652 c
->root_hash
= mfree(c
->root_hash
);
1654 return bus_set_transient_path(u
, "RootHash", &c
->root_hash_path
, message
, flags
, error
);
1657 if (streq(name
, "RootHashSignature")) {
1658 const void *roothash_sig_decoded
;
1659 size_t roothash_sig_decoded_size
;
1661 r
= sd_bus_message_read_array(message
, 'y', &roothash_sig_decoded
, &roothash_sig_decoded_size
);
1665 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
1666 _cleanup_free_
char *encoded
= NULL
;
1668 if (roothash_sig_decoded_size
== 0) {
1669 c
->root_hash_sig_path
= mfree(c
->root_hash_sig_path
);
1670 c
->root_hash_sig
= mfree(c
->root_hash_sig
);
1671 c
->root_hash_sig_size
= 0;
1673 unit_write_settingf(u
, flags
, name
, "RootHashSignature=");
1675 _cleanup_free_
void *p
;
1678 len
= base64mem(roothash_sig_decoded
, roothash_sig_decoded_size
, &encoded
);
1682 p
= memdup(roothash_sig_decoded
, roothash_sig_decoded_size
);
1686 free_and_replace(c
->root_hash_sig
, p
);
1687 c
->root_hash_sig_size
= roothash_sig_decoded_size
;
1688 c
->root_hash_sig_path
= mfree(c
->root_hash_sig_path
);
1690 unit_write_settingf(u
, flags
, name
, "RootHashSignature=base64:%s", encoded
);
1697 if (streq(name
, "RootHashSignaturePath")) {
1698 c
->root_hash_sig_size
= 0;
1699 c
->root_hash_sig
= mfree(c
->root_hash_sig
);
1701 return bus_set_transient_path(u
, "RootHashSignature", &c
->root_hash_sig_path
, message
, flags
, error
);
1704 if (streq(name
, "RootVerity"))
1705 return bus_set_transient_path(u
, name
, &c
->root_verity
, message
, flags
, error
);
1707 if (streq(name
, "RootDirectory"))
1708 return bus_set_transient_path(u
, name
, &c
->root_directory
, message
, flags
, error
);
1710 if (streq(name
, "SyslogIdentifier"))
1711 return bus_set_transient_string(u
, name
, &c
->syslog_identifier
, message
, flags
, error
);
1713 if (streq(name
, "LogLevelMax"))
1714 return bus_set_transient_log_level(u
, name
, &c
->log_level_max
, message
, flags
, error
);
1716 if (streq(name
, "LogRateLimitIntervalUSec"))
1717 return bus_set_transient_usec(u
, name
, &c
->log_ratelimit_interval_usec
, message
, flags
, error
);
1719 if (streq(name
, "LogRateLimitBurst"))
1720 return bus_set_transient_unsigned(u
, name
, &c
->log_ratelimit_burst
, message
, flags
, error
);
1722 if (streq(name
, "Personality"))
1723 return bus_set_transient_personality(u
, name
, &c
->personality
, message
, flags
, error
);
1725 if (streq(name
, "StandardInput"))
1726 return bus_set_transient_std_input(u
, name
, &c
->std_input
, message
, flags
, error
);
1728 if (streq(name
, "StandardOutput"))
1729 return bus_set_transient_std_output(u
, name
, &c
->std_output
, message
, flags
, error
);
1731 if (streq(name
, "StandardError"))
1732 return bus_set_transient_std_output(u
, name
, &c
->std_error
, message
, flags
, error
);
1734 if (streq(name
, "IgnoreSIGPIPE"))
1735 return bus_set_transient_bool(u
, name
, &c
->ignore_sigpipe
, message
, flags
, error
);
1737 if (streq(name
, "TTYVHangup"))
1738 return bus_set_transient_bool(u
, name
, &c
->tty_vhangup
, message
, flags
, error
);
1740 if (streq(name
, "TTYReset"))
1741 return bus_set_transient_bool(u
, name
, &c
->tty_reset
, message
, flags
, error
);
1743 if (streq(name
, "TTYVTDisallocate"))
1744 return bus_set_transient_bool(u
, name
, &c
->tty_vt_disallocate
, message
, flags
, error
);
1746 if (streq(name
, "PrivateTmp"))
1747 return bus_set_transient_bool(u
, name
, &c
->private_tmp
, message
, flags
, error
);
1749 if (streq(name
, "PrivateDevices"))
1750 return bus_set_transient_bool(u
, name
, &c
->private_devices
, message
, flags
, error
);
1752 if (streq(name
, "PrivateMounts"))
1753 return bus_set_transient_bool(u
, name
, &c
->private_mounts
, message
, flags
, error
);
1755 if (streq(name
, "PrivateNetwork"))
1756 return bus_set_transient_bool(u
, name
, &c
->private_network
, message
, flags
, error
);
1758 if (streq(name
, "PrivateIPC"))
1759 return bus_set_transient_bool(u
, name
, &c
->private_ipc
, message
, flags
, error
);
1761 if (streq(name
, "PrivateUsers"))
1762 return bus_set_transient_bool(u
, name
, &c
->private_users
, message
, flags
, error
);
1764 if (streq(name
, "NoNewPrivileges"))
1765 return bus_set_transient_bool(u
, name
, &c
->no_new_privileges
, message
, flags
, error
);
1767 if (streq(name
, "SyslogLevelPrefix"))
1768 return bus_set_transient_bool(u
, name
, &c
->syslog_level_prefix
, message
, flags
, error
);
1770 if (streq(name
, "MemoryDenyWriteExecute"))
1771 return bus_set_transient_bool(u
, name
, &c
->memory_deny_write_execute
, message
, flags
, error
);
1773 if (streq(name
, "RestrictRealtime"))
1774 return bus_set_transient_bool(u
, name
, &c
->restrict_realtime
, message
, flags
, error
);
1776 if (streq(name
, "RestrictSUIDSGID"))
1777 return bus_set_transient_bool(u
, name
, &c
->restrict_suid_sgid
, message
, flags
, error
);
1779 if (streq(name
, "DynamicUser"))
1780 return bus_set_transient_bool(u
, name
, &c
->dynamic_user
, message
, flags
, error
);
1782 if (streq(name
, "RemoveIPC"))
1783 return bus_set_transient_bool(u
, name
, &c
->remove_ipc
, message
, flags
, error
);
1785 if (streq(name
, "ProtectKernelTunables"))
1786 return bus_set_transient_bool(u
, name
, &c
->protect_kernel_tunables
, message
, flags
, error
);
1788 if (streq(name
, "ProtectKernelModules"))
1789 return bus_set_transient_bool(u
, name
, &c
->protect_kernel_modules
, message
, flags
, error
);
1791 if (streq(name
, "ProtectKernelLogs"))
1792 return bus_set_transient_bool(u
, name
, &c
->protect_kernel_logs
, message
, flags
, error
);
1794 if (streq(name
, "ProtectClock"))
1795 return bus_set_transient_bool(u
, name
, &c
->protect_clock
, message
, flags
, error
);
1797 if (streq(name
, "ProtectControlGroups"))
1798 return bus_set_transient_bool(u
, name
, &c
->protect_control_groups
, message
, flags
, error
);
1800 if (streq(name
, "CPUSchedulingResetOnFork"))
1801 return bus_set_transient_bool(u
, name
, &c
->cpu_sched_reset_on_fork
, message
, flags
, error
);
1803 if (streq(name
, "NonBlocking"))
1804 return bus_set_transient_bool(u
, name
, &c
->non_blocking
, message
, flags
, error
);
1806 if (streq(name
, "LockPersonality"))
1807 return bus_set_transient_bool(u
, name
, &c
->lock_personality
, message
, flags
, error
);
1809 if (streq(name
, "ProtectHostname"))
1810 return bus_set_transient_bool(u
, name
, &c
->protect_hostname
, message
, flags
, error
);
1812 if (streq(name
, "UtmpIdentifier"))
1813 return bus_set_transient_string(u
, name
, &c
->utmp_id
, message
, flags
, error
);
1815 if (streq(name
, "UtmpMode"))
1816 return bus_set_transient_utmp_mode(u
, name
, &c
->utmp_mode
, message
, flags
, error
);
1818 if (streq(name
, "PAMName"))
1819 return bus_set_transient_string(u
, name
, &c
->pam_name
, message
, flags
, error
);
1821 if (streq(name
, "TimerSlackNSec"))
1822 return bus_set_transient_nsec(u
, name
, &c
->timer_slack_nsec
, message
, flags
, error
);
1824 if (streq(name
, "ProtectSystem"))
1825 return bus_set_transient_protect_system(u
, name
, &c
->protect_system
, message
, flags
, error
);
1827 if (streq(name
, "ProtectHome"))
1828 return bus_set_transient_protect_home(u
, name
, &c
->protect_home
, message
, flags
, error
);
1830 if (streq(name
, "KeyringMode"))
1831 return bus_set_transient_keyring_mode(u
, name
, &c
->keyring_mode
, message
, flags
, error
);
1833 if (streq(name
, "ProtectProc"))
1834 return bus_set_transient_protect_proc(u
, name
, &c
->protect_proc
, message
, flags
, error
);
1836 if (streq(name
, "ProcSubset"))
1837 return bus_set_transient_proc_subset(u
, name
, &c
->proc_subset
, message
, flags
, error
);
1839 if (streq(name
, "RuntimeDirectoryPreserve"))
1840 return bus_set_transient_preserve_mode(u
, name
, &c
->runtime_directory_preserve_mode
, message
, flags
, error
);
1842 if (streq(name
, "UMask"))
1843 return bus_set_transient_mode_t(u
, name
, &c
->umask
, message
, flags
, error
);
1845 if (streq(name
, "RuntimeDirectoryMode"))
1846 return bus_set_transient_mode_t(u
, name
, &c
->directories
[EXEC_DIRECTORY_RUNTIME
].mode
, message
, flags
, error
);
1848 if (streq(name
, "StateDirectoryMode"))
1849 return bus_set_transient_mode_t(u
, name
, &c
->directories
[EXEC_DIRECTORY_STATE
].mode
, message
, flags
, error
);
1851 if (streq(name
, "CacheDirectoryMode"))
1852 return bus_set_transient_mode_t(u
, name
, &c
->directories
[EXEC_DIRECTORY_CACHE
].mode
, message
, flags
, error
);
1854 if (streq(name
, "LogsDirectoryMode"))
1855 return bus_set_transient_mode_t(u
, name
, &c
->directories
[EXEC_DIRECTORY_LOGS
].mode
, message
, flags
, error
);
1857 if (streq(name
, "ConfigurationDirectoryMode"))
1858 return bus_set_transient_mode_t(u
, name
, &c
->directories
[EXEC_DIRECTORY_CONFIGURATION
].mode
, message
, flags
, error
);
1860 if (streq(name
, "SELinuxContext"))
1861 return bus_set_transient_string(u
, name
, &c
->selinux_context
, message
, flags
, error
);
1863 if (streq(name
, "SecureBits"))
1864 return bus_set_transient_secure_bits(u
, name
, &c
->secure_bits
, message
, flags
, error
);
1866 if (streq(name
, "CapabilityBoundingSet"))
1867 return bus_set_transient_capability(u
, name
, &c
->capability_bounding_set
, message
, flags
, error
);
1869 if (streq(name
, "AmbientCapabilities"))
1870 return bus_set_transient_capability(u
, name
, &c
->capability_ambient_set
, message
, flags
, error
);
1872 if (streq(name
, "RestrictNamespaces"))
1873 return bus_set_transient_namespace_flag(u
, name
, &c
->restrict_namespaces
, message
, flags
, error
);
1875 if (streq(name
, "MountFlags"))
1876 return bus_set_transient_mount_flags(u
, name
, &c
->mount_flags
, message
, flags
, error
);
1878 if (streq(name
, "NetworkNamespacePath"))
1879 return bus_set_transient_path(u
, name
, &c
->network_namespace_path
, message
, flags
, error
);
1881 if (streq(name
, "IPCNamespacePath"))
1882 return bus_set_transient_path(u
, name
, &c
->ipc_namespace_path
, message
, flags
, error
);
1884 if (streq(name
, "SupplementaryGroups")) {
1885 _cleanup_strv_free_
char **l
= NULL
;
1888 r
= sd_bus_message_read_strv(message
, &l
);
1893 if (!isempty(*p
) && !valid_user_group_name(*p
, VALID_USER_ALLOW_NUMERIC
|VALID_USER_RELAX
|VALID_USER_WARN
))
1894 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
,
1895 "Invalid supplementary group names");
1897 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
1898 if (strv_isempty(l
)) {
1899 c
->supplementary_groups
= strv_free(c
->supplementary_groups
);
1900 unit_write_settingf(u
, flags
, name
, "%s=", name
);
1902 _cleanup_free_
char *joined
= NULL
;
1904 r
= strv_extend_strv(&c
->supplementary_groups
, l
, true);
1908 joined
= strv_join(c
->supplementary_groups
, " ");
1912 unit_write_settingf(u
, flags
|UNIT_ESCAPE_SPECIFIERS
, name
, "%s=%s", name
, joined
);
1918 } else if (streq(name
, "SetCredential")) {
1919 bool isempty
= true;
1921 r
= sd_bus_message_enter_container(message
, 'a', "(say)");
1930 r
= sd_bus_message_enter_container(message
, 'r', "say");
1936 r
= sd_bus_message_read(message
, "s", &id
);
1940 r
= sd_bus_message_read_array(message
, 'y', &p
, &sz
);
1944 r
= sd_bus_message_exit_container(message
);
1948 if (!credential_name_valid(id
))
1949 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Credential ID is invalid: %s", id
);
1953 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
1954 _cleanup_free_
char *a
= NULL
, *b
= NULL
;
1955 _cleanup_free_
void *copy
= NULL
;
1956 ExecSetCredential
*old
;
1958 copy
= memdup(p
, sz
);
1962 old
= hashmap_get(c
->set_credentials
, id
);
1964 free_and_replace(old
->data
, copy
);
1967 _cleanup_(exec_set_credential_freep
) ExecSetCredential
*sc
= NULL
;
1969 sc
= new0(ExecSetCredential
, 1);
1973 sc
->id
= strdup(id
);
1977 sc
->data
= TAKE_PTR(copy
);
1980 r
= hashmap_ensure_put(&c
->set_credentials
, &exec_set_credential_hash_ops
, sc
->id
, sc
);
1987 a
= specifier_escape(id
);
1991 b
= cescape_length(p
, sz
);
1995 (void) unit_write_settingf(u
, flags
, name
, "%s=%s:%s", name
, a
, b
);
1999 r
= sd_bus_message_exit_container(message
);
2003 if (!UNIT_WRITE_FLAGS_NOOP(flags
) && isempty
) {
2004 c
->set_credentials
= hashmap_free(c
->set_credentials
);
2005 (void) unit_write_settingf(u
, flags
, name
, "%s=", name
);
2010 } else if (streq(name
, "LoadCredential")) {
2011 bool isempty
= true;
2013 r
= sd_bus_message_enter_container(message
, 'a', "(ss)");
2018 const char *id
, *source
;
2020 r
= sd_bus_message_read(message
, "(ss)", &id
, &source
);
2026 if (!credential_name_valid(id
))
2027 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Credential ID is invalid: %s", id
);
2029 if (!(path_is_absolute(source
) ? path_is_normalized(source
) : credential_name_valid(source
)))
2030 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Credential source is invalid: %s", source
);
2034 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
2035 r
= strv_extend_strv(&c
->load_credentials
, STRV_MAKE(id
, source
), /* filter_duplicates = */ false);
2039 (void) unit_write_settingf(u
, flags
|UNIT_ESCAPE_SPECIFIERS
, name
, "%s=%s:%s", name
, id
, source
);
2043 r
= sd_bus_message_exit_container(message
);
2047 if (!UNIT_WRITE_FLAGS_NOOP(flags
) && isempty
) {
2048 c
->load_credentials
= strv_free(c
->load_credentials
);
2049 (void) unit_write_settingf(u
, flags
, name
, "%s=", name
);
2054 } else if (streq(name
, "SyslogLevel")) {
2057 r
= sd_bus_message_read(message
, "i", &level
);
2061 if (!log_level_is_valid(level
))
2062 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Log level value out of range");
2064 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
2065 c
->syslog_priority
= (c
->syslog_priority
& LOG_FACMASK
) | level
;
2066 unit_write_settingf(u
, flags
, name
, "SyslogLevel=%i", level
);
2071 } else if (streq(name
, "SyslogFacility")) {
2074 r
= sd_bus_message_read(message
, "i", &facility
);
2078 if (!log_facility_unshifted_is_valid(facility
))
2079 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Log facility value out of range");
2081 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
2082 c
->syslog_priority
= (facility
<< 3) | LOG_PRI(c
->syslog_priority
);
2083 unit_write_settingf(u
, flags
, name
, "SyslogFacility=%i", facility
);
2088 } else if (streq(name
, "LogNamespace")) {
2091 r
= sd_bus_message_read(message
, "s", &n
);
2095 if (!isempty(n
) && !log_namespace_name_valid(n
))
2096 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Log namespace name not valid");
2098 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
2101 c
->log_namespace
= mfree(c
->log_namespace
);
2102 unit_write_settingf(u
, flags
, name
, "%s=", name
);
2104 r
= free_and_strdup(&c
->log_namespace
, n
);
2108 unit_write_settingf(u
, flags
, name
, "%s=%s", name
, n
);
2114 } else if (streq(name
, "LogExtraFields")) {
2117 r
= sd_bus_message_enter_container(message
, 'a', "ay");
2122 _cleanup_free_
void *copy
= NULL
;
2128 /* Note that we expect a byte array for each field, instead of a string. That's because on the
2129 * lower-level journal fields can actually contain binary data and are not restricted to text,
2130 * and we should not "lose precision" in our types on the way. That said, I am pretty sure
2131 * actually encoding binary data as unit metadata is not a good idea. Hence we actually refuse
2132 * any actual binary data, and only accept UTF-8. This allows us to eventually lift this
2133 * limitation, should a good, valid usecase arise. */
2135 r
= sd_bus_message_read_array(message
, 'y', &p
, &sz
);
2141 if (memchr(p
, 0, sz
))
2142 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Journal field contains zero byte");
2144 eq
= memchr(p
, '=', sz
);
2146 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Journal field contains no '=' character");
2147 if (!journal_field_valid(p
, eq
- (const char*) p
, false))
2148 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Journal field invalid");
2150 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
2151 t
= reallocarray(c
->log_extra_fields
, c
->n_log_extra_fields
+1, sizeof(struct iovec
));
2154 c
->log_extra_fields
= t
;
2157 copy
= malloc(sz
+ 1);
2161 memcpy(copy
, p
, sz
);
2162 ((uint8_t*) copy
)[sz
] = 0;
2164 if (!utf8_is_valid(copy
))
2165 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Journal field is not valid UTF-8");
2167 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
2168 c
->log_extra_fields
[c
->n_log_extra_fields
++] = IOVEC_MAKE(copy
, sz
);
2169 unit_write_settingf(u
, flags
|UNIT_ESCAPE_SPECIFIERS
|UNIT_ESCAPE_C
, name
, "LogExtraFields=%s", (char*) copy
);
2177 r
= sd_bus_message_exit_container(message
);
2181 if (!UNIT_WRITE_FLAGS_NOOP(flags
) && n
== 0) {
2182 exec_context_free_log_extra_fields(c
);
2183 unit_write_setting(u
, flags
, name
, "LogExtraFields=");
2191 if (streq(name
, "SystemCallErrorNumber"))
2192 return bus_set_transient_errno(u
, name
, &c
->syscall_errno
, message
, flags
, error
);
2194 if (streq(name
, "SystemCallFilter")) {
2196 _cleanup_strv_free_
char **l
= NULL
;
2198 r
= sd_bus_message_enter_container(message
, 'r', "bas");
2202 r
= sd_bus_message_read(message
, "b", &allow_list
);
2206 r
= sd_bus_message_read_strv(message
, &l
);
2210 r
= sd_bus_message_exit_container(message
);
2214 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
2215 _cleanup_free_
char *joined
= NULL
;
2216 SeccompParseFlags invert_flag
= allow_list
? 0 : SECCOMP_PARSE_INVERT
;
2219 if (strv_isempty(l
)) {
2220 c
->syscall_allow_list
= false;
2221 c
->syscall_filter
= hashmap_free(c
->syscall_filter
);
2223 unit_write_settingf(u
, flags
, name
, "SystemCallFilter=");
2227 if (!c
->syscall_filter
) {
2228 c
->syscall_filter
= hashmap_new(NULL
);
2229 if (!c
->syscall_filter
)
2232 c
->syscall_allow_list
= allow_list
;
2234 if (c
->syscall_allow_list
) {
2235 r
= seccomp_parse_syscall_filter("@default",
2238 SECCOMP_PARSE_PERMISSIVE
|
2239 SECCOMP_PARSE_ALLOW_LIST
| invert_flag
,
2247 STRV_FOREACH(s
, l
) {
2248 _cleanup_free_
char *n
= NULL
;
2251 r
= parse_syscall_and_errno(*s
, &n
, &e
);
2255 if (allow_list
&& e
>= 0)
2258 r
= seccomp_parse_syscall_filter(n
,
2261 SECCOMP_PARSE_LOG
| SECCOMP_PARSE_PERMISSIVE
|
2263 (c
->syscall_allow_list
? SECCOMP_PARSE_ALLOW_LIST
: 0),
2270 joined
= strv_join(l
, " ");
2274 unit_write_settingf(u
, flags
, name
, "SystemCallFilter=%s%s", allow_list
? "" : "~", joined
);
2279 } else if (streq(name
, "SystemCallLog")) {
2281 _cleanup_strv_free_
char **l
= NULL
;
2283 r
= sd_bus_message_enter_container(message
, 'r', "bas");
2287 r
= sd_bus_message_read(message
, "b", &allow_list
);
2291 r
= sd_bus_message_read_strv(message
, &l
);
2295 r
= sd_bus_message_exit_container(message
);
2299 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
2300 _cleanup_free_
char *joined
= NULL
;
2301 SeccompParseFlags invert_flag
= allow_list
? 0 : SECCOMP_PARSE_INVERT
;
2304 if (strv_isempty(l
)) {
2305 c
->syscall_log_allow_list
= false;
2306 c
->syscall_log
= hashmap_free(c
->syscall_log
);
2308 unit_write_settingf(u
, flags
, name
, "SystemCallLog=");
2312 if (!c
->syscall_log
) {
2313 c
->syscall_log
= hashmap_new(NULL
);
2314 if (!c
->syscall_log
)
2317 c
->syscall_log_allow_list
= allow_list
;
2320 STRV_FOREACH(s
, l
) {
2321 r
= seccomp_parse_syscall_filter(*s
,
2322 -1, /* errno not used */
2324 SECCOMP_PARSE_LOG
| SECCOMP_PARSE_PERMISSIVE
|
2326 (c
->syscall_log_allow_list
? SECCOMP_PARSE_ALLOW_LIST
: 0),
2333 joined
= strv_join(l
, " ");
2337 unit_write_settingf(u
, flags
, name
, "SystemCallLog=%s%s", allow_list
? "" : "~", joined
);
2342 } else if (streq(name
, "SystemCallArchitectures")) {
2343 _cleanup_strv_free_
char **l
= NULL
;
2345 r
= sd_bus_message_read_strv(message
, &l
);
2349 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
2350 _cleanup_free_
char *joined
= NULL
;
2352 if (strv_isempty(l
))
2353 c
->syscall_archs
= set_free(c
->syscall_archs
);
2357 STRV_FOREACH(s
, l
) {
2360 r
= seccomp_arch_from_string(*s
, &a
);
2364 r
= set_ensure_put(&c
->syscall_archs
, NULL
, UINT32_TO_PTR(a
+ 1));
2371 joined
= strv_join(l
, " ");
2375 unit_write_settingf(u
, flags
, name
, "%s=%s", name
, joined
);
2380 } else if (streq(name
, "RestrictAddressFamilies")) {
2382 _cleanup_strv_free_
char **l
= NULL
;
2384 r
= sd_bus_message_enter_container(message
, 'r', "bas");
2388 r
= sd_bus_message_read(message
, "b", &allow_list
);
2392 r
= sd_bus_message_read_strv(message
, &l
);
2396 r
= sd_bus_message_exit_container(message
);
2400 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
2401 _cleanup_free_
char *joined
= NULL
;
2404 if (strv_isempty(l
)) {
2405 c
->address_families_allow_list
= false;
2406 c
->address_families
= set_free(c
->address_families
);
2408 unit_write_settingf(u
, flags
, name
, "RestrictAddressFamilies=");
2412 if (!c
->address_families
) {
2413 c
->address_families
= set_new(NULL
);
2414 if (!c
->address_families
)
2417 c
->address_families_allow_list
= allow_list
;
2420 STRV_FOREACH(s
, l
) {
2423 af
= af_from_name(*s
);
2427 if (allow_list
== c
->address_families_allow_list
) {
2428 r
= set_put(c
->address_families
, INT_TO_PTR(af
));
2432 (void) set_remove(c
->address_families
, INT_TO_PTR(af
));
2435 joined
= strv_join(l
, " ");
2439 unit_write_settingf(u
, flags
, name
, "RestrictAddressFamilies=%s%s", allow_list
? "" : "~", joined
);
2445 if (STR_IN_SET(name
, "CPUAffinity", "NUMAMask")) {
2448 bool affinity
= streq(name
, "CPUAffinity");
2449 _cleanup_(cpu_set_reset
) CPUSet set
= {};
2451 r
= sd_bus_message_read_array(message
, 'y', &a
, &n
);
2455 r
= cpu_set_from_dbus(a
, n
, &set
);
2459 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
2461 cpu_set_reset(affinity
? &c
->cpu_set
: &c
->numa_policy
.nodes
);
2462 unit_write_settingf(u
, flags
, name
, "%s=", name
);
2464 _cleanup_free_
char *str
= NULL
;
2466 str
= cpu_set_to_string(&set
);
2470 /* We forego any optimizations here, and always create the structure using
2471 * cpu_set_add_all(), because we don't want to care if the existing size we
2472 * got over dbus is appropriate. */
2473 r
= cpu_set_add_all(affinity
? &c
->cpu_set
: &c
->numa_policy
.nodes
, &set
);
2477 unit_write_settingf(u
, flags
, name
, "%s=%s", name
, str
);
2483 } else if (streq(name
, "CPUAffinityFromNUMA")) {
2486 r
= sd_bus_message_read_basic(message
, 'b', &q
);
2490 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
2491 c
->cpu_affinity_from_numa
= q
;
2492 unit_write_settingf(u
, flags
, name
, "%s=%s", "CPUAffinity", "numa");
2497 } else if (streq(name
, "NUMAPolicy")) {
2500 r
= sd_bus_message_read(message
, "i", &type
);
2504 if (!mpol_is_valid(type
))
2505 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Invalid NUMAPolicy value: %i", type
);
2507 if (!UNIT_WRITE_FLAGS_NOOP(flags
))
2508 c
->numa_policy
.type
= type
;
2512 } else if (streq(name
, "Nice")) {
2515 r
= sd_bus_message_read(message
, "i", &q
);
2519 if (!nice_is_valid(q
))
2520 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Invalid Nice value: %i", q
);
2522 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
2526 unit_write_settingf(u
, flags
, name
, "Nice=%i", q
);
2531 } else if (streq(name
, "CPUSchedulingPolicy")) {
2534 r
= sd_bus_message_read(message
, "i", &q
);
2538 if (!sched_policy_is_valid(q
))
2539 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Invalid CPU scheduling policy: %i", q
);
2541 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
2542 _cleanup_free_
char *s
= NULL
;
2544 r
= sched_policy_to_string_alloc(q
, &s
);
2548 c
->cpu_sched_policy
= q
;
2549 c
->cpu_sched_priority
= CLAMP(c
->cpu_sched_priority
, sched_get_priority_min(q
), sched_get_priority_max(q
));
2550 c
->cpu_sched_set
= true;
2552 unit_write_settingf(u
, flags
, name
, "CPUSchedulingPolicy=%s", s
);
2557 } else if (streq(name
, "CPUSchedulingPriority")) {
2558 int32_t p
, min
, max
;
2560 r
= sd_bus_message_read(message
, "i", &p
);
2564 min
= sched_get_priority_min(c
->cpu_sched_policy
);
2565 max
= sched_get_priority_max(c
->cpu_sched_policy
);
2566 if (p
< min
|| p
> max
)
2567 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Invalid CPU scheduling priority: %i", p
);
2569 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
2570 c
->cpu_sched_priority
= p
;
2571 c
->cpu_sched_set
= true;
2573 unit_write_settingf(u
, flags
, name
, "CPUSchedulingPriority=%i", p
);
2578 } else if (streq(name
, "IOSchedulingClass")) {
2581 r
= sd_bus_message_read(message
, "i", &q
);
2585 if (!ioprio_class_is_valid(q
))
2586 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Invalid IO scheduling class: %i", q
);
2588 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
2589 _cleanup_free_
char *s
= NULL
;
2591 r
= ioprio_class_to_string_alloc(q
, &s
);
2595 c
->ioprio
= IOPRIO_PRIO_VALUE(q
, IOPRIO_PRIO_DATA(c
->ioprio
));
2596 c
->ioprio_set
= true;
2598 unit_write_settingf(u
, flags
, name
, "IOSchedulingClass=%s", s
);
2603 } else if (streq(name
, "IOSchedulingPriority")) {
2606 r
= sd_bus_message_read(message
, "i", &p
);
2610 if (!ioprio_priority_is_valid(p
))
2611 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Invalid IO scheduling priority: %i", p
);
2613 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
2614 c
->ioprio
= IOPRIO_PRIO_VALUE(IOPRIO_PRIO_CLASS(c
->ioprio
), p
);
2615 c
->ioprio_set
= true;
2617 unit_write_settingf(u
, flags
, name
, "IOSchedulingPriority=%i", p
);
2622 } else if (streq(name
, "MountAPIVFS")) {
2625 r
= bus_set_transient_bool(u
, name
, &b
, message
, flags
, error
);
2629 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
2630 c
->mount_apivfs
= b
;
2631 c
->mount_apivfs_set
= true;
2636 } else if (streq(name
, "WorkingDirectory")) {
2640 r
= sd_bus_message_read(message
, "s", &s
);
2650 if (!isempty(s
) && !streq(s
, "~") && !path_is_absolute(s
))
2651 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "WorkingDirectory= expects an absolute path or '~'");
2653 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
2654 if (streq(s
, "~")) {
2655 c
->working_directory
= mfree(c
->working_directory
);
2656 c
->working_directory_home
= true;
2658 r
= free_and_strdup(&c
->working_directory
, empty_to_null(s
));
2662 c
->working_directory_home
= false;
2665 c
->working_directory_missing_ok
= missing_ok
;
2666 unit_write_settingf(u
, flags
|UNIT_ESCAPE_SPECIFIERS
, name
, "WorkingDirectory=%s%s", missing_ok
? "-" : "", s
);
2671 } else if (STR_IN_SET(name
,
2672 "StandardInputFileDescriptorName", "StandardOutputFileDescriptorName", "StandardErrorFileDescriptorName")) {
2675 r
= sd_bus_message_read(message
, "s", &s
);
2679 if (!isempty(s
) && !fdname_is_valid(s
))
2680 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Invalid file descriptor name");
2682 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
2684 if (streq(name
, "StandardInputFileDescriptorName")) {
2685 r
= free_and_strdup(c
->stdio_fdname
+ STDIN_FILENO
, empty_to_null(s
));
2689 c
->std_input
= EXEC_INPUT_NAMED_FD
;
2690 unit_write_settingf(u
, flags
|UNIT_ESCAPE_SPECIFIERS
, name
, "StandardInput=fd:%s", exec_context_fdname(c
, STDIN_FILENO
));
2692 } else if (streq(name
, "StandardOutputFileDescriptorName")) {
2693 r
= free_and_strdup(c
->stdio_fdname
+ STDOUT_FILENO
, empty_to_null(s
));
2697 c
->std_output
= EXEC_OUTPUT_NAMED_FD
;
2698 unit_write_settingf(u
, flags
|UNIT_ESCAPE_SPECIFIERS
, name
, "StandardOutput=fd:%s", exec_context_fdname(c
, STDOUT_FILENO
));
2701 assert(streq(name
, "StandardErrorFileDescriptorName"));
2703 r
= free_and_strdup(&c
->stdio_fdname
[STDERR_FILENO
], empty_to_null(s
));
2707 c
->std_error
= EXEC_OUTPUT_NAMED_FD
;
2708 unit_write_settingf(u
, flags
|UNIT_ESCAPE_SPECIFIERS
, name
, "StandardError=fd:%s", exec_context_fdname(c
, STDERR_FILENO
));
2714 } else if (STR_IN_SET(name
,
2715 "StandardInputFile",
2716 "StandardOutputFile", "StandardOutputFileToAppend", "StandardOutputFileToTruncate",
2717 "StandardErrorFile", "StandardErrorFileToAppend", "StandardErrorFileToTruncate")) {
2720 r
= sd_bus_message_read(message
, "s", &s
);
2725 if (!path_is_absolute(s
))
2726 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Path %s is not absolute", s
);
2727 if (!path_is_normalized(s
))
2728 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Path %s is not normalized", s
);
2731 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
2733 if (streq(name
, "StandardInputFile")) {
2734 r
= free_and_strdup(&c
->stdio_file
[STDIN_FILENO
], empty_to_null(s
));
2738 c
->std_input
= EXEC_INPUT_FILE
;
2739 unit_write_settingf(u
, flags
|UNIT_ESCAPE_SPECIFIERS
, name
, "StandardInput=file:%s", s
);
2741 } else if (STR_IN_SET(name
, "StandardOutputFile", "StandardOutputFileToAppend", "StandardOutputFileToTruncate")) {
2742 r
= free_and_strdup(&c
->stdio_file
[STDOUT_FILENO
], empty_to_null(s
));
2746 if (streq(name
, "StandardOutputFile")) {
2747 c
->std_output
= EXEC_OUTPUT_FILE
;
2748 unit_write_settingf(u
, flags
|UNIT_ESCAPE_SPECIFIERS
, name
, "StandardOutput=file:%s", s
);
2749 } else if (streq(name
, "StandardOutputFileToAppend")) {
2750 c
->std_output
= EXEC_OUTPUT_FILE_APPEND
;
2751 unit_write_settingf(u
, flags
|UNIT_ESCAPE_SPECIFIERS
, name
, "StandardOutput=append:%s", s
);
2753 assert(streq(name
, "StandardOutputFileToTruncate"));
2754 c
->std_output
= EXEC_OUTPUT_FILE_TRUNCATE
;
2755 unit_write_settingf(u
, flags
|UNIT_ESCAPE_SPECIFIERS
, name
, "StandardOutput=truncate:%s", s
);
2758 assert(STR_IN_SET(name
, "StandardErrorFile", "StandardErrorFileToAppend", "StandardErrorFileToTruncate"));
2760 r
= free_and_strdup(&c
->stdio_file
[STDERR_FILENO
], empty_to_null(s
));
2764 if (streq(name
, "StandardErrorFile")) {
2765 c
->std_error
= EXEC_OUTPUT_FILE
;
2766 unit_write_settingf(u
, flags
|UNIT_ESCAPE_SPECIFIERS
, name
, "StandardError=file:%s", s
);
2767 } else if (streq(name
, "StandardErrorFileToAppend")) {
2768 c
->std_error
= EXEC_OUTPUT_FILE_APPEND
;
2769 unit_write_settingf(u
, flags
|UNIT_ESCAPE_SPECIFIERS
, name
, "StandardError=append:%s", s
);
2771 assert(streq(name
, "StandardErrorFileToTruncate"));
2772 c
->std_error
= EXEC_OUTPUT_FILE_TRUNCATE
;
2773 unit_write_settingf(u
, flags
|UNIT_ESCAPE_SPECIFIERS
, name
, "StandardError=truncate:%s", s
);
2780 } else if (streq(name
, "StandardInputData")) {
2784 r
= sd_bus_message_read_array(message
, 'y', &p
, &sz
);
2788 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
2789 _cleanup_free_
char *encoded
= NULL
;
2792 c
->stdin_data
= mfree(c
->stdin_data
);
2793 c
->stdin_data_size
= 0;
2795 unit_write_settingf(u
, flags
, name
, "StandardInputData=");
2800 if (c
->stdin_data_size
+ sz
< c
->stdin_data_size
|| /* check for overflow */
2801 c
->stdin_data_size
+ sz
> EXEC_STDIN_DATA_MAX
)
2804 n
= base64mem(p
, sz
, &encoded
);
2808 q
= realloc(c
->stdin_data
, c
->stdin_data_size
+ sz
);
2812 memcpy((uint8_t*) q
+ c
->stdin_data_size
, p
, sz
);
2815 c
->stdin_data_size
+= sz
;
2817 unit_write_settingf(u
, flags
, name
, "StandardInputData=%s", encoded
);
2823 } else if (streq(name
, "Environment")) {
2825 _cleanup_strv_free_
char **l
= NULL
;
2827 r
= sd_bus_message_read_strv(message
, &l
);
2831 if (!strv_env_is_valid(l
))
2832 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Invalid environment block.");
2834 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
2835 if (strv_isempty(l
)) {
2836 c
->environment
= strv_free(c
->environment
);
2837 unit_write_setting(u
, flags
, name
, "Environment=");
2839 _cleanup_free_
char *joined
= NULL
;
2842 joined
= unit_concat_strv(l
, UNIT_ESCAPE_SPECIFIERS
|UNIT_ESCAPE_C
);
2846 e
= strv_env_merge(2, c
->environment
, l
);
2850 strv_free_and_replace(c
->environment
, e
);
2851 unit_write_settingf(u
, flags
, name
, "Environment=%s", joined
);
2857 } else if (streq(name
, "UnsetEnvironment")) {
2859 _cleanup_strv_free_
char **l
= NULL
;
2861 r
= sd_bus_message_read_strv(message
, &l
);
2865 if (!strv_env_name_or_assignment_is_valid(l
))
2866 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Invalid UnsetEnvironment= list.");
2868 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
2869 if (strv_isempty(l
)) {
2870 c
->unset_environment
= strv_free(c
->unset_environment
);
2871 unit_write_setting(u
, flags
, name
, "UnsetEnvironment=");
2873 _cleanup_free_
char *joined
= NULL
;
2876 joined
= unit_concat_strv(l
, UNIT_ESCAPE_SPECIFIERS
|UNIT_ESCAPE_C
);
2880 e
= strv_env_merge(2, c
->unset_environment
, l
);
2884 strv_free_and_replace(c
->unset_environment
, e
);
2885 unit_write_settingf(u
, flags
, name
, "UnsetEnvironment=%s", joined
);
2891 } else if (streq(name
, "OOMScoreAdjust")) {
2894 r
= sd_bus_message_read(message
, "i", &oa
);
2898 if (!oom_score_adjust_is_valid(oa
))
2899 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "OOM score adjust value out of range");
2901 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
2902 c
->oom_score_adjust
= oa
;
2903 c
->oom_score_adjust_set
= true;
2904 unit_write_settingf(u
, flags
, name
, "OOMScoreAdjust=%i", oa
);
2909 } else if (streq(name
, "CoredumpFilter")) {
2912 r
= sd_bus_message_read(message
, "t", &f
);
2916 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
2917 c
->coredump_filter
= f
;
2918 c
->coredump_filter_set
= true;
2919 unit_write_settingf(u
, flags
, name
, "CoredumpFilter=0x%"PRIx64
, f
);
2924 } else if (streq(name
, "EnvironmentFiles")) {
2926 _cleanup_free_
char *joined
= NULL
;
2927 _cleanup_fclose_
FILE *f
= NULL
;
2928 _cleanup_strv_free_
char **l
= NULL
;
2932 r
= sd_bus_message_enter_container(message
, 'a', "(sb)");
2936 f
= open_memstream_unlocked(&joined
, &size
);
2940 fputs("EnvironmentFile=\n", f
);
2942 STRV_FOREACH(i
, c
->environment_files
) {
2943 _cleanup_free_
char *q
= NULL
;
2945 q
= specifier_escape(*i
);
2949 fprintf(f
, "EnvironmentFile=%s\n", q
);
2952 while ((r
= sd_bus_message_enter_container(message
, 'r', "sb")) > 0) {
2956 r
= sd_bus_message_read(message
, "sb", &path
, &b
);
2960 r
= sd_bus_message_exit_container(message
);
2964 if (!path_is_absolute(path
))
2965 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Path %s is not absolute.", path
);
2967 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
2968 _cleanup_free_
char *q
= NULL
, *buf
= NULL
;
2970 buf
= strjoin(b
? "-" : "", path
);
2974 q
= specifier_escape(buf
);
2978 fprintf(f
, "EnvironmentFile=%s\n", q
);
2980 r
= strv_consume(&l
, TAKE_PTR(buf
));
2988 r
= sd_bus_message_exit_container(message
);
2992 r
= fflush_and_check(f
);
2996 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
2997 if (strv_isempty(l
)) {
2998 c
->environment_files
= strv_free(c
->environment_files
);
2999 unit_write_setting(u
, flags
, name
, "EnvironmentFile=");
3001 r
= strv_extend_strv(&c
->environment_files
, l
, true);
3005 unit_write_setting(u
, flags
, name
, joined
);
3011 } else if (streq(name
, "PassEnvironment")) {
3013 _cleanup_strv_free_
char **l
= NULL
;
3015 r
= sd_bus_message_read_strv(message
, &l
);
3019 if (!strv_env_name_is_valid(l
))
3020 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Invalid PassEnvironment= block.");
3022 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
3023 if (strv_isempty(l
)) {
3024 c
->pass_environment
= strv_free(c
->pass_environment
);
3025 unit_write_setting(u
, flags
, name
, "PassEnvironment=");
3027 _cleanup_free_
char *joined
= NULL
;
3029 r
= strv_extend_strv(&c
->pass_environment
, l
, true);
3033 /* We write just the new settings out to file, with unresolved specifiers. */
3034 joined
= unit_concat_strv(l
, UNIT_ESCAPE_SPECIFIERS
);
3038 unit_write_settingf(u
, flags
, name
, "PassEnvironment=%s", joined
);
3044 } else if (STR_IN_SET(name
, "ReadWriteDirectories", "ReadOnlyDirectories", "InaccessibleDirectories",
3045 "ReadWritePaths", "ReadOnlyPaths", "InaccessiblePaths", "ExecPaths", "NoExecPaths")) {
3046 _cleanup_strv_free_
char **l
= NULL
;
3050 r
= sd_bus_message_read_strv(message
, &l
);
3054 STRV_FOREACH(p
, l
) {
3058 offset
= i
[0] == '-';
3059 offset
+= i
[offset
] == '+';
3060 if (!path_is_absolute(i
+ offset
))
3061 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Invalid %s", name
);
3063 path_simplify(i
+ offset
, false);
3066 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
3067 if (STR_IN_SET(name
, "ReadWriteDirectories", "ReadWritePaths"))
3068 dirs
= &c
->read_write_paths
;
3069 else if (STR_IN_SET(name
, "ReadOnlyDirectories", "ReadOnlyPaths"))
3070 dirs
= &c
->read_only_paths
;
3071 else if (streq(name
, "ExecPaths"))
3072 dirs
= &c
->exec_paths
;
3073 else if (streq(name
, "NoExecPaths"))
3074 dirs
= &c
->no_exec_paths
;
3075 else /* "InaccessiblePaths" */
3076 dirs
= &c
->inaccessible_paths
;
3078 if (strv_isempty(l
)) {
3079 *dirs
= strv_free(*dirs
);
3080 unit_write_settingf(u
, flags
, name
, "%s=", name
);
3082 _cleanup_free_
char *joined
= NULL
;
3084 joined
= unit_concat_strv(l
, UNIT_ESCAPE_SPECIFIERS
);
3088 r
= strv_extend_strv(dirs
, l
, true);
3092 unit_write_settingf(u
, flags
, name
, "%s=%s", name
, joined
);
3098 } else if (STR_IN_SET(name
, "RuntimeDirectory", "StateDirectory", "CacheDirectory", "LogsDirectory", "ConfigurationDirectory")) {
3099 _cleanup_strv_free_
char **l
= NULL
;
3102 r
= sd_bus_message_read_strv(message
, &l
);
3106 STRV_FOREACH(p
, l
) {
3107 if (!path_is_normalized(*p
))
3108 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "%s= path is not normalized: %s", name
, *p
);
3110 if (path_is_absolute(*p
))
3111 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "%s= path is absolute: %s", name
, *p
);
3113 if (path_startswith(*p
, "private"))
3114 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "%s= path can't be 'private': %s", name
, *p
);
3117 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
3118 ExecDirectoryType i
;
3121 assert_se((i
= exec_directory_type_from_string(name
)) >= 0);
3122 d
= c
->directories
+ i
;
3124 if (strv_isempty(l
)) {
3125 d
->paths
= strv_free(d
->paths
);
3126 unit_write_settingf(u
, flags
, name
, "%s=", name
);
3128 _cleanup_free_
char *joined
= NULL
;
3130 r
= strv_extend_strv(&d
->paths
, l
, true);
3134 joined
= unit_concat_strv(l
, UNIT_ESCAPE_SPECIFIERS
);
3138 unit_write_settingf(u
, flags
, name
, "%s=%s", name
, joined
);
3144 } else if (STR_IN_SET(name
, "AppArmorProfile", "SmackProcessLabel")) {
3148 r
= sd_bus_message_read(message
, "(bs)", &ignore
, &s
);
3152 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
3156 if (streq(name
, "AppArmorProfile")) {
3157 p
= &c
->apparmor_profile
;
3158 b
= &c
->apparmor_profile_ignore
;
3159 } else { /* "SmackProcessLabel" */
3160 p
= &c
->smack_process_label
;
3161 b
= &c
->smack_process_label_ignore
;
3168 if (free_and_strdup(p
, s
) < 0)
3173 unit_write_settingf(u
, flags
|UNIT_ESCAPE_SPECIFIERS
, name
, "%s=%s%s", name
, ignore
? "-" : "", strempty(s
));
3178 } else if (STR_IN_SET(name
, "BindPaths", "BindReadOnlyPaths")) {
3179 char *source
, *destination
;
3181 uint64_t mount_flags
;
3184 r
= sd_bus_message_enter_container(message
, 'a', "(ssbt)");
3188 while ((r
= sd_bus_message_read(message
, "(ssbt)", &source
, &destination
, &ignore_enoent
, &mount_flags
)) > 0) {
3190 if (!path_is_absolute(source
))
3191 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Source path %s is not absolute.", source
);
3192 if (!path_is_absolute(destination
))
3193 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Destination path %s is not absolute.", destination
);
3194 if (!IN_SET(mount_flags
, 0, MS_REC
))
3195 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Unknown mount flags.");
3197 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
3198 r
= bind_mount_add(&c
->bind_mounts
, &c
->n_bind_mounts
,
3201 .destination
= destination
,
3202 .read_only
= !!strstr(name
, "ReadOnly"),
3203 .recursive
= !!(mount_flags
& MS_REC
),
3204 .ignore_enoent
= ignore_enoent
,
3209 unit_write_settingf(
3210 u
, flags
|UNIT_ESCAPE_SPECIFIERS
, name
,
3213 ignore_enoent
? "-" : "",
3216 (mount_flags
& MS_REC
) ? "rbind" : "norbind");
3224 r
= sd_bus_message_exit_container(message
);
3229 bind_mount_free_many(c
->bind_mounts
, c
->n_bind_mounts
);
3230 c
->bind_mounts
= NULL
;
3231 c
->n_bind_mounts
= 0;
3233 unit_write_settingf(u
, flags
, name
, "%s=", name
);
3238 } else if (streq(name
, "TemporaryFileSystem")) {
3239 const char *path
, *options
;
3242 r
= sd_bus_message_enter_container(message
, 'a', "(ss)");
3246 while ((r
= sd_bus_message_read(message
, "(ss)", &path
, &options
)) > 0) {
3248 if (!path_is_absolute(path
))
3249 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Mount point %s is not absolute.", path
);
3251 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
3252 r
= temporary_filesystem_add(&c
->temporary_filesystems
, &c
->n_temporary_filesystems
, path
, options
);
3256 unit_write_settingf(
3257 u
, flags
|UNIT_ESCAPE_SPECIFIERS
, name
,
3269 r
= sd_bus_message_exit_container(message
);
3274 temporary_filesystem_free_many(c
->temporary_filesystems
, c
->n_temporary_filesystems
);
3275 c
->temporary_filesystems
= NULL
;
3276 c
->n_temporary_filesystems
= 0;
3278 unit_write_settingf(u
, flags
, name
, "%s=", name
);
3283 } else if ((suffix
= startswith(name
, "Limit"))) {
3284 const char *soft
= NULL
;
3287 ri
= rlimit_from_string(suffix
);
3289 soft
= endswith(suffix
, "Soft");
3293 n
= strndupa(suffix
, soft
- suffix
);
3294 ri
= rlimit_from_string(n
);
3296 name
= strjoina("Limit", n
);
3304 r
= sd_bus_message_read(message
, "t", &rl
);
3308 if (rl
== UINT64_MAX
)
3313 if ((uint64_t) x
!= rl
)
3317 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
3318 _cleanup_free_
char *f
= NULL
;
3321 if (c
->rlimit
[ri
]) {
3322 nl
= *c
->rlimit
[ri
];
3329 /* When the resource limit is not initialized yet, then assign the value to both fields */
3330 nl
= (struct rlimit
) {
3335 r
= rlimit_format(&nl
, &f
);
3340 *c
->rlimit
[ri
] = nl
;
3342 c
->rlimit
[ri
] = newdup(struct rlimit
, &nl
, 1);
3347 unit_write_settingf(u
, flags
, name
, "%s=%s", name
, f
);
3353 } else if (streq(name
, "MountImages")) {
3354 _cleanup_free_
char *format_str
= NULL
;
3355 MountImage
*mount_images
= NULL
;
3356 size_t n_mount_images
= 0;
3357 char *source
, *destination
;
3360 r
= sd_bus_message_enter_container(message
, 'a', "(ssba(ss))");
3365 _cleanup_(mount_options_free_allp
) MountOptions
*options
= NULL
;
3366 _cleanup_free_
char *source_escaped
= NULL
, *destination_escaped
= NULL
;
3369 r
= sd_bus_message_enter_container(message
, 'r', "ssba(ss)");
3373 r
= sd_bus_message_read(message
, "ssb", &source
, &destination
, &permissive
);
3377 if (!path_is_absolute(source
))
3378 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Source path %s is not absolute.", source
);
3379 if (!path_is_normalized(source
))
3380 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Source path %s is not normalized.", source
);
3381 if (!path_is_absolute(destination
))
3382 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Destination path %s is not absolute.", destination
);
3383 if (!path_is_normalized(destination
))
3384 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Destination path %s is not normalized.", destination
);
3386 /* Need to store them in the unit with the escapes, so that they can be parsed again */
3387 source_escaped
= shell_escape(source
, ":");
3388 if (!source_escaped
)
3390 destination_escaped
= shell_escape(destination
, ":");
3391 if (!destination_escaped
)
3394 tuple
= strjoin(format_str
,
3395 format_str
? " " : "",
3396 permissive
? "-" : "",
3399 destination_escaped
);
3402 free_and_replace(format_str
, tuple
);
3404 r
= bus_read_mount_options(message
, error
, &options
, &format_str
, ":");
3408 r
= sd_bus_message_exit_container(message
);
3412 r
= mount_image_add(&mount_images
, &n_mount_images
,
3415 .destination
= destination
,
3416 .mount_options
= options
,
3417 .ignore_enoent
= permissive
,
3418 .type
= MOUNT_IMAGE_DISCRETE
,
3426 r
= sd_bus_message_exit_container(message
);
3430 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
3431 if (n_mount_images
== 0) {
3432 c
->mount_images
= mount_image_free_many(c
->mount_images
, &c
->n_mount_images
);
3434 unit_write_settingf(u
, flags
, name
, "%s=", name
);
3436 for (size_t i
= 0; i
< n_mount_images
; ++i
) {
3437 r
= mount_image_add(&c
->mount_images
, &c
->n_mount_images
, &mount_images
[i
]);
3442 unit_write_settingf(u
, flags
|UNIT_ESCAPE_C
|UNIT_ESCAPE_SPECIFIERS
,
3450 mount_images
= mount_image_free_many(mount_images
, &n_mount_images
);
3453 } else if (streq(name
, "ExtensionImages")) {
3454 _cleanup_free_
char *format_str
= NULL
;
3455 MountImage
*extension_images
= NULL
;
3456 size_t n_extension_images
= 0;
3458 r
= sd_bus_message_enter_container(message
, 'a', "(sba(ss))");
3463 _cleanup_(mount_options_free_allp
) MountOptions
*options
= NULL
;
3464 _cleanup_free_
char *source_escaped
= NULL
;
3465 char *source
, *tuple
;
3468 r
= sd_bus_message_enter_container(message
, 'r', "sba(ss)");
3472 r
= sd_bus_message_read(message
, "sb", &source
, &permissive
);
3476 if (!path_is_absolute(source
))
3477 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Source path %s is not absolute.", source
);
3478 if (!path_is_normalized(source
))
3479 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Source path %s is not normalized.", source
);
3481 /* Need to store them in the unit with the escapes, so that they can be parsed again */
3482 source_escaped
= shell_escape(source
, ":");
3483 if (!source_escaped
)
3486 tuple
= strjoin(format_str
,
3487 format_str
? " " : "",
3488 permissive
? "-" : "",
3492 free_and_replace(format_str
, tuple
);
3494 r
= bus_read_mount_options(message
, error
, &options
, &format_str
, ":");
3498 r
= sd_bus_message_exit_container(message
);
3502 r
= mount_image_add(&extension_images
, &n_extension_images
,
3505 .mount_options
= options
,
3506 .ignore_enoent
= permissive
,
3507 .type
= MOUNT_IMAGE_EXTENSION
,
3515 r
= sd_bus_message_exit_container(message
);
3519 if (!UNIT_WRITE_FLAGS_NOOP(flags
)) {
3520 if (n_extension_images
== 0) {
3521 c
->extension_images
= mount_image_free_many(c
->extension_images
, &c
->n_extension_images
);
3523 unit_write_settingf(u
, flags
, name
, "%s=", name
);
3525 for (size_t i
= 0; i
< n_extension_images
; ++i
) {
3526 r
= mount_image_add(&c
->extension_images
, &c
->n_extension_images
, &extension_images
[i
]);
3531 unit_write_settingf(u
, flags
|UNIT_ESCAPE_C
|UNIT_ESCAPE_SPECIFIERS
,
3539 extension_images
= mount_image_free_many(extension_images
, &n_extension_images
);