Check setgid too after dropping root

This commit is contained in:
Sertonix 2024-01-16 12:40:32 +00:00 committed by Simon Ser
parent bb32fd1d50
commit b63aaffcd1

View File

@ -33,9 +33,9 @@ void initialize_pw_backend(int argc, char **argv) {
swaylock_log_errno(LOG_ERROR, "Unable to drop root"); swaylock_log_errno(LOG_ERROR, "Unable to drop root");
exit(EXIT_FAILURE); 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 " 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); exit(EXIT_FAILURE);
} }
} }