File POS36-C.patch of Package ntop
Index: ntop-5.0.2/util.c
===================================================================
--- ntop-5.0.2.orig/util.c
+++ ntop-5.0.2/util.c
@@ -3998,7 +3998,11 @@ void checkUserIdentity(int userSpecified
#ifndef WIN32
if((getuid() != geteuid()) || (getgid() != getegid())) {
/* setuid binary, drop privileges */
- if((setgid(getgid()) != 0) || (setuid(getuid()) != 0)) {
+ if(setgid(getgid()) != 0) {
+ traceEvent(CONST_TRACE_FATALERROR, "Unable to drop privileges");
+ exit(33); /* Just in case */
+ }
+ if(setuid(getuid()) != 0) {
traceEvent(CONST_TRACE_FATALERROR, "Unable to drop privileges");
exit(33); /* Just in case */
}
@@ -4011,7 +4015,11 @@ void checkUserIdentity(int userSpecified
if(userSpecified) {
/* User located */
if((myGlobals.userId != 0) || (myGlobals.groupId != 0)) {
- if((setgid(myGlobals.groupId) != 0) || (setuid(myGlobals.userId) != 0)) {
+ if(setgid(myGlobals.groupId) != 0) {
+ traceEvent(CONST_TRACE_FATALERROR, "Unable to change user");
+ exit(34); /* Just in case */
+ }
+ if(setuid(myGlobals.userId) != 0) {
traceEvent(CONST_TRACE_FATALERROR, "Unable to change user");
exit(34); /* Just in case */
}