Commit graph

79 commits

Author SHA1 Message Date
Miklos Vajna
27f541549c Util: add missing include 2016-09-27 17:07:52 +02:00
Ashod Nakashian
56924299c9 loolwsd: restore Poco regex and old initialization
Unfortunately, std::regex is not well supported by old
compilers, namely gcc 4.8 doesn't seem to pass tests.

In addition, newer gcc versions, such as 5.2, don't like
{0,0} initialization.

For now we agreed on restoring the original Poco regex
and the old initialization of {}. When we move to
newer gcc, we can revert this commit so we get std::regex.

This commit reverts the following 3 commits:

Revert "Util: fix -Werror=shadow"
This reverts commit 01c6cb40ef.

Revert "loolwsd: replace Poco regex with std"
This reverts commit 1fdb4bf862.

Revert "Fix gcc-4.8 build"
This reverts commit 92ff278997.

Change-Id: I04912055d1143a2aeebb8d853c4d0c7fe74a40cc
Reviewed-on: https://gerrit.libreoffice.org/29324
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-09-27 15:00:33 +00:00
Tor Lillqvist
891b942e7c Handle disk full situations more gracefully
Introduce new API in our Util namespace to save data to a file
safely. The data is written to a temporary file in the same directory
and after that has succeeded, it is renamed atomicaly to the intended
name. If any step of the saving fails, neither the temporay file or
the intended target (if one exists before) is left behind.

Also add an API intended to alert the sysadmin in cases where their
attention and action are required. This is not yet properly
implemented. See FIXME comment for discussion.
2016-09-27 15:53:48 +03:00
Miklos Vajna
01c6cb40ef Util: fix -Werror=shadow
gcc-4.8 still doesn't allow using the same name for a member function
and a local variable.

Change-Id: I9c327331b5c3460ec0e6d986a0543b17ba92c7ac
2016-09-27 09:48:06 +02:00
Ashod Nakashian
1fdb4bf862 loolwsd: replace Poco regex with std
Change-Id: Id761d964708bf34b58146b8a3d5ff19df7452b67
Reviewed-on: https://gerrit.libreoffice.org/29309
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-09-27 02:32:36 +00:00
Miklos Vajna
92ff278997 Fix gcc-4.8 build 2016-09-26 10:09:44 +02:00
Miklos Vajna
8ded538d40 Admin: fix uninitialized members
Change-Id: I8b88af167bf26e485e6d9600f88f015c65c1359b
2016-09-26 08:49:19 +02:00
Ashod Nakashian
359731f096 loolwsd: cleanup of RuntimeConstant class
Change-Id: If3d57e73445cdb0b92c6b3721b4b7b0ca030a2d7
Reviewed-on: https://gerrit.libreoffice.org/28129
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-08-15 03:13:01 +00:00
Ashod Nakashian
a3e9fc8139 loolstress: filter trace messages by regex config
Change-Id: I13483cd6614e5753a22408102c9cc310a587db2e
Reviewed-on: https://gerrit.libreoffice.org/27970
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-08-08 03:53:52 +00:00
Miklos Vajna
84ef81b7b4 LOOLWSD, Util: follow coding style when prefixing data members
Change-Id: Iaf788cc8e5b7df473a52fbe8496d500f0f63c117
2016-07-28 08:39:27 +02:00
Jan Holesovsky
6aae20e217 Setting the RuntimeConstant in production should not throw.
It is very bad, but let's not get the production env. down by that.
2016-07-19 11:07:07 +02:00
Marco Cecchetti
6e616b745f loolwsd: SSL support can be enabled/disabled on server start
SSL support is enabled by default, it can be disabled by passing the
`--disable-ssl` switch on the command line or by setting `ssl.enable`
property in loolwsd.xml config file.

It is still possible to build loolwsd with no SSL support at all.

Change-Id: I00f952edc64f87f61505af44fdc2a715780dc44c
Reviewed-on: https://gerrit.libreoffice.org/27288
Reviewed-by: Jan Holesovsky <kendy@collabora.com>
Tested-by: Jan Holesovsky <kendy@collabora.com>
2016-07-19 08:59:49 +00:00
Pranav Kant
e271995ed2 loolwsd: Restructure version information functions
... so that version information can be sent to clients.

Change-Id: Icc90f31fabb501f816ff1dca0c618a73660c88bc
2016-06-21 00:29:41 +05:30
Miklos Vajna
5e1b210891 Util: pass by const ref 2016-06-17 09:18:26 +02:00
Miklos Vajna
afb6a7ebb0 Util: turn TerminationFlag into an std::atomic<bool>
Running unit-fonts under helgrind points out missing synchronization
there.
2016-06-15 15:31:41 +02:00
Ashod Nakashian
3f03860a79 loolwsd: moved and localized png bits to Png.hpp
Change-Id: I4f27143bc2e5f638c8e84c32616b2820136a20e5
Reviewed-on: https://gerrit.libreoffice.org/25266
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-05-21 15:57:57 +00:00
Ashod Nakashian
fae850189d loolwsd: include cleanup and organization
A source file (.cpp) must include its own header first.
This insures that the header is self-contained and
doesn't depend on arbitrary (and accidental) includes
before it to compile.

Furthermore, system headers should go next, followed by
C then C++ headers, then libraries (Poco, etc) and, finally,
project headers come last.

This makes sure that headers and included in the same dependency
order to avoid side-effects. For example, Poco should never rely on
anything from our project in the same way that a C header should
never rely on anything in C++, Poco, or project headers.

Also, includes ought to be sorted where possible, to improve
readability and avoid accidental duplicates (of which there
were a few).

Change-Id: I62cc1343e4a091d69195e37ed659dba20cfcb1ef
Reviewed-on: https://gerrit.libreoffice.org/25262
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-05-21 15:52:54 +00:00
Ashod Nakashian
68b8b2af4f loolwsd: improve temp file creation and delayed delete
Change-Id: I174b87f1aceaacee58121bc60edb420004e69c44
Reviewed-on: https://gerrit.libreoffice.org/24967
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-05-13 12:56:54 +00:00
Ashod Nakashian
6c57e9be4d loolwsd: helper to assert a lock is already taken
Change-Id: Id28f7a39a4d45ea6ad391015364467dc8ded3e66
Reviewed-on: https://gerrit.libreoffice.org/24599
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-05-03 00:00:13 +00:00
Tor Lillqvist
a25b7ad712 Bin unused Util::createRandomFile() 2016-04-25 11:23:08 +03:00
Tor Lillqvist
581037d45e There is no Util::hasCorrectUID() 2016-04-25 11:18:35 +03:00
Tor Lillqvist
d423f7c2fd Add Util::UniqueId() to get a string id that is unique across processes and calls 2016-04-20 18:54:17 +03:00
Miklos Vajna
55f18b4038 loolwsd: fix -Werror=shadow 2016-04-19 09:35:36 +02:00
Ashod Nakashian
3878f3b515 loolwsd: initialization and resetting support in RegexListMatcher
Change-Id: Ic262cf9e4a21d30b6dfd9d9fc0d895f89d7d8e7b
Reviewed-on: https://gerrit.libreoffice.org/24232
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-04-19 01:41:00 +00:00
Ashod Nakashian
7d65e30595 loolwsd: regex matching class against whitelist/blacklist
With unittests.

Change-Id: Ibb14c493cc6de61b6497ab84e34e105481afe464
Reviewed-on: https://gerrit.libreoffice.org/24231
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-04-19 01:40:37 +00:00
Michael Meeks
a49f642801 Tolerate --version, and add git hash version, print on default start.
Should help diagnosing issues - to have this in our logs.
2016-04-15 15:07:24 +01:00
Ashod Nakashian
322a3c1afe loolwsd: logging moved to own files
Change-Id: Idf1dd91cf37675e1bea8aeb5d9e8cf6d2ac9a725
Reviewed-on: https://gerrit.libreoffice.org/24099
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-04-15 01:07:13 +00:00
Tor Lillqvist
1bd6cdde3b Util::getSignalStatus() is unused
Good, its semantics was a bit odd anyway.
2016-04-14 11:39:42 +03:00
Tor Lillqvist
c7d0067969 Util::getChildStatus() is unused
Good, now the odd LOOLExitCode can go away, too.
2016-04-14 11:30:28 +03:00
Michael Meeks
6a990dfb61 Security bits and test cleanup.
Enforce user being 'lool' for setcap binaries loolmount and loolforkit.

Add warnings if configured without --enable-debug.

Developers should pass --enable-debug to configure.
2016-04-12 17:13:56 +01:00
Tor Lillqvist
7d82e059a2 Make Util::signalName() return a const char *instead
Makes its use in handleTerminationSignal() and handleFatalSignal()
less complicated.
2016-04-08 16:06:39 +03:00
Tor Lillqvist
5637064e9a Factor out the prctl() calls
Silly to keep copy-pasting the same couple of lines over and over
again.
2016-04-07 11:53:33 +03:00
Tor Lillqvist
ec604599f1 Introduce separate Log::syserror() function for logging actual syscall errors
Much better than assuming that errno would be relevant at all
Log::error() calls (or alternatively, having to remember to append a
false parameter to the Log::error() call, which had not been done a
single time anyway.)

Call log::syserror() right after a system call has returned an
error. Don't call it otherwise.
2016-04-07 10:36:38 +03:00
Tor Lillqvist
94caec287f We never call Log::warn() with an append_errno parameter
So just drop it. Default parameters are ugly IMHO.
2016-04-07 10:15:51 +03:00
Ashod Nakashian
6e5e9033f2 loolwsd: removed Admin pipe
Admin no longer needs a pipe as it's notified
from WSD. It is now a singleton with improved
locking.

The tracking of documents and views still needs
improvement and corrections.

Change-Id: If614331de6dd595c6dd4443f480d4ab588ca4551
Reviewed-on: https://gerrit.libreoffice.org/23860
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-04-06 13:52:57 +00:00
Tor Lillqvist
422834ebef Improve logging
Don't embed newlines in "lines" written to the log. When logging stuff
read from or written to the fifos, translate newlines to " / " for
clarity.

(If we would want complete, exact verbose logging, we should be really
pedantic and log all non-printable bytes in hex anyway, etc, so
displaying newlines as space-separated slashes should be OK. It isn't
as if there would be totally arbitary data passed through the fifos
anyway.)
2016-03-31 11:01:52 +03:00
Ashod Nakashian
ce2fabb733 loolwsd: moved IO utilities into IoUtil file
Change-Id: I1e8d5562787134cbb490c38b19d83b7514ec9baa
Reviewed-on: https://gerrit.libreoffice.org/23586
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-03-29 14:09:04 +00:00
Ashod Nakashian
d48d9044a1 loolwsd: run tests on doc copies
Tests can modify the test documents they use.
Currently there is data-loss protection that
saves an open doc if connection is lost with
the client. For tests this means modification
are saved when a connection is terminated
ungracefully and this both adds noise
to the git checkout and makes subsequent
tests fail.

This patch makes temp copies of the original
doc before a test is run and deletes them
afterwards.

Change-Id: I1dd6ff2b839701e85c8bd502ba75170c01fa106e
Reviewed-on: https://gerrit.libreoffice.org/23447
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-03-23 00:00:34 +00:00
Ashod Nakashian
019aed134e loolwsd: using random jailId
Change-Id: Ie9501e4346a124994270ca1fac61869ed04b9b72
Reviewed-on: https://gerrit.libreoffice.org/23213
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-03-14 03:06:29 +00:00
Pranav Kant
76542d8d52 loolwsd: Add total memory, total active docs, total active users
Further changes/refactoring to make it possible:
* Add broker pid to Admin class
* Move getMemoryUsage for process to Util
* Change variable name to accurately reflect *active* items
  _nViews -> _nActiveViews, etc.

Change-Id: I4c9206c49ab829b73ebfe226874bfbbcc8f95342
Reviewed-on: https://gerrit.libreoffice.org/22989
Reviewed-by: Tor Lillqvist <tml@collabora.com>
Tested-by: Tor Lillqvist <tml@collabora.com>
2016-03-08 09:34:51 +00:00
Pranav Kant
1908613951 loolwsd: Factor out pipe reading polling logic
Change-Id: I7c06c68031ea14147130d21376ab348bdc672a7f
Reviewed-on: https://gerrit.libreoffice.org/22820
Reviewed-by: Tor Lillqvist <tml@collabora.com>
Tested-by: Tor Lillqvist <tml@collabora.com>
2016-03-03 16:23:21 +00:00
Tor Lillqvist
a959e99004 Make declaration of writeFIFO() match definition 2016-03-01 17:17:14 +02:00
Tor Lillqvist
dc305b2b08 Don't confuse Poco::Util::Application::ExitCode and EXIT_SUCCESS/FAILURE
The getChildStatus() and getSignalStatus() functions returned the
latter, still the returned values were compared against
Poco::Util::Application::EXIT_OK. (Sure, both Poco's
Application::EXIT_SUCCESS and stdlib.h's EXIT_OK are zero, but that
doesn't mean one should mix them up.)

Also add two comments pondering the meaning of the code.
2016-03-01 16:49:12 +02:00
Tor Lillqvist
f560c64471 Document where LOOLExitCode comes from 2016-03-01 16:34:32 +02:00
Tor Lillqvist
248703c6f7 Bin leftover declaration of variable that is not defined anywhere 2016-03-01 16:28:56 +02:00
Henry Castro
e9de068423 loolwsd: fixes coding style naming convention rules in Util files 2016-02-18 13:00:37 -04:00
Henry Castro
a607159a8a loolwsd: catch exception requestTermination 2016-02-16 17:25:51 -04:00
Henry Castro
1b6425913d loolwsd: add LO core exit codes 2016-02-01 22:23:58 -04:00
Henry Castro
b477f41636 loolwsd: add fatal signals handler 2016-02-01 21:26:19 -04:00
Miklos Vajna
4b3c5ea8ff loolwsd: doxygenize class comments 2016-01-28 19:16:32 +01:00