diff --git a/src/core/execute.c b/src/core/execute.c index b485509bdf5..5a2c095e857 100644 --- a/src/core/execute.c +++ b/src/core/execute.c @@ -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); diff --git a/src/core/execute.h b/src/core/execute.h index 4742f4e6c1c..8b2b80d34ea 100644 --- a/src/core/execute.h +++ b/src/core/execute.h @@ -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 { diff --git a/src/core/manager.c b/src/core/manager.c index 7f9c6164c71..6ddaae8c91c 100644 --- a/src/core/manager.c +++ b/src/core/manager.c @@ -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; }