Commit graph

2083 commits

Author SHA1 Message Date
Ashod Nakashian
d8c2578ec4 wsd: detect storage conflict with no clients
When the last client connection is closed,
there is UI (or user) to provide input
on the document conflict dialog. In this
case, we detect that the situation is final
and unresolvable and we simply give up.

We log a warning and dump the document state
before terminating.

Change-Id: I111a446b8743a0d16b7ed8b39751a419036c927f
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-02-08 20:46:01 -05:00
Ashod Nakashian
2d7e4da181 wsd: do not force uploading when in conflict
When the document has been changed in storage,
we should be extra careful not to inadvertently
clobber it because we needed to force the
upload for some unrelated reason.

When in conflict, only a user can force clobbering.

Change-Id: I498a6d1c86242b059ac722d3e48c31a04a79591b
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-02-08 20:46:01 -05:00
Ashod Nakashian
26b6cd4463 wsd: improved removeSession
Since we track active sessions in removeSession,
it's possible that the last session is not active.
In that case, we should set the unload flag while
saving. If we've removed it, we should mark to
destroy. And finally, we should only assert
that mark to destroy is set with active session,
not when we are left with disconnected ones.

Change-Id: I275aeafe67875fa75e0fad5438928f2f77b79a9a
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-02-08 20:46:01 -05:00
Ashod Nakashian
d9a3a42137 wsd: wait for the modified flag before giving up
By waiting at most 2 seconds, we improve the chances
of getting the ModifiedStatus=false before we termiante
the document. This minimizes the noise of warning
of potentially lost data on exit and similarly reduces
the test failures, which test for clear termination.

Change-Id: I284693d1cdd91b1224581fdc29e6e5438ab4c0b2
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-02-08 20:46:01 -05:00
Ashod Nakashian
9702cce25f wsd: preserve the original modified time as string
We no store the origina modified time of the document
as we receive from the storage server in string
form and send it back as-is. This avoids any
potential issues with the roundtrip of conversion
to and from a timestamp.

Change-Id: I524bea8f36c3ce62dcd00c4fe6a1e7e083287ed1
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-02-08 08:05:39 -05:00
Ashod Nakashian
5757c17b6b wsd: clang-tidy fixes
Also, reduce public function surface-area.

Change-Id: Ia922e19c49a731a83bbd3d1dc645355926ddba3c
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-02-04 10:26:49 -05:00
Ashod Nakashian
00cc176af3 wsd: improved DocBroker logging
Change-Id: I2432bcdf06c9fa6335a872aa7354e1f3ddd761f4
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-02-04 10:26:49 -05:00
Ashod Nakashian
7757989795 wsd: save -> upload
Probably the last remaining incorrectly labelled
helper that checks for in-progress uploads, but
had retained the old and misleading label of 'save'.

Change-Id: I693275b1559f3dae4e9e3ab2408d997f56ff86e3
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-02-04 10:26:49 -05:00
Ashod Nakashian
acbfc41afd wsd: remove unused resetUnloadRequested
Change-Id: Icb9ef1c02a9b8d31add5b305c3c1d09d3e251337
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-02-04 10:26:49 -05:00
Pedro Pinto Silva
6d3d2935d7 Rename: outdated loleflet strings
Signed-off-by: Pedro Pinto Silva <pedro.silva@collabora.com>
Change-Id: Ibfb5de3dc5d4c5a57f4d50bf0a9bbc45df2ecadb
2022-01-27 16:15:51 +01:00
Miklos Vajna
4d6ca688f9 wsd, convert-to: allow specifying filter options as JSON
For example, to skip exporting the first page of a document:

curl -k -F "data=@3page.odg" -F "format=pdf" -F "options={\"PageRange\":{\"type\":\"string\",\"value\":\"2-\"}}" https://localhost:9980/cool/convert-to > out.pdf

https://gerrit.libreoffice.org/c/core/+/128849 has more examples.

Signed-off-by: Miklos Vajna <vmiklos@collabora.com>
Change-Id: I6c4ce25bc580dac041f2865f74c856780d6fe137
2022-01-27 13:33:24 +01:00
Henry Castro
d056c872f5 wsd: fix missing port number
use Uri::getAuthority():
"Returns the authority part (userInfo, host and port) of the URI. "
.

Change-Id: I8c63a4c00cc1ad199f6f0cfd15f4e42fac4e7aaa
Signed-off-by: Henry Castro <hcastro@collabora.com>
2022-01-26 16:46:06 +01:00
Henry Castro
ee67cd4f44 wsd: use getHost to allow CSP frame-src
It will be used to update server check versions

Change-Id: I3acadb575bdcc99daed4c68881d3f35da999a22c
Signed-off-by: Henry Castro <hcastro@collabora.com>
2022-01-26 16:46:06 +01:00
Ashod Nakashian
9e5b9d6d37 wsd: support PDF comment saving during unload with test
PDFs are view_comment type documents where
editing is not supported, but adding comments
are. This means that we do get ModifiedStatus=true
but we never get ModifiedStatus=false after
.uno:Save. This is because the save command is
handled in a special way in Core by invoking
save-as instead, which doesn't reset the
ModifiedStatus.

The issue with this was that DocBroker was
stuck on trying to save the document
before unloading, thinking it was modified
due to the stuck ModifiedStatus. Here,
we change the definition of isPossiblyModified()
to ignore the ModifiedStatus for such documents.
Instead, we rely on the last save being successful
and that no new user input exists past the last
save request.

In addition, we now have a new Cypress test
that reproduced the failure without the fix
and now passes with the fix.

Change-Id: Ida9d486ac93a588b9007c5e4583d8bf3c090a62d
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-01-26 15:33:15 +05:30
stellarpower
b05b8e77cf Add more detail to error logs.
We get a syntax error message in the logs - but have no indication as
 to what in the config file caused this issue. Bringing back both more
 detail to the browser and logging the extended details.

Signed-off-by: stellarpower <5004545+stellarpower@users.noreply.github.com>
Change-Id: Ib8ddb20a1968f879558e59f50579ee4b18db0f09
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2022-01-26 09:09:56 +00:00
Andras Timar
6d771bb3b6 Writer document is a better example for framed.doc.html
because the Python macro examples on the top of the page
operate on Writer documwents, and have no effect on Calc documents.

Signed-off-by: Andras Timar <andras.timar@collabora.com>
Change-Id: Ia4f9b28c25689cb2ed9037ffd24086d7fb8c3cf9
2022-01-25 20:25:43 +01:00
Pranam Lashkari
c5f2c5e174 theme: added config flag to switch between integration and cool themes
Signed-off-by: Pranam Lashkari <lpranam@collabora.com>
Change-Id: I679328e29f2e2297491c73249632627d01a1bf42
2022-01-25 12:09:01 +05:30
Ashod Nakashian
a3bb76de2d wsd: handle no-storage when shutting down
When we reject a connection (possibly due to
authorization failure) we will not have a
storage instance to use.

Change-Id: I049c990317e4a78d0e89bc906f1ee48b365cf3c2
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-01-22 17:29:46 +00:00
Yunusemre Şentürk
a41995accd Admin: make time output thread secure
Change-Id: I3927ef9989de2217dee6c4b3034c9ffbd8fb184d
Signed-off-by: Yunusemre Şentürk <yunusemre@collabora.com>
2022-01-21 16:52:20 +01:00
Yunusemre Şentürk
801b67c353 Admin: force un-conditional logging when docstats enabled
Change-Id: Iea0a75927b495735787496468ab39d5314992a50
Signed-off-by: Yunusemre Şentürk <yunusemre@collabora.com>
2022-01-21 10:17:46 +00:00
Yunusemre Şentürk
2314c40873 Admin: introduce docstats subsection in logging in config
Change-Id: Icccc9d842703b3159965f67be2bf16404d50bad6
Signed-off-by: Yunusemre Şentürk <yunusemre@collabora.com>
2022-01-17 16:28:08 +00:00
Ashod Nakashian
fa24c70242 wsd: do not load a new view when unloading
Recovering from an unloading state has a lot of
corner-cases that make it exceedingly tricky to
handle correctly. Luckily, if we reject new
connections, the client will retry connecting
(or at least it can) and that gives very
reliable results.

Change-Id: I3c06c878cb7a333dd49e153096ce01b356e9815d
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-01-17 14:08:51 +01:00
Ashod Nakashian
bb85464d58 wsd: dump the state of the sessions of DocBroker
Change-Id: I98b287e1cbbcd463e76885672f1520b93c25751e
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-01-17 14:08:51 +01:00
Szymon Kłos
a3c5c71107 RTL: Serve html with correct RTL settings
In case of RTL users we want to switch UI to that mode
early so we don't see flipping in the browser.
Setup correct setting at the serving html step.
Using that approach we don't need to extend LOK API.

We detect that using "lang" parameter passed in the request.

Signed-off-by: Szymon Kłos <szymon.klos@collabora.com>
Change-Id: Iaa2962b01f218cae68a6dfd168bff4dbdae94c8a
2022-01-11 21:40:54 +03:00
Ashod Nakashian
e0e988c56c wsd: improve logging and doc state dumping
Change-Id: I62ae4cc8dd52861ce550217fb5fa96405cbe4eed
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
(cherry picked from commit 644ca92d289d77d4e14a6a473ed55daedbb125d7)
2022-01-11 09:28:03 +01:00
Ashod Nakashian
ff43f8626f wsd: stop DocBroker when loading fails
Change-Id: I2bc6a9c367ca280e1748ee356e456a92ea04354b
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
(cherry picked from commit f926f31764777a212afc49e84308ac3d35367db9)
2022-01-11 09:28:03 +01:00
Ashod Nakashian
32e71e45bc wsd: more frequent polling while unloading documents
And always use the stop() helper so that we properly
log the request to stop.

Change-Id: Iee3be5d8591bbb2febe651815741d9ad9ff5d977
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
(cherry picked from commit ab954b9a34813d143b1d409ae80e7531bec625ed)
2022-01-11 09:28:03 +01:00
Ashod Nakashian
70665b328f wsd: do not create client sessions on docs marked to destroy
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
(cherry picked from commit 3eb310d7609e98572959fece196d9bc00147c2ff)

Change-Id: Ic1faa042975816bd15ccc4f5667eeccfb0cf73d7
2022-01-11 09:28:03 +01:00
Ashod Nakashian
f95ff8205a wsd: test: fail when modified docs are unsaved
Change-Id: I444948ce96ff512491fe72f55a7b5abfcf1dab4e
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
(cherry picked from commit 11dad9c87a979eee0fac9c85ea3387174da61760)
2022-01-11 09:28:03 +01:00
Ashod Nakashian
feb01facfa wsd: do not count disconnecting sessions as active
This fixes failures in UnitCopyPaste and
TileCacheTests::testWireIDFilteringOnWSDSide where
the documents are closed while isModified() is true.

Change-Id: I6de683530df9b7987ad87897e9ce70b5fc3d3a15
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
(cherry picked from commit 65105263fbed89d787ac59ca77f64896bacf6832)
2022-01-11 09:28:03 +01:00
Ashod Nakashian
65d5a4f1a5 wsd: test: add slow save and upload test
Change-Id: I5c7e706a1ded7774c9da4545218ba9fa29fc9d81
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
(cherry picked from commit 29c26c9afee593c20bc72a668ba0c3d5634aa35b)
2022-01-11 09:28:03 +01:00
Ashod Nakashian
036bc60c24 wsd: save and wait until document isn't modified
We make sure that we always check for last-minute
modifications before stopping DocBroker. This covers
the cases where there are modifications that we need
to save and/or saved data that needs uploading.

This save, upload, and stop logic is now in a helper
that cleanly handles this exit-time check.

Change-Id: Ibee0e7769a396b205de955f26700ebcb27d5ac95
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
(cherry picked from commit 69f9d86c8b8a477b5a0cf1910eb1b7498eaceeac)
2022-01-11 09:28:03 +01:00
Ashod Nakashian
77d5816cfc wsd: remove DocBroker from Admin last
Change-Id: Ia77b8ce5aacb9ac1dadd1251f78e40da953e7b92
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
(cherry picked from commit caf5ac9c23a612836185475f4efc4c9c0249e3b4)
2022-01-11 09:28:03 +01:00
Ashod Nakashian
b96e8b7c77 wsd: correct use the exit code from UnitWSD
Relevant for catching test failures, which
went unnoticed if the failure wasn't asserted.
E.g. when a test times out.

Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
(cherry picked from commit 426a3ea6eb5d0041432e2f5fa4d99e3cf834f595)

Change-Id: Ic6e5b5aa4344a3048f508a6bec2be7c5a6522f33
2022-01-11 09:28:03 +01:00
Ashod Nakashian
777858e617 wsd: add hsts header with config
Change-Id: I16955edd09cf68e995294055ea2cb3f458b3ba38
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-01-10 21:26:38 +01:00
Szymon Kłos
07003f88e9 Handle JSON exception when parsing commands fixes #3916
Signed-off-by: Szymon Kłos <szymon.klos@collabora.com>
Change-Id: I9bd78ded46d1b5cd4816a106b138583e540f0712
2022-01-09 13:15:36 -05:00
Yunusemre Şentürk
23e9f086e2 Admin: add log info about adding a document.
Change-Id: Ia440662d341803c56a810563a76269835469bb2e
Signed-off-by: Yunusemre Şentürk <yunusemre@collabora.com>
2022-01-08 10:59:15 +00:00
Gleb Popov
4d64f2b466 Create a link to the master UDS file inside the jail when we aren't using abstract sockets.
Signed-off-by: Gleb Popov <6yearold@gmail.com>
Change-Id: I021b906ef545f4d3238f4c61650ced8da15b6374
2022-01-08 10:41:02 +00:00
Rash419
d0dc8eb9df wsd: fix: remove unnecessary condition
Signed-off-by: Rash419 <rashesh.padia@collabora.com>
Change-Id: Ibc5338b34713233c540e0de938dbb76b88398ef5
2022-01-05 07:51:12 -05:00
Rash419
b7f7c518eb wsd: consider possibly-modified docs when handling conflicts
When the storage returns modified-in-storage or conflict status
to an upload attempt, we prompt the user to handle the conflict
when the document is modified. Previously, we only prompted
when we had the modified flag set, ignoring the possibility of
having a race with the modified flag, in case the document was
just modified, or potentially modified.

We now prompt the user even when the document is potentially
modified, giving the user the opportunity to decide what to do.

Signed-off-by: Rash419 <rashesh.padia@collabora.com>
Change-Id: I699aaed92d41f76a8eb9de6bdb65608099802663
2021-12-31 05:38:33 -05:00
Pranam Lashkari
75f37bb1df freemium: added option to make freemium user read only
Signed-off-by: Pranam Lashkari <lpranam@collabora.com>
Change-Id: I4dadb535e722cbeaacf177b30247899795d048f9
2021-12-20 12:03:51 +01:00
Miklos Vajna
15e08d3709 common: introduce COOLProtocol::getNonNegTokenInteger()
To simplify code that wants to extract a non-negative number from a
token value. See
<https://github.com/CollaboraOnline/online/pull/3788#pullrequestreview-826099897>.

Signed-off-by: Miklos Vajna <vmiklos@collabora.com>
Change-Id: I389dfa1a2838e501fc308dbfd7927b142a361922
2021-12-17 02:52:37 -05:00
Tomaž Vajngerl
b9545f932c support for a custom path to NSS certdb files for sign/encrypt
The path of the NSS certdb is defined in the coolwsd.xml config
file and if the config file is set and contains the certdb files,
then the db files are copied to the jail into /tmp/certdb folder.
Also the /tmp/certdb path is set to LO_CERTIFICATE_DATABASE_PATH
env. var, which is then used as the default certdb in LibreOffice
when LOKit starts up.

Signed-off-by: Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>
Change-Id: I72e8f28f27a0306fef9319bc6212cd99cb3f8212
2021-12-15 06:00:55 -05:00
Pranam Lashkari
63b6d8a9d2 Quarantine: fixed quarantining when jail mounting is disabled
Signed-off-by: Pranam Lashkari <lpranam@collabora.com>
Change-Id: I9159c6fe33d66f64e56e084a203af74629e330c6
2021-12-15 08:32:19 +01:00
Michael Meeks
35fac326be trace: emit loadTile as an async event.
Also create pseudo-threads, so we can dis-entangle async tile
loading from other event emissions.

Change-Id: I08dcd4e0f5ade741565ce3d827ec22004e1fae83
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2021-12-13 21:34:56 +00:00
Luboš Luňák
1dfb6d3866 handle properly "EMPTY" invalidatetiles message (T32137)
ChildSession::loKitCallback() may generate a message in the format
"invalidatetiles: EMPTY, 0". Handle it properly in tests.

Signed-off-by: Luboš Luňák <l.lunak@centrum.cz>
Change-Id: If8009be3c4ce031466ed304df7028848a8ab960f
2021-12-13 22:08:25 +01:00
Gabriel Masei
9c4bfaaff1 add pdf version option for conversion
Signed-off-by: Gabriel Masei <gabriel.masei@1and1.ro>
Change-Id: I8a9a05498649dfea80ec425671326aa0c62d4917
2021-12-13 15:27:16 +02:00
Szymon Kłos
f3d2aa4be0 Use correct formatting for string variables
- when reading from config use correct type so SyntaxException
  is thrown when we type non-number into uint field
- handle SyntaxException and send 500 so user will get response
  (previously we left request without response until timeout)
- log about incorrect value in the config
- simplify repeated bool -> string conversion after config read

Signed-off-by: Szymon Kłos <szymon.klos@collabora.com>
Change-Id: I1c50de263ffdb1d97eb9381754bc7cf3bd05dbfa
2021-12-11 21:58:34 +01:00
Miklos Vajna
e2515a7b15 TileCache: improve parsing in parseInvalidateMsg()
Signed-off-by: Miklos Vajna <vmiklos@collabora.com>
Change-Id: I373f85e68964610fe88cb6fa057c548b9a50fb51
2021-12-02 08:21:49 +01:00
Andras Timar
b40a72877a quarantine: add the original file name to the quarantined file name
Instead of
1638118271_12013_%2Findex.php%2Fapps%2Frichdocuments%2Fwopi%2Ffiles%2F289_ocvq040ushf2
we would get
1638118271_12013_%2Findex.php%2Fapps%2Frichdocuments%2Fwopi%2Ffiles%2F289_ocvq040ushf2_bad.docx
I find it more useful.

Signed-off-by: Andras Timar <andras.timar@collabora.com>
Change-Id: I50918908173adeb68964b2aa542592b57ec82020
2021-11-29 13:37:19 +01:00