summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordimitri staessens <dimitri.staessens@ugent.be>2017-09-20 09:44:17 +0200
committerdimitri staessens <dimitri.staessens@ugent.be>2017-09-20 09:49:49 +0200
commitc665c71719225ef6d076c6be24c588049527f31f (patch)
treecbb01b76f47c50e7bf86443d0bb37747b41b8cff /src
parent476a3fe224554780b5737ac8db8f9fd39b32fe14 (diff)
downloadouroboros-c665c71719225ef6d076c6be24c588049527f31f.tar.gz
ouroboros-c665c71719225ef6d076c6be24c588049527f31f.zip
irmd: Init libgcrypt before using it
Diffstat (limited to 'src')
-rw-r--r--src/irmd/config.h.in2
-rw-r--r--src/irmd/main.c16
-rw-r--r--src/lib/CMakeLists.txt2
-rw-r--r--src/lib/dev.c3
4 files changed, 20 insertions, 3 deletions
diff --git a/src/irmd/config.h.in b/src/irmd/config.h.in
index d253a1ac..37e450c0 100644
--- a/src/irmd/config.h.in
+++ b/src/irmd/config.h.in
@@ -50,3 +50,5 @@
#ifdef HAVE_FUSE
#define FUSE_PREFIX "@FUSE_PREFIX@"
#endif
+
+#cmakedefine HAVE_LIBGCRYPT
diff --git a/src/irmd/main.c b/src/irmd/main.c
index df903f40..27c771a6 100644
--- a/src/irmd/main.c
+++ b/src/irmd/main.c
@@ -59,6 +59,10 @@
#include <sys/stat.h>
#include <sys/wait.h>
+#ifdef HAVE_LIBGCRYPT
+#include <gcrypt.h>
+#endif
+
#define IRMD_CLEANUP_TIMER ((IRMD_FLOW_TIMEOUT / 20) * MILLION) /* ns */
#define SHM_SAN_HOLDOFF 1000 /* ms */
#define IPCP_HASH_LEN(e) hash_len(e->dir_hash_algo)
@@ -2260,6 +2264,14 @@ static int irm_init(void)
else
mkdir(FUSE_PREFIX, 0777);
#endif
+
+#ifdef HAVE_LIBGCRYPT
+ if (gcry_control(GCRYCTL_ANY_INITIALIZATION_P))
+ goto fail_gcry_control;
+
+ gcry_control(GCRYCTL_INITIALIZATION_FINISHED);
+#endif
+
irmd.csockfd = -1;
irmd.state = IRMD_RUNNING;
@@ -2267,6 +2279,10 @@ static int irm_init(void)
return 0;
+#ifdef HAVE_LIBGCRYPT
+ fail_gcry_control:
+ shm_rdrbuff_destroy(irmd.rdrb);
+#endif
fail_rdrbuff:
shm_rdrbuff_destroy(irmd.rdrb);
fail_sock_opt:
diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt
index 6f1cfbb3..fa6254bf 100644
--- a/src/lib/CMakeLists.txt
+++ b/src/lib/CMakeLists.txt
@@ -76,7 +76,7 @@ if (LIBGCRYPT_LIBRARIES)
set (DISABLE_LIBGCRYPT FALSE CACHE BOOL "Disable libgcrypt support")
if (NOT DISABLE_LIBGCRYPT)
message(STATUS "libgcrypt support enabled")
- set(HAVE_LIBGCRYPT TRUE)
+ set(HAVE_LIBGCRYPT TRUE CACHE INTERNAL "")
else ()
message(STATUS "libgcrypt support disabled by user")
endif()
diff --git a/src/lib/dev.c b/src/lib/dev.c
index b945968d..9cb6f2ed 100644
--- a/src/lib/dev.c
+++ b/src/lib/dev.c
@@ -676,8 +676,7 @@ int ouroboros_init(const char * ap_name)
if (pthread_rwlock_init(&ai.lock, NULL))
goto fail_lock;
- ai.tw = timerwheel_create(TW_RESOLUTION,
- TW_RESOLUTION * TW_ELEMENTS);
+ ai.tw = timerwheel_create(TW_RESOLUTION, TW_RESOLUTION * TW_ELEMENTS);
if (ai.tw == NULL)
goto fail_timerwheel;