external/libcmis/0001-fix-regression-in-HttpSession-initProtocols.patch | 31 ++ external/libcmis/0002-HttpSession-add-a-callback-that-can-be-used-to-confi.patch | 142 ++++++++++ external/libcmis/0003-HttpSession-fix-regression-setting-wrong-type-of-CUR.patch | 81 +++++ external/libcmis/UnpackedTarball_libcmis.mk | 6 4 files changed, 260 insertions(+)
New commits: commit 9ec513d6346634c8ede37c0d58cf9e42928b87a0 Author: Michael Stahl <michael.st...@allotropia.de> AuthorDate: Mon Nov 6 18:48:37 2023 +0100 Commit: Thorsten Behrens <thorsten.behr...@allotropia.de> CommitDate: Sun Nov 12 10:38:20 2023 +0100 libcmis: fix regression setting wrong type of CURLOPT_SEEKFUNCTION Change-Id: I45421bbe13626aa843380e77f589e793328f99d4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159010 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.st...@allotropia.de> (cherry picked from commit 584c01394ff06072b11ef4bd4bffb9e7f2d31e81) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159031 Reviewed-by: Thorsten Behrens <thorsten.behr...@allotropia.de> diff --git a/external/libcmis/0003-HttpSession-fix-regression-setting-wrong-type-of-CUR.patch b/external/libcmis/0003-HttpSession-fix-regression-setting-wrong-type-of-CUR.patch new file mode 100644 index 000000000000..424fd9e0ea0f --- /dev/null +++ b/external/libcmis/0003-HttpSession-fix-regression-setting-wrong-type-of-CUR.patch @@ -0,0 +1,81 @@ +From 3e6eb4cefd22498824247d91ab4c125deb3277da Mon Sep 17 00:00:00 2001 +From: Michael Stahl <michael.st...@allotropia.de> +Date: Mon, 6 Nov 2023 18:41:37 +0100 +Subject: [PATCH 3/3] HttpSession: fix regression setting wrong type of + CURLOPT_SEEKFUNCTION + +(regression from commit 1b8a646b1d63bfa760d154dd7e51f6298d4a9899) +--- + src/libcmis/http-session.cxx | 28 +++++++++++++++++++++++++--- + 1 file changed, 25 insertions(+), 3 deletions(-) + +diff --git a/src/libcmis/http-session.cxx b/src/libcmis/http-session.cxx +index 8787c50..d7b1a5e 100644 +--- a/src/libcmis/http-session.cxx ++++ b/src/libcmis/http-session.cxx +@@ -31,6 +31,7 @@ + #include <cctype> + #include <memory> + #include <string> ++#include <assert.h> + + #include <libxml/parser.h> + #include <libxml/tree.h> +@@ -110,6 +111,27 @@ namespace + return errCode; + } + ++ int lcl_seekStream(void* data, curl_off_t offset, int origin) ++ { ++ std::ios_base::seekdir dir = {}; ++ switch (origin) ++ { ++ case SEEK_SET: dir = std::ios_base::beg; break; ++ case SEEK_CUR: dir = std::ios_base::cur; break; ++ case SEEK_END: dir = std::ios_base::end; break; ++ default: assert(false); break; ++ } ++ istream& is = *(static_cast<istream*>(data)); ++ is.clear(); ++ is.seekg(offset, dir); ++ if (!is.good()) ++ { ++ fprintf(stderr, "rewind failed\n"); ++ return CURL_SEEKFUNC_FAIL; ++ } ++ return CURL_SEEKFUNC_OK; ++ } ++ + template<typename T> + class ScopeGuard + { +@@ -328,7 +350,7 @@ libcmis::HttpResponsePtr HttpSession::httpPatchRequest( string url, istream& is, + curl_easy_setopt( m_curlHandle, CURLOPT_UPLOAD, 1 ); + curl_easy_setopt( m_curlHandle, CURLOPT_CUSTOMREQUEST, "PATCH" ); + #if (LIBCURL_VERSION_MAJOR > 7) || (LIBCURL_VERSION_MAJOR == 7 && LIBCURL_VERSION_MINOR >= 85) +- curl_easy_setopt( m_curlHandle, CURLOPT_SEEKFUNCTION, lcl_ioctlStream ); ++ curl_easy_setopt( m_curlHandle, CURLOPT_SEEKFUNCTION, lcl_seekStream ); + curl_easy_setopt( m_curlHandle, CURLOPT_SEEKDATA, &isOriginal ); + #else + curl_easy_setopt( m_curlHandle, CURLOPT_IOCTLFUNCTION, lcl_ioctlStream ); +@@ -420,7 +442,7 @@ libcmis::HttpResponsePtr HttpSession::httpPutRequest( string url, istream& is, v + curl_easy_setopt( m_curlHandle, CURLOPT_READFUNCTION, lcl_readStream ); + curl_easy_setopt( m_curlHandle, CURLOPT_UPLOAD, 1 ); + #if (LIBCURL_VERSION_MAJOR > 7) || (LIBCURL_VERSION_MAJOR == 7 && LIBCURL_VERSION_MINOR >= 85) +- curl_easy_setopt( m_curlHandle, CURLOPT_SEEKFUNCTION, lcl_ioctlStream ); ++ curl_easy_setopt( m_curlHandle, CURLOPT_SEEKFUNCTION, lcl_seekStream ); + curl_easy_setopt( m_curlHandle, CURLOPT_SEEKDATA, &isOriginal ); + #else + curl_easy_setopt( m_curlHandle, CURLOPT_IOCTLFUNCTION, lcl_ioctlStream ); +@@ -513,7 +535,7 @@ libcmis::HttpResponsePtr HttpSession::httpPostRequest( const string& url, istrea + curl_easy_setopt( m_curlHandle, CURLOPT_READFUNCTION, lcl_readStream ); + curl_easy_setopt( m_curlHandle, CURLOPT_POST, 1 ); + #if (LIBCURL_VERSION_MAJOR > 7) || (LIBCURL_VERSION_MAJOR == 7 && LIBCURL_VERSION_MINOR >= 85) +- curl_easy_setopt( m_curlHandle, CURLOPT_SEEKFUNCTION, lcl_ioctlStream ); ++ curl_easy_setopt( m_curlHandle, CURLOPT_SEEKFUNCTION, lcl_seekStream ); + curl_easy_setopt( m_curlHandle, CURLOPT_SEEKDATA, &isOriginal ); + #else + curl_easy_setopt( m_curlHandle, CURLOPT_IOCTLFUNCTION, lcl_ioctlStream ); +-- +2.41.0 + diff --git a/external/libcmis/UnpackedTarball_libcmis.mk b/external/libcmis/UnpackedTarball_libcmis.mk index 1ef846aa2b4b..1a1678e5a67c 100644 --- a/external/libcmis/UnpackedTarball_libcmis.mk +++ b/external/libcmis/UnpackedTarball_libcmis.mk @@ -16,6 +16,7 @@ $(eval $(call gb_UnpackedTarball_set_patchlevel,libcmis,1)) $(eval $(call gb_UnpackedTarball_add_patches,libcmis,\ external/libcmis/0001-fix-regression-in-HttpSession-initProtocols.patch \ external/libcmis/0002-HttpSession-add-a-callback-that-can-be-used-to-confi.patch \ + external/libcmis/0003-HttpSession-fix-regression-setting-wrong-type-of-CUR.patch \ )) # vim: set noet sw=4 ts=4: commit e3b0b7c28efe2c5eb0efd6cd8c2863dc4f4ff6d2 Author: Michael Stahl <michael.st...@allotropia.de> AuthorDate: Mon Nov 6 14:43:12 2023 +0100 Commit: Thorsten Behrens <thorsten.behr...@allotropia.de> CommitDate: Sun Nov 12 10:38:15 2023 +0100 libcmis: HttpSession: add a callback that can be used to configure libcurl Change-Id: I6c2a3d1976f2256b21a3a306db7fbf04ca444c32 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159000 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.st...@allotropia.de> (cherry picked from commit 061e48e607291c2992c81d3073a8c41387c56996) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158907 Reviewed-by: Thorsten Behrens <thorsten.behr...@allotropia.de> diff --git a/external/libcmis/0002-HttpSession-add-a-callback-that-can-be-used-to-confi.patch b/external/libcmis/0002-HttpSession-add-a-callback-that-can-be-used-to-confi.patch new file mode 100644 index 000000000000..b47ee4d195b2 --- /dev/null +++ b/external/libcmis/0002-HttpSession-add-a-callback-that-can-be-used-to-confi.patch @@ -0,0 +1,142 @@ +From 94012ca5b669e71ea35508159f63576364736dc2 Mon Sep 17 00:00:00 2001 +From: Michael Stahl <michael.st...@allotropia.de> +Date: Mon, 6 Nov 2023 14:18:59 +0100 +Subject: [PATCH 2/2] HttpSession: add a callback that can be used to configure + libcurl + +--- + inc/libcmis/session-factory.hxx | 7 +++++++ + src/libcmis/http-session.cxx | 8 +++++++- + src/libcmis/http-session.hxx | 8 +++++++- + src/libcmis/session-factory.cxx | 9 ++++++++- + 4 files changed, 29 insertions(+), 3 deletions(-) + +diff --git a/inc/libcmis/session-factory.hxx b/inc/libcmis/session-factory.hxx +index 45abd8b..227ac4d 100644 +--- a/inc/libcmis/session-factory.hxx ++++ b/inc/libcmis/session-factory.hxx +@@ -38,6 +38,9 @@ + #include "libcmis/repository.hxx" + #include "libcmis/session.hxx" + ++// needed for a callback type ++typedef void CURL; ++ + namespace libcmis + { + /** This callback provides the OAuth2 code or NULL. +@@ -80,6 +83,8 @@ namespace libcmis + }; + typedef boost::shared_ptr< CertValidationHandler > CertValidationHandlerPtr; + ++ typedef void(*CurlInitProtocolsFunction)(CURL *); ++ + class LIBCMIS_API SessionFactory + { + private: +@@ -109,6 +114,8 @@ namespace libcmis + static void setCertificateValidationHandler( CertValidationHandlerPtr handler ) { s_certValidationHandler = handler; } + static CertValidationHandlerPtr getCertificateValidationHandler( ) { return s_certValidationHandler; } + ++ static void setCurlInitProtocolsFunction(CurlInitProtocolsFunction); ++ + static void setProxySettings( std::string proxy, + std::string noProxy, + std::string proxyUser, +diff --git a/src/libcmis/http-session.cxx b/src/libcmis/http-session.cxx +index 9703427..8787c50 100644 +--- a/src/libcmis/http-session.cxx ++++ b/src/libcmis/http-session.cxx +@@ -133,8 +133,10 @@ namespace + } + + HttpSession::HttpSession( string username, string password, bool noSslCheck, +- libcmis::OAuth2DataPtr oauth2, bool verbose ) : ++ libcmis::OAuth2DataPtr oauth2, bool verbose, ++ libcmis::CurlInitProtocolsFunction initProtocols) : + m_curlHandle( NULL ), ++ m_CurlInitProtocolsFunction(initProtocols), + m_no100Continue( false ), + m_oauth2Handler( NULL ), + m_username( username ), +@@ -903,6 +905,10 @@ void HttpSession::initProtocols( ) + curl_easy_setopt(m_curlHandle, CURLOPT_PROTOCOLS, protocols); + curl_easy_setopt(m_curlHandle, CURLOPT_REDIR_PROTOCOLS, protocols); + #endif ++ if (m_CurlInitProtocolsFunction) ++ { ++ (*m_CurlInitProtocolsFunction)(m_curlHandle); ++ } + } + + const char* CurlException::what( ) const noexcept +diff --git a/src/libcmis/http-session.hxx b/src/libcmis/http-session.hxx +index 6c9ed1b..34223b2 100644 +--- a/src/libcmis/http-session.hxx ++++ b/src/libcmis/http-session.hxx +@@ -43,6 +43,10 @@ + + class OAuth2Handler; + ++namespace libcmis { ++ typedef void(*CurlInitProtocolsFunction)(CURL *); ++} ++ + class CurlException : public std::exception + { + private: +@@ -93,6 +97,7 @@ class HttpSession + { + protected: + CURL* m_curlHandle; ++ libcmis::CurlInitProtocolsFunction m_CurlInitProtocolsFunction = nullptr; + private: + bool m_no100Continue; + protected: +@@ -111,7 +116,8 @@ class HttpSession + HttpSession( std::string username, std::string password, + bool noSslCheck = false, + libcmis::OAuth2DataPtr oauth2 = libcmis::OAuth2DataPtr(), +- bool verbose = false ); ++ bool verbose = false, ++ libcmis::CurlInitProtocolsFunction = nullptr); + + HttpSession( const HttpSession& copy ); + virtual ~HttpSession( ); +diff --git a/src/libcmis/session-factory.cxx b/src/libcmis/session-factory.cxx +index 1222473..47dc1c8 100644 +--- a/src/libcmis/session-factory.cxx ++++ b/src/libcmis/session-factory.cxx +@@ -38,6 +38,7 @@ using namespace std; + + namespace libcmis + { ++ CurlInitProtocolsFunction g_CurlInitProtocolsFunction = 0; + AuthProviderPtr SessionFactory::s_authProvider; + OAuth2AuthCodeProvider SessionFactory::s_oauth2AuthCodeProvider; + +@@ -48,6 +49,11 @@ namespace libcmis + + CertValidationHandlerPtr SessionFactory::s_certValidationHandler; + ++ void SessionFactory::setCurlInitProtocolsFunction(CurlInitProtocolsFunction const initProtocols) ++ { ++ g_CurlInitProtocolsFunction = initProtocols; ++ } ++ + void SessionFactory::setProxySettings( string proxy, string noProxy, + string proxyUser, string proxyPass ) + { +@@ -81,7 +87,8 @@ namespace libcmis + libcmis::HttpResponsePtr response; + boost::shared_ptr< HttpSession> httpSession( + new HttpSession( username, password, +- noSslCheck, oauth2, verbose ) ); ++ noSslCheck, oauth2, verbose, ++ g_CurlInitProtocolsFunction) ); + + try + { +-- +2.41.0 + diff --git a/external/libcmis/UnpackedTarball_libcmis.mk b/external/libcmis/UnpackedTarball_libcmis.mk index d7ecc207f10d..1ef846aa2b4b 100644 --- a/external/libcmis/UnpackedTarball_libcmis.mk +++ b/external/libcmis/UnpackedTarball_libcmis.mk @@ -15,6 +15,7 @@ $(eval $(call gb_UnpackedTarball_set_patchlevel,libcmis,1)) $(eval $(call gb_UnpackedTarball_add_patches,libcmis,\ external/libcmis/0001-fix-regression-in-HttpSession-initProtocols.patch \ + external/libcmis/0002-HttpSession-add-a-callback-that-can-be-used-to-confi.patch \ )) # vim: set noet sw=4 ts=4: commit 1f6ae39011d77902623acfa442b3ecd7c4ed45d1 Author: Michael Stahl <michael.st...@allotropia.de> AuthorDate: Mon Nov 6 14:24:14 2023 +0100 Commit: Thorsten Behrens <thorsten.behr...@allotropia.de> CommitDate: Sun Nov 12 10:38:09 2023 +0100 libcmis: fix regression in HttpSession::initProtocols() Change-Id: I1d884945cc1f88a3abbf87c78227b56abf865c16 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158999 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.st...@allotropia.de> (cherry picked from commit 385aae6595fa467c73b6fdede5153d785c3ce138) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158906 Reviewed-by: Thorsten Behrens <thorsten.behr...@allotropia.de> diff --git a/external/libcmis/0001-fix-regression-in-HttpSession-initProtocols.patch b/external/libcmis/0001-fix-regression-in-HttpSession-initProtocols.patch new file mode 100644 index 000000000000..8480913cdf20 --- /dev/null +++ b/external/libcmis/0001-fix-regression-in-HttpSession-initProtocols.patch @@ -0,0 +1,31 @@ +From 5b9ed18e518a5214b4a1fb2766627c1d169b8d8c Mon Sep 17 00:00:00 2001 +From: Michael Stahl <michael.st...@allotropia.de> +Date: Mon, 6 Nov 2023 13:33:05 +0100 +Subject: [PATCH 1/2] fix regression in HttpSession::initProtocols() + +(regression from commit 1b8a646b1d63bfa760d154dd7e51f6298d4a9899) +--- + src/libcmis/http-session.cxx | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/src/libcmis/http-session.cxx b/src/libcmis/http-session.cxx +index 3847a2c..9703427 100644 +--- a/src/libcmis/http-session.cxx ++++ b/src/libcmis/http-session.cxx +@@ -894,11 +894,12 @@ catch ( const libcmis::Exception& e ) + + void HttpSession::initProtocols( ) + { +- const unsigned long protocols = CURLPROTO_HTTP | CURLPROTO_HTTPS; + #if (LIBCURL_VERSION_MAJOR > 7) || (LIBCURL_VERSION_MAJOR == 7 && LIBCURL_VERSION_MINOR >= 85) ++ auto const protocols = "https,http"; + curl_easy_setopt(m_curlHandle, CURLOPT_PROTOCOLS_STR, protocols); + curl_easy_setopt(m_curlHandle, CURLOPT_REDIR_PROTOCOLS_STR, protocols); + #else ++ const unsigned long protocols = CURLPROTO_HTTP | CURLPROTO_HTTPS; + curl_easy_setopt(m_curlHandle, CURLOPT_PROTOCOLS, protocols); + curl_easy_setopt(m_curlHandle, CURLOPT_REDIR_PROTOCOLS, protocols); + #endif +-- +2.41.0 + diff --git a/external/libcmis/UnpackedTarball_libcmis.mk b/external/libcmis/UnpackedTarball_libcmis.mk index 1c014d963401..d7ecc207f10d 100644 --- a/external/libcmis/UnpackedTarball_libcmis.mk +++ b/external/libcmis/UnpackedTarball_libcmis.mk @@ -13,4 +13,8 @@ $(eval $(call gb_UnpackedTarball_set_tarball,libcmis,$(LIBCMIS_TARBALL))) $(eval $(call gb_UnpackedTarball_set_patchlevel,libcmis,1)) +$(eval $(call gb_UnpackedTarball_add_patches,libcmis,\ + external/libcmis/0001-fix-regression-in-HttpSession-initProtocols.patch \ +)) + # vim: set noet sw=4 ts=4: