prometheus-node-exporter-lua: add dawn exporter
[feed/packages.git] / lang / erlang / patches / 010-openssl-deprecated.patch
1 --- a/lib/crypto/c_src/crypto.c
2 +++ b/lib/crypto/c_src/crypto.c
3 @@ -41,6 +41,7 @@
4 #include <openssl/des.h>
5 #endif /* #ifndef OPENSSL_NO_DES */
6 /* #include <openssl/idea.h> This is not supported on the openssl OTP requires */
7 +#include <openssl/dh.h>
8 #include <openssl/dsa.h>
9 #include <openssl/rsa.h>
10 #include <openssl/aes.h>
11 @@ -177,7 +178,7 @@
12 #endif
13
14 #if OPENSSL_VERSION_NUMBER >= PACKED_OPENSSL_VERSION_PLAIN(1,1,0)
15 -# ifndef HAS_LIBRESSL
16 +# if !defined(OPENSSL_NO_CHACHA) || !defined(OPENSSL_NO_POLY1305)
17 # define HAVE_CHACHA20_POLY1305
18 # endif
19 #endif
20 @@ -197,8 +198,10 @@
21 /* If OPENSSL_NO_EC is set, there will be an error in ec.h included from engine.h
22 So if EC is disabled, you can't use Engine either....
23 */
24 +#if !defined(OPENSSL_NO_ENGINE)
25 # define HAS_ENGINE_SUPPORT
26 #endif
27 +#endif
28
29
30 #if defined(HAS_ENGINE_SUPPORT)
31 @@ -910,7 +913,11 @@ static void engine_ctx_dtor(ErlNifEnv* env, struct engine_ctx* ctx) {
32
33 static int verify_lib_version(void)
34 {
35 +#if OPENSSL_VERSION_NUMBER < PACKED_OPENSSL_VERSION_PLAIN(1,1,0)
36 const unsigned long libv = SSLeay();
37 +#else
38 + const unsigned long libv = OpenSSL_version_num();
39 +#endif
40 const unsigned long hdrv = OPENSSL_VERSION_NUMBER;
41
42 # define MAJOR_VER(V) ((unsigned long)(V) >> (7*4))
43 @@ -1166,12 +1173,14 @@ static int initialize(ErlNifEnv* env, ERL_NIF_TERM load_info)
44 funcp = &get_crypto_callbacks;
45 #endif
46
47 +#if OPENSSL_VERSION_NUMBER < PACKED_OPENSSL_VERSION_PLAIN(1,1,0)
48 #ifdef OPENSSL_THREADS
49 enif_system_info(&sys_info, sizeof(sys_info));
50 if (sys_info.scheduler_threads > 1) {
51 nlocks = CRYPTO_num_locks();
52 }
53 /* else no need for locks */
54 +#endif
55 #endif
56
57 ccb = (*funcp)(nlocks);
58 @@ -1183,15 +1192,21 @@ static int initialize(ErlNifEnv* env, ERL_NIF_TERM load_info)
59
60 CRYPTO_set_mem_functions(ccb->crypto_alloc, ccb->crypto_realloc, ccb->crypto_free);
61
62 +#if OPENSSL_VERSION_NUMBER < PACKED_OPENSSL_VERSION_PLAIN(1,1,0)
63 #ifdef OPENSSL_THREADS
64 if (nlocks > 0) {
65 CRYPTO_set_locking_callback(ccb->locking_function);
66 +#if OPENSSL_VERSION_NUMBER < 0x10000000
67 CRYPTO_set_id_callback(ccb->id_function);
68 +#else
69 + CRYPTO_THREADID_set_callback(ccb->id_function);
70 +#endif
71 CRYPTO_set_dynlock_create_callback(ccb->dyn_create_function);
72 CRYPTO_set_dynlock_lock_callback(ccb->dyn_lock_function);
73 CRYPTO_set_dynlock_destroy_callback(ccb->dyn_destroy_function);
74 }
75 #endif /* OPENSSL_THREADS */
76 +#endif
77
78 init_digest_types(env);
79 init_cipher_types(env);
80 @@ -1391,7 +1406,11 @@ static ERL_NIF_TERM info_lib(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]
81
82 static const char libname[] = "OpenSSL";
83 unsigned name_sz = strlen(libname);
84 +#if OPENSSL_VERSION_NUMBER < PACKED_OPENSSL_VERSION_PLAIN(1,1,0)
85 const char* ver = SSLeay_version(SSLEAY_VERSION);
86 +#else
87 + const char* ver = OpenSSL_version(OPENSSL_VERSION);
88 +#endif
89 unsigned ver_sz = strlen(ver);
90 ERL_NIF_TERM name_term, ver_term;
91 int ver_num = OPENSSL_VERSION_NUMBER;
92 --- a/lib/crypto/c_src/crypto_callback.c
93 +++ b/lib/crypto/c_src/crypto_callback.c
94 @@ -83,7 +83,7 @@ static void crypto_free(void* ptr CCB_FILE_LINE_ARGS)
95 enif_free(ptr);
96 }
97
98 -
99 +#if OPENSSL_VERSION_NUMBER < 0x10100000
100 #ifdef OPENSSL_THREADS /* vvvvvvvvvvvvvvv OPENSSL_THREADS vvvvvvvvvvvvvvvv */
101
102 static ErlNifRWLock** lock_vec = NULL; /* Static locks used by openssl */
103 @@ -115,10 +115,17 @@ static void locking_function(int mode, int n, const char *file, int line)
104 locking(mode, lock_vec[n]);
105 }
106
107 +#if OPENSSL_VERSION_NUMBER < 0x10000000
108 static unsigned long id_function(void)
109 {
110 return (unsigned long) enif_thread_self();
111 }
112 +#else
113 +static void id_function(CRYPTO_THREADID *id)
114 +{
115 + CRYPTO_THREADID_set_numeric(id, (unsigned long) enif_thread_self());
116 +}
117 +#endif
118
119 /* Dynamic locking, not used by current openssl version (0.9.8)
120 */
121 @@ -136,6 +143,7 @@ static void dyn_destroy_function(struct CRYPTO_dynlock_value *ptr, const char *f
122 }
123
124 #endif /* ^^^^^^^^^^^^^^^^^^^^^^ OPENSSL_THREADS ^^^^^^^^^^^^^^^^^^^^^^ */
125 +#endif
126
127 DLLEXPORT struct crypto_callbacks* get_crypto_callbacks(int nlocks)
128 {
129 @@ -146,7 +154,8 @@ DLLEXPORT struct crypto_callbacks* get_crypto_callbacks(int nlocks)
130 &crypto_alloc,
131 &crypto_realloc,
132 &crypto_free,
133 -
134 +
135 +#if OPENSSL_VERSION_NUMBER < 0x10100000
136 #ifdef OPENSSL_THREADS
137 &locking_function,
138 &id_function,
139 @@ -154,9 +163,11 @@ DLLEXPORT struct crypto_callbacks* get_crypto_callbacks(int nlocks)
140 &dyn_lock_function,
141 &dyn_destroy_function
142 #endif /* OPENSSL_THREADS */
143 +#endif
144 };
145
146 if (!is_initialized) {
147 +#if OPENSSL_VERSION_NUMBER < 0x10100000
148 #ifdef OPENSSL_THREADS
149 if (nlocks > 0) {
150 int i;
151 @@ -169,6 +180,7 @@ DLLEXPORT struct crypto_callbacks* get_crypto_callbacks(int nlocks)
152 if (lock_vec[i]==NULL) return NULL;
153 }
154 }
155 +#endif
156 #endif
157 is_initialized = 1;
158 }
159 --- a/lib/crypto/c_src/crypto_callback.h
160 +++ b/lib/crypto/c_src/crypto_callback.h
161 @@ -34,9 +34,15 @@ struct crypto_callbacks
162 void (*crypto_free)(void* ptr CCB_FILE_LINE_ARGS);
163
164 /* openssl callbacks */
165 +#if OPENSSL_VERSION_NUMBER < 0x10100000
166 #ifdef OPENSSL_THREADS
167 void (*locking_function)(int mode, int n, const char *file, int line);
168 + #if OPENSSL_VERSION_NUMBER < 0x10000000
169 unsigned long (*id_function)(void);
170 + #else
171 + void (*id_function)(CRYPTO_THREADID *id);
172 + #endif
173 +#endif
174 struct CRYPTO_dynlock_value* (*dyn_create_function)(const char *file,
175 int line);
176 void (*dyn_lock_function)(int mode, struct CRYPTO_dynlock_value* ptr,
177 --- a/lib/crypto/c_src/otp_test_engine.c
178 +++ b/lib/crypto/c_src/otp_test_engine.c
179 @@ -42,8 +42,10 @@
180 && !defined(OPENSSL_NO_EC) \
181 && !defined(OPENSSL_NO_ECDH) \
182 && !defined(OPENSSL_NO_ECDSA)
183 +#if !defined(OPENSSL_NO_ENGINE)
184 # define HAVE_EC
185 #endif
186 +#endif
187
188 #if defined(HAVE_EC)
189 /* If OPENSSL_NO_EC is set, there will be an error in ec.h included from engine.h