[Libreoffice-commits] online.git: loolwsd/configure.ac loolwsd/Connect.cpp loolwsd/LOOLWSD.cpp loolwsd/Storage.cpp loolwsd/test
Tor Lillqvist
tml at collabora.com
Thu Apr 14 10:44:52 UTC 2016
loolwsd/Connect.cpp | 4 ++--
loolwsd/LOOLWSD.cpp | 10 +++++-----
loolwsd/Storage.cpp | 6 +++---
loolwsd/configure.ac | 7 +++++--
loolwsd/test/httpposttest.cpp | 4 ++--
loolwsd/test/httpwstest.cpp | 34 +++++++++++++++++-----------------
6 files changed, 34 insertions(+), 31 deletions(-)
New commits:
commit 0140b1cd43a6cbfb8d44e2ee83d98ea320804609
Author: Tor Lillqvist <tml at collabora.com>
Date: Thu Apr 14 13:42:12 2016 +0300
Always define ENABLE_DEBUG and _SSL in config.h, as 1 or 0
Correspondingly always use #if, not #ifdef, to test.
diff --git a/loolwsd/Connect.cpp b/loolwsd/Connect.cpp
index 912ac32..7f0bf83 100644
--- a/loolwsd/Connect.cpp
+++ b/loolwsd/Connect.cpp
@@ -123,7 +123,7 @@ class Connect: public Poco::Util::Application
{
public:
Connect() :
-#ifdef ENABLE_SSL
+#if ENABLE_SSL
_uri("https://127.0.0.1:" + std::to_string(DEFAULT_CLIENT_PORT_NUMBER) + "/ws")
#else
_uri("http://127.0.0.1:" + std::to_string(DEFAULT_CLIENT_PORT_NUMBER) + "/ws")
@@ -147,7 +147,7 @@ protected:
if (args.size() > 1)
_uri = URI(args[1]);
-#ifdef ENABLE_SSL
+#if ENABLE_SSL
Poco::Net::initializeSSL();
SharedPtr<InvalidCertificateHandler> invalidCertHandler = new AcceptCertificateHandler(false);
diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp
index b4d4fe8..d1ac7ac 100644
--- a/loolwsd/LOOLWSD.cpp
+++ b/loolwsd/LOOLWSD.cpp
@@ -991,7 +991,7 @@ std::string LOOLWSD::FileServerRoot;
std::string LOOLWSD::AdminCreds;
bool LOOLWSD::AllowLocalStorage = false;
bool LOOLWSD::SSLEnabled =
-#ifdef ENABLE_SSL
+#if ENABLE_SSL
true;
#else
false;
@@ -1077,7 +1077,7 @@ void LOOLWSD::initialize(Application& self)
ServerApplication::initialize(self);
}
-#ifdef ENABLE_SSL
+#if ENABLE_SSL
void LOOLWSD::initializeSSL()
{
const auto ssl_cert_file_path = getPathFromConfig("ssl.cert_file_path");
@@ -1294,7 +1294,7 @@ int LOOLWSD::main(const std::vector<std::string>& /*args*/)
return Application::EXIT_USAGE;
}
-#ifdef ENABLE_SSL
+#if ENABLE_SSL
initializeSSL();
#endif
@@ -1381,7 +1381,7 @@ int LOOLWSD::main(const std::vector<std::string>& /*args*/)
params2->setMaxThreads(MAX_SESSIONS);
// Start a server listening on the port for clients
-#ifdef ENABLE_SSL
+#if ENABLE_SSL
SecureServerSocket svs(ClientPortNumber);
#else
ServerSocket svs(ClientPortNumber);
@@ -1536,7 +1536,7 @@ int LOOLWSD::main(const std::vector<std::string>& /*args*/)
Util::removeFile(path, true);
}
-#ifdef ENABLE_SSL
+#if ENABLE_SSL
Poco::Net::uninitializeSSL();
Poco::Crypto::uninitializeCrypto();
#endif
diff --git a/loolwsd/Storage.cpp b/loolwsd/Storage.cpp
index 1d17599..b0439c9 100644
--- a/loolwsd/Storage.cpp
+++ b/loolwsd/Storage.cpp
@@ -159,7 +159,7 @@ StorageBase::FileInfo WopiStorage::getFileInfo(const Poco::URI& uri)
Log::debug("Getting info for wopi uri [" + uri.toString() + "].");
Poco::URI uriObject(uri);
-#ifdef ENABLE_SSL
+#if ENABLE_SSL
Poco::Net::HTTPSClientSession session(uriObject.getHost(), uriObject.getPort(), Poco::Net::SSLManager::instance().defaultClientContext());
#else
Poco::Net::HTTPClientSession session(uriObject.getHost(), uriObject.getPort());
@@ -219,7 +219,7 @@ std::string WopiStorage::loadStorageFileToLocal()
const auto url = uriObject.getPath() + "/contents?" + uriObject.getQuery();
Log::debug("Wopi requesting: " + url);
-#ifdef ENABLE_SSL
+#if ENABLE_SSL
Poco::Net::HTTPSClientSession session(uriObject.getHost(), uriObject.getPort(), Poco::Net::SSLManager::instance().defaultClientContext());
#else
Poco::Net::HTTPClientSession session(uriObject.getHost(), uriObject.getPort());
@@ -264,7 +264,7 @@ bool WopiStorage::saveLocalFileToStorage()
const auto url = uriObject.getPath() + "/contents?" + uriObject.getQuery();
Log::debug("Wopi posting: " + url);
-#ifdef ENABLE_SSL
+#if ENABLE_SSL
Poco::Net::HTTPSClientSession session(uriObject.getHost(), uriObject.getPort(), Poco::Net::SSLManager::instance().defaultClientContext());
#else
Poco::Net::HTTPClientSession session(uriObject.getHost(), uriObject.getPort());
diff --git a/loolwsd/configure.ac b/loolwsd/configure.ac
index a396d87..c9f9a49 100644
--- a/loolwsd/configure.ac
+++ b/loolwsd/configure.ac
@@ -82,11 +82,13 @@ AS_IF([test "$enable_debug" = yes -a -n "$with_poco_libs"],
ENABLE_DEBUG=
debug_msg="secure mode: product build"
if test "$enable_debug" = "yes"; then
- AC_DEFINE([ENABLE_DEBUG],1,[Whether to compile in some extra debugging support code and disable some security pieces ])
+ AC_DEFINE([ENABLE_DEBUG],1,[Whether to compile in some extra debugging support code and disable some security pieces])
ENABLE_DEBUG=true
if test "$enable_debug" = yes; then
debug_msg="low security debugging mode"
fi
+else
+ AC_DEFINE([ENABLE_DEBUG],0,[Whether to compile in some extra debugging support code and disable some security pieces])
fi
AC_SUBST(ENABLE_DEBUG)
@@ -169,7 +171,8 @@ AS_IF([test "$enable_tests" != "no"],
[PKG_CHECK_MODULES([CPPUNIT], [cppunit])])
AS_IF([test "$enable_ssl" != "no"],
- [AC_DEFINE([ENABLE_SSL],1,[Enable SSL])])
+ [AC_DEFINE([ENABLE_SSL],1,[Whether to enable SSL])],
+ [AC_DEFINE([ENABLE_SSL],0,[Whether to enable SSL])])
ENABLE_SSL=
if test "$enable_ssl" != "no"; then
diff --git a/loolwsd/test/httpposttest.cpp b/loolwsd/test/httpposttest.cpp
index 5f71ebb..5255830 100644
--- a/loolwsd/test/httpposttest.cpp
+++ b/loolwsd/test/httpposttest.cpp
@@ -35,7 +35,7 @@ class HTTPPostTest : public CPPUNIT_NS::TestFixture
void testConvertTo();
-#ifdef ENABLE_SSL
+#if ENABLE_SSL
public:
HTTPPostTest()
{
@@ -58,7 +58,7 @@ void HTTPPostTest::testConvertTo()
{
const auto srcPath = Util::getTempFilePath(TDOC, "hello.odt");
-#ifdef ENABLE_SSL
+#if ENABLE_SSL
Poco::URI uri("https://127.0.0.1:" + std::to_string(DEFAULT_CLIENT_PORT_NUMBER));
Poco::Net::HTTPSClientSession session(uri.getHost(), uri.getPort());
#else
diff --git a/loolwsd/test/httpwstest.cpp b/loolwsd/test/httpwstest.cpp
index 168242b..a236750 100644
--- a/loolwsd/test/httpwstest.cpp
+++ b/loolwsd/test/httpwstest.cpp
@@ -103,13 +103,13 @@ class HTTPWSTest : public CPPUNIT_NS::TestFixture
public:
HTTPWSTest()
-#ifdef ENABLE_SSL
+#if ENABLE_SSL
: _uri("https://127.0.0.1:" + std::to_string(DEFAULT_CLIENT_PORT_NUMBER))
#else
: _uri("http://127.0.0.1:" + std::to_string(DEFAULT_CLIENT_PORT_NUMBER))
#endif
{
-#ifdef ENABLE_SSL
+#if ENABLE_SSL
Poco::Net::initializeSSL();
// Just accept the certificate anyway for testing purposes
Poco::SharedPtr<Poco::Net::InvalidCertificateHandler> invalidCertHandler = new Poco::Net::AcceptCertificateHandler(false);
@@ -119,7 +119,7 @@ public:
#endif
}
-#ifdef ENABLE_SSL
+#if ENABLE_SSL
~HTTPWSTest()
{
Poco::Net::uninitializeSSL();
@@ -152,7 +152,7 @@ void HTTPWSTest::testBadRequest()
Poco::Net::HTTPResponse response;
Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_GET, documentURL);
-#ifdef ENABLE_SSL
+#if ENABLE_SSL
Poco::Net::HTTPSClientSession session(_uri.getHost(), _uri.getPort());
#else
Poco::Net::HTTPClientSession session(_uri.getHost(), _uri.getPort());
@@ -187,7 +187,7 @@ void HTTPWSTest::testHandShake()
Poco::Net::HTTPResponse response;
Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_GET, documentURL);
-#ifdef ENABLE_SSL
+#if ENABLE_SSL
Poco::Net::HTTPSClientSession session(_uri.getHost(), _uri.getPort());
#else
Poco::Net::HTTPClientSession session(_uri.getHost(), _uri.getPort());
@@ -250,7 +250,7 @@ void HTTPWSTest::testLoad()
const std::string documentURL = "file://" + Poco::Path(documentPath).makeAbsolute().toString();
Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_GET, documentURL);
-#ifdef ENABLE_SSL
+#if ENABLE_SSL
Poco::Net::HTTPSClientSession session(_uri.getHost(), _uri.getPort());
#else
Poco::Net::HTTPClientSession session(_uri.getHost(), _uri.getPort());
@@ -303,7 +303,7 @@ void HTTPWSTest::testBadLoad()
const std::string documentURL = "file://" + Poco::Path(documentPath).makeAbsolute().toString();
Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_GET, documentURL);
-#ifdef ENABLE_SSL
+#if ENABLE_SSL
Poco::Net::HTTPSClientSession session(_uri.getHost(), _uri.getPort());
#else
Poco::Net::HTTPClientSession session(_uri.getHost(), _uri.getPort());
@@ -363,7 +363,7 @@ void HTTPWSTest::testSaveOnDisconnect()
const std::string documentURL = "file://" + Poco::Path(documentPath).makeAbsolute().toString();
Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_GET, documentURL);
-#ifdef ENABLE_SSL
+#if ENABLE_SSL
Poco::Net::HTTPSClientSession session(_uri.getHost(), _uri.getPort());
#else
Poco::Net::HTTPClientSession session(_uri.getHost(), _uri.getPort());
@@ -391,7 +391,7 @@ void HTTPWSTest::testSaveOnDisconnect()
const std::string documentURL = "file://" + Poco::Path(documentPath).makeAbsolute().toString();
Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_GET, documentURL);
-#ifdef ENABLE_SSL
+#if ENABLE_SSL
Poco::Net::HTTPSClientSession session(_uri.getHost(), _uri.getPort());
#else
Poco::Net::HTTPClientSession session(_uri.getHost(), _uri.getPort());
@@ -445,7 +445,7 @@ void HTTPWSTest::testExcelLoad()
const std::string documentURL = "file://" + Poco::Path(documentPath).makeAbsolute().toString();
Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_GET, documentURL);
-#ifdef ENABLE_SSL
+#if ENABLE_SSL
Poco::Net::HTTPSClientSession session(_uri.getHost(), _uri.getPort());
#else
Poco::Net::HTTPClientSession session(_uri.getHost(), _uri.getPort());
@@ -498,7 +498,7 @@ void HTTPWSTest::testPaste()
const std::string documentURL = "file://" + Poco::Path(documentPath).makeAbsolute().toString();
Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_GET, documentURL);
-#ifdef ENABLE_SSL
+#if ENABLE_SSL
Poco::Net::HTTPSClientSession session(_uri.getHost(), _uri.getPort());
#else
Poco::Net::HTTPClientSession session(_uri.getHost(), _uri.getPort());
@@ -558,7 +558,7 @@ void HTTPWSTest::testLargePaste()
const std::string documentURL = "file://" + Poco::Path(documentPath).makeAbsolute().toString();
Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_GET, documentURL);
-#ifdef ENABLE_SSL
+#if ENABLE_SSL
Poco::Net::HTTPSClientSession session(_uri.getHost(), _uri.getPort());
#else
Poco::Net::HTTPClientSession session(_uri.getHost(), _uri.getPort());
@@ -616,7 +616,7 @@ void HTTPWSTest::testRenderingOptions()
const std::string options = "{\"rendering\":{\".uno:HideWhitespace\":{\"type\":\"boolean\",\"value\":\"true\"}}}";
Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_GET, documentURL);
-#ifdef ENABLE_SSL
+#if ENABLE_SSL
Poco::Net::HTTPSClientSession session(_uri.getHost(), _uri.getPort());
#else
Poco::Net::HTTPClientSession session(_uri.getHost(), _uri.getPort());
@@ -675,7 +675,7 @@ void HTTPWSTest::testPasswordProtectedDocumentWithoutPassword()
const std::string documentURL = "file://" + Poco::Path(documentPath).makeAbsolute().toString();
Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_GET, documentURL);
-#ifdef ENABLE_SSL
+#if ENABLE_SSL
Poco::Net::HTTPSClientSession session(_uri.getHost(), _uri.getPort());
#else
Poco::Net::HTTPClientSession session(_uri.getHost(), _uri.getPort());
@@ -716,7 +716,7 @@ void HTTPWSTest::testPasswordProtectedDocumentWithWrongPassword()
const std::string documentURL = "file://" + Poco::Path(documentPath).makeAbsolute().toString();
Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_GET, documentURL);
-#ifdef ENABLE_SSL
+#if ENABLE_SSL
Poco::Net::HTTPSClientSession session(_uri.getHost(), _uri.getPort());
#else
Poco::Net::HTTPClientSession session(_uri.getHost(), _uri.getPort());
@@ -757,7 +757,7 @@ void HTTPWSTest::testPasswordProtectedDocumentWithCorrectPassword()
const std::string documentURL = "file://" + Poco::Path(documentPath).makeAbsolute().toString();
Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_GET, documentURL);
-#ifdef ENABLE_SSL
+#if ENABLE_SSL
Poco::Net::HTTPSClientSession session(_uri.getHost(), _uri.getPort());
#else
Poco::Net::HTTPClientSession session(_uri.getHost(), _uri.getPort());
@@ -791,7 +791,7 @@ void HTTPWSTest::testImpressPartCountChanged()
const std::string documentURL = "file://" + Poco::Path(documentPath).makeAbsolute().toString();
Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_GET, documentURL);
-#ifdef ENABLE_SSL
+#if ENABLE_SSL
Poco::Net::HTTPSClientSession session(_uri.getHost(), _uri.getPort());
#else
Poco::Net::HTTPClientSession session(_uri.getHost(), _uri.getPort());
More information about the Libreoffice-commits
mailing list