shared/exec-util: minor rearrangement, drop unused EXEC_DIR_NONE
This commit is contained in:
@@ -438,6 +438,12 @@ static int gather_environment_consume(int fd, void *arg) {
|
||||
return r;
|
||||
}
|
||||
|
||||
const gather_stdout_callback_t gather_environment[_STDOUT_CONSUME_MAX] = {
|
||||
gather_environment_generate,
|
||||
gather_environment_collect,
|
||||
gather_environment_consume,
|
||||
};
|
||||
|
||||
int exec_command_flags_from_strv(char * const *ex_opts, ExecCommandFlags *ret) {
|
||||
ExecCommandFlags flags = 0;
|
||||
|
||||
@@ -478,12 +484,6 @@ int exec_command_flags_to_strv(ExecCommandFlags flags, char ***ret) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
const gather_stdout_callback_t gather_environment[] = {
|
||||
gather_environment_generate,
|
||||
gather_environment_collect,
|
||||
gather_environment_consume,
|
||||
};
|
||||
|
||||
static const char* const exec_command_strings[] = {
|
||||
"ignore-failure", /* EXEC_COMMAND_IGNORE_FAILURE */
|
||||
"privileged", /* EXEC_COMMAND_FULLY_PRIVILEGED */
|
||||
|
||||
+12
-13
@@ -14,8 +14,7 @@ enum {
|
||||
_STDOUT_CONSUME_MAX,
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
EXEC_DIR_NONE = 0, /* No execdir flags */
|
||||
typedef enum ExecDirFlags {
|
||||
EXEC_DIR_PARALLEL = 1 << 0, /* Execute scripts in parallel, if possible */
|
||||
EXEC_DIR_IGNORE_ERRORS = 1 << 1, /* Ignore non-zero exit status of scripts */
|
||||
EXEC_DIR_SET_SYSTEMD_EXEC_PID = 1 << 2, /* Set $SYSTEMD_EXEC_PID environment variable */
|
||||
@@ -23,15 +22,6 @@ typedef enum {
|
||||
EXEC_DIR_WARN_WORLD_WRITABLE = 1 << 4, /* Warn if world writable files are found */
|
||||
} ExecDirFlags;
|
||||
|
||||
typedef enum ExecCommandFlags {
|
||||
EXEC_COMMAND_IGNORE_FAILURE = 1 << 0,
|
||||
EXEC_COMMAND_FULLY_PRIVILEGED = 1 << 1,
|
||||
EXEC_COMMAND_NO_SETUID = 1 << 2,
|
||||
EXEC_COMMAND_AMBIENT_MAGIC = 1 << 3,
|
||||
EXEC_COMMAND_NO_ENV_EXPAND = 1 << 4,
|
||||
_EXEC_COMMAND_FLAGS_INVALID = -EINVAL,
|
||||
} ExecCommandFlags;
|
||||
|
||||
int execute_strv(
|
||||
const char *name,
|
||||
char* const* paths,
|
||||
@@ -52,11 +42,20 @@ int execute_directories(
|
||||
char *envp[],
|
||||
ExecDirFlags flags);
|
||||
|
||||
extern const gather_stdout_callback_t gather_environment[_STDOUT_CONSUME_MAX];
|
||||
|
||||
typedef enum ExecCommandFlags {
|
||||
EXEC_COMMAND_IGNORE_FAILURE = 1 << 0,
|
||||
EXEC_COMMAND_FULLY_PRIVILEGED = 1 << 1,
|
||||
EXEC_COMMAND_NO_SETUID = 1 << 2,
|
||||
EXEC_COMMAND_AMBIENT_MAGIC = 1 << 3,
|
||||
EXEC_COMMAND_NO_ENV_EXPAND = 1 << 4,
|
||||
_EXEC_COMMAND_FLAGS_INVALID = -EINVAL,
|
||||
} ExecCommandFlags;
|
||||
|
||||
int exec_command_flags_from_strv(char * const *ex_opts, ExecCommandFlags *ret);
|
||||
int exec_command_flags_to_strv(ExecCommandFlags flags, char ***ret);
|
||||
|
||||
extern const gather_stdout_callback_t gather_environment[_STDOUT_CONSUME_MAX];
|
||||
|
||||
const char* exec_command_flags_to_string(ExecCommandFlags i);
|
||||
ExecCommandFlags exec_command_flags_from_string(const char *s);
|
||||
|
||||
|
||||
@@ -402,7 +402,9 @@ TEST(error_catching) {
|
||||
if (access(name, X_OK) < 0 && ERRNO_IS_PRIVILEGE(errno))
|
||||
return;
|
||||
|
||||
r = execute_directories(dirs, DEFAULT_TIMEOUT_USEC, NULL, NULL, NULL, NULL, EXEC_DIR_NONE);
|
||||
r = execute_directories(dirs, DEFAULT_TIMEOUT_USEC,
|
||||
/* callbacks = */ NULL, /* callback_args = */ NULL,
|
||||
/* argv = */ NULL, /* envp = */ NULL, /* flags = */ 0);
|
||||
|
||||
/* we should exit with the error code of the first script that failed */
|
||||
assert_se(r == 42);
|
||||
|
||||
Reference in New Issue
Block a user