Browse Source

daemons: initialize libsodium at setup

According to the doc (https://download.libsodium.org/doc):
"sodium_init() initializes the library and should be called before
any other function provided by Sodium. [...]
the function ensures that the system's random number generator has
been properly seeded.".
travis-debug
darosior 5 years ago
committed by neil saitug
parent
commit
fe2543d8dc
  1. 7
      common/daemon.c

7
common/daemon.c

@ -11,6 +11,7 @@
#include <common/utils.h>
#include <common/version.h>
#include <signal.h>
#include <sodium.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
@ -146,6 +147,12 @@ void daemon_setup(const char *argv0,
memleak_init();
#endif
/* We rely on libsodium for some of the crypto stuff, so we'd better
* not start if it cannot do its job correctly. */
if (sodium_init() == -1)
errx(1, "Could not initialize libsodium. Maybe not enough entropy"
" available ?");
/* We handle write returning errors! */
signal(SIGPIPE, SIG_IGN);
wally_init(0);

Loading…
Cancel
Save