return r;
r = sd_bus_message_append(reply, "bttttuii",
- c->ignore,
+ !!(c->flags & EXEC_COMMAND_IGNORE_FAILURE),
c->exec_status.start_timestamp.realtime,
c->exec_status.start_timestamp.monotonic,
c->exec_status.exit_timestamp.realtime,
c->argv = argv;
argv = NULL;
- c->ignore = b;
+ c->flags = b ? EXEC_COMMAND_IGNORE_FAILURE : 0;
path_kill_slashes(c->path);
exec_command_append_list(&s->exec_command[SERVICE_EXEC_START], c);
return -ENOMEM;
fprintf(f, "ExecStart=%s@%s %s\n",
- c->ignore ? "-" : "",
+ c->flags & EXEC_COMMAND_IGNORE_FAILURE ? "-" : "",
c->path,
a);
}
if (!context->dynamic_user && root_dir)
ns_info.ignore_protect_paths = true;
- apply_restrictions = (params->flags & EXEC_APPLY_PERMISSIONS) && !command->privileged;
+ apply_restrictions = (params->flags & EXEC_APPLY_PERMISSIONS) && !(command->flags & EXEC_COMMAND_FULLY_PRIVILEGED);
r = setup_namespace(root_dir, root_image,
&ns_info, rw,
return r;
}
- needs_exec_restrictions = (params->flags & EXEC_APPLY_PERMISSIONS) && !command->privileged;
+ needs_exec_restrictions = (params->flags & EXEC_APPLY_PERMISSIONS) && !(command->flags & EXEC_COMMAND_FULLY_PRIVILEGED);
if (needs_exec_restrictions) {
if (context->pam_name && username) {
error_message),
"EXECUTABLE=%s", command->path,
NULL);
- else if (r == -ENOENT && command->ignore)
+ else if (r == -ENOENT && (command->flags & EXEC_COMMAND_IGNORE_FAILURE))
log_struct_errno(LOG_INFO, r,
"MESSAGE_ID=" SD_MESSAGE_SPAWN_FAILED_STR,
LOG_UNIT_ID(unit),
int status; /* as in sigingo_t::si_status */
};
+typedef enum ExecCommandFlags {
+ EXEC_COMMAND_IGNORE_FAILURE = 1,
+ EXEC_COMMAND_FULLY_PRIVILEGED = 2,
+} ExecCommandFlags;
+
struct ExecCommand {
char *path;
char **argv;
ExecStatus exec_status;
+ ExecCommandFlags flags;
LIST_FIELDS(ExecCommand, command); /* useful for chaining commands */
- bool ignore:1;
- bool privileged:1;
};
struct ExecRuntime {
nce->argv = n;
nce->path = path;
- nce->ignore = ignore;
- nce->privileged = privileged;
+ nce->flags =
+ (ignore ? EXEC_COMMAND_IGNORE_FAILURE : 0) |
+ (privileged ? EXEC_COMMAND_FULLY_PRIVILEGED : 0);
exec_command_append_list(e, nce);
s->main_command->exec_status = s->main_exec_status;
- if (s->main_command->ignore)
+ if (s->main_command->flags & EXEC_COMMAND_IGNORE_FAILURE)
f = SERVICE_SUCCESS;
} else if (s->exec_command[SERVICE_EXEC_START]) {
* ignore the return value if this was
* configured for the starter process */
- if (s->exec_command[SERVICE_EXEC_START]->ignore)
+ if (s->exec_command[SERVICE_EXEC_START]->flags & EXEC_COMMAND_IGNORE_FAILURE)
f = SERVICE_SUCCESS;
}
if (s->control_command) {
exec_status_exit(&s->control_command->exec_status, &s->exec_context, pid, code, status);
- if (s->control_command->ignore)
+ if (s->control_command->flags & EXEC_COMMAND_IGNORE_FAILURE)
f = SERVICE_SUCCESS;
}
if (s->control_command) {
exec_status_exit(&s->control_command->exec_status, &s->exec_context, pid, code, status);
- if (s->control_command->ignore)
+ if (s->control_command->flags & EXEC_COMMAND_IGNORE_FAILURE)
f = SOCKET_SUCCESS;
}
assert_se(streq_ptr(c->argv[1], argv1));
if (n > 1)
assert_se(streq_ptr(c->argv[2], argv2));
- assert_se(c->ignore == ignore);
+ assert_se(!!(c->flags & EXEC_COMMAND_IGNORE_FAILURE) == ignore);
}
static void test_config_parse_exec(void) {