Just like `mingw-w64-curl`, `mingw-w64-openssl` is now also built with a literal copy of `mingw-w64-pathtools`' source code. This adds the `get_dll_path()` function (which is unused by the `openssl` code), and it also forward-ports the patch where we now preserve UNC paths when normalizing/simplifying paths. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
111 lines
3.4 KiB
Diff
111 lines
3.4 KiB
Diff
diff --git a/crypto/build.info b/crypto/build.info
|
|
index b515b7318e..f090ff458d 100644
|
|
--- a/crypto/build.info
|
|
+++ b/crypto/build.info
|
|
@@ -1,7 +1,7 @@
|
|
LIBS=../libcrypto
|
|
SOURCE[../libcrypto]=\
|
|
cryptlib.c mem.c mem_dbg.c cversion.c ex_data.c cpt_err.c \
|
|
- ebcdic.c uid.c o_time.c o_str.c o_dir.c o_fopen.c ctype.c \
|
|
+ ebcdic.c uid.c o_time.c o_str.c o_dir.c o_fopen.c pathtools.c ctype.c \
|
|
threads_pthread.c threads_win.c threads_none.c getenv.c \
|
|
o_init.c o_fips.c mem_sec.c init.c {- $target{cpuid_asm_src} -} \
|
|
{- $target{uplink_aux_src} -}
|
|
diff --git a/crypto/engine/eng_list.c b/crypto/engine/eng_list.c
|
|
index 4bc7ea173c..5f881fb2cb 100644
|
|
--- a/crypto/engine/eng_list.c
|
|
+++ b/crypto/engine/eng_list.c
|
|
@@ -9,6 +9,7 @@
|
|
*/
|
|
|
|
#include "eng_local.h"
|
|
+#include "pathtools.h"
|
|
|
|
/*
|
|
* The linked-list of pointers to engine types. engine_list_head incorporates
|
|
@@ -30,6 +31,20 @@ static ENGINE *engine_list_tail = NULL;
|
|
* cleanup.
|
|
*/
|
|
|
|
+char * enginedir_relocation(const char *path)
|
|
+{
|
|
+ char exe_path[PATH_MAX];
|
|
+ get_executable_path (NULL, &exe_path[0], sizeof(exe_path)/sizeof(exe_path[0]));
|
|
+ if (strrchr (exe_path, '/') != NULL)
|
|
+ {
|
|
+ strrchr (exe_path, '/')[1] = '\0';
|
|
+ }
|
|
+ char * rel_to_datadir = get_relative_path (OPENSSLBIN, path);
|
|
+ strcat (exe_path, rel_to_datadir);
|
|
+ simplify_path (&exe_path[0]);
|
|
+ return malloc_copy_string(exe_path);
|
|
+}
|
|
+
|
|
static void engine_list_cleanup(void)
|
|
{
|
|
ENGINE *iterator = engine_list_head;
|
|
@@ -318,8 +333,10 @@ ENGINE *ENGINE_by_id(const char *id)
|
|
* Prevent infinite recursion if we're looking for the dynamic engine.
|
|
*/
|
|
if (strcmp(id, "dynamic")) {
|
|
- if ((load_dir = ossl_safe_getenv("OPENSSL_ENGINES")) == NULL)
|
|
- load_dir = ENGINESDIR;
|
|
+ if ((load_dir = ossl_safe_getenv("OPENSSL_ENGINES")) == NULL) {
|
|
+ const char * reloc_engines = enginedir_relocation(ENGINESDIR);
|
|
+ load_dir = reloc_engines;
|
|
+ }
|
|
iterator = ENGINE_by_id("dynamic");
|
|
if (!iterator || !ENGINE_ctrl_cmd_string(iterator, "ID", id, 0) ||
|
|
!ENGINE_ctrl_cmd_string(iterator, "DIR_LOAD", "2", 0) ||
|
|
diff --git a/crypto/x509/x509_def.c b/crypto/x509/x509_def.c
|
|
index bfa8d7d852..6fcc1b021a 100644
|
|
--- a/crypto/x509/x509_def.c
|
|
+++ b/crypto/x509/x509_def.c
|
|
@@ -9,27 +9,42 @@
|
|
|
|
#include <stdio.h>
|
|
#include "internal/cryptlib.h"
|
|
+#include "pathtools.h"
|
|
#include <openssl/crypto.h>
|
|
#include <openssl/x509.h>
|
|
|
|
+char * openssl_relocation(const char *path)
|
|
+{
|
|
+ char exe_path[PATH_MAX];
|
|
+ get_executable_path (NULL, &exe_path[0], sizeof(exe_path)/sizeof(exe_path[0]));
|
|
+ if (strrchr (exe_path, '/') != NULL)
|
|
+ {
|
|
+ strrchr (exe_path, '/')[1] = '\0';
|
|
+ }
|
|
+ char * rel_to_datadir = get_relative_path (OPENSSLBIN, path);
|
|
+ strcat (exe_path, rel_to_datadir);
|
|
+ simplify_path (&exe_path[0]);
|
|
+ return malloc_copy_string(exe_path);
|
|
+}
|
|
+
|
|
const char *X509_get_default_private_dir(void)
|
|
{
|
|
- return X509_PRIVATE_DIR;
|
|
+ return openssl_relocation(X509_PRIVATE_DIR);
|
|
}
|
|
|
|
const char *X509_get_default_cert_area(void)
|
|
{
|
|
- return X509_CERT_AREA;
|
|
+ return openssl_relocation(X509_CERT_AREA);
|
|
}
|
|
|
|
const char *X509_get_default_cert_dir(void)
|
|
{
|
|
- return X509_CERT_DIR;
|
|
+ return openssl_relocation(X509_CERT_DIR);
|
|
}
|
|
|
|
const char *X509_get_default_cert_file(void)
|
|
{
|
|
- return X509_CERT_FILE;
|
|
+ return openssl_relocation(X509_CERT_FILE);
|
|
}
|
|
|
|
const char *X509_get_default_cert_dir_env(void)
|