Skip to contentSkip to conversation

ulogd: Perform nice() before giving up root

PATCH Eric Leblond 1 participant 1 message May 17, 2013 netfilter

lore
Share & tools
lore
#0 lore raw

Hi

I will finish to review both your patches this week end. At first look they are OK.

BR

Chris Boot <[email protected]> a écrit :

Quoted 55 lines · Chris Boot
Quoted 31 lines

The daemon code currently tries to nice(-1) just after having given up root privileges, which fails. This patch moves the nice(-1) call to just before the code that gives up the required privileges.

---
 src/ulogd.c |   14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
src/ulogd.c +7 -0
index b28d0f8..8a144e3 100644
@@ -1235,6 +1235,13 @@ int main(int argc, char* argv[])
 		warn_and_exit(daemonize);
 	}
 
+	errno = 0;
+	if (nice(-1) == -1) {
+		if (errno != 0)
+			ulogd_log(ULOGD_ERROR, "Could not nice process: %s\n",
+				  strerror(errno));
+	}
+
 	if (change_uid) {
 		ulogd_log(ULOGD_NOTICE, "Changing UID / GID\n");
 		if (setgid(gid)) {
@@ -1261,13 +1268,6 @@ int main(int argc, char* argv[])
 		}
 	}
 

src/ulogd.c int main(int argc, char* argv[]) · line 1273

Quoted 10 lines
src/ulogd.c +0 -7
-	errno = 0;
-	if (nice(-1) == -1) {
-		if (errno != 0)
-			ulogd_log(ULOGD_ERROR, "Could not nice process: %s\n",
-				  strerror(errno));
-	}
-
 
 	if (daemonize){
 		if (fork()) {

Hi all,

I have had no comments about this patch since I submitted it; is it likely to get pulled into ulogd?

Cheers,
Chris

Signature · 2 lines
Chris Boot
[email protected]