Commit graph

2192 commits

Author SHA1 Message Date
Miklos Vajna
f5836a5d1d sanitizers: fix unit-base, again
==4544==ERROR: AddressSanitizer: odr-violation (0x000002c40140):
  [1] size=104 'HostUtil::WopiHosts' ../wsd/HostUtil.cpp:12:34
  [2] size=104 'HostUtil::WopiHosts' wsd/HostUtil.cpp:12:34
These globals were registered at these points:
  [1]:
    #0 0x71f618 in __asan_register_globals.part.13 /home/vmiklos/git/libreoffice/lode/packages/llvm-llvmorg-9.0.1.src/compiler-rt/lib/asan/asan_globals.cc:362
    #1 0x7f00cb0f3d7b in asan.module_ctor (/home/vmiklos/git/libreoffice/online-san/test/../test/.libs/unit-base.so+0x10e0d7b)

  [2]:
    #0 0x71f618 in __asan_register_globals.part.13 /home/vmiklos/git/libreoffice/lode/packages/llvm-llvmorg-9.0.1.src/compiler-rt/lib/asan/asan_globals.cc:362
    #1 0x120e2ae in asan.module_ctor (/home/vmiklos/git/libreoffice/online-san/coolwsd+0x120e2ae)

==4544==HINT: if you don't care about these errors you may set ASAN_OPTIONS=detect_odr_violation=0
SUMMARY: AddressSanitizer: odr-violation: global 'HostUtil::WopiHosts' at ../wsd/HostUtil.cpp:12:34
==4544==ABORTING

All of HostUtil was duplicated between the test shared objects and
coolwsd, so remove it from the test objects and rather exclude
RequestDetails::getDocKey() from the test objects instead, which was
linked in but was not used in practice.

Signed-off-by: Miklos Vajna <vmiklos@collabora.com>
Change-Id: Ia2147c89cf4230df97a8f45ac7d509aa11cdca97
2022-04-01 13:31:45 +02:00
Ashod Nakashian
099246d67a wsd: unload when no Kit and nothing to upload
When the Kit dies and there is no data saved to
disk to upload, there is nothing to do but unload
DocBroker and log the fact.

With unit-test that simulates the situation by
killing the Kit of a modified document.

Change-Id: I7dcc0583c053d7166935d15d045fcf6624e43b4e
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-03-30 23:18:57 -04:00
Ashod Nakashian
7920656e36 wsd: remove dup entry in dumpState
Change-Id: I1b5e774d33e743dab98781dbe8609dffa8f5cb63
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-03-30 23:18:57 -04:00
Ashod Nakashian
28b3e165c2 wsd: remove unsed function in DocumentBroker
Change-Id: Ia310cce20b3ca2c95be98d75b13ec7e047cf19b9
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-03-30 23:18:57 -04:00
Rash419
6a1bade376 wsd: handle locked_hosts case where different aliases might have different settings
so now real locked_host settings will be applied if the document accessed with alias

Signed-off-by: Rash419 <rashesh.padia@collabora.com>
Change-Id: Ib76704a4bf2c3da5dc7b83bbad98fe40b5c03316
2022-03-29 12:18:31 +02:00
Rash419
31d8822758 wsd: cleanup: moved all parsing related static methods and containers to HostUtil.cpp
Signed-off-by: Rash419 <rashesh.padia@collabora.com>
Change-Id: I8555522c6216f893b90ba4c27747314830f7abd2
2022-03-29 12:18:31 +02:00
Michael Meeks
9f5c5dcdf4 Show (E) for experimental mode in help->about if present.
Change-Id: I00d6cb861c3050d5b4f80b0cb41e70012d0fe610
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2022-03-24 17:25:40 +00:00
Rash419
ea35dbe350 wsd: added regex support for alias tag
Signed-off-by: Rash419 <rashesh.padia@collabora.com>
Change-Id: I2534ea9afa7d3d3bf10f91eeac44f70381acc76a
2022-03-22 14:13:22 +01:00
Tor Lillqvist
a635f9b8a6 There is no type called COOLWSD::Server
Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: I7ccf4960a4161fdc5b012d72787e94b490cb4a6d
2022-03-22 11:38:51 +02:00
Tor Lillqvist
037a0929f0 Remove two forward declarations from COOLWSD.hpp
Only one of them is needed, and only in COOLWSD.cpp itself.

Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: I03864afdc13e778a2b8ce8205e135d679dddf13d
2022-03-22 11:38:51 +02:00
Gökay Şatır
2a944950e4 Typo in COOLWSD.cpp.
Signed-off-by: Gökay Şatır <gokaysatir@collabora.com>
Change-Id: Ib76fce22e70cb448712a33879c1484418bc75328
2022-03-21 21:34:25 +01:00
Michael Meeks
16386b9aaf Re-work welcome configuration.
Change-Id: Ia99eb5b587a849d32d7d4f392c15f84db2423e95
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2022-03-21 21:34:25 +01:00
Mert Tumer
eec3ef97e2 android: fix unable to exit modified document
We dont upload to storage on mobile we save as locally
and copy the temp file into original on uno save result callback
Doing that once during close is enough since there is no
turning back and it cannot be possibly modified after

Signed-off-by: Mert Tumer <mert.tumer@collabora.com>
Change-Id: I047626be862cdbcb86e083534555e45530f417a2
2022-03-21 16:44:50 +03:00
Ashod Nakashian
140b4f9c08 wsd: minor improvements to StringVector::equals overloads
Change-Id: Ifa975e579392151bef422ff985a93abf3129dfeb
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-03-21 08:57:41 +00:00
Ashod Nakashian
f74192d9ac wsd: always include the BIO errors in SSL logs
And improved socket logging in general while
making them more consistent.

Change-Id: I1ed7f2561476ca5370af91079d5d616804396f8e
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-03-21 08:57:41 +00:00
Rash419
da3143dbdc wsd: added mode attribute to alias_groups
you can switch between 'first' and 'groups' mode
default mode is 'first' it allows only the first host when groups are not defined.
set mode to 'groups' and define group to allow multiple host and its aliases.
also added mode option in JSON format

to make the setup backwards compaitable , auto_host is by default false it won't
resolves aliases and dockey will only use uri's path . To use alias_groups you have
to explicitly set the auto_host allow attribute value to true

Signed-off-by: Rash419 <rashesh.padia@collabora.com>
Change-Id: I3af439edcbc546d9a660d678e52d813951dc237a
2022-03-18 18:30:14 +03:00
Rash419
ddc13c0f4a wsd: added new method to check allowed Aliases
Signed-off-by: Rash419 <rashesh.padia@collabora.com>
Change-Id: I24fab96ff977d3f0a85c98257e779216f50dc92f
2022-03-18 18:30:14 +03:00
Henry Castro
6b701ce613 wsd: use get/set Authority to extract host + port
Change-Id: I91ce4e9cef6854ad2cc113d1ad6f55d7c91d6ab6
Signed-off-by: Henry Castro <hcastro@collabora.com>
2022-03-18 18:30:14 +03:00
Henry Castro
f0bfa5a53c wsd: parse and check syntax alias host
Change-Id: I66e465ed4b8997b72f3cdf1c8b85a95d951bf735
Signed-off-by: Henry Castro <hcastro@collabora.com>
2022-03-18 18:30:14 +03:00
Miklos Vajna
c9bba090b7 sanitizers: fix unit-base
==30332==ERROR: AddressSanitizer: odr-violation (0x0000020b9b20):
  [1] size=1 'StorageBase::SSLAsScheme' ../wsd/Storage.cpp:67:19
  [2] size=1 'StorageBase::SSLAsScheme' wsd/Storage.cpp:67:19
These globals were registered at these points:
  [1]:
    #0 0x71d0f8 in __asan_register_globals.part.13 lode/packages/llvm-llvmorg-9.0.1.src/compiler-rt/lib/asan/asan_globals.cc:362
    #1 0x7f4c362ed33b in asan.module_ctor (online-san/test/../test/.libs/unit-base.so+0x10eb33b)

  [2]:
    #0 0x71d0f8 in __asan_register_globals.part.13 lode/packages/llvm-llvmorg-9.0.1.src/compiler-rt/lib/asan/asan_globals.cc:362
    #1 0x11c709e in asan.module_ctor (online-san/coolwsd+0x11c709e)

==30332==HINT: if you don't care about these errors you may set ASAN_OPTIONS=detect_odr_violation=0
SUMMARY: AddressSanitizer: odr-violation: global 'StorageBase::SSLAsScheme' at ../wsd/Storage.cpp:67:19
==30332==ABORTING

Resolve the conflict by not providing these definitions when building
tests.

Signed-off-by: Miklos Vajna <vmiklos@collabora.com>
Change-Id: I6a8f74bd0b78a76f46b5401acaa816dd0b185aa9
2022-03-18 09:23:59 +01:00
Ashod Nakashian
97a6d1cd98 wsd: support experimental features
This adds a new config option to enable/disable
experimental features and behavior. The default
value can be controlled at build time by
--enable-experimental.

Change-Id: Iffcb4c71d9e0933a646251b63033b6dadcd3b809
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-03-17 18:46:46 -04:00
Ashod Nakashian
82933be193 wsd: last modified timestamp of the upload file is not now
When deciding whether the file on disk needs uploading
or not, we compare it with the last modified timestamp.
For this to work they need to be different.

When there is no file to upload (i.e. when there is
nothing new to save), the timestamp we get is
unix-time of 0. This is always different from 'now'.
So we incorrectly think there is data to be uploaded
when there isn't.

Better to initialize the last modified timestamp to
unix-time of 0, so in this case we correctly
conclude that there is nothing to upload.

Change-Id: I545e9021e9c76d009e08758342effaf3e9b964c7
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-03-16 08:31:54 -04:00
Ashod Nakashian
0c88fd8d6e wsd: gracefully close the document when disconnected from Kit
When disconnecting from Kit we shouldn't bluntly stop
DocBroker, because even though we cannot save, we
can still upload the latest document version from
disk.

What makes this particularly problematic is that
we request to kill Kit when the last client is
disconnected.

This was caught through unit-tests, albeit it was
not very common or easy to reproduce.

This fixes cases where always_save_on_exit
doesn't save/upload.

Change-Id: Ib66281fc68d4c0264602852b0acdc453b6f79963
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-03-16 08:31:54 -04:00
Ashod Nakashian
9732689668 wsd: stop loading when low on disk space
For some reason the disk-space check wasn't
done for WOPI storage. Here we add the check
and bubble the exception up to stop loading.

UnitStorage has been updated and re-enabled.

Change-Id: I15a093554b662d6c0828da7683ca0190a8225fc9
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-03-16 08:31:54 -04:00
Ashod Nakashian
e5e67a71d7 wsd: wait longer when restarting forkit
Forkit takes significantly longer to start than
to fork. At the startup of WSD we do wait 4 times
as long for forkit than when forking kits.
Similarly, we should also wait that much when
forkit crashes and we recover.

This stabalizes the forkit crash tests, which
did fail rather frequently (in one example,
2 out of 10 runs had failed locally).

Change-Id: I990c8e595b64c34a8e202933be833c53d7ebfc01
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-03-16 08:31:54 -04:00
Rash419
d02dd19f33 wsd: use hostname, port and scheme in doc key
This allows us to use multiple hosts using same coolwsd instance.

added aliases configuration to coolwsd.xml to avoid
possibility of opening the same file as two if the
WOPI host is accessed using different aliases

Signed-off-by: Rash419 <rashesh.padia@collabora.com>
Change-Id: I32913015c15fd396cecc702b76e0dcaa8bcafad3
2022-03-16 11:32:59 +03:00
Andras Timar
b8d836f108 Disable export of template files
Signed-off-by: Andras Timar <andras.timar@collabora.com>
Change-Id: I3c5c7da5d1cad6fe7e6703d0941f250e91a5f552
2022-03-15 14:05:30 +01:00
Henry Castro
b614c83098 welcome: preprocess the COOLWSD_VERSION
to our welcome dialog

Change-Id: Ibef4c299ab50ad81f88009e7107638da12e425f6
Signed-off-by: Henry Castro <hcastro@collabora.com>
2022-03-11 15:09:50 +03:00
Ashod Nakashian
02f2860847 wsd: test: assert correct wopi GetFile and PutFile
Change-Id: I7e08d87eb382d67aed3ffaff32230e2c08d8c828
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-03-09 19:24:40 -05:00
Ashod Nakashian
b6920d30af wsd: assert that we don't have more than one active session
Change-Id: I0c404b19187658d28f6371a1e58430d3a93d6cbc
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-03-09 19:24:40 -05:00
Ashod Nakashian
832e308e8f wsd: more informative timestamps in dumpState
The timestamps now helpfully include how
long ago they were.

This also improves the conversion between
chrono clocks by adding generic functions.

Change-Id: I18081330564c8d969b9364cf1b9e33546e241280
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-03-09 19:24:40 -05:00
Ashod Nakashian
4322f87d92 wsd: improved forkit logs
And avoid pid of 0 in getKitPids().

Change-Id: I68743a55aed080ed54d7d8576f269974c644e1b2
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-03-09 19:24:40 -05:00
Rash419
3fab3a1b52 wsd: remote-config: handle null pointer exception when JSON format is not proper
Signed-off-by: Rash419 <rashesh.padia@collabora.com>
Change-Id: Ia3a8aa6340fde13b5d73c69b187b3333b6df88e0
2022-03-04 15:02:41 +05:30
Michael Meeks
f91e0349d8 Admin: shutdown cleanly to avoid races during close.
Suspect cause for SEGV in:

    std::_Rb_tree<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::shared_ptr<DocumentBroker> >, std::_Select1st<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::shared_ptr<DocumentBroker> > >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::shared_ptr<DocumentBroker> > > >::find(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)
    COOLWSD::closeDocument(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)
    Admin::triggerMemoryCleanup(unsigned long)
    Admin::pollingThread()

Change-Id: Id09e4db4b21cb7a11dddb867758aded4b28ff3ec
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2022-03-03 09:04:06 +00:00
Tor Lillqvist
cdc783ec0e Don't require https when ENABLE_DEBUG for the remote config thing
Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: I8b71d4e5a06e2c0a7fcd7dedc370cc4810a204fd
2022-02-28 15:57:51 +02:00
Tor Lillqvist
9bd427235e Add a generic class to fetch a remote JSON file between RemoteConfigPoll and SocketPoll
Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: I991b60044a431fe5aff48617d3f0852c119da095
2022-02-28 12:32:01 +02:00
Rash419
50678c5191 wsd: introduce remote configuration
fetch JSON from remote server and apply new config without restarting coolwsd
- Extended the feature_locked configuration & functionality so that it can be set per wopi host ranges

Signed-off-by: Rash419 <rashesh.padia@collabora.com>
Change-Id: Id0e2b4b524a80de88b2b3559dd18c4a95b8163fb
2022-02-25 18:36:06 +03:00
Ashod Nakashian
08061da286 wsd: faster save and exit when unloading
Change-Id: Ic99739867c3e9529bf0369388700398eb178265c
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-02-25 07:54:11 -05:00
Ashod Nakashian
948e8d5202 wsd: do not skip uploading when last save skipped
When the document isn't modified and we save,
we get back "unmodified" failure from Core.
This has the unwanted side-effect of skipping
uploading.

As we now decide whether to upload or not
based on the file timestamp on disk,
this logic has no purpose and in fact can
cause a lot of grief.

Removing this outdated logic has the nice
side-effect of simplifying the code, as
the save result doesn't need to be propagated.

Also, save failures are now communicated to
clients at the point of handling the save
response, not when uploading (which is
a distinct stage). And upload failures
are reported separately.

Change-Id: Ia465a0069280fb6bea47e413f0d885565f0bbb3d
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-02-25 07:54:11 -05:00
Ashod Nakashian
489c942aae wsd: do not clobber closeReason
The closeReason member isn't just for logging,
it's is also broadcast back to clients. This
means that it has to preserve the original
reason for initiating the document closing,
lest the client misbehaves.

Change-Id: Iddee5dba3943d873e8658ce5c1748f4ecd47c486
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-02-25 07:54:11 -05:00
Ashod Nakashian
3c953faded wsd: send the client 'docunloading' for all unloading cases
And don't load documents when the ShutdownRequestedFlag
is set, not just the TerminationFlag.

Change-Id: I94c720d6fd7c361549bc905e093886619e8f188b
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-02-25 07:54:11 -05:00
Ashod Nakashian
d0597288dc wsd: stop if unloading and have no sessions to upload
It is possible to lose the last writable session
during unloading and get stuck forever.

This can happen in the following scenario (as observed
in a rare test run):

1. always_save_on_exit is true.
2. The last/only writable session disconnects.
3. We save and upload.
4. We attempt to stop because the clients have disconnected,
   but because we are uploading, it doesn't flag to stop.
5. Uploading fails repeatedly until we reach the limit.
6. We endlessly check to save and upload and even though
   there is nothing to save, we couldn't even check for
   the need to upload, getting stuck.

With this patch the above scenario is not possible.

Change-Id: I19e7b621f2b452a9f18964f5f19d6eb378a48797
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-02-25 07:54:11 -05:00
Henry Castro
3bffee13bc wsd: pre-process the welcome.html file
Change-Id: Ib20bb3b5bf4affab42d31acd50030da66537b801
Signed-off-by: Henry Castro <hcastro@collabora.com>
2022-02-24 19:15:35 +03:00
Alexandru Vlăduţu
dc0b02da4c browser: add option for grouping the download as icons
Signed-off-by: Alexandru Vlăduţu <alexandru.vladutu@1and1.ro>
Change-Id: I3c8c1964879bec8c4e31a85baefb7b442ceae29f
2022-02-24 15:22:22 +01:00
Ashod Nakashian
c9f8edc08a wsd: const correctness and minor cleanups
Change-Id: Ic3dd918e371f74ac59684f09f0b4f5bc0a7b9b0a
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-02-24 07:38:13 -05:00
Ashod Nakashian
b53d353779 wsd: reduce debug and generally redundant logs
In 'debug' log-level we expect a detailed, but
still readable output. Having one area with
disproportionately large number of logs reduces
the overall utility of the log output.

This patch reduces a number of redundant log
entries, including errors that are already
logged. It also reduces the level of some
others from 'information' to 'debug' and
from 'debug' to 'trace'.

The goal is to make 'debug' level as useful as
possible to read the progress and be able to
understand what was going on, such that one is
able to decide which area to dig deeper into.
Then, trace level could be used to get more
insight into that area, if necessary. For
example, when investigating a test failure,
one first enables 'debug' logs and reads through.
Once a section between two debug entries is
identified as being of interest, enabling 'trace'
level logs becomes more productive as it's
now possible to easily reach the first DBG
entry and read through until the second one.

It's unfortunate that we don't have per-area
control for enabling/disabling logs, so it
is common to see more and more 'debug' log
entries added all around, making logs
less and less readable.

It is also a limitation of the levels we have
that we really only have 3 usable levels:
one, two, many. That is, 'information' for
the most important events, 'debug' for
technical details needed to investigate issues,
and 'trace' for everything else. ('warning'
and 'error' aren't really 'levels'; they have
semantics that makes them special-cases.)
So we have to avoid degrading one into the
other, or have differences without distinction.

If any of these entries are needed to be
displayed more frequently, changing them
back to 'debug' or even 'information' should
be done. Though for me they seem special
cases that don't benefit most log readings.

Change-Id: Id2c6a9dc027483b81a066b0b4b50a298c5eff449
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-02-24 07:38:13 -05:00
Ashod Nakashian
bef9c3ff65 wsd: dump all the state managers in DocBroker
This adds dumpState to DocumentState, SaveManager,
and StorageManager classes, and dumps all the
missing members.

Also, normalize the format and make it symmetric
and consistent.

Change-Id: Ie0cc8e07d13de60c33d64cd621abf4e815a4ef94
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-02-24 07:38:13 -05:00
Ashod Nakashian
6c1766d156 wsd: test: extend the timeout of the conflict tests
Change-Id: I4171ec923a29ee22abc4e40267949829d40fc776
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-02-24 07:38:13 -05:00
Michael Meeks
96b15bd704 Count and report on various internal exceptions.
An initial set of seven of these, easy to add more as/when needed.

Change-Id: I6c65e052d00f9eaa10adee3c9464043e4c594848
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2022-02-18 13:51:41 +00:00
Ashod Nakashian
c92fb35309 wsd: test: dump DocBroker state when tests fail
Change-Id: Idc98847d6b54ff8057a232022fa62531a2bb3ced
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-02-17 18:52:48 -05:00
Ashod Nakashian
f8b05a0f83 wsd: support unattended runs
With --unattended, do not wait for a debugger
upon seg-faulting. This avoids the unnecessary wait
that prolongs failed unit-tests in automated runs.
Now run_unit.sh and Cypress Makefile set this flag.

Note that the wait only happens when in debug
builds, or when envar COOL_DEBUG is set. This
prevents us from waiting when running a debug
build where we can't see the output, or indeed
the run is on a CI build machine.

This flag can also be used by devs when reproducing
failures where there is no interest in attaching
a debugger. The logs are shorter and more
readable, too. At least in trace level.

Change-Id: Ice15482c6724abc47f5955402295198eb7f671ee
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-02-17 18:52:48 -05:00
Ashod Nakashian
17ef1a4b80 wsd: test: more consistent test logging
And some include cleanup.

Change-Id: I3807553bf2abe6d36c5cc521bc82e5b089ae91ea
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-02-17 18:52:48 -05:00
Ashod Nakashian
2b8944b96e wsd: test: add more DocBroker test events
Change-Id: I89df4709049184e90be21882053b8adfdcbaa868
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-02-17 18:52:48 -05:00
Ashod Nakashian
44796fc6c9 wsd: test: improvements
Change-Id: I2ed744f8d1a8a472645e5db46789226d6d3ba04a
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-02-17 18:52:48 -05:00
Pranam Lashkari
7e22a01d4d refactored feature disabling bits
now it is known as feature locking

Signed-off-by: Pranam Lashkari <lpranam@collabora.com>
Change-Id: I2935edbfe1eb8dcc194641afa2461cf77b2b29d3
2022-02-11 17:00:11 +00:00
Ashod Nakashian
af77b68d97 wsd: limit store failure when unloading
When saving and/or uploading fails, we have
to give up after a certain number of retries.

A new config entry, per_document.limit_store_failures,
controls the number of consecutive failures
before giving up. This prevents locking-up
documents while uploading.

Includes a new unit-test.

Change-Id: I1296df1691fcaa982df9e861d34cb946a2eda860
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-02-09 19:35:19 -05:00
Ashod Nakashian
6c2fe26e3f wsd: count save and upload failures
Change-Id: Ifaae1fb1f28e7c25b359fff313b570c9ed8cf224
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-02-09 19:35:19 -05:00
Ashod Nakashian
2f19b8bdef wsd: merge unloading logic and centralize
Change-Id: Idfae52b5f76ef26795a57af646eef7c4a0e44b0b
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-02-08 20:46:01 -05:00
Ashod Nakashian
ee7679ad8e wsd: reuse autoSaveAndStop for consistentcy
Change-Id: Ia58b490e0c580c8684c75baa9122fb3fa45562c5
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-02-08 20:46:01 -05:00
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