tMore stringent checks added to DropPrivileges(). Both the euid and the egid are now dropped. - vaccinewars - be a doctor and try to vaccinate the world
(HTM) git clone git://src.adamsgaard.dk/vaccinewars
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit cea9bb7cba46eb66054b43c4a51289f59a91c874
(DIR) parent 7a30d096be40b16d8066f49421bc4614127474ca
(HTM) Author: Ben Webb <ben@salilab.org>
Date: Sat, 2 Mar 2002 19:56:56 +0000
More stringent checks added to DropPrivileges(). Both the euid and the egid
are now dropped.
Diffstat:
M src/serverside.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
---
(DIR) diff --git a/src/serverside.c b/src/serverside.c
t@@ -1736,12 +1736,19 @@ void CloseHighScoreFile()
void DropPrivileges()
{
#ifndef CYGWIN
- /* Ignore the error if we've ended up with (gid == egid) anyway */
- if (setregid(getgid(), getgid()) != 0
- && (getgid() != getegid())) {
+ /* Ignore the return from setregid; we'll check it ourselves to be sure
+ * (this avoids problems when running under fakeroot) */
+ setregid(getgid(), getgid());
+ if (getgid() != getegid()) {
perror("setregid");
exit(1);
}
+
+ setreuid(getuid(), getuid());
+ if (getuid() != geteuid()) {
+ perror("setreuid");
+ exit(1);
+ }
#endif
}