From: Timo Teräs Fix setre[gu]id handling for uclibc. uclibc may have non-compliant setre[gu]id implementation calling directly the syscall. This causes per-thread functionality instead of the specified per-process functinality. Fix potential race condition by doing setgroups() only in the main and doing it early. Later call setre[gu]id in all threads. diff -ru fprobe-ulog-1.1.orig/src/fprobe-ulog.c fprobe-ulog-1.1/src/fprobe-ulog.c --- fprobe-ulog-1.1.orig/src/fprobe-ulog.c 2014-07-30 14:13:32.089399841 -0300 +++ fprobe-ulog-1.1/src/fprobe-ulog.c 2014-07-30 14:12:13.626065731 -0300 @@ -625,7 +625,6 @@ Try to change EUID independently of main thread */ if (pw) { - setgroups(0, NULL); setregid(pw->pw_gid, pw->pw_gid); setreuid(pw->pw_uid, pw->pw_uid); } @@ -1382,6 +1381,13 @@ } } + if (pw) { + if (setgroups(0, NULL)) { + my_log(LOG_CRIT, "setgroups(): %s", strerror(errno)); + exit(1); + } + } + schedp.sched_priority = schedp.sched_priority - THREADS + 2; pthread_attr_init(&tattr); for (i = 0; i < THREADS - 1; i++) { @@ -1401,10 +1407,6 @@ } if (pw) { - if (setgroups(0, NULL)) { - my_log(LOG_CRIT, "setgroups(): %s", strerror(errno)); - exit(1); - } if (setregid(pw->pw_gid, pw->pw_gid)) { my_log(LOG_CRIT, "setregid(%u): %s", pw->pw_gid, strerror(errno)); exit(1);