93 lines
6.3 KiB
Diff
93 lines
6.3 KiB
Diff
From 381294403c49f78d10e48ed49f84256df36598c9 Mon Sep 17 00:00:00 2001
|
|
From: Lennart Poettering <lennart@poettering.net>
|
|
Date: Tue, 27 Jun 2023 11:16:01 +0200
|
|
Subject: [PATCH] execute: associate logs from setup_exec_directory() with the
|
|
unit name
|
|
|
|
(cherry picked from commit 59dd2bbbb6fa4e5497b1cae17b76ee132f3107c1)
|
|
|
|
Related: RHEL-137252
|
|
---
|
|
src/core/execute.c | 29 +++++++++++++++--------------
|
|
1 file changed, 15 insertions(+), 14 deletions(-)
|
|
|
|
diff --git a/src/core/execute.c b/src/core/execute.c
|
|
index 2adb4392f9..1e1247e702 100644
|
|
--- a/src/core/execute.c
|
|
+++ b/src/core/execute.c
|
|
@@ -2298,6 +2298,7 @@ static int create_many_symlinks(const char *root, const char *source, char **sym
|
|
}
|
|
|
|
static int setup_exec_directory(
|
|
+ Unit *u,
|
|
const ExecContext *context,
|
|
const ExecParameters *params,
|
|
uid_t uid,
|
|
@@ -2389,13 +2390,13 @@ static int setup_exec_directory(
|
|
if (r < 0)
|
|
goto fail;
|
|
|
|
- log_notice("Unit state directory %s missing but matching configuration directory %s exists, assuming update from systemd 253 or older, creating compatibility symlink.", p, q);
|
|
+ log_unit_notice(u, "Unit state directory %s missing but matching configuration directory %s exists, assuming update from systemd 253 or older, creating compatibility symlink.", p, q);
|
|
continue;
|
|
} else if (r != -ENOENT)
|
|
- log_warning_errno(r, "Unable to detect whether unit configuration directory '%s' exists, assuming not: %m", q);
|
|
+ log_unit_warning_errno(u, r, "Unable to detect whether unit configuration directory '%s' exists, assuming not: %m", q);
|
|
|
|
} else if (r < 0)
|
|
- log_warning_errno(r, "Unable to detect whether unit state directory '%s' is missing, assuming it is: %m", p);
|
|
+ log_unit_warning_errno(u, r, "Unable to detect whether unit state directory '%s' is missing, assuming it is: %m", p);
|
|
}
|
|
|
|
if (exec_directory_is_private(context, type)) {
|
|
@@ -2452,9 +2453,9 @@ static int setup_exec_directory(
|
|
* it over. Most likely the service has been upgraded from one that didn't use
|
|
* DynamicUser=1, to one that does. */
|
|
|
|
- log_info("Found pre-existing public %s= directory %s, migrating to %s.\n"
|
|
- "Apparently, service previously had DynamicUser= turned off, and has now turned it on.",
|
|
- exec_directory_type_to_string(type), p, pp);
|
|
+ log_unit_info(u, "Found pre-existing public %s= directory %s, migrating to %s.\n"
|
|
+ "Apparently, service previously had DynamicUser= turned off, and has now turned it on.",
|
|
+ exec_directory_type_to_string(type), p, pp);
|
|
|
|
if (rename(p, pp) < 0) {
|
|
r = -errno;
|
|
@@ -2521,9 +2522,9 @@ static int setup_exec_directory(
|
|
/* Hmm, apparently DynamicUser= was once turned on for this service,
|
|
* but is no longer. Let's move the directory back up. */
|
|
|
|
- log_info("Found pre-existing private %s= directory %s, migrating to %s.\n"
|
|
- "Apparently, service previously had DynamicUser= turned on, and has now turned it off.",
|
|
- exec_directory_type_to_string(type), q, p);
|
|
+ log_unit_info(u, "Found pre-existing private %s= directory %s, migrating to %s.\n"
|
|
+ "Apparently, service previously had DynamicUser= turned on, and has now turned it off.",
|
|
+ exec_directory_type_to_string(type), q, p);
|
|
|
|
if (unlink(p) < 0) {
|
|
r = -errno;
|
|
@@ -2556,10 +2557,10 @@ static int setup_exec_directory(
|
|
|
|
/* Still complain if the access mode doesn't match */
|
|
if (((st.st_mode ^ context->directories[type].mode) & 07777) != 0)
|
|
- log_warning("%s \'%s\' already exists but the mode is different. "
|
|
- "(File system: %o %sMode: %o)",
|
|
- exec_directory_type_to_string(type), context->directories[type].items[i].path,
|
|
- st.st_mode & 07777, exec_directory_type_to_string(type), context->directories[type].mode & 07777);
|
|
+ log_unit_warning(u, "%s \'%s\' already exists but the mode is different. "
|
|
+ "(File system: %o %sMode: %o)",
|
|
+ exec_directory_type_to_string(type), context->directories[type].items[i].path,
|
|
+ st.st_mode & 07777, exec_directory_type_to_string(type), context->directories[type].mode & 07777);
|
|
|
|
continue;
|
|
}
|
|
@@ -4589,7 +4590,7 @@ static int exec_child(
|
|
needs_mount_namespace = exec_needs_mount_namespace(context, params, runtime);
|
|
|
|
for (ExecDirectoryType dt = 0; dt < _EXEC_DIRECTORY_TYPE_MAX; dt++) {
|
|
- r = setup_exec_directory(context, params, uid, gid, dt, needs_mount_namespace, exit_status);
|
|
+ r = setup_exec_directory(unit, context, params, uid, gid, dt, needs_mount_namespace, exit_status);
|
|
if (r < 0)
|
|
return log_unit_error_errno(unit, r, "Failed to set up special execution directory in %s: %m", params->prefix[dt]);
|
|
}
|