Init logging before actually using it
authorPetr Štetiar <ynezz@true.cz>
Mon, 27 May 2019 13:06:31 +0000 (15:06 +0200)
committerPetr Štetiar <ynezz@true.cz>
Mon, 27 May 2019 13:06:31 +0000 (15:06 +0200)
Otherwise we don't get urngd: prefixed log messages which might be
confusing:

 procd: - watchdog -
 jent-rng init failed, err: 2
 procd: - watchdog -

While at it add missing newline in one error message.

Signed-off-by: Petr Štetiar <ynezz@true.cz>
urngd.c

diff --git a/urngd.c b/urngd.c
index 8b9a762234a0cddc0219e2810d3e53cc0af78db8..f57a162aa039c7485735d919b8c97155b721880d 100644 (file)
--- a/urngd.c
+++ b/urngd.c
@@ -176,7 +176,7 @@ static bool urngd_init(struct urngd *u)
        u->rnd_fd.cb = low_entropy_cb;
        u->rnd_fd.fd = open(DEV_RANDOM, O_WRONLY);
        if (u->rnd_fd.fd < 1) {
-               ERROR(DEV_RANDOM " open failed: %s", strerror(errno));
+               ERROR(DEV_RANDOM " open failed: %s\n", strerror(errno));
                return false;
        }
 
@@ -225,10 +225,11 @@ int main(int argc, char **argv)
                }
        }
 
+       ulog_open(ulog_channels, LOG_DAEMON, "urngd");
+
        if (!urngd_init(&urngd_service))
                return -1;
 
-       ulog_open(ulog_channels, LOG_DAEMON, "urngd");
        LOG("v%s started.\n", URNGD_VERSION);
 
        gather_entropy(&urngd_service);