mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 05:12:45 +01:00
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.".
This commit is contained in:
parent
2c69ece7fe
commit
fe2543d8dc
@ -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…
Reference in New Issue
Block a user