Commit Graph

55 Commits (master)

Author SHA1 Message Date
Ashod Nakashian f1001cddcc wsd: remove unused (Is)ViewWithCommentsFileExtension(s)
Change-Id: I25158862746ce6a3e4ee16ff9d661ec96810ce24
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2024-05-21 04:52:12 -04:00
Michael Meeks 9b6ab4c601 Logging: add Area parameter and new LOGA_ macros to annotate areas.
Add logging.disabled_areas setting to coolwsd.xml with some sensible
things to ignore unless they are warnings/errors.

Kit code duplication around logging is grim; but not fixed in this
commit.

Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Change-Id: I36bebb2b3c8d64a814d7b10c167d582de0baf4e5
2024-05-14 18:37:52 +02:00
Michael Meeks 7f6b59b180 bgsave: improve unit tests.
Force background saving in the config for this test.

Use stamp files to force sequencing between Unit test and Kit.

Change-Id: Ia2c60c3dcfdad87c9c9754e8f20a3c36dbcf74d5
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2024-05-08 16:42:29 +01:00
Rashesh Padia 7572af7486 fix: don't wait for migrate msg if indirection server closes the connection because deployment gets deleted
- if deployment gets deleted than there is no where to migrate the
documents in such cases indirection will close the monitor connection
but we need to set the _migrateMsgReceived flag so that docBroker don't
wait for the message and continue to cleanup the document

Signed-off-by: Rashesh Padia <rashesh.padia@collabora.com>
Change-Id: Ia2732740927ea16e368f91bea7421576a3cf2beb
2024-05-07 20:26:46 +05:30
Rashesh Padia c1f0fcf946 indirection_server: migrate document on shutdown
- when COOLWSD get SIGTERM admin sends a "shutdown_received" message to
indirection server
- indirection server sends back migration messages for each document to
migrate it other available COOL server
- there is timeout associated with migration message if COOLWSD doesn't
get message we move on and close the document
- added a new option in coolwsd.xml to change the migration timeout
default is 180s

Signed-off-by: Rashesh Padia <rashesh.padia@collabora.com>
Change-Id: Id7d5eea94d1b03ea5905ca67a9dd8f6ca15952f3
2024-05-07 20:26:46 +05:30
Michael Meeks d2dae8f2b5 Fix broken conditional compilation for WASM.
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Change-Id: Ib0f3733a0719c87281b432c7c009fc2362ad3cce
2024-04-29 10:56:54 +02:00
Michael Meeks 005ba1567e PrisonerPoll - leave unused Kit sockets in the poll.
This lets us detect when Kit processes die without waiting for
the poll() timeout and feebly spinning the PrisonerPoll loop.

Instead we get notified immediately; but to do this we then need
to be able to safely transfer the socket between SocketPolls.

SocketPoll's should own Sockets - so by switching ChildProcess to
use a weak_ptr and also the NewChildren list - we can have standard
ownership and a sensible transfer between SocketPolls. A Socket is
owned either by PrisonerPoll or a DocumentBroker in the normal way.

Clean the NewChildren list as/when children are unexpectedly killed
apparently there are still some ownership issues probably around
the strong ChildProcess _ws pointer.

Change-Id: Ie541a9d03e36aee53fd57c45953e0de21ebe1828
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2024-03-25 08:18:35 +00:00
Jaume Pujantell 8921e19d84 reduce uses of MOBILEAPP on some files
Reduce the uses of MOBILEAPP conditionals by using the isMobileApp
function.

Signed-off-by: Jaume Pujantell <jaume.pujantell@collabora.com>
Change-Id: If541307fbc457b342674cc560b6c53454f3904cf
2024-03-20 09:13:00 +01:00
Neil Guertin 8717fa6d90 Fix for unit-httpws failure
Fix race condition in testSaveOnDisconnect by waiting for kit process to
stop instead of just counting total kit processes

Signed-off-by: Neil Guertin <neil.guertin@collabora.com>
Change-Id: I6bda6b114070123a1366bc04eac1873f19928ac0
2024-03-06 09:10:32 +00:00
Henry Castro 9344c8000b wsd: add logging token javascript errors
The "logging.html" end point was intended to capture
unhandled javascript exceptions from client side,
only corner cases, when websocket is disconnected or
very early errors before websocket is created.
So add a token to restrict access.

Change-Id: I64b7d7f3b3ddd83f044fea21dc07285b4465b3be
Signed-off-by: Henry Castro <hcastro@collabora.com>
2024-01-19 10:54:42 +00:00
Ashod Nakashian 61cf7b9601 wsd: clean up unused header includes
Clang-tidy recommendation driven header
include clean-up.

Change-Id: I30c32866b7798e70df0463ee6bc7a0bcc3de5049
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2024-01-08 08:38:48 +01:00
Jaume Pujantell 35d6e2925f use isKitInProcess() instead of KIT_IN_PROCESS
Removed all uses of KIT_IN_PROCESS, used Utils::isKitInProcess()
when necessary. Also removed the now unused parameter 'limit' from
forkLibreOfficeKit.

Signed-off-by: Jaume Pujantell <jaume.pujantell@collabora.com>
Change-Id: I068d3f55ab49076590f111847c87b3188f4d25d0
2023-12-18 10:34:10 +00:00
Jaume Pujantell 8f178ef6cd extract some functions to extra files for in process mode
Extract some functions from ForKit.cpp and COOLWSD.cpp to new files
so we can do a kit in process mode without using ifdef directives.

Signed-off-by: Jaume Pujantell <jaume.pujantell@collabora.com>
Change-Id: I7529f8f46a8026318244666b27d1ce72ed5ad4ca
2023-12-18 10:34:10 +00:00
Ashod Nakashian e836637aae wasm: wsd: coolwsd remembers disconnected mode preference
Switching to disconnected mode works.

Change-Id: I653b282af41bac483c76564fdcf72a83a79065e1
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-12-09 19:22:24 +00:00
Szymon Kłos a243bc9f49 Add list of allowed data sources
- uses new lok_allow setting to provide such list
- for backward compatibility uses also all post_allow and storage.wopi
  entries
- Used for example in: PostMessage Action_InsertGraphics,
  =WEBSERVICE() function, external reference in the cell

Signed-off-by: Szymon Kłos <szymon.klos@collabora.com>
Change-Id: Ib930e0119d4ea124b9cd565f6b3683310b1b3ced
2023-12-01 15:25:47 +00:00
Michael Meeks 7183a3d3de spdx: improve machine and human readability of headers.
Change-Id: Ice934380029bf27054e830fffc07a5d037d1430f
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2023-11-14 19:36:31 +00:00
Michael Meeks 47b89b32ef spdx: improve machine and human readability of headers.
Change-Id: I1b6dcd2ec1fbef6556d70b8af3ccfd5d6a95c59a
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2023-10-31 10:33:07 +00:00
Ashod Nakashian 8728cd5ea1 wsd: config cleanup and warning fixes
Change-Id: Idb66227d98f8fcca35307c3598a1fcc6b69e38c6
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-10-26 20:31:45 -04:00
Caolán McNamara 672f3cee2c rework URP to use a dedicated channel
Instead of fighting the SolarMutex to get the messages
processed by the main loop. Simple and no additional
threading, mutexes etc.

messages from the external uno client are just
written to URPtoLoFD and the core reads from that

messages to the external uno client are written
to URPfromLoFD by core, that fd is in poll, and
activity there triggers a read by the DocBroker
to send it to the external uno client.

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: Ib1f0a0d5fb5ab22eee476d5d740b290c51de59dc
2023-10-03 10:15:55 +01:00
Ashod Nakashian d2ebd4cff7 wsd: FileServerRequestHandler instance
This encapsulates and manages the lifetime of
file-serving cache in an instance of
FileServerRequestHandler. Previously, it was
all done through static functions and explicit calls.

Change-Id: I1b0bf0e3c25e6ae82c398bf5d0de255a6fec42a1
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-09-25 19:29:12 -04:00
Skyler Grey 1b3218df04 Add cli option to use settings from env variables
Currently [in docker it is possible to do configuration through
environment variables](https://col.la/dockercodeconfigviaenv), which
works using the start-collabora-online.sh start-collabora-online.pl
scripts. This commit lets COOLWSD listen to the same environment
variables directly

Change-Id: I75762ad620132037523fa82167a3ff17075c7027
Signed-off-by: Skyler Grey <skyler.grey@collabora.com>
2023-09-23 12:44:50 +02:00
Rash419 b717be603e implement document migration
- updated protocol.txt

Signed-off-by: Rash419 <rashesh.padia@collabora.com>
Change-Id: I67a0515580979e15223ea084c835f5ed801ceb5e
2023-06-29 18:21:33 +02:00
Marco Cecchetti 39be94e852 Force notebookbar ui when a11y is enabled
When accessibility is enabled in coolwsd.xml, overrides setting in
<user-interface> section by force to use the notebookbar UI.

Signed-off-by: Marco Cecchetti <marco.cecchetti@collabora.com>
Change-Id: I98f4b288439b21110214ca2a67df639b397184c9
2023-06-15 08:54:51 +01:00
Ashod Nakashian c9542a44cd wsd: thread-safe kit pid
Change-Id: Id8dc3b894d18606e80806950f8bad65cf657a565
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-06-14 07:04:26 -04:00
Ashod Nakashian df89ec90ae wsd: http: killpoco in prisoner http handler
Change-Id: I82f030d1d91afa504a095b852dcdaec9d2df386d
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-05-15 15:25:58 -04:00
Ashod Nakashian 6ed935bf89 wsd: quarantine: encapsulate QuarantineMap
Change-Id: I8b4da2cb4c2291c70f6a0d513a72f47899428e3e
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-05-15 08:47:26 +01:00
Ashod Nakashian 7ea3495f22 wsd: quarantine: convert Quarantine to a class
Change-Id: I9478f35e6c7c3f156aa15072e31c38bc84dc2b64
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-05-15 08:47:26 +01:00
Ashod Nakashian 4456acd2da wsd: make unreusable classes final
Change-Id: Ieea44cdba1315051ede7dde6e154055a0820b0a8
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-05-10 08:46:11 -04:00
Michael Meeks f6bd976f00 Jail cleanup - include coolwsd pid + hash into a jails sub-directory.
This avoids removing the jails of other running coolwsd that share
the same jails/ directory, such as unit-tests, cypress tests etc.

Assert on fatal system error to help catch this during test builds.

Remove old unit-test specific approach, and generalize it, since
apparently we did a recursive cleanup of other people's jails anyway.

Remove over-complicated recursive approach, for a rather simpler
one-level scheme. Avoid following symlinks too for safety.

Remove obsolete lo_jail_subpath setting.

Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Change-Id: I371f8c0e22f64fb2befb4b58f72cefa39567f3b5
2023-04-25 10:41:57 +01:00
Michael Meeks 93b41527e3 Cypress: accelerate tests by not re-downloading & JITting JS.
add forcecaching parameter to coolwsd for debug mode.

Change-Id: I6f38e9a4fd6dbb76e92105c76e8abe3e75f19ef5
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2023-04-15 11:45:22 -04:00
Michael Meeks 7ba6c10e6d valgrind / massif - improve things a little.
Avoid SIGKILL'ing children when valgrinding to allow time to save
massif traces etc.

Change-Id: I255a62b6605164ac5037a06455f1adfcba05759c
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2023-03-23 11:31:24 +00:00
Ashod Nakashian b5de21a0ad wsd: simplify passing mobileAppDocId to getNewChild
It seems more complex to have #ifdef guarded logic
around a function call to pass or not pass an argument
when we that same argument is already defaulted in
that function.

If the difference between the two paths is primarily
the argument, then we can always pass it, making sure
that in the case that defaulting would have been used
that we pass the same default value. This is now done
with assertions.

Change-Id: I333eb3f42cb51dfab8584ae8c5aa52ee45c5a9a1
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-03-14 20:40:40 +01:00
Rash419 f63d07bdea wsd: store routeToken in server
- added routeToken in ClientSession::createPublicURI

Signed-off-by: Rash419 <rashesh.padia@collabora.com>
Change-Id: Ib4a211e69d96589dd735ba8e32ddbe5f98c96509
2023-01-31 15:32:30 +01:00
Rash419 2529fa9ee2 notify client when route tokens get updated
- once client get notification it will update the routetoken
by refetching it from indirection url endpoint
- added support to configure indirectionurl enpoint using
remote config

Signed-off-by: Rash419 <rashesh.padia@collabora.com>
Change-Id: Iead22af56c655bdece6b70cc4e97a1fa401b1bae
2023-01-31 15:32:30 +01:00
Ashod Nakashian 2e01170920 wsd: request Kit termination early when unloading
DocBroker now requests the Kit process to terminate
earlier than before to give it time to disconnect
while we (DocBroker) are still around. In turn,
upon disconnection, PrisonerRequestDispatcher can
query whether we are unloading or not, to detect
unexpected disconnections.

Change-Id: Ifa102e018e32bb252a0c169b0a3df691bca4ab0c
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-12-21 19:41:38 -05:00
Ashod Nakashian 55ed57dce2 wsd: support flushing control in WSProcess::sendFrame
Change-Id: Iba1b3869a5c0aa816f78bdf59347b6e9408e8f97
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-12-21 19:41:38 -05:00
Michael Meeks dadfbf0579 allow more verbose log-level during startup to be configured.
Previously this defaulted to 'trace' - now it can be configured, but
still defaults to 'trace'.

Change-Id: I0ecf2f0b991cd8cc29dbde866dd4589be4ca7957
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2022-11-21 21:44:05 +01:00
Ashod Nakashian ac52505640 wsd: getServerURL is debug/test only
Change-Id: Ic4c2fe3b467fee475cdc7c0b91b1df77f441c0aa
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-11-20 07:50:12 -05:00
Henry Castro abfbf4846d wsd: add remote buy product url
Change-Id: I97617ddf8c7a0fc923788477fb077f3baa16fe13
Signed-off-by: Henry Castro <hcastro@collabora.com>
2022-09-29 10:28:18 +03:00
Michael Meeks 2b20e4050d Forward setclipboard data to the Kit as a binary message:
assert: invalid utf-8 - check Message::detectType()
 #3  0x00007fce7ae57fd6 in __GI___assert_fail at ./net/WebSocketHandler.hpp",
 #4  0x0000558bd2790231 in WebSocketHandler::sendFrame at ./net/WebSocketHandler.hpp:748
 #5  0x0000558bd2851202 in WebSocketHandler::sendMessage (flush=false, code=WSOpCode::Text, len=22118,
     data=0x7fce5c227b50 "child-045 setclipboard\napplication/x-openoffice-embed-source-xml;windows_formatname=\"Star Embed Source (XML)\"\n1370\nPK\003\004\024", this=0x7fce6c003340)
     at ./net/WebSocketHandler.hpp:641
 #6  WebSocketHandler::sendTextMessage (flush=false, len=22118, ...) at ./net/WebSocketHandler.hpp:619
 #7  WebSocketHandler::sendMessage (msg="child-045 setclipboard\nappl...) at ./net/WebSocketHandler.hpp:613
 #8  WSProcess::sendTextFrame (this=0x7fce6c001300, data="child-045 setclipboard\nap...) at wsd/COOLWSD.hpp:142
 #9  0x0000558bd27d5678 in DocumentBroker::forwardToChild (this=this@entry=0x7fce64027940, viewId="045", message="setclipboard\n...) at /usr/include/c++/9/bits/shared_ptr_base.h:1020
 #10 0x0000558bd2899d50 in ClientSession::handleClipboardRequest (this=0x7fce64027dc0, type=type@entry=DocumentBroker::CLIP_REQUEST_SET, ...) at ./common/Session.hpp:76
 #11 0x0000558bd27e0999 in DocumentBroker::handleClipboardRequest (this=0x7fce64027940, type=DocumentBroker::CLIP_REQUEST_SET, ...) at /usr/include/c++/9/bits/shared_ptr_base.h:1020
 #12 0x0000558bd2847b8b in ClientRequestDispatcher::handleClipboardRequest(...) at /usr/include/c++/9/bits/shared_ptr_base.h:1020

Change-Id: I406eee0ac3a47986fdd9511e674c9228d1994d38
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2022-08-27 08:21:28 -04:00
Miklos Vajna 3205899a31 libfuzzer: fix clientsession_fuzzer
The fuzzer case doesn't read the configuration. This is similar to
what getConfigValue() already did, now extended to
getConfigValueNonZero().

Signed-off-by: Miklos Vajna <vmiklos@collabora.com>
Change-Id: I14a838ea9875d81413f22140eeac627520c423ab
2022-08-23 10:50:50 +02:00
Ashod Nakashian 5e0c29c73b wsd: move the autosave interval into SaveManager
Change-Id: I79e33e3089a4da0c1d968b0fdbc2f4bab55c4fc6
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-08-06 20:38:09 -04:00
Ashod Nakashian c2ba9c8a77 wsd: extend the fork timeout when copying systemplate
While bind-mounting is very fast, linking and copying
are both often much slower. Normally, we give extra
time to forking Kit the first time, but then we
reduce the timeout there after. Here, we take into
account whether or not bind-mounting is enabled
before we reduce the timeout to the normal level.
That is, if bind-mounting isn't enabled, we leave
the timeout to be higher-than-normal to accomodate
slow linking or copying.

The benefit of this is evident in the stability of
tests when bind-mounting is disabled (even on fast
filesystems with linking).

Change-Id: I959abf6d3253b2c91be8e0c9a59ec12511817bb9
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-08-02 14:45:12 -04:00
Ashod Nakashian 5c6516e4e4 wsd: support code-coverage report via --with-coverage
This adds support for code-coverage HTML reporting.
To achieve this, we must use file-linking in jails
so that we can update the coverage data (.gcda files)
from the jails. This means that creating jails is
slower than with bind-mounting and we need to
account for that in our timeouts.

We also can't kill child processes with SIGKILL,
which is un-catchable. Instead, we use SIGTERM
and dump the profile data before exiting.

Change-Id: I16fa534f6ed42f7133014d841bb024423315e0a4
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-08-02 14:45:12 -04:00
Ashod Nakashian b77dfc47d2 wsd: remove default arg from SigUtil::killChild
Explicit is always better. We also need to
terminate more gracefully when profiling.

Change-Id: I7145cb59583c5d7c6362bbf9c74e9d21799eaa33
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-08-02 07:51:52 -04:00
Ashod Nakashian b3d298bd84 wsd: minor cleanup of addNewChild
This moves the shared_ptr copy to outside the
lock, as well as reducing logging inside it.

Change-Id: Iedde95b3fe60fc40bbd035a9d43a9b95af7efdcc
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-07-12 13:43:43 +01:00
Henry Castro ccd15ce9a6 wsd: add getter function to obtain the ...
Web server poller thread

Change-Id: I1b1785e41891e408eb6ebc360baf15c4fd07bf5f
Signed-off-by: Henry Castro <hcastro@collabora.com>
2022-06-07 15:42:53 +01:00
Henry Castro 7ed475f25c wsd: infobar: fetch and save the latest version data
Change-Id: I7988fc69d4eaa35a26463cf180c26c6fd9b083e1
Signed-off-by: Henry Castro <hcastro@collabora.com>
2022-05-12 18:25:10 +01:00
Henry Castro 6bfe68ea93 wsd: add parameter --signal
To signal SIGUSR2 to parent to notify
that the server is ready to accept connections,
and begin the tests.

Change-Id: Ie936217243aa7a2e836f3d45cb508ede13fae8c5
Signed-off-by: Henry Castro <hcastro@collabora.com>
2022-04-27 09:18:21 +01:00
Ashod Nakashian 96adaa15d1 wsd: kill coolwsd_fuzzer
coolwsd_fuzzer predates actual fuzzing
with libfuzzer and is currently unsused.

Change-Id: Id095b165943ba14dbf525ddc607ad329f5d952d4
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-04-20 07:12:03 -04:00