This is good practice because there are a few case where group
permissions can't be dropped after the user practice were dropped.
Shouldn't be an issue here, but it can't hurt.
gid = getgid();
/* Drop all privileges. */
- if (setresuid(uid, uid, uid) != 0) {
- perror("setresuid");
- exit(EXIT_FAILURE);
- }
if (setresgid(gid, gid, gid) != 0) {
perror("setresgid");
exit(EXIT_FAILURE);
}
+ if (setresuid(uid, uid, uid) != 0) {
+ perror("setresuid");
+ exit(EXIT_FAILURE);
+ }
/* Verify all privileges were dropped. */
if (getresuid(&ruid, &euid, &suid) != 0) {