]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/core/execute.h
core: Introduce unit private exec runtime
[thirdparty/systemd.git] / src / core / execute.h
CommitLineData
db9ecf05 1/* SPDX-License-Identifier: LGPL-2.1-or-later */
c2f1db8f 2#pragma once
5cb5a6ff
LP
3
4typedef struct ExecStatus ExecStatus;
5typedef struct ExecCommand ExecCommand;
6typedef struct ExecContext ExecContext;
e76506b7 7typedef struct ExecSharedRuntime ExecSharedRuntime;
28135da3 8typedef struct ExecRuntime ExecRuntime;
9fa95f85 9typedef struct ExecParameters ExecParameters;
e8a565cb 10typedef struct Manager Manager;
5cb5a6ff 11
71d35b6b 12#include <sched.h>
5cb5a6ff
LP
13#include <stdbool.h>
14#include <stdio.h>
71d35b6b 15#include <sys/capability.h>
5cb5a6ff 16
9ce93478 17#include "cgroup-util.h"
ad21e542 18#include "coredump-util.h"
0985c7c4 19#include "cpu-set-util.h"
b3d59367 20#include "exec-util.h"
613b411c 21#include "fdset.h"
71d35b6b 22#include "list.h"
e93672ee 23#include "missing_resource.h"
417116f2 24#include "namespace.h"
add00535 25#include "nsflags.h"
1808f768 26#include "numa-util.h"
cd48e23f 27#include "open-file.h"
74e12520 28#include "path-util.h"
523ea123 29#include "set.h"
ca78ad1d 30#include "time-util.h"
5cb5a6ff 31
08f3be7a
LP
32#define EXEC_STDIN_DATA_MAX (64U*1024U*1024U)
33
023a4f67
LP
34typedef enum ExecUtmpMode {
35 EXEC_UTMP_INIT,
36 EXEC_UTMP_LOGIN,
37 EXEC_UTMP_USER,
38 _EXEC_UTMP_MODE_MAX,
2d93c20e 39 _EXEC_UTMP_MODE_INVALID = -EINVAL,
023a4f67
LP
40} ExecUtmpMode;
41
80876c20
LP
42typedef enum ExecInput {
43 EXEC_INPUT_NULL,
44 EXEC_INPUT_TTY,
45 EXEC_INPUT_TTY_FORCE,
46 EXEC_INPUT_TTY_FAIL,
4f2d528d 47 EXEC_INPUT_SOCKET,
52c239d7 48 EXEC_INPUT_NAMED_FD,
08f3be7a 49 EXEC_INPUT_DATA,
2038c3f5 50 EXEC_INPUT_FILE,
80876c20 51 _EXEC_INPUT_MAX,
2d93c20e 52 _EXEC_INPUT_INVALID = -EINVAL,
80876c20
LP
53} ExecInput;
54
071830ff 55typedef enum ExecOutput {
80876c20 56 EXEC_OUTPUT_INHERIT,
94f04347 57 EXEC_OUTPUT_NULL,
80876c20 58 EXEC_OUTPUT_TTY,
9a6bca7a 59 EXEC_OUTPUT_KMSG,
28dbc1e8 60 EXEC_OUTPUT_KMSG_AND_CONSOLE,
706343f4
LP
61 EXEC_OUTPUT_JOURNAL,
62 EXEC_OUTPUT_JOURNAL_AND_CONSOLE,
4f2d528d 63 EXEC_OUTPUT_SOCKET,
52c239d7 64 EXEC_OUTPUT_NAMED_FD,
2038c3f5 65 EXEC_OUTPUT_FILE,
566b7d23 66 EXEC_OUTPUT_FILE_APPEND,
8d7dab1f 67 EXEC_OUTPUT_FILE_TRUNCATE,
94f04347 68 _EXEC_OUTPUT_MAX,
2d93c20e 69 _EXEC_OUTPUT_INVALID = -EINVAL,
071830ff
LP
70} ExecOutput;
71
53f47dfc
YW
72typedef enum ExecPreserveMode {
73 EXEC_PRESERVE_NO,
74 EXEC_PRESERVE_YES,
75 EXEC_PRESERVE_RESTART,
76 _EXEC_PRESERVE_MODE_MAX,
2d93c20e 77 _EXEC_PRESERVE_MODE_INVALID = -EINVAL,
53f47dfc
YW
78} ExecPreserveMode;
79
b1edf445
LP
80typedef enum ExecKeyringMode {
81 EXEC_KEYRING_INHERIT,
82 EXEC_KEYRING_PRIVATE,
83 EXEC_KEYRING_SHARED,
84 _EXEC_KEYRING_MODE_MAX,
2d93c20e 85 _EXEC_KEYRING_MODE_INVALID = -EINVAL,
b1edf445
LP
86} ExecKeyringMode;
87
42cb05d5 88/* Contains start and exit information about an executed command. */
5cb5a6ff 89struct ExecStatus {
63983207
LP
90 dual_timestamp start_timestamp;
91 dual_timestamp exit_timestamp;
0a6991e0 92 pid_t pid;
9152c765 93 int code; /* as in siginfo_t::si_code */
fcb7138c 94 int status; /* as in siginfo_t::si_status */
5cb5a6ff
LP
95};
96
42cb05d5 97/* Stores information about commands we execute. Covers both configuration settings as well as runtime data. */
5cb5a6ff
LP
98struct ExecCommand {
99 char *path;
100 char **argv;
034c6ed7 101 ExecStatus exec_status;
3ed0cd26 102 ExecCommandFlags flags;
034c6ed7 103 LIST_FIELDS(ExecCommand, command); /* useful for chaining commands */
5cb5a6ff
LP
104};
105
42cb05d5
LP
106/* Encapsulates certain aspects of the runtime environment that is to be shared between multiple otherwise separate
107 * invocations of commands. Specifically, this allows sharing of /tmp and /var/tmp data as well as network namespaces
108 * between invocations of commands. This is a reference counted object, with one reference taken by each currently
109 * active command invocation that wants to share this runtime. */
e76506b7 110struct ExecSharedRuntime {
cf4b2f99 111 unsigned n_ref;
613b411c 112
e8a565cb
YW
113 Manager *manager;
114
42cb05d5 115 char *id; /* Unit id of the owner */
e8a565cb 116
613b411c
LP
117 char *tmp_dir;
118 char *var_tmp_dir;
119
29206d46
LP
120 /* An AF_UNIX socket pair, that contains a datagram containing a file descriptor referring to the network
121 * namespace. */
613b411c 122 int netns_storage_socket[2];
a70581ff
XR
123
124 /* Like netns_storage_socket, but the file descriptor is referring to the IPC namespace. */
125 int ipcns_storage_socket[2];
613b411c
LP
126};
127
28135da3
DDM
128struct ExecRuntime {
129 ExecSharedRuntime *shared;
130};
131
3536f49e
YW
132typedef enum ExecDirectoryType {
133 EXEC_DIRECTORY_RUNTIME = 0,
134 EXEC_DIRECTORY_STATE,
135 EXEC_DIRECTORY_CACHE,
136 EXEC_DIRECTORY_LOGS,
137 EXEC_DIRECTORY_CONFIGURATION,
72fd1768 138 _EXEC_DIRECTORY_TYPE_MAX,
2d93c20e 139 _EXEC_DIRECTORY_TYPE_INVALID = -EINVAL,
3536f49e
YW
140} ExecDirectoryType;
141
211a3d87
LB
142typedef struct ExecDirectoryItem {
143 char *path;
144 char **symlinks;
a2ab603c 145 bool only_create;
211a3d87
LB
146} ExecDirectoryItem;
147
3536f49e 148typedef struct ExecDirectory {
3536f49e 149 mode_t mode;
211a3d87
LB
150 size_t n_items;
151 ExecDirectoryItem *items;
3536f49e
YW
152} ExecDirectory;
153
380dc8b0
LP
154typedef enum ExecCleanMask {
155 /* In case you wonder why the bitmask below doesn't use "directory" in its name: we want to keep this
156 * generic so that .timer timestamp files can nicely be covered by this too, and similar. */
157 EXEC_CLEAN_RUNTIME = 1U << EXEC_DIRECTORY_RUNTIME,
158 EXEC_CLEAN_STATE = 1U << EXEC_DIRECTORY_STATE,
159 EXEC_CLEAN_CACHE = 1U << EXEC_DIRECTORY_CACHE,
160 EXEC_CLEAN_LOGS = 1U << EXEC_DIRECTORY_LOGS,
161 EXEC_CLEAN_CONFIGURATION = 1U << EXEC_DIRECTORY_CONFIGURATION,
162 EXEC_CLEAN_NONE = 0,
163 EXEC_CLEAN_ALL = (1U << _EXEC_DIRECTORY_TYPE_MAX) - 1,
2d93c20e 164 _EXEC_CLEAN_MASK_INVALID = -EINVAL,
380dc8b0
LP
165} ExecCleanMask;
166
43144be4
LP
167/* A credential configured with LoadCredential= */
168typedef struct ExecLoadCredential {
169 char *id, *path;
170 bool encrypted;
171} ExecLoadCredential;
172
bb0c0d6f
LP
173/* A credential configured with SetCredential= */
174typedef struct ExecSetCredential {
175 char *id;
43144be4 176 bool encrypted;
bb0c0d6f
LP
177 void *data;
178 size_t size;
179} ExecSetCredential;
180
42cb05d5
LP
181/* Encodes configuration parameters applied to invoked commands. Does not carry runtime data, but only configuration
182 * changes sourced from unit files and suchlike. ExecContext objects are usually embedded into Unit objects, and do not
183 * change after being loaded. */
5cb5a6ff
LP
184struct ExecContext {
185 char **environment;
8c7be95e 186 char **environment_files;
b4c14404 187 char **pass_environment;
00819cc1 188 char **unset_environment;
8c7be95e 189
517d56b1 190 struct rlimit *rlimit[_RLIMIT_MAX];
d4d55b0d
LB
191 char *working_directory, *root_directory, *root_image, *root_verity, *root_hash_path, *root_hash_sig_path;
192 void *root_hash, *root_hash_sig;
193 size_t root_hash_size, root_hash_sig_size;
18d73705 194 LIST_HEAD(MountOptions, root_image_options);
0a6991e0
LP
195 bool working_directory_missing_ok:1;
196 bool working_directory_home:1;
197
198 bool oom_score_adjust_set:1;
ad21e542 199 bool coredump_filter_set:1;
0a6991e0
LP
200 bool nice_set:1;
201 bool ioprio_set:1;
202 bool cpu_sched_set:1;
5e98086d 203 bool mount_apivfs_set:1;
0a6991e0
LP
204
205 /* This is not exposed to the user but available internally. We need it to make sure that whenever we
206 * spawn /usr/bin/mount it is run in the same process group as us so that the autofs logic detects
207 * that it belongs to us and we don't enter a trigger loop. */
208 bool same_pgrp;
209
210 bool cpu_sched_reset_on_fork;
211 bool non_blocking;
9d58f1db
LP
212
213 mode_t umask;
dd6c17b1 214 int oom_score_adjust;
5cb5a6ff 215 int nice;
9eba9da4 216 int ioprio;
94f04347
LP
217 int cpu_sched_policy;
218 int cpu_sched_priority;
ad21e542 219 uint64_t coredump_filter;
9d58f1db 220
0985c7c4 221 CPUSet cpu_set;
b070c7c0 222 NUMAPolicy numa_policy;
e2b2fb7f 223 bool cpu_affinity_from_numa;
fb33a393 224
80876c20
LP
225 ExecInput std_input;
226 ExecOutput std_output;
227 ExecOutput std_error;
0a6991e0 228 bool stdio_as_fds;
52c239d7 229 char *stdio_fdname[3];
2038c3f5 230 char *stdio_file[3];
80876c20 231
08f3be7a
LP
232 void *stdin_data;
233 size_t stdin_data_size;
80876c20 234
d88a251b 235 nsec_t timer_slack_nsec;
071830ff 236
9d58f1db 237 char *tty_path;
5cb5a6ff 238
6ea832a2
LP
239 bool tty_reset;
240 bool tty_vhangup;
241 bool tty_vt_disallocate;
242
51462135
DDM
243 unsigned tty_rows;
244 unsigned tty_cols;
245
353e12c2
LP
246 bool ignore_sigpipe;
247
0a6991e0
LP
248 ExecKeyringMode keyring_mode;
249
61233823 250 /* Since resolving these names might involve socket
5cb5a6ff 251 * connections and we don't want to deadlock ourselves these
94f04347
LP
252 * names are resolved on execution only and in the child
253 * process. */
5cb5a6ff
LP
254 char *user;
255 char *group;
256 char **supplementary_groups;
9d58f1db 257
5b6319dc
LP
258 char *pam_name;
259
169c1bda 260 char *utmp_id;
023a4f67 261 ExecUtmpMode utmp_mode;
169c1bda 262
0a6991e0 263 bool no_new_privileges;
7b52a628 264
0a6991e0 265 bool selinux_context_ignore;
eef65bf3 266 bool apparmor_profile_ignore;
2ca620c4 267 bool smack_process_label_ignore;
2ca620c4 268
0a6991e0
LP
269 char *selinux_context;
270 char *apparmor_profile;
271 char *smack_process_label;
b1edf445 272
ddc155b2 273 char **read_write_paths, **read_only_paths, **inaccessible_paths, **exec_paths, **no_exec_paths;
8c35c10d 274 char **exec_search_path;
874cdcbc 275 unsigned long mount_propagation_flag;
d2d6c096 276 BindMount *bind_mounts;
da6053d0 277 size_t n_bind_mounts;
2abd4e38 278 TemporaryFileSystem *temporary_filesystems;
da6053d0 279 size_t n_temporary_filesystems;
b3d13314
LB
280 MountImage *mount_images;
281 size_t n_mount_images;
93f59701
LB
282 MountImage *extension_images;
283 size_t n_extension_images;
a07b9926 284 char **extension_directories;
15ae422b 285
a103496c 286 uint64_t capability_bounding_set;
755d4b67 287 uint64_t capability_ambient_set;
9d58f1db
LP
288 int secure_bits;
289
7fab9d01 290 int syslog_priority;
7fab9d01 291 bool syslog_level_prefix;
0a6991e0 292 char *syslog_identifier;
d3070fbd
LP
293
294 struct iovec* log_extra_fields;
295 size_t n_log_extra_fields;
523ea123
QD
296 Set *log_filter_allowed_patterns;
297 Set *log_filter_denied_patterns;
d3070fbd 298
5ac1530e
ZJS
299 usec_t log_ratelimit_interval_usec;
300 unsigned log_ratelimit_burst;
90fc172e 301
0a6991e0
LP
302 int log_level_max;
303
91dd5f7c
LP
304 char *log_namespace;
305
4e399953
LP
306 ProtectProc protect_proc; /* hidepid= */
307 ProcSubset proc_subset; /* subset= */
308
24002121 309 int private_mounts;
15ae422b 310 bool private_tmp;
ff01d048 311 bool private_network;
7f112f50 312 bool private_devices;
d251207d 313 bool private_users;
a70581ff 314 bool private_ipc;
59eeb84b 315 bool protect_kernel_tunables;
502d704e 316 bool protect_kernel_modules;
84703040 317 bool protect_kernel_logs;
fc64760d 318 bool protect_clock;
59eeb84b 319 bool protect_control_groups;
0a6991e0
LP
320 ProtectSystem protect_system;
321 ProtectHome protect_home;
322 bool protect_hostname;
5d997827 323 bool mount_apivfs;
9d58f1db 324
29206d46 325 bool dynamic_user;
00d9ef85 326 bool remove_ipc;
29206d46 327
0a6991e0
LP
328 bool memory_deny_write_execute;
329 bool restrict_realtime;
f69567cb 330 bool restrict_suid_sgid;
2e22afe9 331
78e864e5 332 bool lock_personality;
0a6991e0 333 unsigned long personality;
ac45f971 334
add00535
LP
335 unsigned long restrict_namespaces; /* The CLONE_NEWxyz flags permitted to the unit's processes */
336
b1994387
ILG
337 Set *restrict_filesystems;
338 bool restrict_filesystems_allow_list:1;
339
8cfa775f 340 Hashmap *syscall_filter;
57183d11 341 Set *syscall_archs;
17df7223 342 int syscall_errno;
6b000af4 343 bool syscall_allow_list:1;
8351ceae 344
9df2cdd8
TM
345 Hashmap *syscall_log;
346 bool syscall_log_allow_list:1; /* Log listed system calls */
347
6b000af4 348 bool address_families_allow_list:1;
0a6991e0 349 Set *address_families;
a8d08f39
LP
350
351 char *network_namespace_path;
a70581ff 352 char *ipc_namespace_path;
0a6991e0
LP
353
354 ExecDirectory directories[_EXEC_DIRECTORY_TYPE_MAX];
355 ExecPreserveMode runtime_directory_preserve_mode;
12213aed 356 usec_t timeout_clean_usec;
bb0c0d6f
LP
357
358 Hashmap *set_credentials; /* output id → ExecSetCredential */
43144be4 359 Hashmap *load_credentials; /* output id → ExecLoadCredential */
5cb5a6ff
LP
360};
361
add00535
LP
362static inline bool exec_context_restrict_namespaces_set(const ExecContext *c) {
363 assert(c);
364
365 return (c->restrict_namespaces & NAMESPACE_FLAGS_ALL) != NAMESPACE_FLAGS_ALL;
366}
367
b1994387
ILG
368static inline bool exec_context_restrict_filesystems_set(const ExecContext *c) {
369 assert(c);
370
371 return c->restrict_filesystems_allow_list ||
372 !set_isempty(c->restrict_filesystems);
373}
374
74e12520
LP
375static inline bool exec_context_with_rootfs(const ExecContext *c) {
376 assert(c);
377
378 /* Checks if RootDirectory= or RootImage= are used */
379
380 return !empty_or_root(c->root_directory) || c->root_image;
381}
382
c39f1ce2 383typedef enum ExecFlags {
cdebedb4
PM
384 EXEC_APPLY_SANDBOXING = 1 << 0,
385 EXEC_APPLY_CHROOT = 1 << 1,
386 EXEC_APPLY_TTY_STDIN = 1 << 2,
387 EXEC_PASS_LOG_UNIT = 1 << 3, /* Whether to pass the unit name to the service's journal stream connection */
388 EXEC_CHOWN_DIRECTORIES = 1 << 4, /* chown() the runtime/state/cache/log directories to the user we run as, under all conditions */
de90700f 389 EXEC_NSS_DYNAMIC_BYPASS = 1 << 5, /* Set the SYSTEMD_NSS_DYNAMIC_BYPASS environment variable, to disable nss-systemd blocking on PID 1, for use by dbus-daemon */
cdebedb4
PM
390 EXEC_CGROUP_DELEGATE = 1 << 6,
391 EXEC_IS_CONTROL = 1 << 7,
392 EXEC_CONTROL_CGROUP = 1 << 8, /* Place the process not in the indicated cgroup but in a subcgroup '/.control', but only EXEC_CGROUP_DELEGATE and EXEC_IS_CONTROL is set, too */
393 EXEC_WRITE_CREDENTIALS = 1 << 9, /* Set up the credential store logic */
c39f1ce2 394
9c1a61ad 395 /* The following are not used by execute.c, but by consumers internally */
cdebedb4
PM
396 EXEC_PASS_FDS = 1 << 10,
397 EXEC_SETENV_RESULT = 1 << 11,
398 EXEC_SET_WATCHDOG = 1 << 12,
399 EXEC_SETENV_MONITOR_RESULT = 1 << 13, /* Pass exit status to OnFailure= and OnSuccess= dependencies. */
c39f1ce2
LP
400} ExecFlags;
401
42cb05d5
LP
402/* Parameters for a specific invocation of a command. This structure is put together right before a command is
403 * executed. */
9fa95f85 404struct ExecParameters {
a34ceba6 405 char **environment;
8dd4c05b
LP
406
407 int *fds;
408 char **fd_names;
da6053d0 409 size_t n_socket_fds;
25b583d7 410 size_t n_storage_fds;
8dd4c05b 411
c39f1ce2 412 ExecFlags flags;
a34ceba6 413 bool selinux_context_net:1;
8dd4c05b 414
efdb0237 415 CGroupMask cgroup_supported;
9fa95f85 416 const char *cgroup_path;
8dd4c05b 417
3536f49e 418 char **prefix;
2ad591a3
LP
419 const char *received_credentials_directory;
420 const char *received_encrypted_credentials_directory;
8dd4c05b 421
7d5ceb64
FB
422 const char *confirm_spawn;
423
9fa95f85 424 usec_t watchdog_usec;
8dd4c05b 425
9fa95f85 426 int *idle_pipe;
8dd4c05b 427
a34ceba6
LP
428 int stdin_fd;
429 int stdout_fd;
430 int stderr_fd;
5686391b
LP
431
432 /* An fd that is closed by the execve(), and thus will result in EOF when the execve() is done */
433 int exec_fd;
3bdc25a4
LP
434
435 const char *notify_socket;
cd48e23f
RP
436
437 LIST_HEAD(OpenFile, open_files);
9fa95f85
DM
438};
439
9ce93478 440#include "unit.h"
29206d46 441#include "dynamic-user.h"
9ce93478 442
f2341e0a
LP
443int exec_spawn(Unit *unit,
444 ExecCommand *command,
9fa95f85
DM
445 const ExecContext *context,
446 const ExecParameters *exec_params,
28135da3 447 ExecRuntime *runtime,
29206d46 448 DynamicCreds *dynamic_creds,
6bb00842 449 const CGroupContext *cgroup_context,
81a2b7ce 450 pid_t *ret);
5cb5a6ff 451
da6053d0 452void exec_command_done_array(ExecCommand *c, size_t n);
f1acf85a 453ExecCommand* exec_command_free_list(ExecCommand *c);
da6053d0 454void exec_command_free_array(ExecCommand **c, size_t n);
6a1d4d9f
LP
455void exec_command_reset_status_array(ExecCommand *c, size_t n);
456void exec_command_reset_status_list_array(ExecCommand **c, size_t n);
44d8db9e 457void exec_command_dump_list(ExecCommand *c, FILE *f, const char *prefix);
a6a80b4f 458void exec_command_append_list(ExecCommand **l, ExecCommand *e);
7593c3ec
LP
459int exec_command_set(ExecCommand *c, const char *path, ...) _sentinel_;
460int exec_command_append(ExecCommand *c, const char *path, ...) _sentinel_;
44d8db9e 461
034c6ed7 462void exec_context_init(ExecContext *c);
613b411c 463void exec_context_done(ExecContext *c);
34cf6c43 464void exec_context_dump(const ExecContext *c, FILE* f, const char *prefix);
5cb5a6ff 465
34cf6c43 466int exec_context_destroy_runtime_directory(const ExecContext *c, const char *runtime_root);
bb0c0d6f 467int exec_context_destroy_credentials(const ExecContext *c, const char *runtime_root, const char *unit);
b9f976fb 468int exec_context_destroy_mount_ns_dir(Unit *u);
e66cf1a3 469
52c239d7 470const char* exec_context_fdname(const ExecContext *c, int fd_index);
8c7be95e 471
34cf6c43
YW
472bool exec_context_may_touch_console(const ExecContext *c);
473bool exec_context_maintains_privileges(const ExecContext *c);
50a4217b 474bool exec_context_has_encrypted_credentials(ExecContext *c);
6ac8fdc9 475
34cf6c43 476int exec_context_get_effective_ioprio(const ExecContext *c);
5e98086d 477bool exec_context_get_effective_mount_apivfs(const ExecContext *c);
7f452159 478
d3070fbd
LP
479void exec_context_free_log_extra_fields(ExecContext *c);
480
6f765baf
LP
481void exec_context_revert_tty(ExecContext *c);
482
4c2f5842
LP
483int exec_context_get_clean_directories(ExecContext *c, char **prefix, ExecCleanMask mask, char ***ret);
484int exec_context_get_clean_mask(ExecContext *c, ExecCleanMask *ret);
485
b58b4116 486void exec_status_start(ExecStatus *s, pid_t pid);
34cf6c43
YW
487void exec_status_exit(ExecStatus *s, const ExecContext *context, pid_t pid, int code, int status);
488void exec_status_dump(const ExecStatus *s, FILE *f, const char *prefix);
6a1d4d9f 489void exec_status_reset(ExecStatus *s);
5cb5a6ff 490
e76506b7 491int exec_shared_runtime_acquire(Manager *m, const ExecContext *c, const char *name, bool create, ExecSharedRuntime **ret);
e52a696a
DDM
492ExecSharedRuntime *exec_shared_runtime_destroy(ExecSharedRuntime *r);
493ExecSharedRuntime *exec_shared_runtime_unref(ExecSharedRuntime *r);
28135da3 494DEFINE_TRIVIAL_CLEANUP_FUNC(ExecSharedRuntime*, exec_shared_runtime_unref);
613b411c 495
e76506b7
DDM
496int exec_shared_runtime_serialize(const Manager *m, FILE *f, FDSet *fds);
497int exec_shared_runtime_deserialize_compat(Unit *u, const char *key, const char *value, FDSet *fds);
498int exec_shared_runtime_deserialize_one(Manager *m, const char *value, FDSet *fds);
499void exec_shared_runtime_vacuum(Manager *m);
613b411c 500
28135da3
DDM
501int exec_runtime_make(ExecSharedRuntime *shared, ExecRuntime **ret);
502ExecRuntime* exec_runtime_free(ExecRuntime *rt);
503DEFINE_TRIVIAL_CLEANUP_FUNC(ExecRuntime*, exec_runtime_free);
504ExecRuntime* exec_runtime_destroy(ExecRuntime *rt);
505
b9c04eaf
YW
506void exec_params_clear(ExecParameters *p);
507
e2b2fb7f
MS
508bool exec_context_get_cpu_affinity_from_numa(const ExecContext *c);
509
bb0c0d6f
LP
510ExecSetCredential *exec_set_credential_free(ExecSetCredential *sc);
511DEFINE_TRIVIAL_CLEANUP_FUNC(ExecSetCredential*, exec_set_credential_free);
512
43144be4
LP
513ExecLoadCredential *exec_load_credential_free(ExecLoadCredential *lc);
514DEFINE_TRIVIAL_CLEANUP_FUNC(ExecLoadCredential*, exec_load_credential_free);
515
211a3d87 516void exec_directory_done(ExecDirectory *d);
564e5c98 517int exec_directory_add(ExecDirectory *d, const char *path, const char *symlink);
a2ab603c 518void exec_directory_sort(ExecDirectory *d);
211a3d87 519
bb0c0d6f 520extern const struct hash_ops exec_set_credential_hash_ops;
43144be4 521extern const struct hash_ops exec_load_credential_hash_ops;
bb0c0d6f 522
44a6b1b6
ZJS
523const char* exec_output_to_string(ExecOutput i) _const_;
524ExecOutput exec_output_from_string(const char *s) _pure_;
94f04347 525
44a6b1b6
ZJS
526const char* exec_input_to_string(ExecInput i) _const_;
527ExecInput exec_input_from_string(const char *s) _pure_;
023a4f67
LP
528
529const char* exec_utmp_mode_to_string(ExecUtmpMode i) _const_;
530ExecUtmpMode exec_utmp_mode_from_string(const char *s) _pure_;
53f47dfc
YW
531
532const char* exec_preserve_mode_to_string(ExecPreserveMode i) _const_;
533ExecPreserveMode exec_preserve_mode_from_string(const char *s) _pure_;
3536f49e 534
b1edf445
LP
535const char* exec_keyring_mode_to_string(ExecKeyringMode i) _const_;
536ExecKeyringMode exec_keyring_mode_from_string(const char *s) _pure_;
537
3536f49e
YW
538const char* exec_directory_type_to_string(ExecDirectoryType i) _const_;
539ExecDirectoryType exec_directory_type_from_string(const char *s) _pure_;
6b7b2ed9 540
211a3d87
LB
541const char* exec_directory_type_symlink_to_string(ExecDirectoryType i) _const_;
542ExecDirectoryType exec_directory_type_symlink_from_string(const char *s) _pure_;
543
6b7b2ed9
LP
544const char* exec_resource_type_to_string(ExecDirectoryType i) _const_;
545ExecDirectoryType exec_resource_type_from_string(const char *s) _pure_;
5e8deb94 546
28135da3 547bool exec_needs_mount_namespace(const ExecContext *context, const ExecParameters *params, const ExecRuntime *runtime);
fbbb9697 548bool exec_needs_network_namespace(const ExecContext *context);