Commit graph

1933 commits

Author SHA1 Message Date
Ashod Nakashian
1d09484eb8 wsd: check before doing unnecessary work
Change-Id: I4afb812346e3cef4fe9d7d6c39ee72817df067aa
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-03-13 19:34:02 -05:00
Ashod Nakashian
9ce552b5a5 wsd: better logging
Change-Id: I9c6bfcc22b1d80a27a4b4fa7229766d95fc62f9a
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-03-13 19:34:02 -05:00
Ashod Nakashian
5467a7f7ef wsd: simplify and document dumpHex
Change-Id: I636dd6548b0712a72dfc162eb7381e3e7ac18b5a
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-03-13 19:34:02 -05:00
Ashod Nakashian
112b04def5 wsd: move srv instance into LOOLWSD and rename
This makes things more consistent in naming
and in namespace.

Change-Id: I2149c9e0b96eddf9fe2ad1dbc80c932fa7582f84
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-03-13 16:44:09 -05:00
Ashod Nakashian
a99edb5d29 wsd: convert static objects to unique_ptr
This moves WebServerPoll and PrisonerPoll
from the global namespace into LOOLWSD
while converting them to unique_ptr. This
is to manage their lifetimes better and
avoid having out-of-order destruction,
especially with regards to Poco and other
statics that are out of our control.

The PrisonerPoll class had to be renamed
to PrisonPoll because the following is
otherwise invalid:

PrisonerPoll = Util::make_unique<PrisonerPoll>();

Change-Id: Id6c50ebf12ad0f313fea130ffba364beff54f686
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-03-13 16:44:09 -05:00
Ashod Nakashian
3e5be297f5 wsd: avoid static LOOLWSDServer instance
LOOLWSDServer needs to shutdown its
accept_poll SocketPoll in its destructor,
which may be called after Poco's Logging
subsystem has been destroyed.

Instead of managing the lifetime of
accept_poll member of LOOLWSDServer,
it is safer to manage the lifetime
of LOOLWSDServer itself, and destroy
it in the cleanup stage. This makes
sure that its other members, or indeed
LOOLWSDServer itself, can't have any
late-destoryed objects that can cause
trouble.

The stacktrace for this crash:

    terminate called after throwing an instance of 'std::bad_alloc'
      what():  std::bad_alloc

    Program received signal SIGABRT, Aborted.
    __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
    51      ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
    (gdb) bt
    #0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
    #1  0x00007ffff613f801 in __GI_abort () at abort.c:79
    #2  0x00007ffff6d51957 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
    #3  0x00007ffff6d57ae6 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
    #4  0x00007ffff6d56b49 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
    #5  0x00007ffff6d574b8 in __gxx_personality_v0 () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
    #6  0x00007ffff671f573 in ?? () from /lib/x86_64-linux-gnu/libgcc_s.so.1
    #7  0x00007ffff671fad1 in _Unwind_RaiseException () from /lib/x86_64-linux-gnu/libgcc_s.so.1
    #8  0x00007ffff6d57d47 in __cxa_throw () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
    #9  0x00007ffff6d582dc in operator new(unsigned long) () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
    #10 0x00005555556b6127 in void std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct<char*>(char*, char*, std::forward_iterator_tag) [clone .isra.41] ()
    #11 0x0000555555986b94 in Poco::Message::Message(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&, Poco::Message::Priority) ()
    #12 0x000055555585ea49 in SocketPoll::~SocketPoll (this=0x555555d13490 <srv+16>, __in_chrg=<optimized out>) at net/Socket.cpp:145
    #13 0x000055555575d794 in TerminatingPoll::~TerminatingPoll (this=0x555555d13490 <srv+16>, __in_chrg=<optimized out>) at ./net/Socket.hpp:832
    #14 LOOLWSDServer::AcceptPoll::~AcceptPoll (this=0x555555d13490 <srv+16>, __in_chrg=<optimized out>) at wsd/LOOLWSD.cpp:3766
    #15 LOOLWSDServer::~LOOLWSDServer (this=0x555555d13480 <srv>, __in_chrg=<optimized out>) at wsd/LOOLWSD.cpp:3640
    #16 0x00007ffff6142041 in __run_exit_handlers (status=0, listp=0x7ffff64ea718 <__exit_funcs>, run_list_atexit=run_list_atexit@entry=true, run_dtors=run_dtors@entry=true) at exit.c:108
    #17 0x00007ffff614213a in __GI_exit (status=<optimized out>) at exit.c:139
    #18 0x0000555555753658 in LOOLWSD::innerInitialize (this=<optimized out>, self=...) at wsd/LOOLWSD.cpp:1213
    #19 0x0000555555789527 in LOOLWSD::initialize (this=<optimized out>, self=...) at wsd/LOOLWSD.hpp:439
    #20 0x00005555558e1964 in Poco::Util::Application::run() ()
    #21 0x00005555556b6d74 in main (argc=3, argv=0x7fffffffe4f8) at wsd/LOOLWSD.cpp:4286

Change-Id: I28ea6215ce49c752cbb90bc33269ab3b662accf1
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-03-13 16:44:09 -05:00
Ashod Nakashian
42a7607489 wsd: avoid static SocketPoll
The lifetime management of static objects
is extremely unpredictable and depends on
many variables outside of our control or
even reliable reproducibility.

Complex static objects that own threads
and other objects are doubly problematic
because of their dependency and/or
interaction with other objects.

Here we replace the static DelayPoll
instance with one we control its lifetime
in the LOOLWSD main body, such that it
is destroyed properly.

Specifically, DelayPoll's dtor  was
accessing Poco's Logging subsystem out of
order. That is, after Poco had been
destroyed.

Another advantage to this approach is that
we don't even create the DelayPoll at all
if we don't need it. The onus now is on
the user of DelayPoll to make sure they
create a Delay object with a long-enough
lifetime to encompase it use.

For completeness, here is the stacktrace:

    terminate called after throwing an instance of 'std::bad_alloc'
      what():  std::bad_alloc

    Program received signal SIGABRT, Aborted.
    __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
    51      ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
    (gdb) bt
    #0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
    #1  0x00007ffff613f801 in __GI_abort () at abort.c:79
    #2  0x00007ffff6d51957 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
    #3  0x00007ffff6d57ae6 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
    #4  0x00007ffff6d56b49 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
    #5  0x00007ffff6d574b8 in __gxx_personality_v0 () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
    #6  0x00007ffff671f573 in ?? () from /lib/x86_64-linux-gnu/libgcc_s.so.1
    #7  0x00007ffff671fad1 in _Unwind_RaiseException () from /lib/x86_64-linux-gnu/libgcc_s.so.1
    #8  0x00007ffff6d57d47 in __cxa_throw () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
    #9  0x00007ffff6d582dc in operator new(unsigned long) () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
    #10 0x00005555556b5927 in void std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct<char*>(char*, char*, std::forward_iterator_tag) [clone .isra.41] ()
    #11 0x0000555555982a14 in Poco::Message::Message(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&, Poco::Message::Priority) ()
    #12 0x000055555585a909 in SocketPoll::~SocketPoll (this=0x555555d10f60 <DelayPoll>, __in_chrg=<optimized out>) at net/Socket.cpp:145
    #13 0x00007ffff6142041 in __run_exit_handlers (status=0, listp=0x7ffff64ea718 <__exit_funcs>, run_list_atexit=run_list_atexit@entry=true, run_dtors=run_dtors@entry=true) at exit.c:108
    #14 0x00007ffff614213a in __GI_exit (status=<optimized out>) at exit.c:139
    #15 0x0000555555752d78 in LOOLWSD::innerInitialize (this=<optimized out>, self=...) at wsd/LOOLWSD.cpp:1213
    #16 0x0000555555788b07 in LOOLWSD::initialize (this=<optimized out>, self=...) at wsd/LOOLWSD.hpp:432
    #17 0x00005555558dd7e4 in Poco::Util::Application::run() ()
    #18 0x00005555556b6574 in main (argc=2, argv=0x7fffffffe528) at wsd/LOOLWSD.cpp:4276

Change-Id: Ifda55fe869fa6734b9c2490da4497d2551ac21c1
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-03-13 16:44:09 -05:00
Ashod Nakashian
e9cf4681a2 wsd: move TerminatingPoll to Socket.hpp
Makes it accessible to more code.

Change-Id: I73dd1895defe47ae40873b6155203768055206ec
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-03-13 16:44:09 -05:00
Ashod Nakashian
e34b100c03 wsd: capture and log exceptions during un/initialization
Change-Id: I37959fe6f6f1829eb89a81eaf26fac60bbced905
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-03-13 16:44:09 -05:00
Henry Castro
1df271b363 config: add "macro_security_level" item
"Level of Macro security".

Change-Id: I491648f2a89289c7f4455dfad76d73ac8449b965
Signed-off-by: Henry Castro <hcastro@collabora.com>
2021-03-12 08:23:56 -04:00
Henry Castro
50c0fc4492 config: add "enable_macros_execution" item
"Specifies whether the macro execution is enabled in
general. This will disable Basic, Beanshell, Javascript
and Python scripts. If it is set to false, the
macro_security_level is ignored. If it is set to true,
the mentioned entry specified the level of macro security".

Change-Id: I4bc5b690268a93994d17e2b02b7b60b6398646b7
Signed-off-by: Henry Castro <hcastro@collabora.com>
2021-03-12 08:23:56 -04:00
Ashod Nakashian
8dc9c4d8c7 wsd: avoid using invalid DocBroker for clipboard
The clipboard content is handled by the DocBroker,
if it it's available, otherwise, we fallback to the
cached clipboard entries.

When DocBroker has already terminated polling and
is no longer valid, we may end up using it for
the clipboard. In this case, we don't send anything
back, since there is no SocketPoll thread to
process the request or the socket data plumbing.

We avoid this by simply using the fallback (cache)
when we don't have a valid DocBroker.

Change-Id: Idf7f27b453605d173dd8e40d4a5d101f50355468
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-03-12 09:45:20 +00:00
Ashod Nakashian
30fe875419 wsd: better http::Session::create API
Change-Id: I8d89bfc3ed482b775029ef23527e02f379051796
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-03-11 09:15:40 -05:00
Ashod Nakashian
0f9f7629b5 wsd: better logging of socket activity
Especially error reporting is now better.

Change-Id: I032f6e8403660c2ac24be2d80b53b63831ec1066
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-03-11 09:15:40 -05:00
Ashod Nakashian
e3d6baf8c6 wsd: cosmetic
Change-Id: I76e4f5c4b57a6735b2db0e398182431dabbef855
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-03-11 09:15:40 -05:00
Ashod Nakashian
86940a2261 wsd: move ServerSocket creation into ServerSocket class
Change-Id: I25bca69943b69798db2e58af62902111c988a29e
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-03-11 09:15:40 -05:00
merttumer
51705336d7 Added Draw to "Launch one of these" prompt on startup
Signed-off-by: merttumer <mert.tumer@collabora.com>
Change-Id: Idbcd5d1b9063e2ef3b7478906a6a346e236db51d
2021-03-09 12:40:20 +03:00
Ashod Nakashian
af454178ae wsd: avoid unnecessary string copies
Change-Id: I61d50fa2bd1c7e9fc673eb58c9ba85127d6e4883
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-03-08 22:49:53 -05:00
Ashod Nakashian
c740603d14 wsd: simplify dequeue to do more outside the lock
Change-Id: Id27739401e2083e481f120f306418733a3e3563f
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-03-08 22:49:53 -05:00
Ashod Nakashian
3f5e9d5922 wsd: terminate Kit when disconnected while loading
When loading hasn't completed yet, DocBroker can't
simply send a message to Kit that the session is
disconnected, because there would be no UI or
handlers for events if that were the only session.

Of course letting the document load, only to close
it, is also less than helpful to resource consumption.

Here, we recognize this case and simply terminate the
loading by killing the Kit process altogether to
avoid any potential hangs or resource wastage.

Change-Id: Ia72de715cc6238831c244444bb47b417b9b1e1a4
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-03-08 22:17:42 -05:00
Michael Meeks
6307f1ee3d Allow jwt token expiry to be configurable.
Change-Id: Ifd2b078adfa3106765f5b54c0397e04ab66fc804
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2021-03-05 18:33:09 +00:00
Henry Castro
cedf950a52 wsd: add interactive state
Add a new state before load the document,
when Macro Security dialog popup, and avoid
to send the event load timeout.

Change-Id: I5973c5205e90e5447e5478cbab895709a68606f6
Signed-off-by: Henry Castro <hcastro@collabora.com>
2021-03-03 09:18:15 -05:00
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
Ashod Nakashian
0d3a8f77d3 wsd: session is optional to broadcasting doc modification time
The current session is needed only while loading, as it's not
yet in the sessions container. But while saving, broadcasting
to all sessions includes the current session as well, and
we avoid sending duplicate message to the current session.

We also make the broadcast helper a member of DocumentBroker
which simplifies it.

Change-Id: I3bb37cc808d97ba2b772b88474a8c10f7fdff6b7
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2020-11-30 18:46:46 -05:00
Ashod Nakashian
06a45e6db9 wsd: extract wopi upload response handling
This is in preparation for asynchronous uploading.

Change-Id: Ibd0ff0fa8edfc08ad2755a45227891ed40e09d1c
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2020-11-30 18:46:46 -05:00
Ashod Nakashian
70fa07f22e wsd: log helpful messages when we fail to cache files
Change-Id: Ie228edbcea4dfe83b2bd78c34ec2b4423d64f61c
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2020-11-29 19:27:23 -05:00
Ashod Nakashian
0ce2c8f4f4 wsd: reuse file and directory cleanup helpers
Change-Id: I41d681347070245e411e359af57383e323f297ce
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2020-11-29 19:27:23 -05:00
Ashod Nakashian
d4857b603b wsd: cleanup temp incoming directories after use
The temporary directories created for convert-to
and insertfile are used only once and should be
cleaned up to avoid clutter.

We also de-poco the temp directory creation as
it doesn't add value and do a bit of cleanup.

Change-Id: Ie1fd5b4749788ff4407f2cc886d405258f65f97a
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2020-11-23 21:29:34 -05:00
Ashod Nakashian
fad4222a2a wsd: move convert-to docs into the jail
We now download the convert-to files into the
child-root/tmp directory and then move it into
the jail that will convert it. This way ownership
and cleanup become contained within our child-root
and jail subsystems. This reduces the chances of
leaking convert-to files and simplifies the design.

In addition, we avoid an extra file copy and improve
the security of the convert-to API.

Change-Id: I450c24d0d0dc0da447c8072b0701c3b48d07c81b
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2020-11-23 21:29:34 -05:00
Ashod Nakashian
f60753a951 wsd: misc cleanup
Change-Id: Ief6cbc40ef2f7d98b0b76477109332676dab45b2
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2020-11-22 22:26:36 -05:00
mert
5418b4b19b Make AutoSpellChecking option state remembered on first start
Change-Id: I25823025e35ba6f580b03834979fb0bea616bcc1
Signed-off-by: mert <mert.tumer@collabora.com>
2020-11-17 14:55:31 +03:00
Gleb Popov
f7faaad790 Replace all __linux in CPP conditions with __linux__.
Signed-off-by: Gleb Popov <6yearold@gmail.com>
Change-Id: If3e213b1cf1f3c4ab960276fc6edfb71f9416420
2020-11-17 09:21:45 +00:00
Gleb Popov
78904302da Do not call non-standard std:🧵:id constructor.
Change-Id: I916f7ba28bc9a52fa3c601fd695ff8146c1712a1
Signed-off-by: Gleb Popov <6yearold@gmail.com>
2020-11-16 14:02:23 +00:00
Gleb Popov
3ee1ee0b50 AdminModel.cpp: Fix build with libc++.
Change-Id: I46a5d8a44c9d329d52ef355f228be63b8af06947
Signed-off-by: Gleb Popov <6yearold@gmail.com>
2020-11-16 14:02:23 +00:00
Ashod Nakashian
cb4beaca34 wsd: avoid the using keyword and use C++ size_t
size_t in C and in C++ are not necessarily the same
type. The C++ size_t is in the std namespace. Since
we do include many C headers, and indeed some C++
runtime headers do define size_t for backwards
compatibility, it's easy to mix and match the two
types.

Also, 'using std::size_t;' isn't a great practice,
so removed.

This is not exhaustive, just some low-hanging cases.

Change-Id: I85a36b6fd1acd204274b1869de9bcb94c8b3cf13
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2020-11-15 15:41:41 -05:00
Ashod Nakashian
ee0b5203ec wsd: SaveResult final and Result enum class
This makes the code self-documenting and avoids accidental
comparison or assignment of Result variables/values.

Change-Id: I84b8e36aa999191c8704938552b73ddc1c3dc3fc
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2020-11-15 13:50:16 -05:00
Ashod Nakashian
2ddc1afb69 wsd: resuse Stat where possible
This replaces Util::getFileTimestamp with
FileUtil::Stat::modifiedTimepoint() and fixes a potential bug:
getFileTimestamp had only 1 second precision (it simply dropped
sub-second data). This could mean that any modifications to a file
within a second could not be detected.

Minor simplifications done where possible and overly long lines
have been reformatted.

This is a non-functional change (except that file modified-time
now supports microsecond precision).

Change-Id: I3606638a86fc3e00c0ad5cb602bdbb2b4651867b
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2020-11-15 13:50:16 -05:00
Michael Meeks
7a02a8c24e Ensure consistent canonical view id accounting between wsd and kit.
Confusion arose due to separate creation of session, and watermark
property fetch from CheckFileInfo which happens in DocumentBroker::load
which doesn't do a load. This happens in a subsequent 'load url='
message cf. global.js which can then race vs. the session creation.

This causes mis-ordering of another unhelpfully shared Session,
letting the view canonicalization list to get out of sync between
the two processes.

So instead - tell the view it's canonical id. An example of the
problems of trying to share some unclear subset of the Session
class between kit and wsd perhaps.

Change-Id: I63dc30f9a047e3f889fd339b6aaf392b9fef37b9
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2020-11-14 19:56:09 +03:00
Michael Meeks
0d10c2cae8 Set normalized view id for broadcast (ie. slide preview) thumbnails.
Change-Id: Ica5312ae9c7147c8dc969523e28d460348ba2e76
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2020-11-14 19:54:56 +03:00
Miklos Vajna
d7d2bf528e wsd: fix a typo in ClientSession
Signed-off-by: Miklos Vajna <vmiklos@collabora.com>
Change-Id: Ie6d57ec3bc9b70f63b270e50d965ffc14f896969
2020-11-06 09:55:09 +01:00
Miklos Vajna
a4e70f2507 wsd: fix typo: reserverd -> reserved
Signed-off-by: Miklos Vajna <vmiklos@collabora.com>
Change-Id: I736c621723502deceb4f01b005b62c2dfd8c4e37
2020-11-05 12:47:37 +01:00
Ashod Nakashian
8f2ded18da wsd: misc minor cleanup
Change-Id: I39911e6a6b16661173ae69e39d353e517857f282
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2020-11-02 07:56:03 -05:00
Ashod Nakashian
5f07da1298 wsd: privatize public members
Change-Id: Iab57b946cc29814155fccde9b1fbb0c6697b8c26
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2020-10-31 15:07:53 -04:00
Andras Timar
f786244a0b Revert "wsd: temporarily avoid race-conditions when creating documents"
This reverts commit 4410c51b3879c9291b465dea3a59c2e65e94c361.
Reason: this issue should be fixed in the integration that caused the
problem in the first place.

Change-Id: Id41eb66979e4c08dd3b9fd6499e01b4690526541
2020-10-30 11:21:43 +01:00
mert
ffaf53d3ef Make Themeing related CSS vars UI Configurable
Change-Id: If6e4096dc37573ff116f218ceb4ca14135820ff7
Signed-off-by: mert <mert.tumer@collabora.com>
2020-10-30 11:20:00 +01:00
Jan Dageförde
d7656402d3 Migrate code to use generic sendError
Signed-off-by: Jan Dageförde <jan.dagefoerde@googlemail.com>
Change-Id: I0a00ea1220f19479eb021538f67b6bda0c59f7ef
2020-10-28 13:12:27 +03:00
Jan Dageförde
7206231ede Rewrite FileServerRequestHandler::sendError to rely on generic sendError
Signed-off-by: Jan Dageförde <jan.dagefoerde@googlemail.com>
Change-Id: Ib19f95868b61fa43375bf4b19372d9f3f68691dd
2020-10-28 13:12:27 +03:00
Ayhan Yalçınsoy
42c56919b3 Remove Poco/TimeStamp.h left-over part-2
Change-Id: I2d5ce91cab57fb0806f4edb7045207cf32de99bb
Signed-off-by: Ayhan Yalçınsoy <ayhanyalcinsoy@pisilinux.org>
2020-10-27 11:56:51 +03:00
Miklos Vajna
eb5c86a4d3 DocumentBroker::saveToStorage: guard against nullptr _storage
This can happen on a 'savetostorage' which is after a failed load.

Change-Id: Iad26bf6415c772c8646a119b0454c202873d6860
Signed-off-by: Miklos Vajna <vmiklos@collabora.com>
2020-10-26 10:57:23 +01:00
Ashod Nakashian
2785b13a13 wsd: temporarily avoid race-conditions when creating documents
As the comment describes, this is a temporary workaround.
The issue happens when nocaps is enabled, no doubt due
to the timing difference from the more common (and default)
caps-enabled case.

Change-Id: I742d7b9fd63f0babe8e1d45b968e09026d78debc
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2020-10-25 12:20:58 +01:00
Ashod Nakashian
45a065399e wsd: improve wopi upload logging
Change-Id: Iec6c6f2f491266bc2d0b919acc6514c2871a7b7e
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2020-10-25 12:20:58 +01:00
Ashod Nakashian
d0dc93d910 wsd: better file size utility
std::ifstream's tellg() returns -1 on error.
This is handled very poorly and shows up as ULONG_MAX.

Luckily, we have Stat class that does the same
both more safely and more efficiently.

Without opening the file, we now get the necessary
information unambiguously.

Change-Id: I2448bc71e01b0f166a9dd66aa38a88ea97a50cdd
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2020-10-25 12:20:58 +01:00
Ashod Nakashian
11c73db905 wsd: announce the log file location
And set the LOOL_LOGFILE envar only when
we have a path.

Change-Id: Ide5144c7e5aec5ddb9a5a6c32538e9e0a3a6ed0b
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2020-10-25 12:20:58 +01:00
Jan Dageförde
7aae0ddc4f Simplify another Util::getHttpTimeNow() in headers
Change-Id: Ib2718e1dbcff20cd3fa1e6463287ca512f39efc8
2020-10-24 21:29:28 +03:00
Szymon Kłos
7c7fe41f3a Autosave annotations in pdf
Change-Id: Ic4fb2da63e761b78dedf9f67e0612e90e6d4be87
2020-10-23 14:15:50 +02:00
Ashod Nakashian
8190cf7869 wsd: allow some time between retrying saving
Change-Id: I9d923582057467141a3f4d0b260b982464b60511
2020-10-22 14:40:40 +02:00
Ashod Nakashian
c71998438d wsd: document forced storage saving and remove default args
Change-Id: Ic7fde18f07dfe848e219b4ebba30426277ae1287
2020-10-22 14:40:40 +02:00
Ashod Nakashian
eb377ee8d8 wsd: force saving to storage if the last attempt had failed
When uploading to storage fails, we want to retry on next
save. This works when the document is modified between
the last attempt to upload and the current save.

However, when the document isn't modified (f.e. when unloading
the document) we still need to upload the last version of the
document, so we save the document, but that fails as the
document isn't modified. And so we end up not uploading it.
Actually, it gets worse, because we will keep retrying to
save, because there is nothing else to do when we need to
unload the document (say because it has been idle).

This issue was previously not seen because storage failures
are quite rare. However in certain cases NC with complex
access permission controls does fail fairly frequently,
and this edge-case becomes an issue.

This patch enables forced uploading when the last attempt
had failed, regardless of the state of the current save
result.

Change-Id: I951bf19b62f049547913f490d618be20b6191080
2020-10-20 20:50:30 -04:00
Andras Timar
cd23bb7a6c Use Util::getVersionInfo instead of raw LOOLWSD_VERSION_HASH, because the length of the latter is unpredictable
Change-Id: Iab370375f29590d3c34298499ca156cd63dac564
2020-10-20 23:49:54 +02:00
dilaverdemirel
29251ef432 Replaces Poco::DateTimeFormatter to Util::getHttpTimeNow #207
Change-Id: I49b8d4b2acb0d4bcc719325a28537d45700bebdc
2020-10-20 10:04:44 +02:00
Tor Lillqvist
5642e89ccf Add handling of a "DEBUG" message that is just printed to stderr
This is useful in situations where you can't get at console.log()
output from the JavaScript, like when you are using the Nextcloud iOS
app installed from the App Store and want to debug the loleaflet
offered by a Collabora Online server you are using. You can add code
like

    this._map._socket.sendMessage('DEBUG Foo bar=' + bar);

temporarily to the JavaScript and will see those then in the terminal
where you run 'make run.'

Change-Id: I04c78d86faa283e135dbcb86dac0cabd7b6a0724
2020-10-16 12:28:49 +03:00
Aron Budea
4fd9c0617f wsd: resolve host as fallback for allowed WOPI host check
If IP address was set as allowed in storage.wopi, but its host
name was given in WOPI URI, the host was not resolved, and was
not accepted.

Change-Id: I20655cee8b435c9645d5cfdd102bdae9033fc1ab
2020-10-15 14:30:19 +02:00
Yusuf Keten
d977d13976 port to util::make_unique for wsd
Change-Id: I4fcbd350bd40de5044fdf08ba7e082d89c8e525d
2020-10-15 09:20:42 +02:00
Miklos Vajna
ccc52d83f9 wsd: LOK_WHITELIST_LANGUAGES was removed from new enough core
See core.git commit abb6c01519a0318d7165dc9dc5b7d185353f93d6 (replace
usage of whitelist with allowlist, 2020-07-06).

Change-Id: I04646c63df4de14b9aa7dca02a4d5cec10e5eb67
2020-10-14 12:35:07 +02:00
Alan Verdugo
084a295040 Fixing pycodestyle errors
Change-Id: I5e47613d33f87bfddb1bf3f301d6ea0319f2ec3c
2020-10-12 18:31:14 +03:00
Miklos Vajna
f4a87047b6 document broker, tile combined handling: warn only once without tile cache
Follow-up to commit 3a7a6948f1 (document
broker: handle combined tile request without tile cache, 2020-10-05),
requested at <https://github.com/CollaboraOnline/online/pull/242>.

Change-Id: I57124c64dbf3034de8f43584164572eed8d67f86
2020-10-12 10:20:57 +02:00
Andras Timar
977c27b803 extra logging for debugging convert-to failure
Change-Id: I3e38f5f1a53ba2c06323d70d80118267152f43fe
2020-10-11 14:40:37 +02:00
Miklos Vajna
557b14dabd wsd: fix typo, transfering -> transferring
Change-Id: If3729bf278607d33a9c545219cee7db863f0bc7c
2020-10-09 17:28:18 +02:00
Andras Timar
da7543a9e9 typo: its not -> it's not
Change-Id: I27526e14a44b5cb9fe8ad20b8b94bc6b79839ddd
2020-10-09 12:44:14 +02:00
Michael Meeks
abccea8214 Add a X-LOOL-WOPI-ServerId to help cluster debugging to requests.
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Change-Id: Ib964cb84be2cf31257b7ad59c0afb1f18b586afb
2020-10-09 09:30:41 +01:00
Miklos Vajna
3ce20bae68 DocumentBroker::sendRequestedTiles: avoid nullptr _tileCache
Change-Id: I467c7ca451b4f72f4f1205e965be2dd602d6d69d
2020-10-08 11:59:08 +02:00
Miklos Vajna
11897f2db7 Introduce Util::make_unique()
In the old code, if the evaluation first allocates the memory for the
raw pointer, then calls firstLine() and an exception is thrown before
the std::unique_ptr construction, then the memory is leaked. Using
make_unique() has the benefit of avoiding this problem.

Convert only a single usage, so the remaining places can be done as easy
hacks.

Change-Id: Iaf3d8051a8a0627a57fdf1196bde7d5f8612fcff
2020-10-08 09:53:37 +02:00
Ashod Nakashian
08dc42bdaa wsd: log the exception message
Change-Id: Ie9b9cfe38645809c57cec40afbcccc1da87386e1
2020-10-07 08:50:23 -04:00
Yunus Bulut
e982a8665b Remove WebDAVStorage in Storage.hpp #111
Change-Id: Ic95b7354ed3448c0ae77cae338d8eb2bbc01e4e5
2020-10-07 14:55:26 +03:00
Yunus Bulut
35ad7d4265 Destroy WebDAVStorage and <webdav> section #169
Change-Id: I7ce095f722599a37b82e8789baeb6145028dd10d
2020-10-07 14:55:26 +03:00
Andrea Gelmini
9d01540680 Fix typos
Change-Id: I7d487f32ca43e19023760ef3c6bb1683607f93d1
2020-10-07 12:51:08 +02:00
Henry Castro
5a401b1405 wsd: explicit decode URI
is it a POCO bug?
The implicit decode URI is not working
if a file is "test___á.pdf" <=> "test___%C3%A1.pdf"
getPath() returns "test___%C3%A1.pdf"

Change-Id: I79e2ec13cd5500d188a1657e47af03d29b151824
2020-10-06 16:38:44 -04:00
Henry Castro
af70d3c21a wsd: do not encode to send file when the API is "convert-to"
if a file is "test__á.pdf" and if it is encoded "test___%C3%A1.pdf"
then stat("test___%C3%A1.pdf") is false

Change-Id: I28a5ed90c599b7244f0c3a3d2259d83b25be762f
2020-10-05 10:52:29 -04:00
Henry Castro
d541429ec9 wsd: do not encode the URI if the API is "convert-to"
If it is encoded again, the result file does
not exist.

If a file is "test___á.pdf" and encode again
"test___%C3%A1.pdf"

fileExists("test___%C3%A1.pdf") false

Change-Id: I9fa1b8b52ebf0993158eb6ebe383da53921f640a
2020-10-05 10:48:43 -04:00
Miklos Vajna
3a7a6948f1 document broker: handle combined tile request without tile cache
Similar to commit 2b546f72de (document
broker: handle tile request without tile cache, 2020-09-28), though
sadly I don't have a reproducer for this at hand anymore.

Change-Id: I5b3c2c69d5b5719998b3ce261aafb775d5441c2f
2020-10-05 10:24:02 +02:00
Andras Timar
34bc966d68 change product name
Change-Id: Ic34d324c952364442d3f4f9f0758676ab57c8a9a
2020-10-02 14:18:28 +02:00
Miklos Vajna
7c0d0c35fc ClientSession: simplify by using std::any_of()
Change-Id: I92b284883a633ebe3bf47ea8001f8c18692275a1
2020-10-02 09:28:39 +02:00
Andras Timar
0002fdfd6c fix license headers
Change-Id: I8623770b32d278a45357dc7f757fabfadd2b4af7
2020-10-01 11:56:43 +02:00
Mike Kaganski
8a661a1d38 Add favIconUrl to apps in discovery
Change-Id: If164b0c0b302eb8980f51cf4622377e96ba6d5f9
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/99796
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2020-09-29 09:52:21 +02:00
Andras Timar
f9ff9227b7 fix typo in documentation
Change-Id: I8854a217d0bc0b436cb96235e8d213900fb7f991
2020-09-28 13:03:57 +02:00
Jan Holesovsky
4ad8773821 Make various bits of the UI configurable.
This adds the infrastructure to be able to pass the info which elements
like the statusbar / ruler / sidebar are supposed to be shown or hidden
on startup of the editor.

Change-Id: I188264dec6961074444934ff5fd7088e23b170d4
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/103169
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Mert Tumer <mert.tumer@collabora.com>
2020-09-28 11:53:16 +02:00
Miklos Vajna
2b546f72de document broker: handle tile request without tile cache
Change-Id: I5e0006cde07a84e6553db92627fdab943ac51d04
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/103534
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
2020-09-28 10:50:46 +02:00
Miklos Vajna
e080b8af04 ClientSession: clean up copy&paste
dialogevent and formfieldevent has the same handler, do that at a single
place.

Change-Id: I4e0f7b36484f6ef65539616c0fe81a331c9caa98
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/103529
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
2020-09-28 09:33:18 +02:00
Miklos Vajna
92543758a7 wsd: mark these functions as static
So that it's more obvious that they don't even read the state of the
object.

Change-Id: I71d39bf3a20989c8fbf3410c2f1d2a98661c49d5
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/102986
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
2020-09-18 14:05:37 +02:00
Szymon Kłos
87aad0a8bb Decode file name when trying to download file
Simplified download process (ab162b6f9580315700a01c3bc10becd510a2ead4)
introduced a bug. Trying to download file with eg. space in the name
become impossible. This patch decodes the string to fix the issue.

Change-Id: I8e5d98010cf098b889eddcce4ba1ce65367b15d5
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/102874
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
2020-09-16 17:31:59 +02:00
mert
115bb1b652 Fix unable to open password protected documents on mobile
Change-Id: Ifd67cb6f3640784176abfe483f0364c1dfe4b5d9
Signed-off-by: mert <mert.tumer@collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/102388
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Andras Timar <andras.timar@collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/102729
2020-09-15 15:14:40 +02:00
Aron Budea
d876290762 wsd: Don't fail if config item is missing in loolwsd.xml
After upgrading from old versions that didn't include
config.storage.ssl in loolwsd.xml, an exception was thrown
and not caught, and loolwsd failed to start with the following
message: "Not found: storage.ssl.cert_file_path".

Change-Id: Id0ca76632c513c6f5c80797a2c7d20f0173e4b56
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/102250
Tested-by: Jenkins
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
2020-09-09 08:55:55 +02:00
Szymon Kłos
70827c372c Simplify download process
Use hash to identify download and pass that to the client.
This allows us to reduce parameters for download requests.
DocBroker maps download ids to URL in the file system.

Change-Id: I254d4f0ccaf3cff9f038a817c8162510ae228bc5
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/101992
Tested-by: Jenkins
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Tested-by: Michael Meeks <michael.meeks@collabora.com>
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
2020-09-07 15:00:20 +02:00
Mike Kaganski
05dba7ad86 Restructure discovery to have less apps
The apps are not meant to represent MIME types of respective
single file extensions; rather, they represent application/module
that handles several extensions. So this groups extensions under
modules (writer/calc/...). This is required for some WOPI hosts
that whitelist discovery data on per-app base.

The old list of MIME-type-based apps is kept for compatibility
with existing integrations, until they are fixed to use new-style
discovery. Extensions are removed from legacy part, to avoid
duplicating actions.

This also hardcodes content types, to avoid repeated parsing of
discovery.xml.

lint-discovery.py is updated to process new-style information
(ignores legacy part).

Change-Id: Ib8d3518f00510cd0788314d8a9da9a286a52e0ba
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/99637
Tested-by: Jenkins
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2020-08-27 11:29:12 +02:00
Ashod Nakashian
9f5bd85008 wsd: use a shared threadname suffix for each document
The use of a common threadname suffix in the WSD and Kit
processes is intentional. It is designed to help filter
for a single document's logs across both processes.

The thread name has nothing to do with the classes in
the code, nor is it intended to imply any relationship
except with the process and the document in question.

As the comment in this patch explains, the choice of
the suffix is arbitrary and while it may be changed,
it has to be sensible and common between the two threads
to allow for easy grepping.

Historically, there were in fact dedicated threads
within the respective "broker" classes, but this
fact should be safely ignored, since at the log level
we care less about which part of the code generates a
log entry (that info, if needed, is at the end of each
log entry, in the form of filename and line number),
rather we care more about which document it relates to,
which is crucial in investigating production issues.

Logs and code structure are only incidentally related.
Logs are (or at least should be) designed around
the execution structure, not code architecture.

(This reverts 2a16f34812)

Change-Id: Ic6fe2f9425998824774d2644fe4362e75dea6b88
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/101261
Tested-by: Jenkins
Tested-by: Tor Lillqvist <tml@collabora.com>
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Tor Lillqvist <tml@collabora.com>
2020-08-26 17:47:50 +02:00
Samuel Mehrbrodt
8c602e179e Revert "Revert "Don't update modified status after saving to storage fails""
This reverts commit e83e36bd9b.

Unit test failure was fixed

Change-Id: I2176368278725c1711df3b23eef95de6526c68d5
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/100859
Tested-by: Jenkins
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
2020-08-24 14:34:10 +02:00
Michael Meeks
cd98388653 Avoid contention on RSA Digest engine.
Change-Id: If9068371c7ab18083d432f8bc582d85c2f85e80e
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/101081
Tested-by: Jenkins
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
2020-08-20 18:11:12 +02:00
Ashod Nakashian
3cf27ee2c2 wsd: minor cosmetics
Change-Id: I9e67cf870c92197a5c53d45f479d8c9f70818049
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/100833
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Tested-by: Jenkins
Reviewed-by: Ashod Nakashian <ash@collabora.com>
2020-08-17 14:15:37 +02:00
Tamás Zolnai
e83e36bd9b Revert "Don't update modified status after saving to storage fails"
The reverted change breaks unit-wopi-documentconflict test.

This reverts commit 494a5221f5.

Change-Id: I3e89a6e6526e9388e4dc6a1ea8f8d8832e8cb169
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/100678
Tested-by: Tamás Zolnai <tamas.zolnai@collabora.com>
Reviewed-by: Tamás Zolnai <tamas.zolnai@collabora.com>
2020-08-13 17:35:02 +02:00
Samuel Mehrbrodt
494a5221f5 Don't update modified status after saving to storage fails
Otherwise client gets a notification that document is unmodified.
This should not happen, as the document in the storage has not been updated
and so it should be considered as modified until saving to storage succeeds.

Change-Id: I6918f97d96a546ce086f622854f4cbeed48d54ae
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/100162
Tested-by: Jenkins
Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
2020-08-13 09:39:30 +02:00
Ashod Nakashian
c5f9d605e4 wsd: make outgoing connection timeout configurable
The default Poco connection timeout is 60 seconds,
which is probably excessive. The current configurable
default is a more reasonable 30 seconds.

Currently we set this timeout on Storage connections
going out (i.e. WOPI connections).

Change-Id: Ie80a9141ca9bf721addc74baf94e62e0ad72fdd2
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/98913
Tested-by: Jenkins
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Ashod Nakashian <ash@collabora.com>
2020-08-11 20:11:14 +02:00