summaryrefslogtreecommitdiffstats
path: root/src/gnutls-1-fixes.patch
blob: d4ed07d9f5798a21d16fccd7c5f24994382e731d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
This file is part of MXE.
See index.html for further information.

Contains ad hoc patches for cross building.

From 90387fb055e690a0d47c247f2ec8c2478bc7c942 Mon Sep 17 00:00:00 2001
From: Mark Brand <mabrand@mabrand.nl>
Date: Fri, 28 Oct 2011 09:23:41 +0200
Subject: [PATCH 1/7] add missing static library linking


diff --git a/lib/gnutls.pc.in b/lib/gnutls.pc.in
index c45f8f3..57d0dbb 100644
--- a/lib/gnutls.pc.in
+++ b/lib/gnutls.pc.in
@@ -19,6 +19,6 @@ Description: Transport Security Layer implementation for the GNU system
 URL: http://www.gnu.org/software/gnutls/
 Version: @VERSION@
 Libs: -L${libdir} -lgnutls
-Libs.private: @LTLIBNETTLE@
+Libs.private: @LTLIBNETTLE@ @LIBS@
 @GNUTLS_REQUIRES_PRIVATE@
 Cflags: -I${includedir}
-- 
1.7.10.4


From 622969864d2c2ae3e96572bae6e64e3d585d86eb Mon Sep 17 00:00:00 2001
From: Mark Brand <mabrand@mabrand.nl>
Date: Thu, 24 Nov 2011 15:06:06 +0100
Subject: [PATCH 2/7] disable doc and test (mingw-cross-env specific)


diff --git a/Makefile.am b/Makefile.am
index 2eebb77..1633fcb 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -23,7 +23,7 @@ DISTCHECK_CONFIGURE_FLAGS = --enable-gtk-doc --disable-valgrind-tests
 
 SUBDIRS = gl lib extra po
 
-SUBDIRS += src doc tests
+SUBDIRS += src
 
 if HAVE_GUILE
 SUBDIRS += guile
-- 
1.7.10.4


From 922dd8e34aeedfd2130339b037b92b61840d72eb Mon Sep 17 00:00:00 2001
From: Mark Brand <mabrand@mabrand.nl>
Date: Tue, 3 Apr 2012 13:58:42 +0200
Subject: [PATCH 3/7] Revert "make dist will also make lzip compressed
 tarball"

This reverts commit 97ac1bc58274f651338444693bd75441ba12f46f.

diff --git a/configure.ac b/configure.ac
index ccd2729..8797ec7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -25,7 +25,7 @@ AC_INIT([GnuTLS], [3.1.1], [bug-gnutls@gnu.org])
 AC_CONFIG_AUX_DIR([build-aux])
 AC_CONFIG_MACRO_DIR([m4])
 
-AM_INIT_AUTOMAKE([1.11.3 no-dist-gzip dist-xz dist-lzip -Wall -Werror -Wno-override])
+AM_INIT_AUTOMAKE([1.11.3 no-dist-gzip dist-xz -Wall -Werror -Wno-override])
 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
 AM_CONFIG_HEADER(config.h)
 
-- 
1.7.10.4


From fcd06b20700bbf26b740d1c9d22750c829ef6216 Mon Sep 17 00:00:00 2001
From: Mark Brand <mabrand@mabrand.nl>
Date: Wed, 6 Jun 2012 09:57:24 +0200
Subject: [PATCH 4/7] AM_PROG_AR for automake 1.12 compatibility

Taken from
http://lists.gnu.org/archive/html/automake/2012-05/msg00014.html

diff --git a/configure.ac b/configure.ac
index 8797ec7..fb167f9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -37,6 +37,7 @@ dnl Checks for programs.
 AC_PROG_CC
 AM_PROG_AS
 AC_PROG_CXX
+m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
 gl_EARLY
 
 # For includes/gnutls/gnutls.h.in.
-- 
1.7.10.4


From 6b6c5670a25161c61c6bc24a45ede8a4daf6590b Mon Sep 17 00:00:00 2001
From: Mark Brand <mabrand@mabrand.nl>
Date: Thu, 16 Aug 2012 11:13:47 +0200
Subject: [PATCH 5/7] allow automake warnings not to be errors


diff --git a/configure.ac b/configure.ac
index fb167f9..36b4026 100644
--- a/configure.ac
+++ b/configure.ac
@@ -25,7 +25,7 @@ AC_INIT([GnuTLS], [3.1.1], [bug-gnutls@gnu.org])
 AC_CONFIG_AUX_DIR([build-aux])
 AC_CONFIG_MACRO_DIR([m4])
 
-AM_INIT_AUTOMAKE([1.11.3 no-dist-gzip dist-xz -Wall -Werror -Wno-override])
+AM_INIT_AUTOMAKE([1.11.3 no-dist-gzip dist-xz -Wall -Wno-override])
 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
 AM_CONFIG_HEADER(config.h)
 
-- 
1.7.10.4


From 46635a2529108e077ee2585bd3de5532415cf68b Mon Sep 17 00:00:00 2001
From: Nikos Mavrogiannopoulos <nmav@gnutls.org>
Date: Sat, 15 Sep 2012 13:43:28 +0200
Subject: [PATCH 6/7] mingw32 support. Based on patch by LRN. (cherry picked
 from commit 2cc740eb52abac318176c49f8e8358666c8457cd)


diff --git a/lib/gnutls_global.c b/lib/gnutls_global.c
index 8b84f46..4c9eabf 100644
--- a/lib/gnutls_global.c
+++ b/lib/gnutls_global.c
@@ -270,6 +270,13 @@ gnutls_global_init (void)
       goto out;
     }
 
+  result = gnutls_system_global_init ();
+  if (result < 0)
+    {
+      gnutls_assert ();
+      goto out;
+    }
+
 #ifdef ENABLE_PKCS11
   gnutls_pkcs11_init (GNUTLS_PKCS11_FLAG_AUTO, NULL);
 #endif
@@ -302,6 +309,7 @@ gnutls_global_deinit (void)
       asn1_delete_structure (&_gnutls_pkix1_asn);
       _gnutls_crypto_deregister ();
       _gnutls_cryptodev_deinit ();
+      gnutls_system_global_deinit ();
 #ifdef ENABLE_PKCS11
       gnutls_pkcs11_deinit ();
 #endif
diff --git a/lib/system.c b/lib/system.c
index 067f189..b22e07d 100644
--- a/lib/system.c
+++ b/lib/system.c
@@ -31,6 +31,11 @@
 #ifdef _WIN32
 # include <windows.h>
 # include <wincrypt.h>
+#  if defined(__MINGW32__) && !defined(__MINGW64__) && __MINGW32_MAJOR_VERSION <= 3 && __MINGW32_MINOR_VERSION <= 20
+typedef PCCRL_CONTEXT WINAPI (*Type_CertEnumCRLsInStore) (HCERTSTORE hCertStore, PCCRL_CONTEXT pPrevCrlContext);
+static Type_CertEnumCRLsInStore Loaded_CertEnumCRLsInStore;
+static HMODULE Crypt32_dll;
+#  endif
 
 #else
 # ifdef HAVE_PTHREAD_LOCKS
@@ -51,10 +56,7 @@
 /* System specific function wrappers.
  */
 
-/* wrappers for write() and writev()
- */
 #ifdef _WIN32
-
 int
 system_errno (gnutls_transport_ptr p)
 {
@@ -150,9 +152,6 @@ int fd = GNUTLS_POINTER_TO_INT(ptr);
 /* Thread stuff */
 
 #ifdef HAVE_WIN32_LOCKS
-
-
-/* FIXME: win32 locks are untested */
 static int
 gnutls_system_mutex_init (void **priv)
 {
@@ -285,6 +284,41 @@ mutex_deinit_func gnutls_mutex_deinit = gnutls_system_mutex_deinit;
 mutex_lock_func gnutls_mutex_lock = gnutls_system_mutex_lock;
 mutex_unlock_func gnutls_mutex_unlock = gnutls_system_mutex_unlock;
 
+int
+gnutls_system_global_init ()
+{
+#ifdef _WIN32
+# if defined(__MINGW32__) && !defined(__MINGW64__) && __MINGW32_MAJOR_VERSION <= 3 && __MINGW32_MINOR_VERSION <= 20
+  HMODULE crypto;
+  crypto = LoadLibraryA ("Crypt32.dll");
+
+  if (crypto == NULL)
+    return GNUTLS_E_CRYPTO_INIT_FAILED;
+
+  Loaded_CertEnumCRLsInStore = (Type_CertEnumCRLsInStore) GetProcAddress (crypto, "CertEnumCRLsInStore");
+  if (Loaded_CertEnumCRLsInStore == NULL)
+    {
+      FreeLibrary (crypto);
+      return GNUTLS_E_CRYPTO_INIT_FAILED;
+    }
+
+  Crypt32_dll = crypto;
+# endif
+#endif
+  return 0;
+}
+
+void
+gnutls_system_global_deinit ()
+{
+#ifdef _WIN32
+# if defined(__MINGW32__) && !defined(__MINGW64__) && __MINGW32_MAJOR_VERSION <= 3 && __MINGW32_MINOR_VERSION <= 20
+  FreeLibrary (Crypt32_dll);
+# endif
+#endif
+}
+
+
 #define CONFIG_PATH ".gnutls"
 
 /* Returns a path to store user-specific configuration
@@ -392,7 +426,7 @@ gnutls_x509_trust_list_add_system_trust(gnutls_x509_trust_list_t list,
     if (store == NULL) return GNUTLS_E_FILE_ERROR;
 
     cert = CertEnumCertificatesInStore(store, NULL);
-    crl = CertEnumCRLsInStore(store, NULL);
+    crl = Loaded_CertEnumCRLsInStore(store, NULL);
 
     while(cert != NULL) 
       {
@@ -414,7 +448,7 @@ gnutls_x509_trust_list_add_system_trust(gnutls_x509_trust_list_t list,
             data.size = crl->cbCrlEncoded;
             gnutls_x509_trust_list_add_trust_mem(list, NULL, &data, GNUTLS_X509_FMT_DER, tl_flags, tl_vflags);
           }
-        crl = CertEnumCRLsInStore(store, crl);
+        crl = Loaded_CertEnumCRLsInStore(store, crl);
       }
     CertCloseStore(store, 0);
   }
diff --git a/lib/system.h b/lib/system.h
index 0178bd5..0afbdd2 100644
--- a/lib/system.h
+++ b/lib/system.h
@@ -71,4 +71,7 @@ struct timespec ts;
 
 int _gnutls_find_config_path(char* path, size_t max_size);
 
+int gnutls_system_global_init ();
+void gnutls_system_global_deinit ();
+
 #endif /* SYSTEM_H */
-- 
1.7.10.4


From ee1fab5fb04a698fb50e6ba2b571424ef40ffbbe Mon Sep 17 00:00:00 2001
From: Mark Brand <mabrand@mabrand.nl>
Date: Thu, 20 Sep 2012 12:59:19 +0200
Subject: [PATCH 7/7] add missing libs to Libs.private


diff --git a/lib/gnutls.pc.in b/lib/gnutls.pc.in
index 57d0dbb..02a6ef7 100644
--- a/lib/gnutls.pc.in
+++ b/lib/gnutls.pc.in
@@ -19,6 +19,6 @@ Description: Transport Security Layer implementation for the GNU system
 URL: http://www.gnu.org/software/gnutls/
 Version: @VERSION@
 Libs: -L${libdir} -lgnutls
-Libs.private: @LTLIBNETTLE@ @LIBS@
+Libs.private: @LTLIBNETTLE@ @LIBS@ -lcrypt32 -lws2_32
 @GNUTLS_REQUIRES_PRIVATE@
 Cflags: -I${includedir}
-- 
1.7.10.4