logrotate/backport-Also-check-seteuid-fails-after-dropping-privileges.patch

31 lines
1013 B
Diff

From 68d343b1c97f35ffbc77e07f83c84fc24df59f97 Mon Sep 17 00:00:00 2001
From: cgzones <cgzones@googlemail.com>
Date: Sat, 5 Jun 2021 18:56:55 +0200
Subject: [PATCH] Also check seteuid fails after dropping privileges
This patch is the rear patch of "switch_user_permanently: skip switchback check if switched to root"
Conflict:NA
Reference:https://github.com/logrotate/logrotate/commit/68d343b1c97f35ffbc77e07f83c84fc24df59f97
---
logrotate.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/logrotate.c b/logrotate.c
index 645105c..165a1df 100644
--- a/logrotate.c
+++ b/logrotate.c
@@ -206,7 +206,7 @@ static int switch_user_permanently(const struct logInfo *log) {
return 1;
}
- if (user != ROOT_UID && setuid(ROOT_UID) != -1) {
+ if (user != ROOT_UID && (setuid(ROOT_UID) != -1 || seteuid(ROOT_UID) != -1)) {
message(MESS_ERROR, "failed to switch user permanently, able to switch back (pid %d)\n",
getpid());
return 1;
--
2.27.0