Kaydet (Commit) 07174b62 authored tarafından Aron Budea's avatar Aron Budea Kaydeden (comit) Thorsten Behrens

tdf#114227: set better proxy params in cURL for crash reporting

Take proxy server from internet settings, and pass to cURL.
Allow forwarding authentication as well (explicitely setting
user/password is still missing).

Change-Id: I19a6c9057a11a5911a6117f71060d3f386953602
Reviewed-on: https://gerrit.libreoffice.org/51621Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarThorsten Behrens <Thorsten.Behrens@CIB.de>
üst 71f89889
...@@ -30,12 +30,15 @@ $(eval $(call gb_Library_add_libs,crashreport,\ ...@@ -30,12 +30,15 @@ $(eval $(call gb_Library_add_libs,crashreport,\
) \ ) \
)) ))
$(eval $(call gb_Library_use_sdk_api,crashreport))
$(eval $(call gb_Library_use_libraries,crashreport,\ $(eval $(call gb_Library_use_libraries,crashreport,\
comphelper \ comphelper \
cppu \ cppu \
cppuhelper \ cppuhelper \
sal \ sal \
salhelper \ salhelper \
ucbhelper \
utl \ utl \
)) ))
......
...@@ -10,6 +10,8 @@ ...@@ -10,6 +10,8 @@
#include <desktop/crashreport.hxx> #include <desktop/crashreport.hxx>
#include <rtl/bootstrap.hxx> #include <rtl/bootstrap.hxx>
#include <osl/file.hxx> #include <osl/file.hxx>
#include <comphelper/processfactory.hxx>
#include <ucbhelper/proxydecider.hxx>
#include <unotools/bootstrap.hxx> #include <unotools/bootstrap.hxx>
#include <o3tl/char16_t2wchar_t.hxx> #include <o3tl/char16_t2wchar_t.hxx>
...@@ -70,13 +72,28 @@ void CrashReporter::AddKeyValue(const OUString& rKey, const OUString& rValue) ...@@ -70,13 +72,28 @@ void CrashReporter::AddKeyValue(const OUString& rKey, const OUString& rValue)
void CrashReporter::writeCommonInfo() void CrashReporter::writeCommonInfo()
{ {
osl::MutexGuard aGuard(maMutex); osl::MutexGuard aGuard(maMutex);
ucbhelper::InternetProxyDecider proxy_decider(::comphelper::getProcessComponentContext());
const OUString protocol = "https";
const OUString url = "crashreport.libreoffice.org";
const sal_Int32 port = 443;
const ucbhelper::InternetProxyServer proxy_server = proxy_decider.getProxy(protocol, url, port);
// limit the amount of code that needs to be executed before the crash reporting // limit the amount of code that needs to be executed before the crash reporting
std::string ini_path = CrashReporter::getIniFileName(); std::string ini_path = CrashReporter::getIniFileName();
std::ofstream minidump_file(ini_path, std::ios_base::trunc); std::ofstream minidump_file(ini_path, std::ios_base::trunc);
minidump_file << "ProductName=LibreOffice\n"; minidump_file << "ProductName=LibreOffice\n";
minidump_file << "Version=" LIBO_VERSION_DOTTED "\n"; minidump_file << "Version=" LIBO_VERSION_DOTTED "\n";
minidump_file << "BuildID=" << utl::Bootstrap::getBuildIdData("") << "\n"; minidump_file << "BuildID=" << utl::Bootstrap::getBuildIdData("") << "\n";
minidump_file << "URL=https://crashreport.libreoffice.org/submit/\n"; minidump_file << "URL=" << protocol << "://" << url << "/submit/\n";
if (proxy_server.aName != OUString())
{
minidump_file << "Proxy=" << proxy_server.aName << ":" << proxy_server.nPort << "\n";
}
for (auto& keyValue : maKeyValues) for (auto& keyValue : maKeyValues)
{ {
writeToStream(minidump_file, keyValue.first, keyValue.second); writeToStream(minidump_file, keyValue.first, keyValue.second);
......
...@@ -111,9 +111,16 @@ bool uploadContent(std::map<std::string, std::string>& parameters, std::string& ...@@ -111,9 +111,16 @@ bool uploadContent(std::map<std::string, std::string>& parameters, std::string&
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, false); curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, false);
// Set proxy information if necessary. // Set proxy information if necessary.
if (!proxy.empty()) if (!proxy.empty())
{
curl_easy_setopt(curl, CURLOPT_PROXY, proxy.c_str()); curl_easy_setopt(curl, CURLOPT_PROXY, proxy.c_str());
if (!proxy_user_pwd.empty())
curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, proxy_user_pwd.c_str()); curl_easy_setopt(curl, CURLOPT_PROXYAUTH, CURLAUTH_ANYSAFE);
if (!proxy_user_pwd.empty())
curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, proxy_user_pwd.c_str());
else
curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, ":");
}
if (!ca_certificate_file.empty()) if (!ca_certificate_file.empty())
curl_easy_setopt(curl, CURLOPT_CAINFO, ca_certificate_file.c_str()); curl_easy_setopt(curl, CURLOPT_CAINFO, ca_certificate_file.c_str());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment