Merges for dll refactor
This commit is contained in:
@@ -73,8 +73,8 @@ CORE_OBJ_FILES=\
|
|||||||
|
|
||||||
|
|
||||||
DRV_OBJ_FILES=\
|
DRV_OBJ_FILES=\
|
||||||
objdrv/drvutil.o\
|
obj/drv/drvutil.o\
|
||||||
objdrv/sslutil.o\
|
obj/drv/sslutil.o\
|
||||||
|
|
||||||
|
|
||||||
-include $(LUA_OBJ_FILES:%.o=%.d)
|
-include $(LUA_OBJ_FILES:%.o=%.d)
|
||||||
@@ -86,8 +86,8 @@ ifeq ($(OS),linux)
|
|||||||
|
|
||||||
OPT=-g -O0
|
OPT=-g -O0
|
||||||
|
|
||||||
main: $(DRV_OBJ_FILES) $(CORE_OBJ_FILES) $(LUA_OBJ_FILES) objdrv/driver-linux.o
|
main: $(DRV_OBJ_FILES) $(CORE_OBJ_FILES) $(LUA_OBJ_FILES) obj/drv/driver-linux.o
|
||||||
g++ -std=c++17 -export-dynamic -Wall $(OPT) -o $@ $(DRV_OBJ_FILES) $(CORE_OBJ_FILES) $(LUA_OBJ_FILES) objdrv/driver-linux.o -L../linuxlib -lssl -lcrypto -ldl
|
g++ -std=c++17 -export-dynamic -Wall $(OPT) -o $@ $(DRV_OBJ_FILES) $(CORE_OBJ_FILES) $(LUA_OBJ_FILES) obj/drv/driver-linux.o -L../linuxlib -lssl -lcrypto -ldl
|
||||||
|
|
||||||
obj/lua/%.o: ../eris-master/src/%.c
|
obj/lua/%.o: ../eris-master/src/%.c
|
||||||
gcc -Wall -fvisibility=hidden $(OPT) -DLUA_USE_APICHECK -DLUA_USE_POSIX -c -MMD $< -o $@
|
gcc -Wall -fvisibility=hidden $(OPT) -DLUA_USE_APICHECK -DLUA_USE_POSIX -c -MMD $< -o $@
|
||||||
@@ -95,13 +95,13 @@ obj/lua/%.o: ../eris-master/src/%.c
|
|||||||
obj/cpp/%.o: cpp/%.cpp
|
obj/cpp/%.o: cpp/%.cpp
|
||||||
g++ -Wall -fvisibility=hidden $(OPT) -std=c++17 -I../linuxlib -I../eris-master/src -Iwrap -Icpp -c -MMD $< -o $@
|
g++ -Wall -fvisibility=hidden $(OPT) -std=c++17 -I../linuxlib -I../eris-master/src -Iwrap -Icpp -c -MMD $< -o $@
|
||||||
|
|
||||||
objdrv/%.o: drv/%.cpp
|
obj/drv/%.o: drv/%.cpp
|
||||||
g++ -Wall -fvisibility=hidden $(OPT) -std=c++17 -I../linuxlib -Idrv -c -MMD $< -o $@
|
g++ -Wall -fvisibility=hidden $(OPT) -std=c++17 -I../linuxlib -Idrv -c -MMD $< -o $@
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f main.exe main obj/cpp/*.* objdrv/*.* obj/lua/*.*
|
rm -f main.exe main obj/cpp/*.* obj/drv/*.* obj/lua/*.*
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ const int INVALID_SOCKET = -1;
|
|||||||
|
|
||||||
struct termios orig_termios;
|
struct termios orig_termios;
|
||||||
|
|
||||||
|
|
||||||
void set_nonblocking(int fd) {
|
void set_nonblocking(int fd) {
|
||||||
int flags = fcntl(fd, F_GETFL, 0);
|
int flags = fcntl(fd, F_GETFL, 0);
|
||||||
assert(flags != -1);
|
assert(flags != -1);
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
#include <filesystem>
|
||||||
|
|
||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
#include <ws2tcpip.h>
|
#include <ws2tcpip.h>
|
||||||
@@ -23,6 +24,20 @@
|
|||||||
#include <openssl/bio.h>
|
#include <openssl/bio.h>
|
||||||
#include <openssl/pem.h>
|
#include <openssl/pem.h>
|
||||||
|
|
||||||
|
// OpenSSL requires plain ascii pathnames. Returns empty string
|
||||||
|
// if the path cannot be converted to plain ascii.
|
||||||
|
std::string path_to_plain_ascii(const std::filesystem::path &path) {
|
||||||
|
std::wstring s = path.native();
|
||||||
|
for (wchar_t c : s) {
|
||||||
|
if ((c < 1) || (c > 127)) return "";
|
||||||
|
}
|
||||||
|
std::ostringstream oss;
|
||||||
|
for (wchar_t c : s) {
|
||||||
|
oss << ((char)c);
|
||||||
|
}
|
||||||
|
return oss.str();
|
||||||
|
}
|
||||||
|
|
||||||
static void set_nonblocking(SOCKET sock) {
|
static void set_nonblocking(SOCKET sock) {
|
||||||
u_long mode = 1; // 1 to enable non-blocking socket
|
u_long mode = 1; // 1 to enable non-blocking socket
|
||||||
int status = ioctlsocket(sock, FIONBIO, &mode);
|
int status = ioctlsocket(sock, FIONBIO, &mode);
|
||||||
|
|||||||
@@ -87,6 +87,14 @@ std::string error_string() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string path_to_plain_ascii(const std::filesystem::path &path) {
|
||||||
|
std::string s = path.native();
|
||||||
|
for (char c : s) {
|
||||||
|
if ((c < 1) || (c > 127)) return "";
|
||||||
|
}
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
void clear_all_errors() {
|
void clear_all_errors() {
|
||||||
ERR_clear_error();
|
ERR_clear_error();
|
||||||
errno = 0;
|
errno = 0;
|
||||||
@@ -162,13 +170,17 @@ void ctx_load_cert_from_directory(SSL_CTX *ctx, const std::string &dir) {
|
|||||||
std::vector<std::string> cert_paths;
|
std::vector<std::string> cert_paths;
|
||||||
|
|
||||||
for (const auto & entry : std::filesystem::directory_iterator(dir)) {
|
for (const auto & entry : std::filesystem::directory_iterator(dir)) {
|
||||||
std::string fn = entry.path();
|
std::string fn = path_to_plain_ascii(entry.path());
|
||||||
if (count_certificates(fn.c_str()) >= 1) {
|
if (fn.empty()) {
|
||||||
cert_paths.push_back(fn);
|
std::cerr << "Ignoring file with non-ascii filename: " << entry.path() << std::endl;
|
||||||
}
|
} else {
|
||||||
if (contains_privatekey(fn.c_str())) {
|
if (count_certificates(fn.c_str()) >= 1) {
|
||||||
key_paths.push_back(fn);
|
cert_paths.push_back(fn);
|
||||||
}
|
}
|
||||||
|
if (contains_privatekey(fn.c_str())) {
|
||||||
|
key_paths.push_back(fn);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cert_paths.size() > 1) {
|
if (cert_paths.size() > 1) {
|
||||||
|
|||||||
Reference in New Issue
Block a user