external/libcmis/UnpackedTarball_libcmis.mk | 1 + external/libcmis/sharepoint-auth.patch.1 | 13 +++++++++++++ include/comphelper/errcode.hxx | 1 + svtools/inc/errtxt.hrc | 1 + ucb/source/ucp/webdav-curl/CurlSession.cxx | 7 ++++--- ucb/source/ucp/webdav-curl/DAVException.hxx | 9 +++++++++ ucb/source/ucp/webdav-curl/webdavcontent.cxx | 10 +++++++++- uui/source/iahndl-errorhandler.cxx | 10 ++++++++++ uui/source/iahndl.cxx | 1 + 9 files changed, 49 insertions(+), 4 deletions(-)
New commits: commit 5eb54fcc93ee3dad65eb3bc7610390ae265ce9ac Author: Michael Stahl <[email protected]> AuthorDate: Thu Jun 20 18:11:57 2024 +0200 Commit: Michael Stahl <[email protected]> CommitDate: Fri Jun 21 14:21:14 2024 +0200 libcmis: improve Sharepoint authentication Sharepoint 16 apparently won't authenticate with NTLM unless the header "X-FORMS_BASED_AUTH_ACCEPTED: f" is sent. Change-Id: I13fe658a1fc5a18c22a49488dd634cbc07607aef Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169306 Reviewed-by: Michael Stahl <[email protected]> Tested-by: Jenkins (cherry picked from commit d2d973950bf35aa07251c77fae5b7283b4c91ea3) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169298 diff --git a/external/libcmis/UnpackedTarball_libcmis.mk b/external/libcmis/UnpackedTarball_libcmis.mk index 4a0a1a5e9e03..ede32bc8fad3 100644 --- a/external/libcmis/UnpackedTarball_libcmis.mk +++ b/external/libcmis/UnpackedTarball_libcmis.mk @@ -20,6 +20,7 @@ $(eval $(call gb_UnpackedTarball_add_patches,libcmis,\ external/libcmis/0001-Fix-warning-C4589-when-building-with-MSVC.patch \ external/libcmis/http-session-cleanup.patch.1 \ external/libcmis/factory-no-retry-ssl.patch.1 \ + external/libcmis/sharepoint-auth.patch.1 \ )) # vim: set noet sw=4 ts=4: diff --git a/external/libcmis/sharepoint-auth.patch.1 b/external/libcmis/sharepoint-auth.patch.1 new file mode 100644 index 000000000000..ff01c1291787 --- /dev/null +++ b/external/libcmis/sharepoint-auth.patch.1 @@ -0,0 +1,13 @@ +--- libcmis/src/libcmis/sharepoint-session.cxx.orig 2024-06-20 18:02:12.751118095 +0200 ++++ libcmis/src/libcmis/sharepoint-session.cxx 2024-06-20 18:04:36.467083223 +0200 +@@ -207,6 +207,10 @@ + + headers_slist.reset(curl_slist_append(headers_slist.release(), "accept:application/json; odata=verbose")); + headers_slist.reset(curl_slist_append(headers_slist.release(), ("x-requestdigest:" + m_digestCode).c_str())); ++ // newer Sharepoint requires this; this can be detected based on header ++ // "x-msdavext_error" starting with "917656;" typically with a 403 status ++ // but since this class is specifically for SharePoint just add it always ++ headers_slist.reset(curl_slist_append(headers_slist.release(), "X-FORMS_BASED_AUTH_ACCEPTED: f")); + + if ( !getUsername().empty() && !getPassword().empty() ) + { commit 31a3c9ad786efa5925ea54e5ce67300e8aae45de Author: Michael Stahl <[email protected]> AuthorDate: Thu Jun 20 15:13:17 2024 +0200 Commit: Michael Stahl <[email protected]> CommitDate: Fri Jun 21 14:21:04 2024 +0200 uui,ucb: webdav-curl: display curl error message on connection failure Show this in the dialog, which requires extending DAVException to store 2 strings for this case. Store it in the Exception::Message member of InteractiveNetworkConnectException, which appears to be unused. Add another UI string ERRCODE_INET_CONNECT_MSG so that the text can be shown optionally in the dialog. Change-Id: Iaf139d77051e7480113eb4df82ef40eb498f329e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169278 Reviewed-by: Michael Stahl <[email protected]> Tested-by: Jenkins (cherry picked from commit b02eb998c1f05ccb2c1e82f4ba24779398bce72e) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169297 diff --git a/include/comphelper/errcode.hxx b/include/comphelper/errcode.hxx index 31c4457db4b5..547be70a13dd 100644 --- a/include/comphelper/errcode.hxx +++ b/include/comphelper/errcode.hxx @@ -366,5 +366,6 @@ enum class ErrCodeClass { #define ERRCODE_INET_WRITE ErrCode(ErrCodeArea::Inet, ErrCodeClass::Write, 4) #define ERRCODE_INET_GENERAL ErrCode(ErrCodeArea::Inet, ErrCodeClass::Write, 5) #define ERRCODE_INET_OFFLINE ErrCode(ErrCodeArea::Inet, ErrCodeClass::Read, 6) +#define ERRCODE_INET_CONNECT_MSG ErrCode(ErrCodeArea::Inet, ErrCodeClass::Read, 7) /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svtools/inc/errtxt.hrc b/svtools/inc/errtxt.hrc index a70c0b284704..f98f12e916ea 100644 --- a/svtools/inc/errtxt.hrc +++ b/svtools/inc/errtxt.hrc @@ -108,6 +108,7 @@ const ErrMsgCode RID_ERRHDL[] = { NC_("RID_ERRHDL", "General OLE Error.") , ERRCODE_SFX_OLEGENERAL }, { NC_("RID_ERRHDL", "The host name $(ARG1) could not be resolved.") , ERRCODE_INET_NAME_RESOLVE }, { NC_("RID_ERRHDL", "Could not establish Internet connection to $(ARG1).") , ERRCODE_INET_CONNECT }, + { NC_("RID_ERRHDL", "Client error message: $(ARG2)") , ERRCODE_INET_CONNECT_MSG }, { NC_("RID_ERRHDL", "Error reading data from the Internet. Server error message: $(ARG1).") , ERRCODE_INET_READ }, { NC_("RID_ERRHDL", "Error transferring data to the Internet. Server error message: $(ARG1).") , ERRCODE_INET_WRITE }, { NC_("RID_ERRHDL", "General Internet error has occurred.") , ERRCODE_INET_GENERAL }, diff --git a/ucb/source/ucp/webdav-curl/CurlSession.cxx b/ucb/source/ucp/webdav-curl/CurlSession.cxx index ebc26784186e..183f8ad6f96a 100644 --- a/ucb/source/ucp/webdav-curl/CurlSession.cxx +++ b/ucb/source/ucp/webdav-curl/CurlSession.cxx @@ -987,8 +987,8 @@ auto CurlProcessor::ProcessRequestImpl( if (rc != CURLE_OK) { // TODO: is there any value in extracting CURLINFO_OS_ERRNO - SAL_WARN("ucb.ucp.webdav.curl", - "curl_easy_perform failed: " << GetErrorString(rc, rSession.m_ErrorBuffer)); + auto const errorString(GetErrorString(rc, rSession.m_ErrorBuffer)); + SAL_WARN("ucb.ucp.webdav.curl", "curl_easy_perform failed: " << errorString); switch (rc) { case CURLE_UNSUPPORTED_PROTOCOL: @@ -1013,7 +1013,8 @@ auto CurlProcessor::ProcessRequestImpl( #endif throw DAVException( DAVException::DAV_HTTP_CONNECT, - ConnectionEndPointString(rSession.m_URI.GetHost(), rSession.m_URI.GetPort())); + ConnectionEndPointString(rSession.m_URI.GetHost(), rSession.m_URI.GetPort()), + rtl::OStringToOUString(errorString, RTL_TEXTENCODING_UTF8)); case CURLE_REMOTE_ACCESS_DENIED: case CURLE_LOGIN_DENIED: case CURLE_AUTH_ERROR: diff --git a/ucb/source/ucp/webdav-curl/DAVException.hxx b/ucb/source/ucp/webdav-curl/DAVException.hxx index bd3053305901..adfa29317789 100644 --- a/ucb/source/ucp/webdav-curl/DAVException.hxx +++ b/ucb/source/ucp/webdav-curl/DAVException.hxx @@ -145,6 +145,7 @@ class DAVException : public std::exception private: ExceptionCode mExceptionCode; OUString mData; + OUString mMessage; sal_uInt16 mStatusCode; public: @@ -159,6 +160,13 @@ class DAVException : public std::exception , mData(std::move( aData )) , mStatusCode( SC_NONE ) {}; + DAVException( ExceptionCode inExceptionCode, + OUString aData, OUString message) + : mExceptionCode( inExceptionCode ) + , mData(std::move( aData )) + , mMessage(std::move(message)) + , mStatusCode( SC_NONE ) + {}; DAVException( ExceptionCode inExceptionCode, OUString aData, sal_uInt16 nStatusCode ) @@ -169,6 +177,7 @@ class DAVException : public std::exception const ExceptionCode & getError() const { return mExceptionCode; } const OUString & getData() const { return mData; } + const OUString & getMessage() const { return mMessage; } sal_uInt16 getStatus() const { return mStatusCode; } }; diff --git a/ucb/source/ucp/webdav-curl/webdavcontent.cxx b/ucb/source/ucp/webdav-curl/webdavcontent.cxx index c33e4cb24bcc..e2533fee9bca 100644 --- a/ucb/source/ucp/webdav-curl/webdavcontent.cxx +++ b/ucb/source/ucp/webdav-curl/webdavcontent.cxx @@ -3606,7 +3606,7 @@ uno::Any Content::MapDAVException( const DAVException & e, bool bWrite ) case DAVException::DAV_HTTP_CONNECT: aException <<= ucb::InteractiveNetworkConnectException( - OUString(), + e.getMessage(), getXWeak(), task::InteractionClassification_ERROR, e.getData() ); @@ -3907,6 +3907,9 @@ Content::ResourceType Content::getResourceType( { case USC_CONNECT_FAILED: e = DAVException::DAV_HTTP_CONNECT; + throw DAVException(e, + ConnectionEndPointString(aHostName, nPort), + aDAVOptions.getHttpResponseStatusText()); break; case USC_CONNECTION_TIMED_OUT: e = DAVException::DAV_HTTP_TIMEOUT; @@ -4062,6 +4065,11 @@ void Content::getResourceOptions( // cache the internal unofficial status code aDAVOptions.setHttpResponseStatusCode(e.getError() == DAVException::DAV_HTTP_CONNECT ? USC_CONNECT_FAILED : USC_CONNECTION_TIMED_OUT); + if (e.getError() == DAVException::DAV_HTTP_CONNECT) + { // ugly: this is not a HTTP status from the server but message + // from libcurl but the string member is unused... + aDAVOptions.setHttpResponseStatusText(e.getMessage()); + } // used only internally, so the text doesn't really matter.. aStaticDAVOptionsCache.addDAVOptions( aDAVOptions, m_nOptsCacheLifeNotFound ); diff --git a/uui/source/iahndl-errorhandler.cxx b/uui/source/iahndl-errorhandler.cxx index e4be8a713911..c6b17d627eaa 100644 --- a/uui/source/iahndl-errorhandler.cxx +++ b/uui/source/iahndl-errorhandler.cxx @@ -160,6 +160,16 @@ UUIInteractionHelper::handleErrorHandlerRequest( ErrorResource aErrorResource(aId[eSource], aResLocale); if (!aErrorResource.getString(nErrorCode, aMessage)) return; + if (nErrorCode == ERRCODE_INET_CONNECT) + { + OUString aMessage2; + aErrorResource.getString(ERRCODE_INET_CONNECT_MSG, aMessage2); + if (!aMessage2.isEmpty() && !rArguments[1].isEmpty()) + { + aMessage2 = replaceMessageWithArguments(aMessage2, rArguments); + aMessage += " " + aMessage2; + } + } } aMessage = replaceMessageWithArguments( aMessage, rArguments ); diff --git a/uui/source/iahndl.cxx b/uui/source/iahndl.cxx index 298754138990..de8809c404fc 100644 --- a/uui/source/iahndl.cxx +++ b/uui/source/iahndl.cxx @@ -498,6 +498,7 @@ UUIInteractionHelper::handleRequest_impl( { nErrorCode = ERRCODE_INET_CONNECT; aArguments.push_back(aConnectException.Server); + aArguments.push_back(aConnectException.Message); } else if (aAnyRequest >>= aReadException) {
