diff --git a/.onedev-buildspec.yml b/.onedev-buildspec.yml index dc7bef6..63126cc 100644 --- a/.onedev-buildspec.yml +++ b/.onedev-buildspec.yml @@ -25,7 +25,7 @@ jobs: name: Build Docker Image dockerfile: Dockerfile.run output: !RegistryOutput - tags: onedev.site.tesses.net/tesses-framework/tesses-framework:latest + tags: onedev.site.tesses.net/tesses-framework/tesses-framework:latest onedev.site.tesses.net/tesses-framework/tesses-framework:@commit_hash@ registryLogins: - registryUrl: '@server_url@' userName: '@job_token@' diff --git a/CMakeLists.txt b/CMakeLists.txt index 8483da5..b3e037c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -51,8 +51,8 @@ src/Filesystem/NullFilesystem.cpp src/Filesystem/MountableFilesystem.cpp src/Filesystem/FSHelpers.cpp src/Filesystem/TempFS.cpp -src/Crypto/ClientTLSStream.cpp -src/Crypto/MbedHelpers.cpp +src/Crypto/MbedTLS/ClientTLSStream.cpp +src/Crypto/MbedTLS/Crypto.cpp src/Args.cpp src/TF_Init.cpp src/HiddenField.cpp diff --git a/include/TessesFramework/Crypto/ClientTLSStream.hpp b/include/TessesFramework/Crypto/ClientTLSStream.hpp index 78176e1..b469501 100644 --- a/include/TessesFramework/Crypto/ClientTLSStream.hpp +++ b/include/TessesFramework/Crypto/ClientTLSStream.hpp @@ -6,8 +6,6 @@ namespace Tesses::Framework::Crypto { class ClientTLSStream : public Tesses::Framework::Streams::Stream { void* privateData; - static int strm_send(void* ctx,const unsigned char* buf,size_t len); - static int strm_recv(void* ctx,unsigned char* buf,size_t len); public: static std::string GetCertChain(); diff --git a/include/TessesFramework/Crypto/MbedHelpers.hpp b/include/TessesFramework/Crypto/Crypto.hpp similarity index 100% rename from include/TessesFramework/Crypto/MbedHelpers.hpp rename to include/TessesFramework/Crypto/Crypto.hpp diff --git a/include/TessesFramework/Filesystem/VFS.hpp b/include/TessesFramework/Filesystem/VFS.hpp index 76cad32..13fd84f 100644 --- a/include/TessesFramework/Filesystem/VFS.hpp +++ b/include/TessesFramework/Filesystem/VFS.hpp @@ -29,8 +29,7 @@ namespace Tesses::Framework::Filesystem static std::vector SplitPath(std::string path); std::vector path; VFSPath(); - VFSPath(const char* path) : VFSPath((std::string)path) - {} + VFSPath(std::vector path); VFSPath(std::string path); VFSPath(VFSPath p, std::string subent); @@ -61,9 +60,17 @@ namespace Tesses::Framework::Filesystem VFSPath MakeRelative(VFSPath toMakeRelativeTo) const; }; VFSPath operator/(VFSPath p, VFSPath p2); + VFSPath operator/(VFSPath p, std::string p2); + VFSPath operator/(std::string p, VFSPath p2); VFSPath operator+(VFSPath p, VFSPath p2); + VFSPath operator+(VFSPath p, std::string p2); + VFSPath operator+(std::string p, VFSPath p2); bool operator==(VFSPath p,VFSPath p2); bool operator!=(VFSPath p,VFSPath p2); + bool operator==(std::string p,VFSPath p2); + bool operator!=(std::string p,VFSPath p2); + bool operator==(VFSPath p,std::string p2); + bool operator!=(VFSPath p,std::string p2); class VFSPathEnumeratorData { public: VFSPathEnumeratorData(std::function moveNext, std::function destroy) diff --git a/include/TessesFramework/TessesFramework.hpp b/include/TessesFramework/TessesFramework.hpp index f522f9b..07dbaf7 100644 --- a/include/TessesFramework/TessesFramework.hpp +++ b/include/TessesFramework/TessesFramework.hpp @@ -31,7 +31,7 @@ #include "Filesystem/MemoryFilesystem.hpp" #include "Filesystem/FSHelpers.hpp" #include "Crypto/ClientTLSStream.hpp" -#include "Crypto/MbedHelpers.hpp" +#include "Crypto/Crypto.hpp" #include "Lazy.hpp" #include "Mail/Smtp.hpp" #include "HiddenField.hpp" diff --git a/pkgconfig/CMakeLists.txt b/pkgconfig/CMakeLists.txt index bcb667f..40847b9 100644 --- a/pkgconfig/CMakeLists.txt +++ b/pkgconfig/CMakeLists.txt @@ -10,12 +10,16 @@ else() set(PKGCONFIG_DEPS "") endif() +if(TESSESFRAMEWORK_ENABLE_STATIC) configure_file(tessesframework_static.pc.in tessesframework_static.pc @ONLY) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/tessesframework_static.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) +endif() +if(TESSESFRAMEWORK_ENABLE_SHARED) configure_file(tessesframework.pc.in tessesframework.pc @ONLY) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/tessesframework.pc - DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) \ No newline at end of file + DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) +endif() \ No newline at end of file diff --git a/src/Crypto/ClientTLSStream.cpp b/src/Crypto/MbedTLS/ClientTLSStream.cpp similarity index 92% rename from src/Crypto/ClientTLSStream.cpp rename to src/Crypto/MbedTLS/ClientTLSStream.cpp index 9c2ebc0..b486f3e 100644 --- a/src/Crypto/ClientTLSStream.cpp +++ b/src/Crypto/MbedTLS/ClientTLSStream.cpp @@ -41,7 +41,20 @@ namespace Tesses::Framework::Crypto mbedtls_ssl_free(&ssl); } }; + static int strm_send(void* ctx,const unsigned char* buf,size_t len) + { + auto priv = static_cast(ctx); + return (int)priv->strm->Write(buf, len); + + } + static int strm_recv(void* ctx,unsigned char* buf,size_t len) + { + auto priv = static_cast(ctx); + return (int)priv->strm->Read(buf, len); + + } #endif + std::string ClientTLSStream::GetCertChain() { #if defined(TESSESFRAMEWORK_ENABLE_MBED) @@ -88,16 +101,7 @@ namespace Tesses::Framework::Crypto int ret=0; -/* -#if defined(MBEDTLS_USE_PSA_CRYPTO) - psa_status_t status = psa_crypto_init(); - if (status != PSA_SUCCESS) { - mbedtls_fprintf(stderr, "Failed to initialize PSA Crypto implementation: %d\n", - (int) status); - return; - } -#endif -*/ + if ((ret = mbedtls_ctr_drbg_seed(&data->ctr_drbg, mbedtls_entropy_func, &data->entropy, (const unsigned char *) pers, strlen(pers))) != 0) @@ -209,24 +213,7 @@ namespace Tesses::Framework::Crypto return (size_t)0; #endif } - int ClientTLSStream::strm_send(void* ctx,const unsigned char* buf,size_t len) - { - #if defined(TESSESFRAMEWORK_ENABLE_MBED) - auto priv = static_cast(ctx); - return (int)priv->strm->Write(buf, len); - #else - return 0; - #endif - } - int ClientTLSStream::strm_recv(void* ctx,unsigned char* buf,size_t len) - { - #if defined(TESSESFRAMEWORK_ENABLE_MBED) - auto priv = static_cast(ctx); - return (int)priv->strm->Read(buf, len); - #else - return 0; - #endif - } + bool ClientTLSStream::CanRead() { #if defined(TESSESFRAMEWORK_ENABLE_MBED) diff --git a/src/Crypto/MbedHelpers.cpp b/src/Crypto/MbedTLS/Crypto.cpp similarity index 99% rename from src/Crypto/MbedHelpers.cpp rename to src/Crypto/MbedTLS/Crypto.cpp index 4502279..5b7f493 100644 --- a/src/Crypto/MbedHelpers.cpp +++ b/src/Crypto/MbedTLS/Crypto.cpp @@ -1,4 +1,4 @@ -#include "TessesFramework/Crypto/MbedHelpers.hpp" +#include "TessesFramework/Crypto/Crypto.hpp" #if defined(TESSESFRAMEWORK_ENABLE_MBED) #include diff --git a/src/Filesystem/VFS.cpp b/src/Filesystem/VFS.cpp index 465079b..4af15a2 100644 --- a/src/Filesystem/VFS.cpp +++ b/src/Filesystem/VFS.cpp @@ -107,11 +107,18 @@ namespace Tesses::Framework::Filesystem { return VFSPathEnumeratorItterator(); } - VFSPath operator/(VFSPath p, VFSPath p2) + VFSPath operator/(VFSPath p, VFSPath p2) + { + return VFSPath(p,p2); + } + VFSPath operator/(VFSPath p, std::string p2) + { + return VFSPath(p,p2); + } + VFSPath operator/(std::string p, VFSPath p2) { return VFSPath(p,p2); } - VFSPath operator+(VFSPath p, VFSPath p2) { VFSPath pout; @@ -139,7 +146,14 @@ namespace Tesses::Framework::Filesystem return pout; } - + VFSPath operator+(VFSPath p, std::string p2) + { + return p + VFSPath(p2); + } + VFSPath operator+(std::string p, VFSPath p2) + { + return VFSPath(p) + p2; + } bool operator==(VFSPath p,VFSPath p2) { if(p.relative != p2.relative) return false; @@ -157,6 +171,22 @@ namespace Tesses::Framework::Filesystem return false; } + bool operator==(std::string p,VFSPath p2) + { + return VFSPath(p) == p2; + } + bool operator!=(std::string p,VFSPath p2) + { + return VFSPath(p) != p2; + } + bool operator==(VFSPath p,std::string p2) + { + return p == VFSPath(p2); + } + bool operator!=(VFSPath p,std::string p2) + { + return p != VFSPath(p2); + } VFSPath VFS::ReadLink(VFSPath path) { return VFSPath("/"); diff --git a/src/Http/HttpClient.cpp b/src/Http/HttpClient.cpp index 7387140..7bc3827 100644 --- a/src/Http/HttpClient.cpp +++ b/src/Http/HttpClient.cpp @@ -1,6 +1,6 @@ #include "TessesFramework/Http/HttpClient.hpp" #include "TessesFramework/Crypto/ClientTLSStream.hpp" -#include "TessesFramework/Crypto/MbedHelpers.hpp" +#include "TessesFramework/Crypto/Crypto.hpp" #include "TessesFramework/Streams/NetworkStream.hpp" #include "TessesFramework/TextStreams/StreamWriter.hpp" #include "TessesFramework/TextStreams/StreamReader.hpp" diff --git a/src/Http/HttpServer.cpp b/src/Http/HttpServer.cpp index a32bb22..ed3c03d 100644 --- a/src/Http/HttpServer.cpp +++ b/src/Http/HttpServer.cpp @@ -6,7 +6,7 @@ #include "TessesFramework/Http/ContentDisposition.hpp" #include "TessesFramework/Streams/BufferedStream.hpp" #include "TessesFramework/Http/HttpStream.hpp" -#include "TessesFramework/Crypto/MbedHelpers.hpp" +#include "TessesFramework/Crypto/Crypto.hpp" #include "TessesFramework/Threading/Mutex.hpp" #include "TessesFramework/Common.hpp" #include "TessesFramework/TextStreams/StdIOWriter.hpp" diff --git a/src/Mail/Smtp.cpp b/src/Mail/Smtp.cpp index fa9581c..80ef567 100644 --- a/src/Mail/Smtp.cpp +++ b/src/Mail/Smtp.cpp @@ -1,5 +1,5 @@ #include "TessesFramework/Mail/Smtp.hpp" -#include "TessesFramework/Crypto/MbedHelpers.hpp" +#include "TessesFramework/Crypto/Crypto.hpp" #include "TessesFramework/Streams/MemoryStream.hpp" #include "TessesFramework/TextStreams/StreamWriter.hpp" #include "TessesFramework/Http/HttpUtils.hpp" diff --git a/src/Platform/Process.cpp b/src/Platform/Process.cpp index 0476622..9e1649e 100644 --- a/src/Platform/Process.cpp +++ b/src/Platform/Process.cpp @@ -613,7 +613,7 @@ CreateProcessW( } if(!this->workingDirectory.empty()) Tesses::Framework::Filesystem::VFSPath::SetAbsoluteCurrentDirectory(this->workingDirectory); - execve(this->name.c_str(),argv,envp); + execvpe(this->name.c_str(),argv,envp); exit(1); } p->pid = pid;