Commit graph

64 commits

Author SHA1 Message Date
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
Ashod Nakashian
d3fc5ac37b loolwsd: sockets are shutdown on disconnect
Change-Id: I1c00be4648cff94013ceab87fcb607b9bb921535
Reviewed-on: https://gerrit.libreoffice.org/21684
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-01-21 16:06:37 +00:00
Ashod Nakashian
ad7509d449 loolwsd: writeFIFO overload to take std::string
Change-Id: Ibfac97d1d4f101a10bd0f696b8b89a22170b1b11
Reviewed-on: https://gerrit.libreoffice.org/21672
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-01-21 15:43:11 +00:00
Miklos Vajna
9185012704 Log::StreamLogger: Stream -> _stream
As it's not a static member.
2016-01-18 09:43:49 +01:00
Ashod Nakashian
5d07c46065 loolwsd: logging improvements
Error can supress printing errno and warning can
be asked to print it by setting a bool argument.

Formatting has been improved for readability.

Change-Id: I93d2808fbff4f6cacc583923905438ada7b8e90e
Reviewed-on: https://gerrit.libreoffice.org/21471
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-01-14 13:41:18 +00:00
Tomaž Vajngerl
9071f7c9bc encode PNG from buffer at arbitrary buffer position
This commit add 2 methods to encode a buffer to PNG: the "old"
method which encodes the whole buffer to a PNG, and a new method
to encode a part of a buffer (sub image) to PNG. The first method
is only added for convenience.
2016-01-14 12:34:01 +01:00
Ashod Nakashian
9b5a94b018 loolwsd: callbacks use shared_ptr to avoid race with destructors
Change-Id: I19e06850764c6dbd1cfcc15dcd9a64029ab4fc0c
Reviewed-on: https://gerrit.libreoffice.org/21326
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-01-11 04:07:30 +00:00
Ashod Nakashian
5bf75f56ca loolwsd: centralized signal handling and eased debugging
Change-Id: Ifdb3e2bca540bec3c6dea1ab24173c8ea0267706
Reviewed-on: https://gerrit.libreoffice.org/21325
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-01-11 04:06:56 +00:00
Miklos Vajna
e1a3a86ff3 loolwsd: default initialization of an object of const type 'const struct ...
... _end_marker' without a user-provided default constructor

Add one to make clang happy.
2016-01-07 15:10:34 +01:00
Ashod Nakashian
0b5bc5f244 loolwsd: random jailId dir created by WSD and renamed childId -> jailId
Change-Id: Ib5ce65c578c0c7fd3dbf81628906cd17728fb3ff
Reviewed-on: https://gerrit.libreoffice.org/21182
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-01-07 05:56:01 +00:00
Ashod Nakashian
9e9e2f60ef loolwsd: broker handles sigint and wsd removes childroot
Change-Id: Ie408bff7944ff0b9abfa8433b1e8ea6f62a9ab2c
Reviewed-on: https://gerrit.libreoffice.org/20999
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2015-12-28 23:39:13 +00:00
Ashod Nakashian
88b76fe9d4 loolwsd: removed dead code
Variables and options lingering from previous iterations removed.
Standardizing static member names.
Header inclusion cleanups.

Change-Id: I65182ad4d100e0077f1b450be50cf95d7b8f0fc7
Reviewed-on: https://gerrit.libreoffice.org/20997
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2015-12-28 23:36:55 +00:00
Ashod Nakashian
3811abb40a loolwsd: replaced threadId with globally unique sessionId
Change-Id: I55b16d4baa1753bc67dcd72de13e7a516da27abe
Reviewed-on: https://gerrit.libreoffice.org/20981
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2015-12-28 04:14:15 +00:00
Ashod Nakashian
1e24456121 loolwsd: logPrefix cleanup
Change-Id: I41465a06b17876c5d5fb7a6f9d8569d80571fcca
Reviewed-on: https://gerrit.libreoffice.org/20977
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2015-12-28 04:08:34 +00:00
Ashod Nakashian
538478826d loolwsd: workaround for older gcc that require explicit move ctor
Change-Id: I2a4c232ad89c32ea8739809a13e17522dee7e7c1
Reviewed-on: https://gerrit.libreoffice.org/20976
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2015-12-28 04:07:57 +00:00
Ashod Nakashian
d26944b715 loolwsd: safely remove files and directories
Change-Id: Ie017a9da720a470a6b8ed340bd4ea5ffc279cf4b
Reviewed-on: https://gerrit.libreoffice.org/20949
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2015-12-26 03:59:20 +00:00