tMore stringent checks added to DropPrivileges(). Both the euid and the egid ar… | |
git clone git://src.adamsgaard.dk/vaccinewars | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit cea9bb7cba46eb66054b43c4a51289f59a91c874 | |
parent 7a30d096be40b16d8066f49421bc4614127474ca | |
Author: Ben Webb <[email protected]> | |
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(-) | |
--- | |
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 | |
} | |