The call to setuid() may fail, e.g. because it brings the process over its RLIMIT_NPROC
resource limit. So print an error message and exit in this case.
exit(EXIT_FAILURE);
}
PARA_INFO_LOG("dropping root privileges\n");
- setuid(p->pw_uid);
+ if (setuid(p->pw_uid) < 0) {
+ PARA_EMERG_LOG("failed to set effective user ID (%s)",
+ strerror(errno));
+ exit(EXIT_FAILURE);
+ }
PARA_DEBUG_LOG("uid: %d, euid: %d\n", (int)getuid(), (int)geteuid());
}