170 lines
4.5 KiB
Diff
170 lines
4.5 KiB
Diff
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
|
index 8437e02..1316f2e 100644
|
|
--- a/CMakeLists.txt
|
|
+++ b/CMakeLists.txt
|
|
@@ -123,6 +123,7 @@ add_definitions(-DLIBRESSL_INTERNAL)
|
|
add_definitions(-DOPENSSL_NO_HW_PADLOCK)
|
|
add_definitions(-D__BEGIN_HIDDEN_DECLS=)
|
|
add_definitions(-D__END_HIDDEN_DECLS=)
|
|
+add_definitions(-DOPENSSLBIN=\"${CMAKE_INSTALL_FULL_BINDIR}\")
|
|
|
|
set(CMAKE_POSITION_INDEPENDENT_CODE true)
|
|
|
|
diff --git a/Makefile.am.common b/Makefile.am.common
|
|
index 5405704..a166c15 100644
|
|
--- a/Makefile.am.common
|
|
+++ b/Makefile.am.common
|
|
@@ -3,3 +3,4 @@ AM_CPPFLAGS = -I$(top_srcdir)/include
|
|
AM_CPPFLAGS += -I$(abs_top_builddir)/include
|
|
AM_CPPFLAGS += -I$(top_srcdir)/include/compat -DLIBRESSL_INTERNAL
|
|
AM_CPPFLAGS += -D__BEGIN_HIDDEN_DECLS= -D__END_HIDDEN_DECLS=
|
|
+AM_CPPFLAGS += -DOPENSSLBIN=\"$(bindir)\"
|
|
diff --git a/crypto/CMakeLists.txt b/crypto/CMakeLists.txt
|
|
index 64bccd8..aebb0d0 100644
|
|
--- a/crypto/CMakeLists.txt
|
|
+++ b/crypto/CMakeLists.txt
|
|
@@ -584,6 +584,8 @@ if(WIN32)
|
|
set(CRYPTO_SRC ${CRYPTO_SRC} ui/ui_openssl_win.c)
|
|
endif()
|
|
|
|
+set(CRYPTO_SRC ${CRYPTO_SRC} pathtools.c)
|
|
+
|
|
if(WIN32)
|
|
set(COMPAT_SRC ${COMPAT_SRC} compat/posix_win.c)
|
|
endif()
|
|
diff --git a/crypto/Makefile.am b/crypto/Makefile.am
|
|
index d1c5b76..c7e64dd 100644
|
|
--- a/crypto/Makefile.am
|
|
+++ b/crypto/Makefile.am
|
|
@@ -237,6 +237,10 @@ noinst_HEADERS += crypto_internal.h
|
|
noinst_HEADERS += crypto_local.h
|
|
noinst_HEADERS += x86_arch.h
|
|
|
|
+# pathtools
|
|
+libcrypto_la_SOURCES += pathtools.c
|
|
+noinst_HEADERS += pathtools.h
|
|
+
|
|
# aes
|
|
libcrypto_la_SOURCES += aes/aes.c
|
|
libcrypto_la_SOURCES += aes/aes_core.c
|
|
diff --git a/crypto/ct/ct_log.c b/crypto/ct/ct_log.c
|
|
index 7204547..47a4efd 100644
|
|
--- a/crypto/ct/ct_log.c
|
|
+++ b/crypto/ct/ct_log.c
|
|
@@ -72,6 +72,7 @@
|
|
|
|
#include "conf_local.h"
|
|
#include "crypto_local.h"
|
|
+#include "pathtools.h"
|
|
|
|
|
|
/*
|
|
@@ -202,7 +203,10 @@ ctlog_new_from_conf(CTLOG **ct_log, const CONF *conf, const char *section)
|
|
int
|
|
CTLOG_STORE_load_default_file(CTLOG_STORE *store)
|
|
{
|
|
- return CTLOG_STORE_load_file(store, CTLOG_FILE);
|
|
+ char *reloc = single_path_relocation_lib(OPENSSLBIN, CTLOG_FILE);
|
|
+ int ret = CTLOG_STORE_load_file(store, reloc);
|
|
+ free(reloc);
|
|
+ return ret;
|
|
}
|
|
LCRYPTO_ALIAS(CTLOG_STORE_load_default_file);
|
|
|
|
diff --git a/crypto/x509/x509_def.c b/crypto/x509/x509_def.c
|
|
index f9b395c..45d0bd8 100644
|
|
--- a/crypto/x509/x509_def.c
|
|
+++ b/crypto/x509/x509_def.c
|
|
@@ -59,6 +59,41 @@
|
|
#include <openssl/x509.h>
|
|
|
|
#include "crypto_local.h"
|
|
+#include "pathtools.h"
|
|
+
|
|
+static char *x509_private_dir;
|
|
+static char *x509_cert_area;
|
|
+static char *x509_cert_dir;
|
|
+static char *x509_cert_file;
|
|
+
|
|
+__attribute__((constructor)) static void
|
|
+do_setup_msys2(void)
|
|
+{
|
|
+ x509_private_dir =
|
|
+ single_path_relocation_lib(OPENSSLBIN, X509_PRIVATE_DIR);
|
|
+ x509_cert_area = single_path_relocation_lib(OPENSSLBIN, X509_CERT_AREA);
|
|
+ x509_cert_dir = single_path_relocation_lib(OPENSSLBIN, X509_CERT_DIR);
|
|
+ x509_cert_file = single_path_relocation_lib(OPENSSLBIN, X509_CERT_FILE);
|
|
+}
|
|
+
|
|
+__attribute__((destructor)) static void
|
|
+do_cleanup_msys2(void)
|
|
+{
|
|
+ free(x509_private_dir);
|
|
+ free(x509_cert_area);
|
|
+ free(x509_cert_dir);
|
|
+ free(x509_cert_file);
|
|
+}
|
|
+
|
|
+/* redefine these macros as relocated path */
|
|
+#undef X509_PRIVATE_DIR
|
|
+#undef X509_CERT_AREA
|
|
+#undef X509_CERT_DIR
|
|
+#undef X509_CERT_FILE
|
|
+#define X509_PRIVATE_DIR x509_private_dir
|
|
+#define X509_CERT_AREA x509_cert_area
|
|
+#define X509_CERT_DIR x509_cert_dir
|
|
+#define X509_CERT_FILE x509_cert_file
|
|
|
|
const char *
|
|
X509_get_default_private_dir(void)
|
|
diff --git a/tls/CMakeLists.txt b/tls/CMakeLists.txt
|
|
index c81bbb0..36218bc 100644
|
|
--- a/tls/CMakeLists.txt
|
|
+++ b/tls/CMakeLists.txt
|
|
@@ -1,5 +1,6 @@
|
|
set(
|
|
TLS_SRC
|
|
+ pathtools.c
|
|
tls.c
|
|
tls_bio_cb.c
|
|
tls_client.c
|
|
diff --git a/tls/Makefile.am b/tls/Makefile.am
|
|
index 22f3222..a00b1fe 100644
|
|
--- a/tls/Makefile.am
|
|
+++ b/tls/Makefile.am
|
|
@@ -59,3 +59,7 @@ libtls_la_SOURCES += compat/ftruncate.c
|
|
libtls_la_SOURCES += compat/pread.c
|
|
libtls_la_SOURCES += compat/pwrite.c
|
|
endif
|
|
+
|
|
+# pathtools
|
|
+libtls_la_SOURCES += pathtools.c
|
|
+noinst_HEADERS += pathtools.h
|
|
diff --git a/tls/tls_config.c b/tls/tls_config.c
|
|
index 5774d40..c1c25db 100644
|
|
--- a/tls/tls_config.c
|
|
+++ b/tls/tls_config.c
|
|
@@ -29,7 +29,21 @@
|
|
|
|
#include "tls_internal.h"
|
|
|
|
-static const char default_ca_file[] = TLS_DEFAULT_CA_FILE;
|
|
+#include "pathtools.h"
|
|
+
|
|
+static char *default_ca_file;
|
|
+
|
|
+__attribute__((constructor)) static void
|
|
+do_setup_msys2(void)
|
|
+{
|
|
+ default_ca_file = single_path_relocation_lib(OPENSSLBIN, TLS_DEFAULT_CA_FILE);
|
|
+}
|
|
+
|
|
+__attribute__((destructor)) static void
|
|
+do_cleanup_msys2(void)
|
|
+{
|
|
+ free(default_ca_file);
|
|
+}
|
|
|
|
const char *
|
|
tls_default_ca_cert_file(void)
|