Browse code

core: don't do initgroups() if started by same user as -u - closing FS#473

Ovidiu Sas authored on 03/01/2015 03:03:22
Showing 1 changed files
... ...
@@ -465,12 +465,12 @@ int do_suid()
465 465
 			LM_CRIT("user lookup failed: %s\n", strerror(errno));
466 466
 			goto error;
467 467
 		}
468
-		if(initgroups(pw->pw_name, pw->pw_gid)<0){
469
-			LM_CRIT("cannot set supplementary groups: %s\n", 
470
-							strerror(errno));
471
-			goto error;
472
-		}
473 468
 		if(uid!=getuid()) {
469
+			if(initgroups(pw->pw_name, pw->pw_gid)<0){
470
+				LM_CRIT("cannot set supplementary groups: %s\n", 
471
+							strerror(errno));
472
+				goto error;
473
+			}
474 474
 			if(setuid(uid)<0){
475 475
 				LM_CRIT("cannot change uid to %d: %s\n", uid, strerror(errno));
476 476
 				goto error;