Skip to content

Commit

Permalink
Check setgid too after dropping root
Browse files Browse the repository at this point in the history
  • Loading branch information
sertonix authored and emersion committed Jan 16, 2024
1 parent bb32fd1 commit b63aaff
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions shadow.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down

0 comments on commit b63aaff

Please sign in to comment.