summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/lib/eet/eet_lib.c82
-rw-r--r--src/lib/emile/emile_main.c75
2 files changed, 84 insertions, 73 deletions
diff --git a/src/lib/eet/eet_lib.c b/src/lib/eet/eet_lib.c
index dcf11e936d..0d5eb58c5c 100644
--- a/src/lib/eet/eet_lib.c
+++ b/src/lib/eet/eet_lib.c
@@ -26,20 +26,7 @@
26#endif /* ifdef HAVE_EVIL */ 26#endif /* ifdef HAVE_EVIL */
27 27
28#include <Eina.h> 28#include <Eina.h>
29 29#include <Emile.h>
30#ifdef HAVE_GNUTLS
31# include <gnutls/gnutls.h>
32# include <gcrypt.h>
33#endif /* ifdef HAVE_GNUTLS */
34
35#ifdef HAVE_OPENSSL
36# include <openssl/err.h>
37# include <openssl/evp.h>
38#endif /* ifdef HAVE_OPENSSL */
39
40#ifdef HAVE_GNUTLS
41GCRY_THREAD_OPTION_PTHREAD_IMPL;
42#endif /* ifdef HAVE_GNUTLS */
43 30
44#include "Eet.h" 31#include "Eet.h"
45#include "Eet_private.h" 32#include "Eet_private.h"
@@ -562,49 +549,20 @@ eet_init(void)
562 goto shutdown_mempool; 549 goto shutdown_mempool;
563 } 550 }
564 551
565#ifdef HAVE_GNUTLS 552 if (!emile_init())
566 /* Before the library can be used, it must initialize itself if needed. */
567 if (gcry_control(GCRYCTL_ANY_INITIALIZATION_P) == 0)
568 { 553 {
569 gcry_check_version(NULL); 554 EINA_LOG_ERR("Emile: failed to initialize");
570 /* Disable warning messages about problems with the secure memory subsystem. 555 goto shutdown_emile;
571 This command should be run right after gcry_check_version. */
572 if (gcry_control(GCRYCTL_DISABLE_SECMEM_WARN))
573 goto shutdown_eet; /* This command is used to allocate a pool of secure memory and thus
574 enabling the use of secure memory. It also drops all extra privileges the
575 process has (i.e. if it is run as setuid (root)). If the argument nbytes
576 is 0, secure memory will be disabled. The minimum amount of secure memory
577 allocated is currently 16384 bytes; you may thus use a value of 1 to
578 request that default size. */
579
580 if (gcry_control(GCRYCTL_INIT_SECMEM, 16384, 0))
581 WRN(
582 "BIG FAT WARNING: I AM UNABLE TO REQUEST SECMEM, Cryptographic operation are at risk !");
583 } 556 }
584 557
585 if (gcry_control(GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread))
586 WRN(
587 "YOU ARE USING PTHREADS, BUT I CANNOT INITIALIZE THREADSAFE GCRYPT OPERATIONS!");
588
589 if (gnutls_global_init())
590 goto shutdown_eet;
591
592#endif /* ifdef HAVE_GNUTLS */
593#ifdef HAVE_OPENSSL
594 ERR_load_crypto_strings();
595 OpenSSL_add_all_algorithms();
596#endif /* ifdef HAVE_OPENSSL */
597
598 eina_log_timing(_eet_log_dom_global, 558 eina_log_timing(_eet_log_dom_global,
599 EINA_LOG_STATE_STOP, 559 EINA_LOG_STATE_STOP,
600 EINA_LOG_STATE_INIT); 560 EINA_LOG_STATE_INIT);
601 561
602 return eet_init_count; 562 return eet_init_count;
603 563
604#ifdef HAVE_GNUTLS 564shutdown_emile:
605shutdown_eet:
606 eet_node_shutdown(); 565 eet_node_shutdown();
607#endif
608shutdown_mempool: 566shutdown_mempool:
609 eet_mempool_shutdown(); 567 eet_mempool_shutdown();
610unregister_log_domain: 568unregister_log_domain:
@@ -627,8 +585,8 @@ eet_shutdown(void)
627 return eet_init_count; 585 return eet_init_count;
628 586
629 eina_log_timing(_eet_log_dom_global, 587 eina_log_timing(_eet_log_dom_global,
630 EINA_LOG_STATE_START, 588 EINA_LOG_STATE_START,
631 EINA_LOG_STATE_SHUTDOWN); 589 EINA_LOG_STATE_SHUTDOWN);
632 590
633 eet_clearcache(); 591 eet_clearcache();
634 592
@@ -663,26 +621,8 @@ eet_shutdown(void)
663 621
664 eina_lock_free(&eet_cache_lock); 622 eina_lock_free(&eet_cache_lock);
665 623
666#ifdef HAVE_GNUTLS 624 emile_shutdown();
667 /* Note that gnutls has a leak where it doesnt free stuff it alloced 625
668 * on init. valgrind trace here:
669 * 21 bytes in 1 blocks are definitely lost in loss record 24 of 194
670 * at 0x4C2B6CD: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
671 * by 0x68AC801: strdup (strdup.c:43)
672 * by 0xD215B6A: p11_kit_registered_module_to_name (in /usr/lib/x86_64-linux-gnu/libp11-kit.so.0.0.0)
673 * by 0x9571574: gnutls_pkcs11_init (in /usr/lib/x86_64-linux-gnu/libgnutls.so.26.21.8)
674 * by 0x955B031: gnutls_global_init (in /usr/lib/x86_64-linux-gnu/libgnutls.so.26.21.8)
675 * by 0x6DFD6D0: eet_init (eet_lib.c:608)
676 *
677 * yes - i've tried calling gnutls_pkcs11_deinit() by hand but no luck.
678 * the leak is in there.
679 */
680 gnutls_global_deinit();
681#endif /* ifdef HAVE_GNUTLS */
682#ifdef HAVE_OPENSSL
683 EVP_cleanup();
684 ERR_free_strings();
685#endif /* ifdef HAVE_OPENSSL */
686 eina_log_domain_unregister(_eet_log_dom_global); 626 eina_log_domain_unregister(_eet_log_dom_global);
687 _eet_log_dom_global = -1; 627 _eet_log_dom_global = -1;
688 eina_shutdown(); 628 eina_shutdown();
diff --git a/src/lib/emile/emile_main.c b/src/lib/emile/emile_main.c
index 389f66022b..5aa80acd66 100644
--- a/src/lib/emile/emile_main.c
+++ b/src/lib/emile/emile_main.c
@@ -1,6 +1,27 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif /* ifdef HAVE_CONFIG_H */
4
5#ifdef HAVE_GNUTLS
6# include <gnutls/gnutls.h>
7# include <gnutls/x509.h>
8# include <gcrypt.h>
9#endif /* ifdef HAVE_GNUTLS */
10
11#ifdef HAVE_OPENSSL
12# include <openssl/ssl.h>
13# include <openssl/err.h>
14# include <openssl/evp.h>
15#endif /* ifdef HAVE_OPENSSL */
16
1#include <Eina.h> 17#include <Eina.h>
2 18
3#include "Emile.h" 19#include "Emile.h"
20#include "emile_private.h"
21
22#ifdef HAVE_GNUTLS
23GCRY_THREAD_OPTION_PTHREAD_IMPL;
24#endif /* ifdef HAVE_GNUTLS */
4 25
5static unsigned int _emile_init_count = 0; 26static unsigned int _emile_init_count = 0;
6int _emile_log_dom_global = -1; 27int _emile_log_dom_global = -1;
@@ -21,7 +42,38 @@ emile_init(void)
21 goto shutdown_eina; 42 goto shutdown_eina;
22 } 43 }
23 44
24 // FIXME: Init the rest here. 45#ifdef HAVE_GNUTLS
46 /* Before the library can be used, it must initialize itself if needed. */
47 if (gcry_control(GCRYCTL_ANY_INITIALIZATION_P) == 0)
48 {
49 gcry_check_version(NULL);
50 /* Disable warning messages about problems with the secure memory subsystem.
51 This command should be run right after gcry_check_version. */
52 if (gcry_control(GCRYCTL_DISABLE_SECMEM_WARN))
53 goto shutdown_eet; /* This command is used to allocate a pool of secure memory and thus
54 enabling the use of secure memory. It also drops all extra privileges the
55 process has (i.e. if it is run as setuid (root)). If the argument nbytes
56 is 0, secure memory will be disabled. The minimum amount of secure memory
57 allocated is currently 16384 bytes; you may thus use a value of 1 to
58 request that default size. */
59
60 if (gcry_control(GCRYCTL_INIT_SECMEM, 16384, 0))
61 WRN(
62 "BIG FAT WARNING: I AM UNABLE TO REQUEST SECMEM, Cryptographic operation are at risk !");
63 }
64
65 if (gcry_control(GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread))
66 WRN(
67 "YOU ARE USING PTHREADS, BUT I CANNOT INITIALIZE THREADSAFE GCRYPT OPERATIONS!");
68
69 if (gnutls_global_init())
70 goto shutdown_eet;
71
72#endif /* ifdef HAVE_GNUTLS */
73#ifdef HAVE_OPENSSL
74 ERR_load_crypto_strings();
75 OpenSSL_add_all_algorithms();
76#endif /* ifdef HAVE_OPENSSL */
25 77
26 eina_log_timing(_emile_log_dom_global, 78 eina_log_timing(_emile_log_dom_global,
27 EINA_LOG_STATE_STOP, 79 EINA_LOG_STATE_STOP,
@@ -45,7 +97,26 @@ emile_shutdown(void)
45 EINA_LOG_STATE_START, 97 EINA_LOG_STATE_START,
46 EINA_LOG_STATE_SHUTDOWN); 98 EINA_LOG_STATE_SHUTDOWN);
47 99
48 // FIXME: Shutdown the rest here. 100#ifdef HAVE_GNUTLS
101 /* Note that gnutls has a leak where it doesnt free stuff it alloced
102 * on init. valgrind trace here:
103 * 21 bytes in 1 blocks are definitely lost in loss record 24 of 194
104 * at 0x4C2B6CD: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
105 * by 0x68AC801: strdup (strdup.c:43)
106 * by 0xD215B6A: p11_kit_registered_module_to_name (in /usr/lib/x86_64-linux-gnu/libp11-kit.so.0.0.0)
107 * by 0x9571574: gnutls_pkcs11_init (in /usr/lib/x86_64-linux-gnu/libgnutls.so.26.21.8)
108 * by 0x955B031: gnutls_global_init (in /usr/lib/x86_64-linux-gnu/libgnutls.so.26.21.8)
109 * by 0x6DFD6D0: eet_init (eet_lib.c:608)
110 *
111 * yes - i've tried calling gnutls_pkcs11_deinit() by hand but no luck.
112 * the leak is in there.
113 */
114 gnutls_global_deinit();
115#endif /* ifdef HAVE_GNUTLS */
116#ifdef HAVE_OPENSSL
117 EVP_cleanup();
118 ERR_free_strings();
119#endif /* ifdef HAVE_OPENSSL */
49 120
50 eina_log_domain_unregister(_emile_log_dom_global); 121 eina_log_domain_unregister(_emile_log_dom_global);
51 _emile_log_dom_global = -1; 122 _emile_log_dom_global = -1;