Skip to content

Commit

Permalink
cnid_dbd: Run setgroups() before changing user, GitHub #1308
Browse files Browse the repository at this point in the history
  • Loading branch information
rdmark committed Sep 22, 2024
1 parent fad8a57 commit b185fe2
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions etc/cnid_dbd/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,10 @@ static void switch_to_user(char *dir)
LOG(log_error, logtype_cnid, "error in stat for %s: %s", dir, strerror(errno));
exit(1);
}
if (setgroups(0, NULL) < 0) {
LOG(log_error, logtype_cnid, "error in setgroups: %s", strerror(errno));
exit(1);
}
if (!getuid()) {
LOG(log_debug, logtype_cnid, "Setting uid/gid to %i/%i", st.st_uid, st.st_gid);
if (setgid(st.st_gid) < 0 || setuid(st.st_uid) < 0) {
Expand Down

0 comments on commit b185fe2

Please sign in to comment.