Emscripten: Enable the WebDAV UCP

*  Which also requires external/curl.  But implicitly use --without-gssapi,
checking for it in configure.ac would fail with

> configure: error: could not find function 'gss_init_sec_context' required for GSSAPI

And building ExternalProject_curl needs to see the -pthread from
gb_EMSCRIPTEN_CPPFLAGS, otherwise linking Executable_soffice_bin would fail with

> wasm-ld: error: --shared-memory is disallowed by libcurl_la-easy.o because it was not compiled with 'atomics' or 'bulk-memory' features.

*  By default, GetCABundleFile in include/systools/opensslinit.hxx will fail
now.  (But to make https work, applications could bring along their own such
file in the Emscripten FS, in one of the places where GetCABundleFile checks for
it.)  So, for Emscripten only, make failure of GetCABundleFile non-fatal in
InitCurl_easy.

*  Some code in sw was erroneously hidden behind !ENABLE_WASM_STRIP_EXTRA (off
by default for Emscripten), but is needed with HAVE_FEATURE_CURL.

*  See <https://emscripten.org/docs/porting/networking.html> for how to actually
use networking in an Emscripten application.

Change-Id: I2bbe9f3fd0e20143e18eb1e8104568b1c7a304de
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172167
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
This commit is contained in:
Stephan Bergmann 2024-08-21 08:00:48 +02:00
parent b20e7aaac5
commit e180d2a8fd
7 changed files with 30 additions and 18 deletions

View file

@ -3204,7 +3204,6 @@ if test "$enable_wasm_strip" = "yes"; then
enable_libcmis=no
enable_coinmp=no
enable_cups=no
test "$_os" = Emscripten && enable_curl=no
enable_database_connectivity=no
enable_dbus=no
enable_dconf=no
@ -3239,10 +3238,9 @@ if test "$enable_wasm_strip" = "yes"; then
test_libqxp=no
test_libvisio=no
test_libzmf=no
test_webdav=no
with_galleries=no
with_gssapi=no
with_templates=no
with_webdav=no
with_x=no
test "${with_fonts+set}" = set || with_fonts=yes

View file

@ -20,7 +20,11 @@ $(eval $(call gb_ExternalProject_register_targets,curl,\
ifneq ($(OS),WNT)
ifeq ($(OS),EMSCRIPTEN)
curl_CPPFLAGS := $(gb_EMSCRIPTEN_CPPFLAGS)
else
curl_CPPFLAGS :=
endif
curl_LDFLAGS := $(if $(filter LINUX FREEBSD,$(OS)),-Wl$(COMMA)-z$(COMMA)origin -Wl$(COMMA)-rpath$(COMMA)\$$$$ORIGIN)
ifneq ($(OS),ANDROID)

View file

@ -34,10 +34,21 @@ static void InitCurl_easy(CURL* const pCURL)
#if defined(LO_CURL_NEEDS_CA_BUNDLE)
char const* const path = GetCABundleFile();
rc = curl_easy_setopt(pCURL, CURLOPT_CAINFO, path);
if (rc != CURLE_OK) // only if OOM?
if (path == nullptr)
{
throw css::uno::RuntimeException(u"CURLOPT_CAINFO failed"_ustr);
#if defined EMSCRIPTEN
SAL_WARN("ucb.ucp.webdav.curl", "no OpenSSL CA certificate bundle found");
#else
throw css::uno::RuntimeException(u"no OpenSSL CA certificate bundle found"_ustr);
#endif
}
else
{
rc = curl_easy_setopt(pCURL, CURLOPT_CAINFO, path);
if (rc != CURLE_OK) // only if OOM?
{
throw css::uno::RuntimeException(u"CURLOPT_CAINFO failed"_ustr);
}
}
#endif

View file

@ -36,7 +36,7 @@ static char const* GetCABundleFile()
}
}
throw css::uno::RuntimeException(u"no OpenSSL CA certificate bundle found"_ustr);
return nullptr;
}
#endif

View file

@ -40,7 +40,7 @@ struct SW_DLLPUBLIC TranslateAPIConfig final
};
SW_DLLPUBLIC OString ExportPaMToHTML(SwPaM* pCursor);
SW_DLLPUBLIC void PasteHTMLToPaM(SwWrtShell& rWrtSh, SwPaM* pCursor, const OString& rData);
#if HAVE_FEATURE_CURL && !ENABLE_WASM_STRIP_EXTRA
#if HAVE_FEATURE_CURL
SW_DLLPUBLIC void TranslateDocument(SwWrtShell& rWrtSh, const TranslateAPIConfig& rConfig);
SW_DLLPUBLIC void TranslateDocumentCancellable(SwWrtShell& rWrtSh,
const TranslateAPIConfig& rConfig,

View file

@ -94,7 +94,7 @@ void PasteHTMLToPaM(SwWrtShell& rWrtSh, SwPaM* pCursor, const OString& rData)
}
}
#if HAVE_FEATURE_CURL && !ENABLE_WASM_STRIP_EXTRA
#if HAVE_FEATURE_CURL
void TranslateDocument(SwWrtShell& rWrtSh, const TranslateAPIConfig& rConfig)
{
bool bCancel = false;
@ -212,5 +212,5 @@ void TranslateDocumentCancellable(SwWrtShell& rWrtSh, const TranslateAPIConfig&
if (xStatusIndicator.is())
xStatusIndicator->end();
}
#endif // HAVE_FEATURE_CURL && !ENABLE_WASM_STRIP_EXTRA
#endif // HAVE_FEATURE_CURL
}

View file

@ -201,18 +201,17 @@ int ImplSVMain()
OUString temp;
if (osl_getEnvironment(name.pData, &temp.pData) == osl_Process_E_NotFound)
{
try // to point bundled OpenSSL to some system certificate file
{ // ... this only works if the client actually calls
// SSL_CTX_set_default_verify_paths() or similar; e.g. python ssl.
char const*const path = GetCABundleFile();
// Try to point bundled OpenSSL to some system certificate file
// ... this only works if the client actually calls
// SSL_CTX_set_default_verify_paths() or similar; e.g. python ssl.
char const*const path = GetCABundleFile();
if (path == nullptr) {
SAL_WARN("vcl", "no OpenSSL CA certificate bundle found");
} else {
OUString const filepath(::rtl::OStringToOUString(
::std::string_view(path), osl_getThreadTextEncoding()));
osl_setEnvironment(name.pData, filepath.pData);
}
catch (uno::RuntimeException const& e)
{
SAL_WARN("vcl", e.Message);
}
}
}
#endif