From bf18aec66a2a8bc0c3ef56c6be41846076c8a3f1 Mon Sep 17 00:00:00 2001 From: cgzones Date: Wed, 8 Apr 2020 16:38:00 +0200 Subject: [PATCH] switch_user_permanently: skip switchback check if switched to root Allow switching only the real group (not the user) with a configuration like `su root somegroup`. E.g. mailman uses `su root list`, which currently fails with: error: failed to switch user permanently, able to switch back error: failed to compress log /var/log/mailman/qrunner.1 Fixes: a0b05e42a590efa3e575dd2001b6aa390a79c769 ("switch_user_permanently: check if switchback is possible") 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/bf18aec66a2a8bc0c3ef56c6be41846076c8a3f1 --- logrotate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/logrotate.c b/logrotate.c index 25902bc..2e315b9 100644 --- a/logrotate.c +++ b/logrotate.c @@ -187,7 +187,7 @@ static int switch_user_permanently(const struct logInfo *log) { return 1; } - if (setuid(ROOT_UID) != -1) { + if (user != ROOT_UID && setuid(ROOT_UID) != -1) { message(MESS_ERROR, "failed to switch user permanently, able to switch back\n"); return 1; } -- 2.27.0