systemd/1315-execute-shorten-some-code-by-using-RET_NERRNO.patch
Jan Macku fdda15f23a systemd-252-66
Resolves: RHEL-138414, RHEL-92752, RHEL-111135, RHEL-137252
2026-02-23 15:13:13 +01:00

63 lines
3.1 KiB
Diff

From 17119db763328e6b329cbd580f79472e26104040 Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Tue, 27 Jun 2023 11:19:12 +0200
Subject: [PATCH] execute: shorten some code by using RET_NERRNO()
(cherry picked from commit db58f5de3d9f0eb4897c2781fc226307b7ac0a5e)
Related: RHEL-137252
---
src/core/execute.c | 20 ++++++++------------
1 file changed, 8 insertions(+), 12 deletions(-)
diff --git a/src/core/execute.c b/src/core/execute.c
index 1e1247e702..b1f7eeca8a 100644
--- a/src/core/execute.c
+++ b/src/core/execute.c
@@ -2457,10 +2457,9 @@ static int setup_exec_directory(
"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;
+ r = RET_NERRNO(rename(p, pp));
+ if (r < 0)
goto fail;
- }
} else {
/* Otherwise, create the actual directory for the service */
@@ -2526,15 +2525,13 @@ static int setup_exec_directory(
"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;
+ r = RET_NERRNO(unlink(p));
+ if (r < 0)
goto fail;
- }
- if (rename(q, p) < 0) {
- r = -errno;
+ r = RET_NERRNO(rename(q, p));
+ if (r < 0)
goto fail;
- }
}
}
@@ -2550,10 +2547,9 @@ static int setup_exec_directory(
* as in the common case it is not written to by a service, and shall
* not be writable. */
- if (stat(p, &st) < 0) {
- r = -errno;
+ r = RET_NERRNO(stat(p, &st));
+ if (r < 0)
goto fail;
- }
/* Still complain if the access mode doesn't match */
if (((st.st_mode ^ context->directories[type].mode) & 07777) != 0)