mirror of
https://github.com/systemd/systemd.git
synced 2024-11-01 09:21:26 +03:00
execute: let's decouple execute.c a bit from the unit logic
Let's try to decouple the execution engine a bit from the Unit/Manager concept, and hence pass one more flag as part of the ExecParameters flags field.
This commit is contained in:
parent
3ed0cd26ea
commit
af635cf377
@ -321,6 +321,7 @@ static int connect_journal_socket(int fd, uid_t uid, gid_t gid) {
|
||||
static int connect_logger_as(
|
||||
Unit *unit,
|
||||
const ExecContext *context,
|
||||
const ExecParameters *params,
|
||||
ExecOutput output,
|
||||
const char *ident,
|
||||
int nfd,
|
||||
@ -330,6 +331,7 @@ static int connect_logger_as(
|
||||
int fd, r;
|
||||
|
||||
assert(context);
|
||||
assert(params);
|
||||
assert(output < _EXEC_OUTPUT_MAX);
|
||||
assert(ident);
|
||||
assert(nfd >= 0);
|
||||
@ -358,7 +360,7 @@ static int connect_logger_as(
|
||||
"%i\n"
|
||||
"%i\n",
|
||||
context->syslog_identifier ?: ident,
|
||||
MANAGER_IS_SYSTEM(unit->manager) ? unit->id : "",
|
||||
params->flags & EXEC_PASS_LOG_UNIT ? unit->id : "",
|
||||
context->syslog_priority,
|
||||
!!context->syslog_level_prefix,
|
||||
output == EXEC_OUTPUT_SYSLOG || output == EXEC_OUTPUT_SYSLOG_AND_CONSOLE,
|
||||
@ -572,7 +574,7 @@ static int setup_output(
|
||||
case EXEC_OUTPUT_KMSG_AND_CONSOLE:
|
||||
case EXEC_OUTPUT_JOURNAL:
|
||||
case EXEC_OUTPUT_JOURNAL_AND_CONSOLE:
|
||||
r = connect_logger_as(unit, context, o, ident, fileno, uid, gid);
|
||||
r = connect_logger_as(unit, context, params, o, ident, fileno, uid, gid);
|
||||
if (r < 0) {
|
||||
log_unit_error_errno(unit, r, "Failed to connect %s to the journal socket, ignoring: %m", fileno == STDOUT_FILENO ? "stdout" : "stderr");
|
||||
r = open_null_as(O_WRONLY, fileno);
|
||||
|
@ -259,12 +259,13 @@ typedef enum ExecFlags {
|
||||
EXEC_APPLY_CHROOT = 1U << 1,
|
||||
EXEC_APPLY_TTY_STDIN = 1U << 2,
|
||||
EXEC_NEW_KEYRING = 1U << 3,
|
||||
EXEC_PASS_LOG_UNIT = 1U << 4, /* Whether to pass the unit name to the service's journal stream connection */
|
||||
|
||||
/* The following are not used by execute.c, but by consumers internally */
|
||||
EXEC_PASS_FDS = 1U << 4,
|
||||
EXEC_IS_CONTROL = 1U << 5,
|
||||
EXEC_SETENV_RESULT = 1U << 6,
|
||||
EXEC_SET_WATCHDOG = 1U << 7,
|
||||
EXEC_PASS_FDS = 1U << 5,
|
||||
EXEC_IS_CONTROL = 1U << 6,
|
||||
EXEC_SETENV_RESULT = 1U << 7,
|
||||
EXEC_SET_WATCHDOG = 1U << 8,
|
||||
} ExecFlags;
|
||||
|
||||
struct ExecParameters {
|
||||
|
@ -3422,6 +3422,8 @@ int manager_set_exec_params(Manager *m, ExecParameters *p) {
|
||||
p->cgroup_supported = m->cgroup_supported;
|
||||
p->prefix = m->prefix;
|
||||
|
||||
SET_FLAG(p->flags, EXEC_PASS_LOG_UNIT, MANAGER_IS_SYSTEM(m));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user