Commit graph

243 commits

Author SHA1 Message Date
Rash419
c91b8b01b4 wsd: new config entry to add unlock_link for feature lock dialog per alias_group
- also added unlock_link option in dynamic configuration

Signed-off-by: Rash419 <rashesh.padia@collabora.com>
Change-Id: I075a4aed4f82059714412def965a8ed4d3581b2f
2022-07-20 17:41:19 +05:30
Rash419
04f81f8590 wsd: fix: use only alias_groups entries when defined
ignore wopi.storage.host entries when storage.wopi.alias_groups entry is defined in config

Signed-off-by: Rash419 <rashesh.padia@collabora.com>
Change-Id: I7ea73f147e283077b02bdacb37f8850f7613c0c3
2022-06-27 20:44:47 +05:30
Ashod Nakashian
c11fab5b78 wsd: browser: handle 413 Entity Too Large from storage
It seems at least some storage hosts report disk-full
errors via 413. This logic of handling 413 error as
disk-full was introduced in
f8e0b8c11e.

Here we handle 413 as it is defined, as Entity Too Large.

Change-Id: I61297c2fab9de663643336a6eba47949f82d1737
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-05-24 22:48:37 +03:00
Rash419
2163e2f043 wsd: cleanup setting firsthost code
we added AllHosts to give admin the err log that host is not in alias_groups but now as we removed the host list entries from configuration we don't need that log

Signed-off-by: Rash419 <rashesh.padia@collabora.com>
Change-Id: I8b5e9e6b7df7df59befb496c12966c7ddc60c707
2022-05-05 11:04:22 +05:30
Ashod Nakashian
14d96957cd wsd: log macro cleanup
* Simplify log macros.
* Reduce expanded lines (faster compilation).
* Avoid flushing (since we always use ostringstream).

Change-Id: Id10c1a75b5af5d8cdba62d768192ab0a6a9e0aca
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-04-26 11:13:44 +03:00
Ashod Nakashian
92c6428e4b wsd: minor log improvements
Change-Id: Iea317ac1a04163d9eb45b8ac2b6d1c4f9f77009c
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-04-20 08:34:59 -04:00
Ashod Nakashian
16617bee2d wsd: fallback only when COOLStatusCode is missing
Since the json parser logs an error when the
entry isn't found, parsing both LOOLStatusCode
and COOLStatusCode almost guarantees at least
one ERR log entry. We should only fallback
when COOLStatusCode isn't found and avoid
erroring when we got what we wanted.

Change-Id: Icace964820c250f4ceba98281e57cb7c29fbd118
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-04-20 08:34:59 -04:00
Ashod Nakashian
480fb7b931 wsd: move tokenizer helpers into StringVector
In an attempt to reduce the size of Util.{c,h}pp
which has grown to contain all sorts of unrelated
helpers, we move StringVector helpers into
the StringVector.{c,h}pp files.

This makes the code better organized.

Change-Id: I152f341606807ae66253415b951bc9f89b09df57
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-04-12 07:39:07 -04:00
Rash419
89f5989eab wsd: fix: log messages to coolwsd.log of firsthost and denied hosts
Signed-off-by: Rash419 <rashesh.padia@collabora.com>
Change-Id: I2bdc7b21d11afa70214e8cb498b7e2dec77ef655
2022-04-05 22:34:15 +05:30
Rash419
13d644be2b wsd: removed host list from coolwsd.xml
- first host is by default allowed without any condition

Signed-off-by: Rash419 <rashesh.padia@collabora.com>
Change-Id: Iacca38868f06a417cbb99984e2dac1eef727df6e
2022-04-05 13:45:51 +02: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
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
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
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
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
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
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
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
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
Miklos Vajna
e5ef35f716 WopiStorage: log what is the final suggested target for save-as
unit-wopi-saveas sometimes fails on me with sanitizers. The reason is
still not yet clear (the test is quite stable without them), but at
least try to find out if the suggested target is already wrong when we
put them to the HTTP header or it goes wrong later.

Signed-off-by: Miklos Vajna <vmiklos@collabora.com>
Change-Id: I25f65fd6e211022aa93c699cdaef49eb8978fdee
2021-11-25 11:30:28 +01:00
Andras Timar
5ffcd450a8 rename: add compatibility for existing integrations
Signed-off-by: Andras Timar <andras.timar@collabora.com>
Change-Id: I013a042b47906ab48a0d02de422982dd8a6c85e4
2021-11-19 11:21:22 +01:00
Andras Timar
f07ff8c7e0 rename: remaining lool->cool changes
Signed-off-by: Andras Timar <andras.timar@collabora.com>
Change-Id: Ib7d4e804bebe52dead8d53b0e0bbaed0f08bf3d0
2021-11-18 14:14:11 +01:00
Henry Castro
c2d60f3627 wsd: rename 'lool' -> 'cool'
Change-Id: I4ece04921a0e12d4c69b2a70b563e66cc89be0a6
Signed-off-by: Henry Castro <hcastro@collabora.com>
2021-11-17 09:17:54 +01:00
Ashod Nakashian
4d897435a5 kill reuse_cookies
This remove reuse_cookies as a setting and feature
altogether. It was originally a workaround to aid
with authentication, prior to having access_token.
However, it proved to be less useful than originally
anticipated, primarily because cookies nowadays have
security restrictions in browsers. In addition to
the fact that access_token simply deprecated it.

While the documentation has also been updated,
tests still have reuse_cookies in input data.
This is intentional to ensure the code is
backwards compatible with any deployment that might
still pass URLs with reuse_cookies around.

Change-Id: If214b299b34a910face8cabc7c1335621990c85e
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-11-02 08:45:00 -04:00
Pranam Lashkari
88601440d0 introduce way to hide/restrict uno commands
Signed-off-by: Pranam Lashkari <lpranam@collabora.com>
Change-Id: I1225190a67f726832e5b38a7c3f690b51c1385f3
2021-10-21 12:28:13 +03:00
Pranam Lashkari
f02a0a1447 freemium: renamed Freemium namespace to CommandControl
also renamed freemium files accordingly

Signed-off-by: Pranam Lashkari <lpranam@collabora.com>
Change-Id: Id33b8a1d1a2a8725bfa6e7b7c562430ea126993c
2021-10-21 12:28:13 +03:00
Mert Tumer
73ea638d1d Include X-WOPI-Lock header to rename
bug is described here: #3208
Missing Lock header according to the wopi specs on rename
operation

Signed-off-by: Mert Tumer <mert.tumer@collabora.com>
Change-Id: I6c73f4f1a0a057935a6885cea274ce66c73365d4
2021-10-13 09:17:42 -04:00
Ashod Nakashian
2b95acb153 wsd: close the upload socket if exit-save
When we are uploading before exit we don't
want the upload socket to linger, because
that would keep the SocketPoll alive for
longer than necessary, holding up the DocBroker.
Instead, we flag the socket for closure, right
after that single request, via HTTP headers.

This allows for very fast unloading of the
DocBroker right after uploading.

Change-Id: I926763383093d2d2dfb10ed41293b1f5d54d090b
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
(cherry picked from commit 4e132606d1849f82991c46d641c50794d632233c)
2021-09-26 17:02:01 -04:00
Pranam Lashkari
e02e1df76d Introduce Freemium options
Signed-off-by: Pranam Lashkari <lpranam@collabora.com>
Change-Id: Ib6b68ff74839cf84f2d8c8cfb7d380be9209f923
2021-07-20 14:41:18 +05:30
Ashod Nakashian
90f0360ada wsd: close the connection after failing to load
Change-Id: I571c9afba3ae2d9be83382dab571902669e8b059
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-07-19 17:31:55 +01:00
Ashod Nakashian
f63d077916 wsd: ssl certificate verification requirements
Change-Id: I72ffa586310296f1986276c3007672c41146c92b
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-07-18 21:14:48 -04:00
Ashod Nakashian
0690f23ee4 wsd: move isLocalhost to a common area
Change-Id: I2a7986863138a254a6d74644112f5cd60bb898cd
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-07-18 21:14:48 -04:00
Szymon Kłos
27799f23eb HTTP 302 - updates after review
Change-Id: Iaac4384385e05f33472b6678422b4a444319b59c
Signed-off-by: Szymon Kłos <szymon.klos@collabora.com>
2021-07-12 08:44:39 +02:00
Szymon Kłos
fef43e237a HTTP 302 Found - block redirection loops
Change-Id: I686a801a7003d14210a0319d421b326b7f8c107a
Signed-off-by: Szymon Kłos <szymon.klos@collabora.com>
2021-07-12 08:44:39 +02:00
Szymon Kłos
b72c8e9ae6 Handle all redirect HTTP verbs
Signed-off-by: Szymon Kłos <szymon.klos@collabora.com>
Change-Id: I6d8417da1e147c63bc44c3fe238bdda7e3dac1b2
2021-07-12 08:44:39 +02:00
Szymon Kłos
3330293e57 HTTP 302 Found - redirrect support for downloadDocument
Signed-off-by: Szymon Kłos <szymon.klos@collabora.com>
Change-Id: I7030159c1d745f877f927e21bea7caba25c1eb8b
2021-07-12 08:44:39 +02:00
Szymon Kłos
850f3cee71 HTTP 302 Found - remember the correct resource address
remember correct URI so all the following communication
(eg. downloading the file, upload) will be performed on new location.

Signed-off-by: Szymon Kłos <szymon.klos@collabora.com>
Change-Id: Id14c5209eb1d9ffc7c24d7e02f0c7c32a60568b7
2021-07-12 08:44:39 +02:00
Szymon Kłos
f8bea2e9c5 HTTP 302 Found - redirrect support for getWOPIFileInfo
With some loadbalancers it may happen that HTTP 302 Found
response with redirect location will appear.

Change-Id: I7bac807761423adcd827cf775bd1d3d2ba87a6cc
Signed-off-by: Szymon Kłos <szymon.klos@collabora.com>
2021-07-12 08:44:39 +02:00
Ashod Nakashian
5a310a2232 wsd: separate client SSL context from the server
Change-Id: I4d86f733a16e6c76340b18ff836831ebe6acfd4d
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-06-23 23:39:34 -04:00
Ashod Nakashian
1139c99972 wsd: failure to upload is not an error
Change-Id: Ifa0fb37c33c8059cadcd30ff02d9d0e44868f629
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-06-19 17:44:59 -04:00
Ashod Nakashian
f2f713cdaf wsd: rename file after saving to support async uploading
To avoid writing (saving) while reading (uploading) or
any other undesirable racse on the document file,
we atomically rename the file after saving on disk
to pass ownership.

After saving in Core, we rename the document in the
jail to .upload (by appending it). DocumentBroker
looks for the file with that extension and atomically
renames it to .uploading (by appening the 'ing' suffix).
This way, the Kit only renames from the original to
.upload and DocBroker renames only .upload to .uploading.
This guarantees that we never rename the same file
concurrently.

Uploading decision is strictly based on the modified
timestamp of the .uploading file, compared to the
timestamp of the last file we uploaded successfully.

Change-Id: I03520cd8c87605f6dad417e7a978204f76fc0c38
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-06-19 17:44:59 -04:00
Ashod Nakashian
cb077179b0 wsd: logs and assertion in upload completion handler
Change-Id: I7abec95525e73d7d9a9621f8c389a63b7dd66afc
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-06-19 17:44:59 -04:00
Ashod Nakashian
1d0c717d0a wsd: handle async upload callback
Now we can handle the response of the storage
after the async upload is complete (or timed out).

Change-Id: I29d450646bddb07f02bb17d257e7e0fa372ce357
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-06-19 17:44:59 -04:00