From b63aaffcd17b4115aa779e49016c6c4dcf06ecd9 Mon Sep 17 00:00:00 2001 From: Sertonix Date: Tue, 16 Jan 2024 12:40:32 +0000 Subject: [PATCH] Check setgid too after dropping root --- shadow.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shadow.c b/shadow.c index b3f898a..be1ac0f 100644 --- a/shadow.c +++ b/shadow.c @@ -33,9 +33,9 @@ void initialize_pw_backend(int argc, char **argv) { swaylock_log_errno(LOG_ERROR, "Unable to drop root"); exit(EXIT_FAILURE); } - if (setuid(0) != -1) { + if (setuid(0) != -1 || setgid(0) != -1) { swaylock_log_errno(LOG_ERROR, "Unable to drop root (we shouldn't be " - "able to restore it after setuid)"); + "able to restore it after setuid/setgid)"); exit(EXIT_FAILURE); } }