Commit graph

1811 commits

Author SHA1 Message Date
Ashod Nakashian
561a9ce991 wsd: storage: upload to storage using http::Request
This converts Poco to http::Request in sync mode,
thereby not changing functionality. In a follow-up,
this will be converted to async.

Change-Id: Ifbecd44ff599394799c1131470d77f803ed8cc45
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-02-27 08:57:25 -05:00
Henry Castro
851c532508 wsd: revisit log messages misc files
LOG_FTL = abnormal, crash, denied service
LOG_ERR = load, save, session, connection, wrong parameters
other cases LOG_WRN, LOG_INF

Change-Id: Iaddfcf7f0853abfa96948fff28acda606cf88b55
Signed-off-by: Henry Castro <hcastro@collabora.com>
2021-02-23 23:48:19 -05:00
Henry Castro
bac79a1a4a wsd: revisit log messages Storage.cpp
LOG_FTL = abnormal, crash, denied service
LOG_ERR = load, save, session, connection, wrong parameters
other cases LOG_WRN, LOG_INF

Change-Id: Ia014602cc3288f5cb0e2b06fd46cdf0ad7294f43
Signed-off-by: Henry Castro <hcastro@collabora.com>
2021-02-23 22:04:24 -05:00
Henry Castro
aad38107d8 wsd: revisit log messages FileServer.cpp
LOG_FTL = abnormal, crash, denied service
LOG_ERR = load, save, session, connection, wrong parameters
other cases LOG_WRN, LOG_INF

Change-Id: I44b84853e951f5a9d6a8bbb5bd0ceebcff75abe2
Signed-off-by: Henry Castro <hcastro@collabora.com>
2021-02-23 21:36:11 -05:00
Henry Castro
41a7767c86 wsd: revisit log messages FileServerUtil.cpp
LOG_FTL = abnormal, crash, denied service
LOG_ERR = load, save, session, connection, wrong parameters
other cases LOG_WRN, LOG_INF

Change-Id: I1f6708c566fc69edc76e7c0d32625f6b1f4b3af4
Signed-off-by: Henry Castro <hcastro@collabora.com>
2021-02-23 21:35:14 -05:00
Ashod Nakashian
0292334805 wsd: properly log time duration natively
Change-Id: I12d900d44d0f79932f4454f06a16d1e1b727ab63
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-02-22 14:24:36 -05:00
Ashod Nakashian
135359afff wsd: storage: better handling of failed http requests
Change-Id: Ie7a855b692f3de28092b6b59ff4627fc4e5534ea
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-02-22 14:24:36 -05:00
Henry Castro
c24c7d9335 wsd: add an option "batch mode" to load the document
disable any dialog interactivity

Change-Id: I6d6fde721c7b3c18c519f87139525fcac1f6fb31
Signed-off-by: Henry Castro <hcastro@collabora.com>
2021-02-22 14:59:59 -04:00
Henry Castro
2c52b53f25 wsd: set state loaded when "statusindicatorfinish:" received
Normally the client session waits for a message
"status:" when the document has loaded to forward
to client side. However, when the document has macros
embedded, and a Macro Warning Security dialog popup
it will never receive the "status:" message.
So it is added "statusindicatorfinish:" to formally set that
the document has loaded.

Change-Id: Id40b853c002403577d7664c4f8206cb5a01403b6
Signed-off-by: Henry Castro <hcastro@collabora.com>
2021-02-22 14:58:37 -04:00
Gleb Popov
21bfa19e9e Fix compilation with libc++
```
wsd/DocumentBroker.cpp:772:57: error: constexpr variable cannot have non-literal type 'const std::chrono::system_clock::time_point' (aka 'const time_point<std::__1::chrono::system_clock>')
        constexpr std::chrono::system_clock::time_point Zero;
                                                        ^
/usr/include/c++/v1/chrono:1355:28: note: 'time_point<std::__1::chrono::system_clock, std::__1::chrono::duration<long long, std::__1::ratio<1, 1000000>>>' is not literal because it is not an aggregate and has no constexpr constructors other than copy or move con
class _LIBCPP_TEMPLATE_VIS time_point
                           ^
```

Signed-off-by: Gleb Popov <6yearold@gmail.com>
Change-Id: I88c5466b8ad104178cf7fa4101f5f5265ccf5e86
2021-02-22 14:39:57 +03:00
Ashod Nakashian
f24aec95e2 wsd: reuse RequestManager in SaveManager
Change-Id: Ic1842d126edeb8e8771998466aba79598e741a68
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-02-21 13:07:05 -05:00
Ashod Nakashian
3431a68709 wsd: simplify, comment, and organize RequestManager
Change-Id: I92d19bb0e0d13ae2c1683e5703924dbd87d47d2f
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-02-21 13:07:05 -05:00
Ashod Nakashian
550bddc27b wsd: storage: GetFileInfo with http::Request
Change-Id: Id04ece6918b084f5192ca357220afff6bf9fc987
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-02-20 16:47:17 -05:00
Ashod Nakashian
f5f1a64591 wsd: storage: download with http::Request and http::Session
Change-Id: I11e553fd65faf4d33c51f9b6e7e6e256fd87ba05
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-02-20 16:47:17 -05:00
Ashod Nakashian
f056d2be01 wsd: set the result of saving and mark the response time
Change-Id: Ia31376c38b4bad3dc15f618c902258af9b8f81f2
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-02-20 16:47:17 -05:00
Ashod Nakashian
c1da9af494 wsd: Loaded -> Downloaded
Disambiguate between document loading
and downloading.

Change-Id: Ia16e580d8239a1aebd9192e01860e2f17cdc3878
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-02-20 16:47:17 -05:00
Ashod Nakashian
26d0d48b4c wsd: wopiLoadDuration -> wopiDownloadDuration
Consistent with names elsewhere and less confusing.

Change-Id: Ia72cdef0f6d6cd9589ce54028472e10008cf882c
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-02-18 11:08:38 -05:00
Ashod Nakashian
d0516b4391 wsd: correct GetFile duration tracking
The download operation itself is done
after reading the response from the Poco
object. Therefore, the time duration that
was captured for the GetFile operation
was inaccurate. Luckily, we only need
to time the download API of the Storage
object, which actually is simpler, and
more accurate.

Change-Id: I05c94a29fa59d5efae215f2daea17672abc6efc7
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-02-18 11:08:38 -05:00
Ashod Nakashian
ce9276f201 wsd: actually compute the CheckFileInfo duration
For some reason, the duration of the CheckFileInfo
request was not set/updated, and therefore it was
always 0. This fixes this oversight and also
moves the duration variable locally, since
the request is synchronous anyway and there is
hardly any reason to store it elsewhere.

Change-Id: I613b24311bc5c8ee9ab98d675057f354990226e8
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-02-18 11:08:38 -05:00
Ashod Nakashian
a350dad19b wsd: Save -> Upload in StorageManager
We use download/upload in the storage
and load/save elsewhere, to avoid confusion.

This renames 'save' to 'upload' in the storage
for consistency.

Change-Id: I9ac991c2b52e2586b97c58db02110ff04bfd17d3
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-02-15 09:54:41 -05:00
Ashod Nakashian
81da7c7bff wsd: download templates by wsd
Templates were downloaded by Core
upon loading. This works fine, as
long as there is no special network
setup in loolwsd. However, when
loolwsd has a complex network setup,
such as when using reverse proxies,
Core wouldn't know about the details
and would likely fail to download
the template.

Luckily, there is no reason to rely
on Core for downloading templates.
Instead, we download it in loolwsd,
just like any other document, and
load it in Core as normal. The
remaining post-load saving of
templates remain unchanged.

Change-Id: Ib22ada4ae469863d5e5c8baeee27f667f7cd40ff
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-02-15 09:41:17 -05:00
Ashod Nakashian
725f19ab4d wsd: encapsulate common request members
Instead of inheritance we use composition
to preserve the uniqueness of the members
of SaveManager and StorageManager.

Change-Id: Ifad82787e54089d49226085e009ade67bfc7938a
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-02-13 13:25:36 -05:00
Ashod Nakashian
0a8eaff48b wsd: track the timestamp of the uploaded file
This will be used to detect whether we need
to upload the document or not.

Change-Id: I2c5f6d058b1a8e0a6ab20c9561b6701413fb5878
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-02-13 13:25:36 -05:00
Ashod Nakashian
9a040ac815 wsd: add fixme/todo for forced uploading
Change-Id: Ic6c0a50c6ee493625fe7efae3b98fdd5f52344a8
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-02-13 13:25:36 -05:00
Ashod Nakashian
e5d33a7f3e wsd: lift lastStorageUploadSuccessful into RequestManagerBase
Change-Id: I06eba0b539ecc0586be3aea178120f23762229d3
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-02-13 13:25:36 -05:00
Ashod Nakashian
8046de6146 wsd: lift ModifiedTime into RequestManager
Change-Id: Id02f7ba58e96b6b93d38cfe8f15c74ce2553517d
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-02-13 13:25:36 -05:00
Ashod Nakashian
4282f5b10a wsd: introduce RequestManager
This is to encapsulate and track the
common logic between SaveManager and
StorageManager.

Change-Id: I0c5a59edb8a26b258ba66d65983e2f76198ecbc9
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-02-13 13:25:36 -05:00
Ashod Nakashian
8035c99f3b wsd: move lastSaveTime into StorageManager
Change-Id: I74f4bdf00e94a7010ff8f7a9389613beedb64fad
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-02-13 13:25:36 -05:00
Ashod Nakashian
92487cfa5d move lastStorageUploadSuccessful into StorageManager
Change-Id: I33a64b9bbb596bcd819adbfd5d7dcee0180bb5fb
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-02-13 13:25:36 -05:00
Ashod Nakashian
6bfbcf7a5f wsd: move documentLastModifiedTime into StorageManager
Change-Id: Ib33e5d142ce59b8d57177b1fd91cc309063a2d59
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-02-13 13:25:36 -05:00
Ashod Nakashian
4fc574e539 wsd: introduce StorageManager
This is to encapsulate and track the logic
for uploading documents from the Storage.

Change-Id: I5b972151fe9548526755d18063d37cc95949e68f
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-02-13 13:25:36 -05:00
Ashod Nakashian
55b49a3c14 wsd: separate save handling from save-as and rename
We should only update the save timestamps when we
really save a new version of the document.

Requesting renaming or moving ("save as") in storage
should not be confused with actually saving in Core.

Here we take the first step in this separation,
and we only update the last save response time
when we truely get a response from Core, and
not when we execute a document path/name in storage.

Change-Id: I931c62b306dd3b4906a9e910f844a35fb3f4b6f0
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-02-13 13:25:36 -05:00
Ashod Nakashian
d8cddcea06 wsd: lastFileModifiedTime -> modifiedTime
The SaveManager is responsible for the file on disk.

Change-Id: I92f7843375fdc875bc7d1af3fba387f67a4f0ca5
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-02-13 13:25:36 -05:00
Ashod Nakashian
d806353af1 wsd: move lastFileModifiedTime into SaveManager
Change-Id: Ic3dd4f193e1676a47288bc77e75f6643438bafc7
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-02-13 13:25:36 -05:00
Ashod Nakashian
76be0d562b wsd: move save tracking into SaveManager
Change-Id: Ic98cc50469f1e25bb2e007554e1d9d42e020dc91
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-02-13 13:25:36 -05:00
Ashod Nakashian
ea96f43df9 wsd: introduce SaveManager
The SaveManager is responsible for the document's
save state. It also encapsulates the members
necessary to track the save state and related
data.

Change-Id: I3ed0f1d93f25988b1ad8b1a121a2080288866a53
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-02-13 13:25:36 -05:00
Tamás Zolnai
d0deb5eaa0 wsd: filter-out redundant 'formfieldbutton' messages.
Signed-off-by: Tamás Zolnai <tamas.zolnai@collabora.com>
Change-Id: I37834c63631fa44c9d37c9e1a4d448c1fef68c9e
2021-02-10 16:51:30 +01:00
Ashod Nakashian
bafcc98285 wsd: support FileUrl
Change-Id: I433b5f79956be9d8557df1a1f433a99d6ae10f65
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-02-09 10:45:37 -05:00
Ashod Nakashian
ec58e833e8 wsd: refactor downloadStorageFileToLocal
Prepare to support FileUrl.

Change-Id: I0ac4eccb937653ba86e74c2e6cecb7ddd5dd4ffe
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-02-09 10:45:37 -05:00
Ashod Nakashian
f7d61ae0d3 wsd: remove single-use member
And a couple of const cases.
The removed const is to allow move on return.

Change-Id: I7a81b531e75c39379871f5ffeb82d49ba1110ab1
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-02-09 10:45:37 -05:00
Aron Budea
c4faeb049b wsd: tweak SSL logging
Signed-off-by: Aron Budea <aron.budea@collabora.com>
Change-Id: I4e1e4f99cd2ac3d21b9426602de11e10bdd47a61
2021-02-06 21:43:03 +01:00
Ashod Nakashian
2304b52587 wsd: correct assertion on storage and not tilecache
We already access _storage before the assertion,
so it must move before the first use.

Also, we have no use for _tileCache when uploading,
so no point in asserting its validity here.

Change-Id: I4196d0719e6750cfd2dba8d5f449a1b76286bde9
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-01-31 22:20:59 -05:00
Ashod Nakashian
8a37738fdb wsd: documentation of DocumentBroker states
This details the design of the DocumentBroker
states and state-machines as they are to be
eventually implemented. Not everything described
is current, but the goal is to document what
the design ought to be, not what it is.

Change-Id: I938177812777af058b46c41a396407d0a083cbc4
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-01-31 22:20:59 -05:00
Ashod Nakashian
aba6d5b6c5 wsd: log at info level when we force uploading
Change-Id: Ic6da7e2c0f29ddbf5884b75866794609f69f8a8f
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-01-31 22:20:59 -05:00
Ashod Nakashian
523cfec790 wsd: save -> upload
Change-Id: I08445bd9f726225809c443f4bdfc611bbfc03bf6
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-01-31 22:20:59 -05:00
Ashod Nakashian
30f7ea2e9a wsd: remove default arguments of uploadToStorageInternal
Only the last argument (force) was implicit, and only
in one call (of total two calls). Explicit is better.

Change-Id: Ic26f4dd265f48156d1730f1b95bb70145ca47873
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-01-31 22:20:59 -05:00
Ashod Nakashian
2b96bf3fd6 wsd: move the loaded flag into DocumentStatus
The loaded flag is used to track whether or not
the document was ever loaded. It does *not* reflect
whether or not the document is currently loaded,
rather it is used to save the document, if necessary,
before unloaded.

This is why we need to track it as a separate boolean,
rather than implicitly tracking this state via the
DocumentState enum, which would not be able to
differentiate between a failed-to-load state and
one of a normal end-of-life, after loading.

Change-Id: I1fc3fb09c31cadf7ebb6b0123e462e78dd0af356
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-01-29 09:22:36 -05:00
Ashod Nakashian
048c468caa wsd: move the markToDestroy flag into DocumentStatus
The markToDestroy flag tracks whether or not the
document is in the process of being unloaded.

Change-Id: I8f2339f75ed6d7c5d318eb1d467d6a9cbc1d61c2
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-01-29 09:22:36 -05:00
Ashod Nakashian
1041346928 wsd: move the closeRequested flag into DocumentStatus
The closeRequested flag tracks owner termination.

Change-Id: I91d7491396cd8db6ca493ba8015a5310c361a2f3
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-01-29 09:22:36 -05:00
Ashod Nakashian
ca0c2a24cc wsd: introduce DocumentState class
DocumentState is responsible for tracking
the state of the document, properly documenting
the different stages of the document lifetime
and encapsulating all the relevant members.

DocumentState is still unused in this commit.

Change-Id: Ic2c8de3a9f2d42c5550c5f4ad5f889040f697890
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-01-29 09:22:36 -05:00
Ashod Nakashian
b4dd9f82a3 wsd: saveToStorageInternal -> uploadToStorageInternal
Change-Id: I0273314d65ebee91092a883bebeb53ab31051194
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-01-26 21:40:59 -05:00
Ashod Nakashian
f14034584f wsd: saveAsToStroage -> uploadAsToStorage
Change-Id: I6edbff6da6b2c29000c0a66524266138aeb88b89
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-01-26 21:40:59 -05:00
Ashod Nakashian
ed1e08662a wsd: saveToStorage -> uploadToStorage
Change-Id: Ie00728ca81d481676ae3a3c44d8d79e80ee29278
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-01-26 21:40:59 -05:00
Ashod Nakashian
a176213750 wsd: lastStorageSaveSuccessful -> lastStorageUploadSuccessful
Change-Id: I71618e388f44ac7b74f295c8af5d0235b395fe87
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-01-26 21:40:59 -05:00
Ashod Nakashian
7a9dc03e46 wsd: DocumentBroker documentation
Change-Id: Iaacb2bb961719e23ef0e955587d70f38ef5ce464
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-01-26 21:40:59 -05:00
Andras Timar
92f44a4695 On-disk cache was removed long ago, clean-up in packaging
Signed-off-by: Andras Timar <andras.timar@collabora.com>
Change-Id: I2eeaed12af6ac8789151b95a9c2a2aa1fd72573b
2021-01-26 21:10:50 +01:00
Tor Lillqvist
b92e13de96 Add an ERROR message from client to server that is logged with LOG_ERR()
Change-Id: If9f3316bb07f68b609c96135227a3e06a1112786
Signed-off-by: Tor Lillqvist <tml@collabora.com>
2021-01-26 15:24:08 +02:00
Tor Lillqvist
e60f972b05 Correct description of handling of the DEBUG message from the client
Change-Id: I19fd4ed92315908af36362368ee2fdbc8558c2ae
Signed-off-by: Tor Lillqvist <tml@collabora.com>
2021-01-26 14:38:46 +02:00
Tor Lillqvist
cb63bb6bed Log the DEBUG messages from client with LOG_DBG and not to stderr
Change-Id: I4fbb05b3b703ebcd1221faafd1ab3e33a1f8f144
Signed-off-by: Tor Lillqvist <tml@collabora.com>
2021-01-25 14:24:43 +02:00
Ashod Nakashian
21b1a54d00 wsd: access _isLoaded member via getter
This prepares for moving this flag into
the upcoming state machine.

Change-Id: I0fa0e26f72a8f4da6813c3be6df5b16a94773591
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-01-23 23:55:43 +00:00
Ashod Nakashian
c12313676e wsd: cosmetic
Change-Id: Ie0df45003a0d4221c4e03ad093229cb703e6bf3a
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-01-23 23:55:43 +00:00
Ashod Nakashian
f038204021 wsd: load -> download
To differentiate between the different stages
of document lifecycle, fetching documents
from the storage is now called 'download',
as opposed to the previous 'load', which is
reserved to loading document in Core.

This is a cosmetic renaming to avoid
confusing usage and intent going forward.

Change-Id: Ib9451e6f73bab19b877a3e6c8fb5b17ba82a06ab
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-01-23 23:55:43 +00:00
Michael Meeks
f4008cd979 clipboard: give a more explicit clustering error earlier.
Change-Id: I3050fd5f9e66174ece03620e956ee394684f369f
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2021-01-15 09:31:22 +00:00
Ashod Nakashian
18446d63cf wsd: test: don't report test timeout outside of tests
Change-Id: I6c5042578a3b718e2305139c0e4ea390b4a43ed3
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-01-13 22:03:29 -05:00
Ashod Nakashian
307900ef9f wsd: misc and cosmetics
Change-Id: I407a20af9297278bdfd06ef3587cdb1d5fff0195
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-01-13 16:24:29 -05:00
Ashod Nakashian
6713c2a8d5 wsd: avoid reading the config entry more than once
This code is executed regularly, at every poll.
The config getter internally throws exceptions,
catches and handles, before returning. While
this isn't performance sensitive, it is noisy
to have such poor-behaving code executed
frequently and regularly.

But the real motivation is the pain this exception
causes when debugging an exception. GDB ends up
catching this rogue exception, which is hardly
useful or helpful.

At any rate, we don't need to get a config entry
more than once, as they can't change during the
lifetime of the process.

Change-Id: Ic69fb94674b74b298987131d44d9baa27e9fa4aa
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-01-13 16:24:29 -05:00
Ashod Nakashian
06c5c90dd5 wsd: test: support SSL in classic tests
Add support for configuring the SSL certificates
when running the test binary as well as setting
up the SSL context.

Also adds the SSL socket headers with proper
compile-time guards for when SSL is disabled.

Change-Id: I99992639a66a64871f8ff8a2b2105279ead63ca1
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-01-13 08:07:06 -05:00
Ashod Nakashian
feac95ab77 wsd: test: shorter poll interval during tests
Technically, the poll interval should be
irrelevant because the tests should wakeupWorld
when they need to break the poll. However, it
turns out that many tests implicitly rely on
the poll interval to be large, and if for
any reason the poll wakes up, the tests either
advance their phase too soon, or assert, causing
random failures and reliability issues.

As the tests should now be more robust (at
least the ones that were non-deterministic
in this way), we can now lower the interval
to catch other cases (either extant or in the
future).

Change-Id: Id0d472e70875db8669bb21c6582b0d5052b19bfb
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-01-13 08:07:06 -05:00
Ashod Nakashian
1fb968ac08 wsd: test: remove redundant wakeupWorld and log the exit status
And introduce passTest and failTest to log a reason
and be more informative when reading logs.

Change-Id: I5090793b802a29135de8ea3783a457e189cc7df3
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-01-13 08:07:06 -05:00
Ashod Nakashian
07cf0d52ef wsd: default UserFriendlyName if missing
While UserFriendlyName is an optional field
in the WOPI protocol, Core needs it for
the Author of the document. When it's blank
the Author is not set and the document fails
to load.

By default we are at least able to load the
document with a sensible placeholder for the
Author. Meanwhile, we log a warning to let
the integrators know of the issue.

Documentation updated.

Change-Id: I4dd2c9d164b4d889f85701a4a27ee8d395bff220
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-01-11 22:07:21 -05:00
Henry Castro
722a152caa wsd: disable setting "SAL_LOG" in "DEBUG" mode
The development environment is necessary analyse
the logs, so disable setting SAL_LOG instead to
add a parameter to already a long list of options

Change-Id: Id8e4a66e1dcb32c636806e47e1d69270af4c53f5
Signed-off-by: Henry Castro <hcastro@collabora.com>
2021-01-11 08:15:39 -04:00
Ashod Nakashian
e8a5b4843c wsd: UploadResult cleanup
A minor cleanup of UploadResult to make tidy
it up a little bit and make it less specific.

Single-argument constructors should be explicit
to avoid unexpected conversion and other surprises.

Change-Id: I57599805743dffddac620f501dc6ca79c2217f89
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-01-10 11:13:27 -05:00
Michael Meeks
234962dc79 Remind admins of the costs of high log levels.
Change-Id: Ie83ec794eb0962b6ecf3f1f7b201390d19fb0958
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2021-01-04 17:39:45 +00:00
Michael Meeks
317dffb817 Optimize copy of jails to hard-linking with new capability.
In some cases we cannot do a fast bind-mount of the files we want
in our jail since we don't have cap_sys_admin for loolmount inside
eg. docker.

Thus we need to fallback to hard-linking, however various security
systems namespace parts of our tree, such that link() fails with
EXDEV even across the (apparently) same file-system.

As such we need to assemble a copy of what we want to hard-link
close to our jails. However, this needs to be owned by root / the
system to avoid having writable files shared between jails. Hence
we need cap_chown in addition to cap_fowner, to get ownership right
and then hard-link.

Change-Id: Iba0ef46ddbc1c03f3dc7177bc1ec1755624135db
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2021-01-04 15:05:36 +00:00
Ashod Nakashian
01138d7ae0 wsd: save errno before invoking any other functions
Most C and Posix API clobber errno. By failing to save
it immediately after invoking an API we risk simply
reporting the result of an arbitrary subsequent API call.

This adds LOG_SYS_ERRNO to take errno explicitly.
This is necessary because sometimes logging is not done
immediately after calling the function for which we
want to report errno. Similarly, log macros that log
errno need to save errno before calling any functions.
This is necessary as the argements might contain calls
that clobber errno.

This also converts some LOG_SYS entries to LOG_ERR
because there can be no relevant errno in that context
(f.e. in a catch clause).

A couple of LOG_ macros have been folded into others,
reducing redundancy.

Finally, both of these log macros append errno to the
log message, so there is little point in ending the
messages with a period.

Change-Id: Iecc656f67115fec78b65cad4e7c17a17623ecf43
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2020-12-29 11:40:17 +00:00
Ashod Nakashian
0072a4080e wsd: test: log timeout better
Change-Id: I3643a2bad8611d1f6402615435295717eb2e93c1
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2020-12-28 12:04:53 -04:00
Ashod Nakashian
693a2e19e3 wsd: SocketPoll::poll accepts chrono duration
Cleans up some of the conversions and implicity
unit in integral types.

Change-Id: I79f35b92f8f631894e55bdb39851b050870fce96
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2020-12-22 11:24:13 -05:00
Ashod Nakashian
13d7d23cbe wsd: use chrono for readability and conversion safety
Change-Id: If5d478605fef0199b331d91310673a460e70d48e
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2020-12-22 11:24:13 -05:00
Ashod Nakashian
693ac2fa52 wsd: logs and const
Change-Id: Id7e4f81ab9709b62eddfa747479ab593a5ad45a2
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2020-12-22 11:24:13 -05:00
Miklos Vajna
f77c8076a7 wsd: fix crash on renderfont when the doc broker has no tile cache
Happens when renderfont is called without first loading a document.

Signed-off-by: Miklos Vajna <vmiklos@collabora.com>
Change-Id: I1152d1f4b3f610364e22c406cda5494672f20aed
2020-12-21 10:23:56 +01:00
Michael Meeks
e5b2d3381f Check ENABLE_DEBUG conditional correctly.
Avoiding some debug code ending up in the product.

Change-Id: If37b2986f134986a33b9dd5b4729b50c56cbc248
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2020-12-10 11:53:02 +00:00
Miklos Vajna
8b0ab31864 WopiStorage: fix uninitialized reads
Change-Id: I603a5205f111b7c8f99baecd6ed482fc9502a6d5
Signed-off-by: Miklos Vajna <vmiklos@collabora.com>
2020-12-10 09:35:25 +01:00
Ashod Nakashian
583c627a66 wsd: avoid single-character strings
Change-Id: I709e8e797bc5e68984823d8c46c590e109d23f18
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2020-12-09 17:19:58 +01:00
Ashod Nakashian
a26d587760 killpoco: use standard data types where possible
Change-Id: I723797be18f6eba1e494639f5698c0d8d9a665bc
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2020-12-09 17:19:58 +01:00
Ashod Nakashian
8298fdb2d6 wsd: cosmetic and consts
Change-Id: Ibb4bb7c527f68786bd6288b407008a3e3a7b2e17
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2020-12-09 17:19:58 +01:00
Ashod Nakashian
a76375234d wsd: remove unsused return values
Saving documents to storage also logs and broadcasts
the result to the users. Return values from these
functions are ignored, and anyway not actionable.

Change-Id: Iaf0dab9c6ac8c593e4df292c71fcb30e8b6d7eeb
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2020-12-09 17:19:58 +01:00
Gabriel Masei
99c9ac1723 wsd: allow different UI mode for different views
Signed-off-by: Gabriel Masei <gabriel.masei@1and1.ro>
Change-Id: Icad28de7a75a6392cafb4fd3385e564616ece499
2020-12-09 15:46:24 +01:00
Ashod Nakashian
ba4e52e7b9 wsd: log: overload chrono duration to simplify logging
Also, makes the logging of units much less error prone.

The overloaded streaming operators are temporary as
they are provided in C++20. The ones here (though
incomplete) are fashioned after the C++20 specs.

Change-Id: Ieb499282ccb6e63fa939ba07bed3e5a4fbef1bd0
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2020-12-08 09:26:41 +00:00
Ashod Nakashian
47630f826e wsd: use steady_clock for measuring time interval
chrono::system_clock can go back in time.
For time interval measurements, where we don't
care about the local time, a monotonic clock
should be used.

This avoids the server uptime jumping around
with daylight saving (or indeed by regular
synchronization with an atomic clock), among
other cases.

Change-Id: I09f9b24c82d19439348a2e66cad9e9de7d755208
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2020-12-08 09:26:41 +00:00
Ashod Nakashian
4cd460e239 wsd: avoid chrono::duration<double>
While chrono supports double as a datatype, it
is opaque and doesn't lend itself to any obvious
units of time (presumably seconds). Using
chrono::milliseconds is much more readable and
also safe when converting from seconds or any
other units. Ultimately, we typically convert
to milliseconds anyway, mostly for logging.
There is but one exception where we convert
in seconds, and now that case is documented.

Change-Id: Ide98f45f2ad8da8225d41ae870bbc4bc09a2a0b5
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2020-12-08 09:26:41 +00:00
Ashod Nakashian
90f79998fb wsd: convert limitLifeSeconds from int to chrono
No advantage in using int when chrono handles
conversion and comparisons transparently for us.

Change-Id: Idc942e7a2557ef979d876f378cf6bb84d3e657cd
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2020-12-08 09:26:41 +00:00
Ashod Nakashian
6574fbd881 wsd: use chrono datatypes as much as possible
std::chrono handles unit conversion handsomely
and where there could be logical errors, the
compiler errors out. We only ever need to
use raw integer or double values to interface
C functions and possibly for IO.

Change-Id: I5c2b43c36bd69840f1a4172e9898666c4d68c567
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2020-12-08 09:26:41 +00:00
Gökay Şatır
8b937cfc14 Rename _channelName to channelName.
Change-Id: Ib0fe1f7cfcff4747cd8c0a520204fcf36410d546
Signed-off-by: Gökay Şatır <gokaysatir@collabora.com>
2020-12-07 17:30:51 -05:00
Gökay Şatır
cdd10066df AdminConsole: Additional changes based on reviews.
Change-Id: I277d9179a84dc34aae9770a07a3a72d35a24a0a6
Signed-off-by: Gökay Şatır <gokaysatir@collabora.com>
2020-12-07 17:30:51 -05:00
Gökay Şatır
b51413c0a0 Admin console: Cosmetic changes and documentation.
Change-Id: I977b5bc56f44c44b8bedf9f9bd710e7050fe67ff
Signed-off-by: Gökay Şatır <gokaysatir@collabora.com>
2020-12-07 17:30:51 -05:00
Gökay Şatır
ace1c23a99 Admin console log levels.
Now chosen log level is propagated to forkit and kits.
Also, admin console users can filter logs according to their channel names on client side.

Change-Id: Ife15a6148ed87533b81e9d63da252c633e74e559
Signed-off-by: Gökay Şatır <gokaysatir@collabora.com>
2020-12-07 17:30:51 -05:00
Michael Meeks
c069f72c4d Socket - re-work disposition to ensure we transfer sockets.
A number of call-sites, eg. clipboard, or admin-ws were
writing to sockets assuming they could return all the data
in a single series of writes, without needing to poll. As
such they failed to addSocketToPoll on the new poll - eg.
the docBroker. Unfortunately this meant that on EAGAIN
writes, the socket would be closed and the last parts
of a message lost.

Browsers would give net::ERR_CONTENT_LENGTH_MISMATCH 200 (OK)

The situation is/was intermittent, so painful to debug.
On under-loaded developer machines, socket buffers are larger,
so this was seldom seen.

The re-factor forces a transfer to another SocketPoll via
the disposition, except for a couple of corner cases.

Change-Id: I2f1b2f99f179c4fda84464c9241fe434fa527725
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2020-12-07 14:32:43 +00:00
Ashod Nakashian
0704514730 wsd: label storage operations as upload and download
Using "load" and "save" in the storage was a poor
choice of verbs, in hindsight, because these very
same verbs are also used to describe the loading
and saving of documents in Core.

It is more appropriate to label the storage
operations as download and upload, respectively,
to avoid any confusion. This is especially useful
because when reporting we have for some time now
been reporting the results of each of these
stages separately, there is no longer reason
to label them the same.

We already used "upload" and "download" in
some of the logs, but not all.

Change-Id: I0fac9130032e2c3c6dfb4d671c31130265091f0d
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2020-11-30 18:46:46 -05:00
Ashod Nakashian
3f2ae319c9 wsd: make session in the upload details weak_ptr
Change-Id: I9e25526333977ada276f59f2e7e33a20dd27f924
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2020-11-30 18:46:46 -05:00
Ashod Nakashian
4162803e64 wsd: extract storage saving reponse handling
This is in preparation for asynchronous uploading.

Change-Id: I5c9977107b415efd24cbd99c29599b86cfe32933
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2020-11-30 18:46:46 -05:00