libsemanage/backport-libsemanage-simplify-file-deletion.patch
changhan 868210c456 Change the author's mailbox
Signed-off-by: changhan <changhan@xfusion.com>
(cherry picked from commit 6c2d136f1fada3dd3d9c98a6979d97f2d35cdb94)
2025-05-07 11:08:46 +08:00

64 lines
1.6 KiB
Diff

From 46b6d4593fd0bf3286977a9fe7d48f849524543c Mon Sep 17 00:00:00 2001
From: Christian Göttsche <cgzones@googlemail.com>
Date: Fri, 18 Apr 2025 16:43:48 +0800
Subject: [PATCH] libsemanage-simplify-file-deletion
Reference: https://github.com/SELinuxProject/selinux/commit/d3a5ae39bee42eac520a3d07f252251a2167a323
---
src/direct_api.c | 24 +++++++++---------------
1 file changed, 9 insertions(+), 15 deletions(-)
diff --git a/src/direct_api.c b/src/direct_api.c
index 025b26e..03fc6ad 100644
--- a/src/direct_api.c
+++ b/src/direct_api.c
@@ -2738,7 +2738,6 @@ static int semanage_direct_install_info(semanage_handle_t *sh,
int status = 0;
int ret = 0;
int type;
- struct stat sb;
char path[PATH_MAX];
mode_t mask = umask(0077);
@@ -2839,13 +2838,11 @@ static int semanage_direct_install_info(semanage_handle_t *sh,
goto cleanup;
}
- if (stat(path, &sb) == 0) {
- ret = unlink(path);
- if (ret != 0) {
- ERR(sh, "Error while removing cached CIL file %s.", path);
- status = -3;
- goto cleanup;
- }
+ ret = unlink(path);
+ if (ret != 0 && errno != ENOENT) {
+ ERR(sh, "Error while removing cached CIL file %s.", path);
+ status = -3;
+ goto cleanup;
}
}
@@ -2942,13 +2939,10 @@ static int semanage_direct_remove_key(semanage_handle_t *sh,
goto cleanup;
}
- struct stat sb;
- if (stat(path, &sb) == 0) {
- ret = unlink(path);
- if (ret != 0) {
- status = -1;
- goto cleanup;
- }
+ ret = unlink(path);
+ if (ret != 0 && errno != ENOENT) {
+ status = -1;
+ goto cleanup;
}
}
else {
--
2.33.0