Commit Graph

279 Commits (246e87fea21d6121fd4bd2daeff8a4f92082477e)

Author SHA1 Message Date
Aron Budea 246e87fea2 wsd: Unconditionally compile support-key-enabled code paths
Signed-off-by: Aron Budea <aron.budea@collabora.com>
Change-Id: Iec477c223f2dc75e0be8b472c8439ca9311d6aae
2024-04-14 01:23:00 +01:00
Michael Meeks 144b701453 cool#8703 - Drop random node creation and rely on inherited fd.
Re-using an inherited file descriptor to /dev/urandom frees us
from problems with mount options including 'nodev' and removes a
capability from the set we need.

Change-Id: I70337e923f802d7efbd3159c11a4e39f6529b6e6
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2024-04-07 12:11:48 +02:00
Parth Raiyani c9ef8c3015 Removed Group download as option from coolwsd.xml
Signed-off-by: Parth Raiyani <pmr642001@gmail.com>
Change-Id: I47c07ed88d68de5fc65b2e5e1e0896bc2a082131
2024-03-29 15:07:07 +01:00
Michael Meeks 80eeabb1a6 Watchdog: expose global watchdog thread.
This will enable thread joining before fork for bgsave.

Change-Id: I68c7c53f892f5edef861137c48759c7ccb8532ab
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2024-03-29 13:04:09 +00: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
Ashod Nakashian 5880312981 wsd: fix support-key build
Change-Id: Ib59494884333a200d768eec8b829e565f6470e2a
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2024-03-23 09:47:44 +10:30
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
Michael Meeks 5105e4202a unipoll cleanup - remove obsolete DocumentBroker mutex.
This should not have been necessary for a long time; but add
some assertions to help check.

Change-Id: Iedbc0bb57839209d1f1caeaab7094e335c881e57
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2024-03-19 20:44:59 -04:00
Rashesh Padia 464358ca70 fix: data loss when shutting down while using typer
- Docbroker only uploads the document when the document is already saved and
  there are no further modifications.
- But when using typer once dockerbroker saves the document and tries to upload
  there are already new changes to the document. Therefore, docbroker keeps on
  saving this new changes and keeps on skiping the upload as there are new
  changes to the document; until it times out

Signed-off-by: Rashesh Padia <rashesh.padia@collabora.com>
Change-Id: I427d37a6228299006530daddebdf4365af63588b
2024-03-19 19:42:20 +05:30
Michael Meeks c1b6b5d30f Watchdog to call probe-point when SocketPolls are slow.
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Change-Id: Id58efab0c0fee88a3da094765eb6b7641aec6e02
2024-03-19 11:29:07 +00:00
Ashod Nakashian 21b0394828 wsd: better empty string operations
Change-Id: Ic14efcaa8a1c345b875c27446b16f51740c55efa
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2024-03-18 18:41:49 +00:00
Gökay Şatır a1d0745de5 Add sample URLs for readonly mode to console output.
Signed-off-by: Gökay Şatır <gokaysatir@gmail.com>
Change-Id: I2e10a25850a64bb666d0473d8881878ff41ad6b1
2024-03-08 17:21:51 +03: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
Szymon Kłos 17015c1109 lok_allow: remove also port
Noticed in some k8s deployments where alias groups were
defined with port. For lok_allow we need only host name.
Avoid adding empty hosts.

Signed-off-by: Szymon Kłos <szymon.klos@collabora.com>
Change-Id: Ic9cd574f9b6faa3c382229a853883a128e9b0620
2024-03-06 08:47:28 +00:00
Ashod Nakashian 1896baa539 wsd: test: use STATE_ENUM in tests
Change-Id: Ie37bfdb7aba986dc17c1ebaac80d9b1b662a5df6
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2024-03-05 12:21:50 +01:00
Ashod Nakashian 2e8561195c wsd: move deprecated logic under legacy_server config
We no longer send LOOL-WOPI headers, unless
the configuration specifically flags for
legacy servers. But we always send COOL-WOPI
even to legacy servers, to help them upgrade
seamlessly.

Change-Id: Ifc919ed8f6665cd8f846117ef4e8b7ef09fbd563
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2024-03-02 04:02:26 -05:00
Ashod Nakashian f76bcaa4b4 wsd: use a single shared_ptr instead of container for RequestVettingStation
Change-Id: I38c496edccf5d6ccc352f06b1c75972913248517
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2024-02-24 14:09:22 -05:00
Ashod Nakashian 32ba3e34b5 wsd: restructure RequestVettingStation interface
This makes it easier to support even earlier use
of RequestVettingStation, when cool.html is served.

Change-Id: I206f5f593a33806c24c6ed1e126d4cae5500f405
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2024-02-24 14:09:22 -05:00
Ashod Nakashian 7570dd299c wsd: use RequestVettingStation for async loading
This replaces the synchronous loading logic
with the new asynchronous one.

Change-Id: I20fd7903cffbbd7c524d8051295113439ef75d5b
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2024-02-24 14:09:22 -05:00
Ashod Nakashian 8d55aab329 wsd: exclude HostUtil from non-mobile apps
It's not used, since no external storage
is supported in the apps.

Change-Id: I5cf765ef3cb38dcb396318f6b9ace56bf4e127a2
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2024-02-21 20:13:39 -05:00
Ashod Nakashian 5d36c19cea wsd: include cleanup in COOLWSD.cpp
Change-Id: Ia89a2da4c5a0e12478c65b59af1b2be6ffb55089
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2024-02-21 20:13:39 -05:00
Ashod Nakashian 5a82c36680 wsd: move ClientRequestDispatcher to own file
This moves ClientRequestDispatcher and all
its direct exclusive dependencies to its
own file and adjusts formatting.

No functional changes were performed,
although namespaces were restored and
other minor changes were done for
consistency.

The resulting file is still rather large
at around 2000 lines, but that makes
COOLWSD.cpp smaller by about 30% now.

Change-Id: I59bcd997ad08702ce7029c6791095e75ad9b23b0
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2024-02-21 20:13:39 -05:00
Michael Meeks 7031c3b0ce cool#8328 - config header fixup.
config.h should be included as the 1st line in each source file.
It should not be included in headers.

config_version.h which changes on every commit should not be
included widely - so remove it from the HttpRequest heeader to
save tinderbox's ccache.

Fetch version info from helper methods rather than in-lining via
defines, to better encapsulate.

Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Change-Id: If449a36f1ac61940f04d70d5f4180db389d9b4c4
2024-02-21 09:35:25 +00:00
Caolán McNamara 377c826894 disable getting the host printer queue
and default printer. In typical deployment these should be effectively
no no-op, so mostly aligns debugging env with deployment env so whatever
printer happens to be installed locally has no effect.

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I09651d9af2de9817d4d278d25937c9ce0dc87352
2024-02-12 20:39:02 +00:00
Caolán McNamara 71a427c465 cid#344351 COPY_INSTEAD_OF_MOVE
and

cid#336280 COPY_INSTEAD_OF_MOVE
cid#318848 COPY_INSTEAD_OF_MOVE
cid#318964 COPY_INSTEAD_OF_MOVE
cid#344354 COPY_INSTEAD_OF_MOVE

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I60a904be4b5edf61cfd5b2efab81e5c1a089b661
2024-02-12 11:12:33 +01:00
Ashod Nakashian 7bba9b5b7d wsd: refactor findOrCreateDocBroker
This separates error-reporting to the client
through the WebSocket from the actual logic
of finding or creating a DocBroker.

This should be useful in creating a DocBroker
without having the client's WebSocket.

Change-Id: I66fc8ac09264fcbdb79ddf62867b8551a72929d6
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2024-02-09 15:50:50 +00:00
Ashod Nakashian d3905698b0 wsd: detect unencoded WOPISrc
We should always have an encoded WOPISrc.
We add detection logic to make sure
that all URIs that contain WOPISrc have
it encoded properly. We do this by
comparing the decoded WOPISrc with
the original URI.

Change-Id: Ia0c2a79b009ce105321ad35db3d4f81006e81cb3
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2024-02-09 03:57:04 -05:00
Caolán McNamara 95c98805a0 cid#336284 COPY_INSTEAD_OF_MOVE
and

cid#336290 COPY_INSTEAD_OF_MOVE
cid#336288 COPY_INSTEAD_OF_MOVE
cid#336282 COPY_INSTEAD_OF_MOVE
cid#318980 COPY_INSTEAD_OF_MOVE
cid#318853 COPY_INSTEAD_OF_MOVE

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: Icf6447b8298432359ec37242427ce595f8de4160
2024-02-08 08:49:26 +01:00
Caolán McNamara f04d3450cd rng::getHardRandomHexString is now the same impl as rng::getHexString
so remove one in favor of the other

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I47778f7bce24f0687565aa179b7a3bbea9d95120
2024-02-05 16:19:38 +00:00
Aron Budea 81d743281a Capture this explicitely by name
To avoid the following warning in C++20:
error: implicit capture of ‘this’ via ‘[=]’ is deprecated in C++20 [-Werror=deprecated]

Signed-off-by: Aron Budea <aron.budea@collabora.com>
Change-Id: I8b195d675ddc87fa6b16f7240a046fac9a7769e1
2024-02-01 08:30:30 +01:00
Aron Budea 8e111f497d wsd: Add config to customize OS version info
Signed-off-by: Aron Budea <aron.budea@collabora.com>
Change-Id: I12abdd0755883acb7bae126ac3c9c999598b4428
2024-01-31 19:33:18 +10:30
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 733883fb11 wsd: make findOrCreateDocBroker non-static
Needed to reference from ourside COOLWSD.

Change-Id: Ib8a160d912c6d3a2d972cc1fcf231e862f2fe24b
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2024-01-18 18:59:18 +00:00
Michael Meeks ca34860bbc clipboard - dump saved clipboard state and details.
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Change-Id: I1dcee22ad66bce1081b88262b58e9999f6e81ada
2024-01-17 09:52:58 +00:00
Michael Meeks 5bd1f1d0e8 convert-to: be more tolerant of unusual filenames.
But re-write them anyway to be more sensible.

Change-Id: Ie146f4f84b539ab7e826a1c1b947497acde7e384
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2024-01-15 11:57:55 +01:00
Caolán McNamara 0f922c2322 Rewinding and rereading proc/smaps_rollup doubles the values on some kernels
So this only affects the case where we reuse the fd from opening smaps_rollup

Bug seen in 4.15.0 and not in 6.5.10, suspected to be fixed by:
258f669e7e
included in >= v4.19

Test for this in coolwsd and set a flag if it is broken

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I0a4aca77b9d9201e4f70172340296e5eb5460229
2024-01-10 17:30:46 +00:00
Szymon Kłos e8f77a6b06 Don't pass invalid hosts for lok_allow #7885
Fixes #7885

Be more flexible and allow to run service with configured
hosts which doesn't work with lok_allow (invalid regular
expression for std::regex which is used in core).

This change instead adds error report in the logs, without
it it was crashing when any host was not compatible.
For example when using domain like:
"*.example.com" which should be ".*\.example\.com"

Signed-off-by: Szymon Kłos <szymon.klos@collabora.com>
Change-Id: Id664df95899bda866b9179a3941280626a2c0299
2024-01-02 11:57:32 +01:00
Ashod Nakashian 29cfaa7682 wsd: quarantine: absolute-path and better logging
The quarantine path should be an absolute path.

Unfortunately, because we had relative=true in
the path config, we couldn't detect empty configs.
This is because with relative=true the getter
would create a path based on the current directory
and the config value, which would default to
"quarantine" when empty.
This would result in /opt/cool/quarantine or
/usr/bin/quarantine when in fact the path is
really empty.

Now, the config has relative=false and
there is no default. In addition, we
warn if the path is no absolute.

Change-Id: I1b3eb5e76866a12d214b47e6556942715a210e54
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2024-01-02 10:57:20 +01:00
Ashod Nakashian 373c04fe4e wsd: admin: use the cgroup limit as available memory
This applies the cgroup memory limit, if set,
such that if it is lower than the configured
memproportion percentage, we do not exceed it.
Otherwise, we risk running out of our cgroup
limit and by then it is too late to do anything
but die due to OOM.

This also moves the logging of the cgroup memory
stats from COOLWSD into Admin, to avoid duplicate
logging.

Also updated the description of memproportion
config entry to account for the cgroup logic.

Change-Id: I870ae61c1260eb2b3275bd2fa1a4c48ff30957a2
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-12-30 10:36:44 +00:00
Szymon Kłos 2190cbdc20 Remove protocol when adding to lok_allow
We automatically add allowed wopi hosts to lok_allow.
But we expect to have plain host names, we need to remove
protocol if it is present.

Example:
wopi - group - host: https://.*\.mydomain.com
we need to add: .*\.mydomain.com to lok_allow list.

Signed-off-by: Szymon Kłos <szymon.klos@collabora.com>
Change-Id: I80bf3b7c25c0df15e422cd8369eceaddbb588e26
2023-12-20 19:58:43 +00: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
Caolán McNamara c231b3b2ec wasm: limit threads using for scaling
disable this with VCL_NO_THREAD_SCALE for wasm

"Yacht.odt" document with lots or large images fails to
render:

Tried to spawn a new thread, but the thread pool is exhausted. This
might result in a deadlock unless some threads eventually exit or the
code explicitly breaks out to the event loop. If you want to increase
the pool size, use setting `-sPTHREAD_POOL_SIZE=...`. If you want to
throw an explicit error instead of the risk of deadlocking in those
cases, use setting `-sPTHREAD_POOL_SIZE_STRICT=2`.

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I8b2f994d2d3d23f8a0043f0c7fefa4d5e250b8bc
2023-12-12 20:24:26 +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
Ashod Nakashian fd5c130d2d wasm: wsd: make switching wasm-only
Change-Id: I13386d60a469ec05c5b15369c32c5b3ccdffa232
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-12-09 19:22:24 +00:00
Ashod Nakashian 4879049d9e wasm: disable file and color logging
Change-Id: Id9d13552af7e963739e6c30e5faa97519ddec76a
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-12-09 19:22:24 +00:00
Ashod Nakashian a96f8a0f92 configure: WASMAPP is now defined for WASM targets
This is in line with MOBILEAPP and GTKAPP and
is independent of __EMSCRIPTEN__.

Replace all application-specific cases, leaving
only toolchain-specific ones (such as include
protection).

Change-Id: Ic44288aa5ace51e0a8b54566170c19120f7bf0dd
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-12-09 19:22:24 +00:00
Ashod Nakashian 1954f9abcb wsd: reduce includes where possible
Change-Id: I99f489e57cb9391ea819d52b49b0d0034a289cf9
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-12-09 19:22:24 +00:00
Caolán McNamara 5f1c943a98 add hasWASMSupport to capabilities
so the launching site can query if wasm is enabled to see if it needs to
insert the required headers, so we can then in turn make it optional on
those being set to also require matching headers.

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: Icd73081809abb8098c21bc61a8357869db45ff6c
2023-12-06 09:58:57 +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