[Libreoffice-commits] online.git: kit/ForKit.cpp test/UnitAdmin.cpp
kit/ForKit.cpp |8 test/UnitAdmin.cpp |4 +++- 2 files changed, 7 insertions(+), 5 deletions(-) New commits: commit b67b335b50e980f73f379b1537e32b563d453c64 Author: Pranam Lashkari AuthorDate: Tue Nov 19 14:00:30 2019 +0530 Commit: Jan Holesovsky CommitDate: Wed Apr 29 10:28:53 2020 +0200 killpoco: Removed Poco::Thread::sleep Replaced method with std::this_thread::sleep_for Change-Id: I26e37475d67816e4f1d68d222b1c067107c27b05 Reviewed-on: https://gerrit.libreoffice.org/c/online/+/83200 Tested-by: Jenkins CollaboraOffice Reviewed-by: Jan Holesovsky diff --git a/kit/ForKit.cpp b/kit/ForKit.cpp index c3c672c68..b15a4bea2 100644 --- a/kit/ForKit.cpp +++ b/kit/ForKit.cpp @@ -24,10 +24,11 @@ #include #include #include +#include +#include #include #include -#include #include #include "Kit.hpp" @@ -45,7 +46,6 @@ #include using Poco::Process; -using Poco::Thread; #ifndef KIT_IN_PROCESS static bool NoCapsForKit = false; @@ -322,7 +322,7 @@ static int createLibreOfficeKit(const std::string& childRoot, std::cerr << "Kit: Sleeping " << delaySecs << " seconds to give you time to attach debugger to process " << Process::id() << std::endl; -Thread::sleep(delaySecs * 1000); +std::this_thread::sleep_for(std::chrono::seconds(delaySecs)); } } @@ -424,7 +424,7 @@ int main(int argc, char** argv) std::cerr << "Forkit: Sleeping " << delaySecs << " seconds to give you time to attach debugger to process " << Process::id() << std::endl; -Thread::sleep(delaySecs * 1000); +std::this_thread::sleep_for(std::chrono::seconds(delaySecs)); } } diff --git a/test/UnitAdmin.cpp b/test/UnitAdmin.cpp index 65a4fccd0..4cb030047 100644 --- a/test/UnitAdmin.cpp +++ b/test/UnitAdmin.cpp @@ -11,6 +11,8 @@ #include #include +#include +#include #include #include @@ -200,7 +202,7 @@ private: // FIXME: we really should wait for the subscription to be // registered and have a reply to avoid a race here. -Poco::Thread::sleep(250); +std::this_thread::sleep_for(std::chrono::milliseconds(250)); std::string documentPath1, documentURL1; helpers::getDocumentPathAndURL("hello.odt", documentPath1, documentURL1, "unitAdmin-hello.odt "); ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] online.git: kit/ForKit.cpp kit/Kit.cpp net/DelaySocket.cpp net/ServerSocket.hpp net/Socket.cpp net/Socket.hpp net/SslSocket.hpp net/WebSocketHandler.hpp tools/WebSocketDump.cpp w
kit/ForKit.cpp |2 +- kit/Kit.cpp |4 ++-- net/DelaySocket.cpp |4 ++-- net/ServerSocket.hpp |4 ++-- net/Socket.cpp |6 +++--- net/Socket.hpp | 18 +- net/SslSocket.hpp|6 +++--- net/WebSocketHandler.hpp |2 +- tools/WebSocketDump.cpp |6 +++--- wsd/Admin.cpp| 38 +- wsd/Admin.hpp|9 - wsd/DocumentBroker.cpp |4 ++-- wsd/LOOLWSD.cpp | 10 +- 13 files changed, 62 insertions(+), 51 deletions(-) New commits: commit 28a9c4dc05646f32883387bd071ac79e853044d5 Author: Michael Meeks AuthorDate: Fri Apr 10 12:34:15 2020 +0100 Commit: Michael Meeks CommitDate: Fri Apr 10 13:58:00 2020 +0200 Poll - cleanup method naming, and fix merge issues. This mends several problems from commit 5710c8632383e92372e1d81b6e26acc975e25ec4. Change-Id: I1b29f29ca81679608a2692488fa1ef22b2e62dfd Reviewed-on: https://gerrit.libreoffice.org/c/online/+/92032 Tested-by: Jenkins CollaboraOffice Reviewed-by: Michael Meeks diff --git a/kit/ForKit.cpp b/kit/ForKit.cpp index 5506fa339..1c763f8a3 100644 --- a/kit/ForKit.cpp +++ b/kit/ForKit.cpp @@ -606,7 +606,7 @@ int main(int argc, char** argv) { UnitKit::get().invokeForKitTest(); -mainPoll.ppoll(POLL_TIMEOUT_MICRO_S); +mainPoll.poll(POLL_TIMEOUT_MICRO_S); #if ENABLE_DEBUG if (!SingleKit) diff --git a/kit/Kit.cpp b/kit/Kit.cpp index acec37bb9..bb7933c93 100644 --- a/kit/Kit.cpp +++ b/kit/Kit.cpp @@ -2261,7 +2261,7 @@ public: if (timeoutMicroS < 0) { // Flush at most 1 + maxExtraEvents, or return when nothing left. -while (ppoll(0) > 0 && maxExtraEvents-- > 0) +while (poll(0) > 0 && maxExtraEvents-- > 0) ++eventsSignalled; } else @@ -2270,7 +2270,7 @@ public: _pollEnd = std::chrono::steady_clock::now() + std::chrono::microseconds(timeoutMicroS); do { -if (ppoll(timeoutMicroS) <= 0) +if (poll(timeoutMicroS) <= 0) break; const auto now = std::chrono::steady_clock::now(); diff --git a/net/DelaySocket.cpp b/net/DelaySocket.cpp index b07b46cc4..fe9478bca 100644 --- a/net/DelaySocket.cpp +++ b/net/DelaySocket.cpp @@ -77,8 +77,8 @@ public: // FIXME - really need to propagate 'noDelay' etc. // have a debug only lookup of delayed sockets for this case ? -int pgetPollEvents(std::chrono::steady_clock::time_point now, - int64_t &timeoutMaxMicroS) override +int getPollEvents(std::chrono::steady_clock::time_point now, + int64_t &timeoutMaxMicroS) override { if (_chunks.size() > 0) { diff --git a/net/ServerSocket.hpp b/net/ServerSocket.hpp index 65f826913..5316d3318 100644 --- a/net/ServerSocket.hpp +++ b/net/ServerSocket.hpp @@ -65,8 +65,8 @@ public: /// Returns a valid Socket shared_ptr on success only. virtual std::shared_ptr accept(); -int pgetPollEvents(std::chrono::steady_clock::time_point /* now */, - int64_t & /* timeoutMaxMicroS */) override +int getPollEvents(std::chrono::steady_clock::time_point /* now */, + int64_t & /* timeoutMaxMicroS */) override { return POLLIN; } diff --git a/net/Socket.cpp b/net/Socket.cpp index 47ae1ad41..372f9ea1a 100644 --- a/net/Socket.cpp +++ b/net/Socket.cpp @@ -194,7 +194,7 @@ void SocketPoll::pollingThreadEntry() LOG_INF("Finished polling thread [" << _name << "]."); } -int SocketPoll::ppoll(int64_t timeoutMaxMicroS) +int SocketPoll::poll(int64_t timeoutMaxMicroS) { if (_runOnClientThread) checkAndReThread(); @@ -205,7 +205,7 @@ int SocketPoll::ppoll(int64_t timeoutMaxMicroS) std::chrono::steady_clock::now(); // The events to poll on change each spin of the loop. -psetupPollFds(now, timeoutMaxMicroS); +setupPollFds(now, timeoutMaxMicroS); const size_t size = _pollSockets.size(); int rc; @@ -529,7 +529,7 @@ void WebSocketHandler::dumpState(std::ostream& os) void StreamSocket::dumpState(std::ostream& os) { int64_t timeoutMaxMicroS = SocketPoll::DefaultPollTimeoutMicroS; -int events = pgetPollEvents(std::chrono::steady_clock::now(), timeoutMaxMicroS); +int events = getPollEvents(std::chrono::steady_clock::now(), timeoutMaxMicroS); os << "\t" << getFD() << "\t" << events << "\t" << _inBuffer.size() << "\t" << _outBuffer.size() << "\t" << " r: " << _bytesRecvd << "\t w: " << _bytesSent << "\t" diff --git a/net/Socket.hpp b/net/Socket.hpp index 852012424..199ea0a09 100644 --- a/net/Socket.hpp +++ b/net/Socket.hpp @@ -154,7 +154,7 @@ public: /// Prepare our poll record; adjust @timeoutMaxMs downwards /// fo
[Libreoffice-commits] online.git: kit/ForKit.cpp Makefile.am wsd/LOOLWSD.cpp wsd/LOOLWSD.hpp
Makefile.am | 19 +++ kit/ForKit.cpp | 11 +++ wsd/LOOLWSD.cpp | 25 + wsd/LOOLWSD.hpp |3 +++ 4 files changed, 58 insertions(+) New commits: commit 7ba4e9dd2324534c729b053afcf7062f58ebed9a Author: Henry Castro AuthorDate: Wed Mar 4 15:38:17 2020 -0400 Commit: Henry Castro CommitDate: Fri Mar 6 13:37:53 2020 +0100 wsd: debug: run the server with a single "lokit" process Sometimes it is very useful to have one "lokit" process, to focus on a 100% reproducible bug, and not worry that server pre-spawn several processes. Change-Id: I414a8145b53a0601a282cba9c245833f5d07f404 Reviewed-on: https://gerrit.libreoffice.org/c/online/+/8 Tested-by: Jenkins CollaboraOffice Reviewed-by: Henry Castro diff --git a/Makefile.am b/Makefile.am index f183ad6ff..9d04569b2 100644 --- a/Makefile.am +++ b/Makefile.am @@ -331,6 +331,25 @@ run: all @JAILS_PATH@ --o:admin_console.username=admin --o:admin_console.password=admin \ --o:logging.file[@enable]=true --o:logging.level=trace +if ENABLE_DEBUG +run-one: all @JAILS_PATH@ + @echo "Launching loolwsd" + @fc-cache "@LO_PATH@"/share/fonts/truetype + @cp $(abs_top_srcdir)/test/data/hello.odt $(abs_top_srcdir)/test/data/hello-world.odt + @cp $(abs_top_srcdir)/test/data/hello.ods $(abs_top_srcdir)/test/data/hello-world.ods + @cp $(abs_top_srcdir)/test/data/hello.odp $(abs_top_srcdir)/test/data/hello-world.odp + @echo + ./loolwsd --o:sys_template_path="@SYSTEMPLATE_PATH@" \ + --o:security.capabilities="$(CAPABILITIES)" \ + --o:child_root_path="@JAILS_PATH@" --o:storage.filesystem[@allow]=true \ + --o:ssl.cert_file_path="$(abs_top_srcdir)/etc/cert.pem" \ + --o:ssl.key_file_path="$(abs_top_srcdir)/etc/key.pem" \ + --o:ssl.ca_file_path="$(abs_top_srcdir)/etc/ca-chain.cert.pem" \ + --o:admin_console.username=admin --o:admin_console.password=admin \ + --o:logging.file[@enable]=true --o:logging.level=trace \ + --singlekit +endif + sync-writer: browser-sync start --config browsersync-config.js --startPath "loleaflet/96c23f663/loleaflet.html?file_path=file://$(abs_top_srcdir)/test/data/hello-world.odt" diff --git a/kit/ForKit.cpp b/kit/ForKit.cpp index 3af723a99..b1fe997a0 100644 --- a/kit/ForKit.cpp +++ b/kit/ForKit.cpp @@ -47,7 +47,11 @@ using Poco::Thread; #ifndef KIT_IN_PROCESS static bool NoCapsForKit = false; static bool NoSeccomp = false; +#if ENABLE_DEBUG +static bool SingleKit = false; +#endif #endif + static bool DisplayVersion = false; static std::string UnitTestLibrary; static std::string LogLevel; @@ -462,6 +466,10 @@ int main(int argc, char** argv) eq = std::strchr(cmd, '='); UnitTestLibrary = std::string(eq+1); } +else if (std::strstr(cmd, "--singlekit") == cmd) +{ +SingleKit = true; +} #endif // we are running in a lower-privilege mode - with no chroot else if (std::strstr(cmd, "--nocaps") == cmd) @@ -550,6 +558,9 @@ int main(int argc, char** argv) break; } +#if ENABLE_DEBUG +if (!SingleKit) +#endif forkLibreOfficeKit(childRoot, sysTemplate, loTemplate, loSubPath); } diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp index 8ff0564e3..6eaa05020 100644 --- a/wsd/LOOLWSD.cpp +++ b/wsd/LOOLWSD.cpp @@ -356,6 +356,13 @@ void cleanupDocBrokers() LOG_END(logger, true); } + +#if ENABLE_DEBUG +if (LOOLWSD::SingleKit && DocBrokers.size() == 0) +{ +SigUtil::requestShutdown(); +} +#endif } } @@ -702,6 +709,9 @@ std::atomic LOOLWSD::ForKitProcId(-1); bool LOOLWSD::NoCapsForKit = false; bool LOOLWSD::NoSeccomp = false; bool LOOLWSD::AdminEnabled = true; +#if ENABLE_DEBUG +bool LOOLWSD::SingleKit = false; +#endif #endif #ifdef FUZZER bool LOOLWSD::DummyLOK = false; @@ -1361,6 +1371,10 @@ void LOOLWSD::defineOptions(OptionSet& optionSet) .required(false) .repeatable(false) .argument("seconds")); + +optionSet.addOption(Option("singlekit", "", "Spawn one libreoffice kit.") +.required(false) +.repeatable(false)); #endif #ifdef FUZZER @@ -1408,6 +1422,11 @@ void LOOLWSD::handleOption(const std::string& optionName, UnitTestLibrary = value; else if (optionName == "careerspan") careerSpanMs = std::stoi(value) * 1000; // Convert second to ms +else if (optionName == "singlekit") +{ +SingleKit = true; +NumPreSpawnedChildren = 1; +} static const char* latencyMs = std::getenv("LOOL_DELAY
[Libreoffice-commits] online.git: kit/ForKit.cpp kit/Kit.cpp kit/Kit.hpp test/test.cpp test/test.hpp wsd/LOOLWSD.cpp
kit/ForKit.cpp |9 ++--- kit/Kit.cpp |9 + kit/Kit.hpp |5 +++-- test/test.cpp | 22 -- test/test.hpp |7 ++- wsd/LOOLWSD.cpp |2 +- 6 files changed, 37 insertions(+), 17 deletions(-) New commits: commit 720c26176a09d8622cb7a8414b555b6f4f986d58 Author: Ashod Nakashian AuthorDate: Sat Sep 21 14:39:32 2019 -0400 Commit: Ashod Nakashian CommitDate: Sun Sep 22 20:23:27 2019 +0200 wsd: improved kit thread naming Now the wsd docbroker thread and its peer kit thread are trivial to match, since they are called docbroker_xxx and kitbroker_xxx (where xxx is the instance ID) respectively. Also, label spare kit instances as kit_spare_xxx to differentiate from ones with actual documents, where xxx is a running counter to differentiate spare instances from one another. Now we are able to easily see (and count) the number of spare kit instances, and match wsd and kit threads handling a given document. Unit-test logic updated to reflect the new thread naming scheme. Change-Id: I154dc8f200fbe0e65f3f5984e6dad2cef1b52e22 Reviewed-on: https://gerrit.libreoffice.org/79328 Reviewed-by: Ashod Nakashian Tested-by: Ashod Nakashian diff --git a/kit/ForKit.cpp b/kit/ForKit.cpp index 81bff060e..2eea47725 100644 --- a/kit/ForKit.cpp +++ b/kit/ForKit.cpp @@ -250,7 +250,10 @@ static int createLibreOfficeKit(const std::string& childRoot, // Generate a jail ID to be used for in the jail path. const std::string jailId = Util::rng::getFilename(16); -LOG_DBG("Forking a loolkit process with jailId: " << jailId << "."); +// Used to label the spare kit instances +static size_t spareKitId = 0; +++spareKitId; +LOG_DBG("Forking a loolkit process with jailId: " << jailId << " as spare loolkit #" << spareKitId << "."); const Process::PID pid = fork(); if (!pid) @@ -277,9 +280,9 @@ static int createLibreOfficeKit(const std::string& childRoot, } #ifndef KIT_IN_PROCESS -lokit_main(childRoot, jailId, sysTemplate, loTemplate, loSubPath, NoCapsForKit, NoSeccomp, queryVersion, DisplayVersion); +lokit_main(childRoot, jailId, sysTemplate, loTemplate, loSubPath, NoCapsForKit, NoSeccomp, queryVersion, DisplayVersion, spareKitId); #else -lokit_main(childRoot, jailId, sysTemplate, loTemplate, loSubPath, true, true, queryVersion, DisplayVersion); +lokit_main(childRoot, jailId, sysTemplate, loTemplate, loSubPath, true, true, queryVersion, DisplayVersion, spareKitId); #endif } else diff --git a/kit/Kit.cpp b/kit/Kit.cpp index beebb8aa2..b2a4a8b23 100644 --- a/kit/Kit.cpp +++ b/kit/Kit.cpp @@ -490,7 +490,6 @@ public: // Shrink cache when we exceed the size to maximize // the chance of hitting these entries in the future. _cacheSize -= it->second.getData()->size(); - it = _cache.erase(it); } else @@ -2262,6 +2261,7 @@ protected: std::string url; URI::decode(docKey, url); LOG_INF("New session [" << sessionId << "] request on url [" << url << "]."); +Util::setThreadName("kitbroker_" + docId); if (!document) document = std::make_shared(_loKit, _jailId, docKey, docId, url, _queue, shared_from_this()); @@ -2428,11 +2428,12 @@ void lokit_main( bool noCapabilities, bool noSeccomp, bool queryVersion, -bool displayVersion +bool displayVersion, #else const std::string& documentUri, -int docBrokerSocket +int docBrokerSocket, #endif +size_t spareKitId ) { #if !MOBILEAPP @@ -2442,7 +2443,7 @@ void lokit_main( SigUtil::setTerminationSignals(); #endif -Util::setThreadName("loolkit"); +Util::setThreadName("kit_spare_" + Util::encodeId(spareKitId, 3)); // Reinitialize logging when forked. const bool logToFile = std::getenv("LOOL_LOGFILE"); diff --git a/kit/Kit.hpp b/kit/Kit.hpp index 0f8d90d6c..5c94c1342 100644 --- a/kit/Kit.hpp +++ b/kit/Kit.hpp @@ -35,11 +35,12 @@ void lokit_main( bool noCapabilities, bool noSeccomp, bool queryVersionInfo, -bool displayVersion +bool displayVersion, #else const std::string& documentUri, -int docBrokerSocket +int docBrokerSocket, #endif +size_t spareKitId ); bool globalPreinit(const std::string& loTemplate); diff --git a/test/test.cpp b/test/test.cpp index f5824b1d1..8df5d1e79 100644 --- a/test/test.cpp +++ b/test/test.cpp @@ -181,7 +181,7 @@ std::vector getProcPids(const char* exec_filename) std::vec
[Libreoffice-commits] online.git: kit/ForKit.cpp
kit/ForKit.cpp |9 +++-- 1 file changed, 7 insertions(+), 2 deletions(-) New commits: commit b9db83518bf7a3236a5c9d970162302ecf7ff65a Author: Ashod Nakashian Date: Sun Jun 3 17:54:50 2018 -0400 wsd: warn when we have no kits and we are not exiting just yet Change-Id: I8c19dcea3eb900a989aebac7ef96793af31bdce8 Reviewed-on: https://gerrit.libreoffice.org/55576 Reviewed-by: Jan Holesovsky Tested-by: Jan Holesovsky diff --git a/kit/ForKit.cpp b/kit/ForKit.cpp index 89f49e53d..8d373ee6a 100644 --- a/kit/ForKit.cpp +++ b/kit/ForKit.cpp @@ -221,6 +221,11 @@ static void cleanupChildren() LOG_INF("Child " << exitedChildPid << " has exited, will remove its jail [" << it->second << "]."); jails.emplace_back(it->second); childJails.erase(it); +if (childJails.empty() && !TerminationFlag) +{ +// We ran out of kits and we aren't terminating. +LOG_WRN("No live Kits exist, and we are not terminating yet."); +} } else { @@ -264,7 +269,7 @@ static int createLibreOfficeKit(const std::string& childRoot, const size_t delaySecs = std::stoul(std::getenv("SLEEPKITFORDEBUGGER")); if (delaySecs > 0) { -std::cerr << "Sleeping " << delaySecs +std::cerr << "Kit: Sleeping " << delaySecs << " seconds to give you time to attach debugger to process " << Process::id() << std::endl; Thread::sleep(delaySecs * 1000); @@ -353,7 +358,7 @@ int main(int argc, char** argv) const size_t delaySecs = std::stoul(std::getenv("SLEEPFORDEBUGGER")); if (delaySecs > 0) { -std::cerr << "Sleeping " << delaySecs +std::cerr << "Forkit: Sleeping " << delaySecs << " seconds to give you time to attach debugger to process " << Process::id() << std::endl; Thread::sleep(delaySecs * 1000); ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] online.git: kit/ForKit.cpp kit/Kit.cpp kit/Kit.hpp loolwsd.xml.in Makefile.am wsd/LOOLWSD.cpp wsd/LOOLWSD.hpp
Makefile.am |4 kit/ForKit.cpp | 17 + kit/Kit.cpp | 13 ++--- kit/Kit.hpp |1 + loolwsd.xml.in |5 + wsd/LOOLWSD.cpp | 36 +--- wsd/LOOLWSD.hpp |1 + 7 files changed, 51 insertions(+), 26 deletions(-) New commits: commit 8f134aa1a94af558f387c14b292d415a2c7a1127 Author: Michael Meeks Date: Mon Mar 19 15:20:10 2018 + Allow running without seccomp and capabilities. There are some significant security trade-offs here which are now at least configurable. Change-Id: I1d879d69e91392f4ccf5db250a2277f53df60db7 diff --git a/Makefile.am b/Makefile.am index cd3133820..ec1faf917 100644 --- a/Makefile.am +++ b/Makefile.am @@ -86,7 +86,6 @@ loolwsd_SOURCES = $(loolwsd_sources) \ noinst_PROGRAMS = clientnb \ connect \ lokitclient \ - loolforkit-nocaps \ loolwsd_fuzzer connect_SOURCES = tools/Connect.cpp \ @@ -116,9 +115,6 @@ clientnb_SOURCES = net/clientnb.cpp \ common/Log.cpp \ common/Util.cpp -# build a binary with no caps to help debugging -loolforkit_nocaps_SOURCES = $(loolforkit_SOURCES) - loolmount_SOURCES = tools/mount.cpp loolmap_SOURCES = tools/map.cpp diff --git a/kit/ForKit.cpp b/kit/ForKit.cpp index eead266f4..3dac8ac18 100644 --- a/kit/ForKit.cpp +++ b/kit/ForKit.cpp @@ -49,6 +49,7 @@ using Poco::Util::Application; #ifndef KIT_IN_PROCESS static bool NoCapsForKit = false; +static bool NoSeccomp = false; #endif static bool DisplayVersion = false; static std::string UnitTestLibrary; @@ -271,9 +272,9 @@ static int createLibreOfficeKit(const std::string& childRoot, } #ifndef KIT_IN_PROCESS -lokit_main(childRoot, jailId, sysTemplate, loTemplate, loSubPath, NoCapsForKit, queryVersion, DisplayVersion); +lokit_main(childRoot, jailId, sysTemplate, loTemplate, loSubPath, NoCapsForKit, NoSeccomp, queryVersion, DisplayVersion); #else -lokit_main(childRoot, jailId, sysTemplate, loTemplate, loSubPath, true, queryVersion, DisplayVersion); +lokit_main(childRoot, jailId, sysTemplate, loTemplate, loSubPath, true, true, queryVersion, DisplayVersion); #endif } else @@ -461,12 +462,20 @@ int main(int argc, char** argv) eq = std::strchr(cmd, '='); UnitTestLibrary = std::string(eq+1); } -// we are running in no-privilege mode - with no chroot etc. +#endif +// we are running in a lower-privilege mode - with no chroot else if (std::strstr(cmd, "--nocaps") == cmd) { +LOG_ERR("Security: Running without the capability to enter a chroot jail is ill advised."); NoCapsForKit = true; } -#endif + +// we are running without seccomp protection +else if (std::strstr(cmd, "--noseccomp") == cmd) +{ +LOG_ERR("Security :Running without the ability to filter system calls is ill advised."); +NoSeccomp = true; +} } if (loSubPath.empty() || sysTemplate.empty() || diff --git a/kit/Kit.cpp b/kit/Kit.cpp index 89f045ad9..ddd0b2c83 100644 --- a/kit/Kit.cpp +++ b/kit/Kit.cpp @@ -1967,6 +1967,7 @@ void lokit_main(const std::string& childRoot, const std::string& loTemplate, const std::string& loSubPath, bool noCapabilities, +bool noSeccomp, bool queryVersion, bool displayVersion) { @@ -2119,7 +2120,7 @@ void lokit_main(const std::string& childRoot, } else // noCapabilities set { -LOG_INF("Using template " << loTemplate << " as install subpath - skipping jail setup"); +LOG_ERR("Security warning - using template " << loTemplate << " as install subpath - skipping chroot jail setup"); userdir_url = "file:///" + jailPath.toString() + "/user"; instdir_path = "/" + loTemplate + "/program"; } @@ -2156,8 +2157,14 @@ void lokit_main(const std::string& childRoot, // Lock down the syscalls that can be used if (!Seccomp::lockdown(Seccomp::Type::KIT)) { -LOG_ERR("LibreOfficeKit security lockdown failed. Exiting."); -std::_Exit(Application::EXIT_SOFTWARE); +if (!noSeccomp) +{ +LOG_ERR("LibreOfficeKit seccomp security lockdown failed. Exiting."); +std::_Exit(Application::EXIT_SOFTWARE); +} + +LOG_ERR("LibreOfficeKit seccomp security lockdown failed, but configured to continue. " +"You are running in a significantly less secure mode."); } rlimit rlim = { 0, 0 }; diff --git a/kit/Kit.hpp b/kit/Kit.hpp index 829ab2e2e..ac80b4869 100644 --- a/kit/Kit.hpp +++ b/kit/Kit.hpp @@ -20,6 +20,7 @@ void lokit_main(const std::string& child
[Libreoffice-commits] online.git: kit/ForKit.cpp
kit/ForKit.cpp |1 + 1 file changed, 1 insertion(+) New commits: commit 00dc0658d3fd7ae274da9589515fc97335567e64 Author: Samuel Mehrbrodt Date: Wed Jan 31 11:45:03 2018 +0100 Missing capabilities: Add hint to check mount options Change-Id: I946df0082b385b2eaaad9c23b9e5e7ac508f64aa diff --git a/kit/ForKit.cpp b/kit/ForKit.cpp index 798126fa..bfd076fa 100644 --- a/kit/ForKit.cpp +++ b/kit/ForKit.cpp @@ -509,6 +509,7 @@ int main(int argc, char** argv) if (!NoCapsForKit && !haveCorrectCapabilities()) { std::cerr << "FATAL: Capabilities are not set for the loolforkit program." << std::endl; +std::cerr << "Please make sure that the current partition was *not* mounted with the 'nosuid' option." << std::endl; std::cerr << "If you are on SLES11, please set 'file_caps=1' as kernel boot option." << std::endl << std::endl; return Application::EXIT_SOFTWARE; } ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] online.git: kit/ForKit.cpp kit/Kit.cpp
kit/ForKit.cpp | 17 ++--- kit/Kit.cpp| 14 +- 2 files changed, 23 insertions(+), 8 deletions(-) New commits: commit 95af839fd9183aa0ccb41ec6c13838739d90c819 Author: Ashod Nakashian Date: Mon Jan 8 23:56:15 2018 -0500 wsd: trace first child's startup activity To help debug early failure, log the first child's statup at trace-level. Change-Id: I8a6c8fe535bbc971174c0d950a2243460f81a2c7 Reviewed-on: https://gerrit.libreoffice.org/47628 Reviewed-by: Michael Meeks Tested-by: Michael Meeks diff --git a/kit/ForKit.cpp b/kit/ForKit.cpp index 48e4ebb5..798126fa 100644 --- a/kit/ForKit.cpp +++ b/kit/ForKit.cpp @@ -246,12 +246,6 @@ static int createLibreOfficeKit(const std::string& childRoot, LOG_DBG("Forking a loolkit process with jailId: " << jailId << "."); -if (LogLevel != "trace") -{ -LOG_INF("Setting log-level to [" << LogLevel << "]."); -Log::logger().setLevel(LogLevel); -} - const Process::PID pid = fork(); if (!pid) { @@ -526,7 +520,8 @@ int main(int argc, char** argv) LOG_INF("Preinit stage OK."); // We must have at least one child, more are created dynamically. -// Ask this first child to send version information to master process +// Ask this first child to send version information to master process and trace startup. +::setenv("LOOL_TRACE_STARTUP", "1", 1); Process::PID forKitPid = createLibreOfficeKit(childRoot, sysTemplate, loTemplate, loSubPath, true); if (forKitPid < 0) { @@ -534,6 +529,14 @@ int main(int argc, char** argv) std::_Exit(Application::EXIT_SOFTWARE); } +// No need to trace subsequent children. +::unsetenv("LOOL_TRACE_STARTUP"); +if (LogLevel != "trace") +{ +LOG_INF("Setting log-level to [" << LogLevel << "]."); +Log::logger().setLevel(LogLevel); +} + CommandDispatcher commandDispatcher(0); LOG_INF("ForKit process is ready."); diff --git a/kit/Kit.cpp b/kit/Kit.cpp index dba54ecb..8bb4864c 100644 --- a/kit/Kit.cpp +++ b/kit/Kit.cpp @@ -1934,8 +1934,14 @@ void lokit_main(const std::string& childRoot, logProperties["path"] = std::string(logFilename); } -Log::initialize("kit", logLevel ? logLevel : "", logColor != nullptr, logToFile, logProperties); Util::rng::reseed(); +const std::string LogLevel = logLevel ? logLevel : "trace"; +const bool bTraceStartup = (std::getenv("LOOL_TRACE_STARTUP") != nullptr); +Log::initialize("kit", bTraceStartup ? "trace" : logLevel, logColor != nullptr, logToFile, logProperties); +if (bTraceStartup && LogLevel != "trace") +{ +LOG_INF("Setting log-level to [trace] and delaying setting to requested [" << LogLevel << "]."); +} assert(!childRoot.empty()); assert(!sysTemplate.empty()); @@ -2146,6 +2152,12 @@ void lokit_main(const std::string& childRoot, auto queue = std::make_shared(); +if (bTraceStartup && LogLevel != "trace") +{ +LOG_INF("Setting log-level to [" << LogLevel << "]."); +Log::logger().setLevel(LogLevel); +} + const std::string socketName = "child_ws_" + pid; IoUtil::SocketProcessor(ws, socketName, [&socketName, &ws, &loKit, &jailId, &queue](const std::vector& data) ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] online.git: kit/ForKit.cpp wsd/LOOLWSD.cpp wsd/LOOLWSD.hpp
kit/ForKit.cpp | 16 ++-- wsd/LOOLWSD.cpp | 19 --- wsd/LOOLWSD.hpp |1 + 3 files changed, 31 insertions(+), 5 deletions(-) New commits: commit 94781ec6d989b7f96ac606faeee0fd7fa6fa3bea Author: Ashod Nakashian Date: Sun Jan 7 22:34:28 2018 -0500 wsd: log at trace level until first child is forked Change-Id: I1b995b4714738f3bffd6dac58cf90ee6f1a32898 Reviewed-on: https://gerrit.libreoffice.org/47565 Reviewed-by: Ashod Nakashian Tested-by: Ashod Nakashian diff --git a/kit/ForKit.cpp b/kit/ForKit.cpp index e399c116..48e4ebb5 100644 --- a/kit/ForKit.cpp +++ b/kit/ForKit.cpp @@ -52,6 +52,7 @@ static bool NoCapsForKit = false; #endif static bool DisplayVersion = false; static std::string UnitTestLibrary; +static std::string LogLevel; static std::atomic ForkCounter(0); static std::map childJails; @@ -245,6 +246,12 @@ static int createLibreOfficeKit(const std::string& childRoot, LOG_DBG("Forking a loolkit process with jailId: " << jailId << "."); +if (LogLevel != "trace") +{ +LOG_INF("Setting log-level to [" << LogLevel << "]."); +Log::logger().setLevel(LogLevel); +} + const Process::PID pid = fork(); if (!pid) { @@ -376,7 +383,12 @@ int main(int argc, char** argv) logProperties["path"] = std::string(logFilename); } -Log::initialize("frk", logLevel ? logLevel : "", logColor != nullptr, logToFile, logProperties); +Log::initialize("frk", "trace", logColor != nullptr, logToFile, logProperties); +LogLevel = logLevel ? logLevel : "trace"; +if (LogLevel != "trace") +{ +LOG_INF("Setting log-level to [trace] and delaying setting to requested [" << LogLevel << "]."); +} std::string childRoot; std::string loSubPath; @@ -478,7 +490,7 @@ int main(int argc, char** argv) } // Setup & check environment -std::string layers( +const std::string layers( "xcsxcu:${BRAND_BASE_DIR}/share/registry " "res:${BRAND_BASE_DIR}/share/registry " "bundledext:${${BRAND_BASE_DIR}/program/lounorc:BUNDLED_EXTENSIONS_USER}/registry/com.sun.star.comp.deployment.configuration.PackageRegistryBackend/configmgr.ini " diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp index 99174cca..b3336f01 100644 --- a/wsd/LOOLWSD.cpp +++ b/wsd/LOOLWSD.cpp @@ -562,6 +562,7 @@ std::string LOOLWSD::FileServerRoot; std::string LOOLWSD::LOKitVersion; std::string LOOLWSD::ConfigFile = LOOLWSD_CONFIGDIR "/loolwsd.xml"; std::string LOOLWSD::ConfigDir = LOOLWSD_CONFIGDIR "/conf.d"; +std::string LOOLWSD::LogLevel = "trace"; Util::RuntimeConstant LOOLWSD::SSLEnabled; Util::RuntimeConstant LOOLWSD::SSLTermination; std::set LOOLWSD::EditFileExtensions; @@ -716,8 +717,9 @@ void LOOLWSD::initialize(Application& self) // Allow UT to manipulate before using configuration values. UnitWSD::get().configure(config()); -const auto logLevel = getConfigValue(conf, "logging.level", "trace"); -setenv("LOOL_LOGLEVEL", logLevel.c_str(), true); +// Set the log-level after complete initialization to force maximum details at startup. +LogLevel = getConfigValue(conf, "logging.level", "trace"); +setenv("LOOL_LOGLEVEL", LogLevel.c_str(), true); const auto withColor = getConfigValue(conf, "logging.color", true) && isatty(fileno(stderr)); if (withColor) { @@ -755,7 +757,12 @@ void LOOLWSD::initialize(Application& self) } } -Log::initialize("wsd", logLevel, withColor, logToFile, logProperties); +// Log at trace level until we complete the initialization. +Log::initialize("wsd", "trace", withColor, logToFile, logProperties); +if (LogLevel != "trace") +{ +LOG_INF("Setting log-level to [trace] and delaying setting to requested [" << LogLevel << "]."); +} #if ENABLE_SSL LOOLWSD::SSLEnabled.set(getConfigValue(conf, "ssl.enable", true)); @@ -2713,6 +2720,12 @@ int LOOLWSD::innerMain() } #endif +if (LogLevel != "trace") +{ +LOG_INF("Setting log-level to [" << LogLevel << "]."); +Log::logger().setLevel(LogLevel); +} + // Start the server. srv.start(ClientPortNumber); diff --git a/wsd/LOOLWSD.hpp b/wsd/LOOLWSD.hpp index 40a32b73..9e388a6c 100644 --- a/wsd/LOOLWSD.hpp +++ b/wsd/LOOLWSD.hpp @@ -55,6 +55,7 @@ public: static std::string ServerName; static std::string FileServerRoot; static std::string LOKitVersion; +static std::string LogLevel; static std::atomic NumConnections; static bool TileCachePersistent; static std::unique_ptr TraceDumper; ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] online.git: kit/ForKit.cpp wsd/LOOLWSD.cpp
kit/ForKit.cpp |4 wsd/LOOLWSD.cpp |2 +- 2 files changed, 5 insertions(+), 1 deletion(-) New commits: commit 894c5f2cc256d9db69add9c0922dd937e297fb98 Author: Jan Holesovsky Date: Thu Aug 10 11:11:05 2017 +0200 Warn more about missing capabilities, and advise what to do on SLES11. Change-Id: I93587db6fa32c1c505877c20857799be71ee162f diff --git a/kit/ForKit.cpp b/kit/ForKit.cpp index 5dde307f..32ee85e1 100644 --- a/kit/ForKit.cpp +++ b/kit/ForKit.cpp @@ -501,7 +501,11 @@ int main(int argc, char** argv) LOG_INF("Note: LD_BIND_NOW is not set."); if (!NoCapsForKit && !haveCorrectCapabilities()) +{ +std::cerr << "FATAL: Capabilities are not set for the loolforkit program." << std::endl; +std::cerr << "If you are on SLES11, please set 'file_caps=1' as kernel boot option." << std::endl << std::endl; return Application::EXIT_SOFTWARE; +} // Initialize LoKit if (!globalPreinit(loTemplate)) diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp index 17eb4ff6..8cc04d37 100644 --- a/wsd/LOOLWSD.cpp +++ b/wsd/LOOLWSD.cpp @@ -2597,7 +2597,7 @@ int LOOLWSD::innerMain() { const auto msg = "Failed to fork child processes."; LOG_FTL(msg); -std::cerr << msg << std::endl; +std::cerr << "FATAL: " << msg << std::endl; throw std::runtime_error(msg); } ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] online.git: kit/ForKit.cpp
kit/ForKit.cpp |3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) New commits: commit 98dd83338c8c5b6d3579562279d7e7b7dba153c0 Author: Ashod Nakashian Date: Sun Jul 2 22:09:12 2017 -0400 wsd: log jail removal Change-Id: I1fef24d66bcab800dc1b4536da781ab8d344586e Reviewed-on: https://gerrit.libreoffice.org/39463 Reviewed-by: Ashod Nakashian Tested-by: Ashod Nakashian diff --git a/kit/ForKit.cpp b/kit/ForKit.cpp index ed3d2f2a..fa95321d 100644 --- a/kit/ForKit.cpp +++ b/kit/ForKit.cpp @@ -216,7 +216,7 @@ static void cleanupChildren() const auto it = childJails.find(exitedChildPid); if (it != childJails.end()) { -LOG_INF("Child " << exitedChildPid << " has exited, removing its jail '" << it->second << "'."); +LOG_INF("Child " << exitedChildPid << " has exited, will remove its jail [" << it->second << "]."); jails.emplace_back(it->second); childJails.erase(it); } @@ -229,6 +229,7 @@ static void cleanupChildren() // Now delete the jails. for (const auto& path : jails) { +LOG_INF("Removing jail [" << path << "]."); FileUtil::removeFile(path, true); } } ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] online.git: kit/ForKit.cpp
kit/ForKit.cpp | 30 +- 1 file changed, 17 insertions(+), 13 deletions(-) New commits: commit f062b2058ea97be06a40b9a159ad4de58c7a2dc9 Author: Ashod Nakashian Date: Sat May 6 22:13:02 2017 -0400 wsd: use fast tokenizer Change-Id: I477bac24a5e944ce3d747db6e694f2766b44c7f3 Reviewed-on: https://gerrit.libreoffice.org/37370 Reviewed-by: Ashod Nakashian Tested-by: Ashod Nakashian diff --git a/kit/ForKit.cpp b/kit/ForKit.cpp index 035f69a9..64d17f45 100644 --- a/kit/ForKit.cpp +++ b/kit/ForKit.cpp @@ -26,7 +26,6 @@ #include #include -#include #include #include @@ -42,7 +41,6 @@ #include "security.h" using Poco::Process; -using Poco::StringTokenizer; using Poco::Thread; #ifndef KIT_IN_PROCESS using Poco::Util::Application; @@ -96,21 +94,27 @@ public: } LOG_INF("ForKit command: [" << message << "]."); -StringTokenizer tokens(message, " ", StringTokenizer::TOK_IGNORE_EMPTY | StringTokenizer::TOK_TRIM); - -if (tokens[0] == "spawn" && tokens.count() == 2) +try { -const auto count = std::stoi(tokens[1]); -if (count > 0) -{ -LOG_INF("Setting to spawn " << tokens[1] << " child" << (count == 1 ? "" : "ren") << " per request."); -ForkCounter = count; -} -else +std::vector tokens = LOOLProtocol::tokenize(message); +if (tokens.size() == 2 && tokens[0] == "spawn") { -LOG_WRN("Cannot spawn " << tokens[1] << " children as requested."); +const auto count = std::stoi(tokens[1]); +if (count > 0) +{ +LOG_INF("Setting to spawn " << tokens[1] << " child" << (count == 1 ? "" : "ren") << " per request."); +ForkCounter = count; +} +else +{ +LOG_WRN("Cannot spawn " << tokens[1] << " children as requested."); +} } } +catch (const std::exception& exc) +{ +LOG_ERR("Error while processing forkit request [" << message << "]: " << exc.what()); +} return true; } ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] online.git: kit/ForKit.cpp
kit/ForKit.cpp |4 1 file changed, 4 insertions(+) New commits: commit 36900f7d78bd6c08e8e065ecb2425c4052521470 Author: Michael Meeks Date: Sat Apr 8 13:31:07 2017 +0100 Clear display to avoid potential problems. Running --nocaps under massif; it is unexpected to see fire_glxtest_process doing heavy lifting glx work. diff --git a/kit/ForKit.cpp b/kit/ForKit.cpp index 59da5d64..035f69a9 100644 --- a/kit/ForKit.cpp +++ b/kit/ForKit.cpp @@ -453,6 +453,10 @@ int main(int argc, char** argv) "user:*file://" LOOLWSD_CONFIGDIR "/loolkitconfig.xcu " #endif ); + +// No-caps tracing can spawn eg. glxinfo & other oddness. +unsetenv("DISPLAY"); + ::setenv("CONFIGURATION_LAYERS", layers.c_str(), 1 /* override */); ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] online.git: kit/ForKit.cpp test/httpwstest.cpp test/UnitFuzz.cpp wsd/Auth.cpp wsd/TileCache.cpp
kit/ForKit.cpp |2 - test/UnitFuzz.cpp |2 - test/httpwstest.cpp |4 +- wsd/Auth.cpp| 78 wsd/TileCache.cpp | 64 ++ 5 files changed, 79 insertions(+), 71 deletions(-) New commits: commit 57e7d22e28c574632631f6773affa1f600c0c2a7 Author: Ashod Nakashian Date: Sat Mar 11 14:42:50 2017 -0500 wsd: logging and formatting cleanup Change-Id: I5bfbd517c37b6df864d181abe7c70857815b9ece Reviewed-on: https://gerrit.libreoffice.org/35082 Reviewed-by: Ashod Nakashian Tested-by: Ashod Nakashian diff --git a/kit/ForKit.cpp b/kit/ForKit.cpp index ca58e2a..fe81ac2 100644 --- a/kit/ForKit.cpp +++ b/kit/ForKit.cpp @@ -53,7 +53,7 @@ static bool NoCapsForKit = false; #endif static bool DisplayVersion = false; static std::string UnitTestLibrary; -static std::atomic ForkCounter( 0 ); +static std::atomic ForkCounter(0); static std::map childJails; diff --git a/test/UnitFuzz.cpp b/test/UnitFuzz.cpp index 18ee753..460fcf1 100644 --- a/test/UnitFuzz.cpp +++ b/test/UnitFuzz.cpp @@ -43,7 +43,7 @@ public: std::string corruptString(const std::string &str) { std::string ret; -for ( auto it = str.begin(); it != str.end(); ++it) +for (auto it = str.begin(); it != str.end(); ++it) { int op = _dist(_mt); if (op < 10) { diff --git a/test/httpwstest.cpp b/test/httpwstest.cpp index cd5e156..9e9df3e 100644 --- a/test/httpwstest.cpp +++ b/test/httpwstest.cpp @@ -1229,7 +1229,7 @@ void HTTPWSTest::testMaxColumn() CPPUNIT_ASSERT(docHeight >= 0); const std::string text = "key type=input char=0 key=1027"; -while ( cursorX <= docWidth ) +while (cursorX <= docWidth) { sendTextFrame(socket, text); cursorX += cursorWidth; @@ -1268,7 +1268,7 @@ void HTTPWSTest::testMaxRow() CPPUNIT_ASSERT(docHeight >= 0); const std::string text = "key type=input char=0 key=1024"; -while ( cursorY <= docHeight ) +while (cursorY <= docHeight) { sendTextFrame(socket, text); cursorY += cursorHeight; diff --git a/wsd/Auth.cpp b/wsd/Auth.cpp index 96765c9..0def0fe 100644 --- a/wsd/Auth.cpp +++ b/wsd/Auth.cpp @@ -48,18 +48,18 @@ const std::string JWTAuth::getAccessToken() // trim '=' from end of encoded payload encodedPayload.erase(std::find_if(encodedPayload.rbegin(), encodedPayload.rend(), [](char& ch)->bool { return ch != '='; }).base(), encodedPayload.end()); -Log::info("Encoded JWT header: " + encodedHeader); -Log::info("Encoded JWT payload: " + encodedPayload); +LOG_INF("Encoded JWT header: " << encodedHeader); +LOG_INF("Encoded JWT payload: " << encodedPayload); // Convert to a URL and filename safe variant: // Replace '+' with '-' && '/' with '_' -std::replace(encodedHeader.begin(), encodedHeader.end(), '+','-'); -std::replace(encodedHeader.begin(), encodedHeader.end(), '/','_'); +std::replace(encodedHeader.begin(), encodedHeader.end(), '+', '-'); +std::replace(encodedHeader.begin(), encodedHeader.end(), '/', '_'); -std::replace(encodedPayload.begin(), encodedPayload.end(), '+','-'); -std::replace(encodedPayload.begin(), encodedPayload.end(), '/','_'); +std::replace(encodedPayload.begin(), encodedPayload.end(), '+', '-'); +std::replace(encodedPayload.begin(), encodedPayload.end(), '/', '_'); -std::string encodedBody = encodedHeader + "." + encodedPayload; +const std::string encodedBody = encodedHeader + '.' + encodedPayload; // sign the encoded body _digestEngine.update(encodedBody.c_str(), static_cast(encodedBody.length())); @@ -79,13 +79,13 @@ const std::string JWTAuth::getAccessToken() [](char& ch)->bool { return ch != '='; }).base(), encodedSig.end()); // Be URL and filename safe -std::replace(encodedSig.begin(), encodedSig.end(), '+','-'); -std::replace(encodedSig.begin(), encodedSig.end(), '/','_'); +std::replace(encodedSig.begin(), encodedSig.end(), '+', '-'); +std::replace(encodedSig.begin(), encodedSig.end(), '/', '_'); -Log::info("Sig generated is : " + encodedSig); +LOG_INF("Sig generated is : " << encodedSig); -const std::string jwtToken = encodedBody + "." + encodedSig; -Log::info("JWT token generated: " + jwtToken); +const std::string jwtToken = encodedBody + '.' + encodedSig; +LOG_INF("JWT token generated: " << jwtToken); return jwtToken; } @@ -96,7 +96,7 @@ bool JWTAuth::verify(const std::string& accessToken) try { -std::string encodedBody = tokens[0] + "." + tokens[1]; +const std::string encodedBody = tokens[0] + '.
[Libreoffice-commits] online.git: kit/ForKit.cpp wsd/LOOLWSD.cpp
kit/ForKit.cpp |2 ++ wsd/LOOLWSD.cpp |6 +- 2 files changed, 7 insertions(+), 1 deletion(-) New commits: commit f296c0ffeb60e5560eed79246ca877251f279c55 Author: Miklos Vajna Date: Tue Feb 14 09:33:23 2017 +0100 wsd: avoid redundant string initialization Change-Id: I5ac26d56c3b73e380d26226e83020ace3f1b54f4 diff --git a/kit/ForKit.cpp b/kit/ForKit.cpp index fa2bebe..ca58e2a 100644 --- a/kit/ForKit.cpp +++ b/kit/ForKit.cpp @@ -44,7 +44,9 @@ using Poco::Process; using Poco::StringTokenizer; using Poco::Thread; +#ifndef KIT_IN_PROCESS using Poco::Util::Application; +#endif #ifndef KIT_IN_PROCESS static bool NoCapsForKit = false; diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp index c910f98..a79d631 100644 --- a/wsd/LOOLWSD.cpp +++ b/wsd/LOOLWSD.cpp @@ -150,9 +150,13 @@ using Poco::Net::SocketAddress; using Poco::Net::StreamSocket; using Poco::Net::WebSocket; using Poco::Path; +#ifndef KIT_IN_PROCESS using Poco::Pipe; +#endif using Poco::Process; +#ifndef KIT_IN_PROCESS using Poco::ProcessHandle; +#endif using Poco::StreamCopier; using Poco::StringTokenizer; using Poco::TemporaryFile; @@ -1743,7 +1747,7 @@ bool LOOLWSD::NoCapsForKit = false; #endif #ifdef FUZZER bool LOOLWSD::DummyLOK = false; -std::string LOOLWSD::FuzzFileName = ""; +std::string LOOLWSD::FuzzFileName; #endif std::string LOOLWSD::Cache = LOOLWSD_CACHEDIR; std::string LOOLWSD::SysTemplate; ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] online.git: kit/ForKit.cpp wsd/Admin.cpp wsd/LOOLWSD.cpp
kit/ForKit.cpp |4 +++- wsd/Admin.cpp |2 +- wsd/LOOLWSD.cpp |9 ++--- 3 files changed, 10 insertions(+), 5 deletions(-) New commits: commit 3fb136170f1ac8b27f5aa2e0a1f4bf0c4d5a939f Author: Ashod Nakashian Date: Wed Feb 8 23:19:29 2017 -0500 wsd: extend timeout when nocaps is specified Change-Id: Id10b38716cc184bf899120bbe18d9095fd2f48e5 Reviewed-on: https://gerrit.libreoffice.org/34053 Reviewed-by: Ashod Nakashian Tested-by: Ashod Nakashian diff --git a/kit/ForKit.cpp b/kit/ForKit.cpp index 6362940..fa2bebe 100644 --- a/kit/ForKit.cpp +++ b/kit/ForKit.cpp @@ -439,8 +439,10 @@ int main(int argc, char** argv) if (!std::getenv("LD_BIND_NOW")) LOG_INF("Note: LD_BIND_NOW is not set."); -if (!haveCorrectCapabilities()) +if (!NoCapsForKit && !haveCorrectCapabilities()) +{ return Application::EXIT_SOFTWARE; +} // Initialize LoKit if (!globalPreinit(loTemplate)) diff --git a/wsd/Admin.cpp b/wsd/Admin.cpp index 68b511f..b1e8c11 100644 --- a/wsd/Admin.cpp +++ b/wsd/Admin.cpp @@ -354,7 +354,7 @@ void Admin::rescheduleMemTimer(unsigned interval) _memStatsTask->cancel(); _memStatsTaskInterval = interval; _memStatsTask = new MemoryStatsTask(this); -_memStatsTimer.schedule(_memStatsTask.get(), _memStatsTaskInterval, _memStatsTaskInterval); +_memStatsTimer.schedule(_memStatsTask, _memStatsTaskInterval, _memStatsTaskInterval); LOG_INF("Memory stats interval changed - New interval: " << interval); } diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp index 3f719cb..6a3784a 100644 --- a/wsd/LOOLWSD.cpp +++ b/wsd/LOOLWSD.cpp @@ -421,7 +421,8 @@ static void preForkChildren(std::unique_lock& lock) UnitWSD::get().preSpawnCount(numPreSpawn); // Wait until we have at least one child. -const auto timeoutMs = CHILD_TIMEOUT_MS * 3; +// With valgrind we need extended time to spawn kits. +const auto timeoutMs = CHILD_TIMEOUT_MS * (LOOLWSD::NoCapsForKit ? 150 : 3); const auto timeout = std::chrono::milliseconds(timeoutMs); LOG_TRC("Waiting for a new child for a max of " << timeoutMs << " ms."); NewChildrenCV.wait_for(lock, timeout, []() { return !NewChildren.empty(); }); @@ -500,8 +501,10 @@ static std::shared_ptr getNewChild() return nullptr; } -LOG_TRC("Waiting for a new child for a max of " << CHILD_TIMEOUT_MS << " ms."); -const auto timeout = chrono::milliseconds(CHILD_TIMEOUT_MS); +// With valgrind we need extended time to spawn kits. +const auto timeoutMs = CHILD_TIMEOUT_MS * (LOOLWSD::NoCapsForKit ? 100 : 1); +LOG_TRC("Waiting for a new child for a max of " << timeoutMs << " ms."); +const auto timeout = chrono::milliseconds(timeoutMs); if (NewChildrenCV.wait_for(lock, timeout, []() { return !NewChildren.empty(); })) { auto child = NewChildren.back(); ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] online.git: kit/ForKit.cpp
kit/ForKit.cpp | 16 1 file changed, 12 insertions(+), 4 deletions(-) New commits: commit 93858c5b9e7c61c33ac3c45710a351bf22f481d9 Author: Ashod Nakashian Date: Sun Jan 29 20:19:23 2017 -0500 wsd: forkit removes jails after reaping dead children Change-Id: Ia4b8dd85b41fa59ececbed85e35616fee6a02254 Reviewed-on: https://gerrit.libreoffice.org/33678 Reviewed-by: Ashod Nakashian Tested-by: Ashod Nakashian diff --git a/kit/ForKit.cpp b/kit/ForKit.cpp index ba3d548..b6383a8 100644 --- a/kit/ForKit.cpp +++ b/kit/ForKit.cpp @@ -182,21 +182,29 @@ static bool haveCorrectCapabilities() /// Check if some previously forked kids have died. static void cleanupChildren() { +std::vector jails; Process::PID exitedChildPid; int status; while ((exitedChildPid = waitpid(-1, &status, WUNTRACED | WNOHANG)) > 0) { -if (childJails.find(exitedChildPid) != childJails.end()) +const auto it = childJails.find(exitedChildPid); +if (it != childJails.end()) { -LOG_INF("Child " << exitedChildPid << " has exited, removing its jail '" << childJails[exitedChildPid] << "'"); -FileUtil::removeFile(childJails[exitedChildPid], true); -childJails.erase(exitedChildPid); +LOG_INF("Child " << exitedChildPid << " has exited, removing its jail '" << it->second << "'."); +jails.emplace_back(it->second); +childJails.erase(it); } else { LOG_ERR("Unknown child " << exitedChildPid << " has exited"); } } + +// Now delete the jails. +for (const auto& path : jails) +{ +FileUtil::removeFile(path, true); +} } static int createLibreOfficeKit(const std::string& childRoot, ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] online.git: kit/ForKit.cpp
kit/ForKit.cpp | 29 +++-- 1 file changed, 11 insertions(+), 18 deletions(-) New commits: commit f242865c3df107ae1de4d0ed4358871b07b719d1 Author: Ashod Nakashian Date: Sun Jan 8 15:17:47 2017 -0500 wsd: simplify kit forking Change-Id: I49338fbd2ccf944493f94a8f2c98750711733f1a Reviewed-on: https://gerrit.libreoffice.org/32865 Reviewed-by: Ashod Nakashian Tested-by: Ashod Nakashian diff --git a/kit/ForKit.cpp b/kit/ForKit.cpp index f0fe536..ba3d548 100644 --- a/kit/ForKit.cpp +++ b/kit/ForKit.cpp @@ -207,8 +207,8 @@ static int createLibreOfficeKit(const std::string& childRoot, { LOG_DBG("Forking a loolkit process."); -Process::PID pid; -if (!(pid = fork())) +const Process::PID pid = fork(); +if (!pid) { // Child @@ -412,31 +412,24 @@ int main(int argc, char** argv) break; } +// Cleanup first, to reduce disk load. +cleanupChildren(); + if (ForkCounter > 0) { // Create as many as requested. -int spawn = ForkCounter; -LOG_INF("Creating " << spawn << " new child."); -size_t newInstances = 0; -do +const size_t count = ForkCounter; +LOG_INF("Spawning " << count << " new child" << (count == 1 ? "." : "ren.")); +const size_t retry = count * 2; +for (size_t i = 0; ForkCounter > 0 && i < retry; ++i) { -if (createLibreOfficeKit(childRoot, sysTemplate, loTemplate, loSubPath) < 0) +if (ForkCounter-- <= 0 || createLibreOfficeKit(childRoot, sysTemplate, loTemplate, loSubPath) < 0) { LOG_ERR("Failed to create a kit process."); -} -else -{ -++newInstances; +++ForkCounter; } } -while (--spawn > 0); - -// If we need to spawn more, retry later. -ForkCounter = (newInstances >= ForkCounter ? 0 : ForkCounter - newInstances); } - -// We virtually always fork when a child exits. -cleanupChildren(); } int returnValue = Application::EXIT_OK; ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] online.git: kit/ForKit.cpp
kit/ForKit.cpp |5 + 1 file changed, 5 insertions(+) New commits: commit 38549b0c9b3926ce3e560bede3987723005422d0 Author: Henry Castro Date: Sat Dec 17 07:56:03 2016 -0400 kit: debug, wait until unique kit die Very useful to debug preinit stage when it is ensured 1 kit process diff --git a/kit/ForKit.cpp b/kit/ForKit.cpp index 60595b1..cda0303 100644 --- a/kit/ForKit.cpp +++ b/kit/ForKit.cpp @@ -443,6 +443,11 @@ int main(int argc, char** argv) int returnValue = Application::EXIT_OK; UnitKit::get().returnValue(returnValue); +#if 0 +int status = 0; +waitpid(forKitPid, &status, WUNTRACED); +#endif + LOG_INF("ForKit process finished."); std::_Exit(returnValue); } ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits