1- From 9bc4150738ef5d92b0050f8539758c8f03335442 Mon Sep 17 00:00:00 2001
1+ From 80b680d4796d1ce913185dbaf4c36c6a64669e86 Mon Sep 17 00:00:00 2001
22From: Ray Donnelly <
[email protected] >
33Date: Wed, 22 Feb 2017 11:03:04 +0100
44Subject: [PATCH 1/2] Make cURL relocatable
2525 configure.ac | 1 +
2626 lib/Makefile.inc | 2 ++
2727 lib/curl_config.h.in | 3 +++
28- lib/url .c | 38 ++++++++++++++++++++++++++++++++++++++
29- 4 files changed, 44 insertions(+)
28+ lib/vtls/vtls .c | 49 ++++++ ++++++++++++++++++++++++++++++++++++++
29+ 4 files changed, 55 insertions(+)
3030
3131diff --git a/configure.ac b/configure.ac
32- index aba3d82af..2d30abb2c 100644
32+ index cc16f4120..827d04948 100644
3333--- a/configure.ac
3434+++ b/configure.ac
35- @@ -4027 ,6 +4027 ,7 @@ dnl default includes
35+ @@ -4069 ,6 +4069 ,7 @@ dnl default includes
3636 ]
3737 )
3838
@@ -41,18 +41,18 @@ index aba3d82af..2d30abb2c 100644
4141 dnl Checks for typedefs, structures, and compiler characteristics.
4242 AC_C_CONST
4343diff --git a/lib/Makefile.inc b/lib/Makefile.inc
44- index b384e0962..216fec947 100644
44+ index 8b506febc..841e8a7ea 100644
4545--- a/lib/Makefile.inc
4646+++ b/lib/Makefile.inc
47- @@ -225 ,6 +225 ,7 @@ LIB_CFILES = \
47+ @@ -229 ,6 +229 ,7 @@ LIB_CFILES = \
4848 noproxy.c \
4949 openldap.c \
5050 parsedate.c \
5151+ pathtools.c \
5252 pingpong.c \
5353 pop3.c \
5454 progress.c \
55- @@ -357 ,6 +358 ,7 @@ LIB_HFILES = \
55+ @@ -361 ,6 +362 ,7 @@ LIB_HFILES = \
5656 netrc.h \
5757 noproxy.h \
5858 parsedate.h \
@@ -61,7 +61,7 @@ index b384e0962..216fec947 100644
6161 pop3.h \
6262 progress.h \
6363diff --git a/lib/curl_config.h.in b/lib/curl_config.h.in
64- index 87d60a274..990895776 100644
64+ index 668be5ea1..9c3139764 100644
6565--- a/lib/curl_config.h.in
6666+++ b/lib/curl_config.h.in
6767@@ -14,6 +14,9 @@
@@ -74,75 +74,105 @@ index 87d60a274..990895776 100644
7474 /* Default SSL backend */
7575 #undef CURL_DEFAULT_SSL_BACKEND
7676
77- diff --git a/lib/url .c b/lib/url .c
78- index dac24b35e..6fe831e1e 100644
79- --- a/lib/url .c
80- +++ b/lib/url .c
81- @@ -121 ,6 +121,9 @@
82- #include "curlx/dynbuf.h"
83- #include "headers.h"
84- #include "curlx/strparse.h"
77+ diff --git a/lib/vtls/vtls .c b/lib/vtls/vtls .c
78+ index df0449cbe..bb45551b0 100644
79+ --- a/lib/vtls/vtls .c
80+ +++ b/lib/vtls/vtls .c
81+ @@ -81 ,6 +81,10 @@
82+ #include <Security/Security.h>
83+ #endif
84+
8585+ #if defined(__MINGW32__)
86- + #include "pathtools.h"
86+ + #include "../ pathtools.h"
8787+ #endif
88- /* The last 3 #include files should be in this order */
89- #include "curl_printf.h"
90- #include "curl_memory.h"
91- @@ -430,22 +433,57 @@ CURLcode Curl_init_userdefined(struct Curl_easy *data)
92- if(Curl_ssl_backend() != CURLSSLBACKEND_SCHANNEL &&
93- Curl_ssl_backend() != CURLSSLBACKEND_SECURETRANSPORT) {
94- #ifdef CURL_CA_BUNDLE
88+ +
89+ /* The last #include files should be: */
90+ #include "../curl_memory.h"
91+ #include "../memdebug.h"
92+ @@ -297,6 +301,15 @@ CURLcode Curl_ssl_easy_config_complete(struct Curl_easy *data)
93+ #if defined(CURL_CA_PATH) || defined(CURL_CA_BUNDLE)
94+ struct UserDefined *set = &data->set;
95+ CURLcode result;
9596+ #ifdef __MINGW32__
9697+ const size_t path_max = PATH_MAX;
98+ + #ifdef CURL_CA_PATH
99+ + char relocated_ca_path[path_max];
100+ + #endif
101+ + #ifdef CURL_CA_BUNDLE
97102+ char relocated_bundle[path_max];
98- + get_dll_path(relocated_bundle, path_max);
99- + strip_n_suffix_folders(relocated_bundle, 1);
100- + strncat(relocated_bundle, "/", path_max - 1);
101- + char *relative = get_relative_path(CURL_BINDIR, CURL_CA_BUNDLE);
102- + strncat(relocated_bundle, relative, path_max - 1);
103- + free((void*)relative);
104- + simplify_path(relocated_bundle);
105- + result = Curl_setstropt(&set->str[STRING_SSL_CAFILE], relocated_bundle);
106- + #else
107- result = Curl_setstropt(&set->str[STRING_SSL_CAFILE], CURL_CA_BUNDLE);
108- + #endif /* defined(__MINGW32__) */
109- if(result)
110- return result;
111- #ifndef CURL_DISABLE_PROXY
112- + #if defined(__MINGW32__)
113- + result = Curl_setstropt(&set->str[STRING_SSL_CAFILE_PROXY],
114- + relocated_bundle);
115- + #else
116- result = Curl_setstropt(&set->str[STRING_SSL_CAFILE_PROXY],
117- CURL_CA_BUNDLE);
118103+ #endif
119- if(result)
120- return result;
104+ + #endif /* defined(__MINGW32__) */
121105 #endif
106+
107+ if(Curl_ssl_backend() != CURLSSLBACKEND_SCHANNEL) {
108+ @@ -305,16 +318,42 @@ CURLcode Curl_ssl_easy_config_complete(struct Curl_easy *data)
109+ sslc->native_ca_store = TRUE;
122110 #endif
123111 #ifdef CURL_CA_PATH
124112+ #ifdef __MINGW32__
125- + const size_t path_max = PATH_MAX;
126- + char relocated_ca_path[path_max];
127113+ get_dll_path(relocated_ca_path, path_max);
128114+ strip_n_suffix_folders(relocated_ca_path, 1);
129115+ strncat(relocated_ca_path, "/", path_max - 1);
130116+ char *relative = get_relative_path(CURL_BINDIR, CURL_CA_PATH);
131117+ strncat(relocated_ca_path, relative, path_max - 1);
132118+ free((void*)relative);
133119+ simplify_path(relocated_ca_path);
134- + result = Curl_setstropt(&set->str[STRING_SSL_CAPATH], relocated_ca_path);
120+ + #endif /* defined(__MINGW32__) */
121+ if(!sslc->custom_capath && !set->str[STRING_SSL_CAPATH]) {
122+ + #ifdef __MINGW32__
123+ + result = Curl_setstropt(&set->str[STRING_SSL_CAPATH], relocated_ca_path);
135124+ #else
136- result = Curl_setstropt(&set->str[STRING_SSL_CAPATH], CURL_CA_PATH);
125+ result = Curl_setstropt(&set->str[STRING_SSL_CAPATH], CURL_CA_PATH);
137126+ #endif /* defined(__MINGW32__) */
138- if(result)
139- return result;
140- #ifndef CURL_DISABLE_PROXY
141- + #if defined(__MINGW32__)
142- + result = Curl_setstropt(&set->str[STRING_SSL_CAPATH_PROXY], relocated_ca_path);
127+ if(result)
128+ return result;
129+ }
130+ sslc->primary.CApath = data->set.str[STRING_SSL_CAPATH];
131+ #endif
132+ #ifdef CURL_CA_BUNDLE
133+ + #ifdef __MINGW32__
134+ + get_dll_path(relocated_bundle, path_max);
135+ + strip_n_suffix_folders(relocated_bundle, 1);
136+ + strncat(relocated_bundle, "/", path_max - 1);
137+ + char *relative = get_relative_path(CURL_BINDIR, CURL_CA_BUNDLE);
138+ + strncat(relocated_bundle, relative, path_max - 1);
139+ + free((void*)relative);
140+ + simplify_path(relocated_bundle);
141+ + #endif /* defined(__MINGW32__) */
142+ if(!sslc->custom_cafile && !set->str[STRING_SSL_CAFILE]) {
143+ + #ifdef __MINGW32__
144+ + result = Curl_setstropt(&set->str[STRING_SSL_CAFILE], relocated_bundle);
143145+ #else
144- result = Curl_setstropt(&set->str[STRING_SSL_CAPATH_PROXY], CURL_CA_PATH);
145- + #endif
146- if(result)
147- return result;
146+ result = Curl_setstropt(&set->str[STRING_SSL_CAFILE], CURL_CA_BUNDLE);
147+ + #endif /* defined(__MINGW32__) */
148+ if(result)
149+ return result;
150+ }
151+ @@ -353,8 +392,13 @@ CURLcode Curl_ssl_easy_config_complete(struct Curl_easy *data)
148152 #endif
153+ #ifdef CURL_CA_PATH
154+ if(!sslc->custom_capath && !set->str[STRING_SSL_CAPATH_PROXY]) {
155+ + #ifdef __MINGW32__
156+ + result = Curl_setstropt(&set->str[STRING_SSL_CAPATH_PROXY],
157+ + relocated_ca_path);
158+ + #else
159+ result = Curl_setstropt(&set->str[STRING_SSL_CAPATH_PROXY],
160+ CURL_CA_PATH);
161+ + #endif /* defined(__MINGW32__) */
162+ if(result)
163+ return result;
164+ }
165+ @@ -362,8 +406,13 @@ CURLcode Curl_ssl_easy_config_complete(struct Curl_easy *data)
166+ #endif
167+ #ifdef CURL_CA_BUNDLE
168+ if(!sslc->custom_cafile && !set->str[STRING_SSL_CAFILE_PROXY]) {
169+ + #ifdef __MINGW32__
170+ + result = Curl_setstropt(&set->str[STRING_SSL_CAFILE_PROXY],
171+ + relocated_bundle);
172+ + #else
173+ result = Curl_setstropt(&set->str[STRING_SSL_CAFILE_PROXY],
174+ CURL_CA_BUNDLE);
175+ + #endif /* defined(__MINGW32__) */
176+ if(result)
177+ return result;
178+ }
0 commit comments