6ee4abe797
Remove resolved scriptlets Don't install tests Resolves: RHEL-46277,RHEL-46576,RHEL-46280
36 lines
1.5 KiB
Diff
36 lines
1.5 KiB
Diff
From 90ec0265707d381ed8cc77de475cd963686eaba3 Mon Sep 17 00:00:00 2001
|
|
From: Lennart Poettering <lennart@poettering.net>
|
|
Date: Tue, 18 Jun 2024 09:54:33 +0200
|
|
Subject: [PATCH] tmpfiles: honour --dry-run when removing directories
|
|
|
|
(cherry picked from commit edeceb80a91e8400e8c22f08a41045a2ba270fe6)
|
|
---
|
|
src/tmpfiles/tmpfiles.c | 14 ++++++++++----
|
|
1 file changed, 10 insertions(+), 4 deletions(-)
|
|
|
|
diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c
|
|
index 807925f199..283be21d16 100644
|
|
--- a/src/tmpfiles/tmpfiles.c
|
|
+++ b/src/tmpfiles/tmpfiles.c
|
|
@@ -3024,10 +3024,16 @@ static int remove_recursive(
|
|
return r;
|
|
|
|
if (remove_instance) {
|
|
- log_debug("Removing directory \"%s\".", instance);
|
|
- r = RET_NERRNO(rmdir(instance));
|
|
- if (r < 0 && !IN_SET(r, -ENOENT, -ENOTEMPTY))
|
|
- return log_error_errno(r, "Failed to remove %s: %m", instance);
|
|
+ log_action("Would remove", "Removing", "%s directory \"%s\".", instance);
|
|
+ if (!arg_dry_run) {
|
|
+ r = RET_NERRNO(rmdir(instance));
|
|
+ if (r < 0) {
|
|
+ bool fatal = !IN_SET(r, -ENOENT, -ENOTEMPTY);
|
|
+ log_full_errno(fatal ? LOG_ERR : LOG_DEBUG, r, "Failed to remove %s: %m", instance);
|
|
+ if (fatal)
|
|
+ return r;
|
|
+ }
|
|
+ }
|
|
}
|
|
return 0;
|
|
}
|