summaryrefslogtreecommitdiffstats
path: root/src/ulogd.c
diff options
context:
space:
mode:
authorChris Boot <bootc@bootc.net>2013-05-11 18:01:52 +0100
committerEric Leblond <eric@regit.org>2013-05-21 19:57:07 +0200
commit401c446ce73dfee19afb668a2761f335bcb91877 (patch)
tree557ec245c161a74bb80b47f74a1fdb802f1ea2bc /src/ulogd.c
parent61b7946e90165de3ebf943e5c454fc0b62c029ad (diff)
ulogd: Perform nice() before giving up root
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. Signed-off-by: Chris Boot <bootc@bootc.net>
Diffstat (limited to 'src/ulogd.c')
-rw-r--r--src/ulogd.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/ulogd.c b/src/ulogd.c
index 8f21cc2..76190d9 100644
--- a/src/ulogd.c
+++ b/src/ulogd.c
@@ -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[])
}
}
- 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()) {