mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 23:24:27 +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:
@@ -11,6 +11,7 @@
|
|||||||
#include <common/utils.h>
|
#include <common/utils.h>
|
||||||
#include <common/version.h>
|
#include <common/version.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
#include <sodium.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
@@ -146,6 +147,12 @@ void daemon_setup(const char *argv0,
|
|||||||
memleak_init();
|
memleak_init();
|
||||||
#endif
|
#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! */
|
/* We handle write returning errors! */
|
||||||
signal(SIGPIPE, SIG_IGN);
|
signal(SIGPIPE, SIG_IGN);
|
||||||
wally_init(0);
|
wally_init(0);
|
||||||
|
|||||||
Reference in New Issue
Block a user