From dc49327c5e55f488397c1e3f48b25fe2fc372e22 Mon Sep 17 00:00:00 2001 From: cgzones Date: Wed, 8 Apr 2020 17:07:08 +0200 Subject: [PATCH] rotateLogSet: call switch_user_back on early return This patch is for fixing the issue of "switch_user_permanently: skip switchback check if switched to root" Conflict:NA Reference:https://github.com/logrotate/logrotate/pull/319/commits/dc49327c5e55f488397c1e3f48b25fe2fc372e22 --- logrotate.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/logrotate.c b/logrotate.c index 55887a5..645105c 100644 --- a/logrotate.c +++ b/logrotate.c @@ -2294,6 +2294,9 @@ static int rotateLogSet(struct logInfo *log, int force) if (state == NULL || rotNames == NULL) { message(MESS_ERROR, "can not allocate memory\n"); + if (log->flags & LOG_FLAG_SU) { + switch_user_back(); + } free(rotNames); free(state); free(logHasErrors); @@ -2314,6 +2317,9 @@ static int rotateLogSet(struct logInfo *log, int force) rotNames[i] = malloc(sizeof(struct logNames)); if (rotNames[i] == NULL) { message(MESS_ERROR, "can not allocate memory\n"); + if (log->flags & LOG_FLAG_SU) { + switch_user_back(); + } free(rotNames); free(state); free(logHasErrors); -- 2.27.0