1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
8 typedef int (*gather_stdout_callback_t
) (int fd
, void *arg
);
11 STDOUT_GENERATE
, /* from generators to helper process */
12 STDOUT_COLLECT
, /* from helper process to main process */
13 STDOUT_CONSUME
, /* process data in main process */
18 EXEC_DIR_NONE
= 0, /* No execdir flags */
19 EXEC_DIR_PARALLEL
= 1 << 0, /* Execute scripts in parallel, if possible */
20 EXEC_DIR_IGNORE_ERRORS
= 1 << 1, /* Ignore non-zero exit status of scripts */
21 EXEC_DIR_SET_SYSTEMD_EXEC_PID
= 1 << 2, /* Set $SYSTEMD_EXEC_PID environment variable */
22 EXEC_DIR_SKIP_REMAINING
= 1 << 3, /* Ignore remaining executions when one exit with 77. */
25 typedef enum ExecCommandFlags
{
26 EXEC_COMMAND_IGNORE_FAILURE
= 1 << 0,
27 EXEC_COMMAND_FULLY_PRIVILEGED
= 1 << 1,
28 EXEC_COMMAND_NO_SETUID
= 1 << 2,
29 EXEC_COMMAND_AMBIENT_MAGIC
= 1 << 3,
30 EXEC_COMMAND_NO_ENV_EXPAND
= 1 << 4,
31 _EXEC_COMMAND_FLAGS_INVALID
= -EINVAL
,
39 gather_stdout_callback_t
const callbacks
[_STDOUT_CONSUME_MAX
],
40 void* const callback_args
[_STDOUT_CONSUME_MAX
],
45 int execute_directories(
46 const char* const* directories
,
48 gather_stdout_callback_t
const callbacks
[_STDOUT_CONSUME_MAX
],
49 void* const callback_args
[_STDOUT_CONSUME_MAX
],
54 int exec_command_flags_from_strv(char **ex_opts
, ExecCommandFlags
*flags
);
55 int exec_command_flags_to_strv(ExecCommandFlags flags
, char ***ex_opts
);
57 extern const gather_stdout_callback_t gather_environment
[_STDOUT_CONSUME_MAX
];
59 const char* exec_command_flags_to_string(ExecCommandFlags i
);
60 ExecCommandFlags
exec_command_flags_from_string(const char *s
);
62 int fexecve_or_execve(int executable_fd
, const char *executable
, char *const argv
[], char *const envp
[]);
64 int fork_agent(const char *name
, const int except
[], size_t n_except
, pid_t
*ret_pid
, const char *path
, ...) _sentinel_
;