Commit graph

1458 commits

Author SHA1 Message Date
gokaysatir
9e0594ee2d add pretty name - Android patch
Change-Id: If0de49884954cde26bfbe8ba1dce8844af5b30bf
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/91831
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
2020-04-11 13:43:31 +02:00
Michael Meeks
a7dc2d1467 kill IoUtil - obsolete & unused.
The switch away from LOOLWebSocket and the use of a websocket
for talking to forkit removes the need for the pipe code.

Change-Id: Ifb0c6c88681289e7a1709d9bc3281532935c7be4
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/92033
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
2020-04-10 16:38:25 +02:00
Michael Meeks
28a9c4dc05 Poll - cleanup method naming, and fix merge issues.
This mends several problems from commit
5710c86323.

Change-Id: I1b29f29ca81679608a2692488fa1ef22b2e62dfd
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/92032
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
2020-04-10 13:58:00 +02:00
Michael Meeks
5710c86323 Poll - switch to ppoll for closer to microsecond accuracy.
Change-Id: Ib8a2bb6f60302df8631edadbbb8db626894c457c
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/92000
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
2020-04-10 10:06:23 +02:00
Jan Holesovsky
7d8477f511 Revert "wsd: minimize wait when DocBroker terminates"
With the change that is reverted here, the editing session on Android
returns without proper cleanup which leads to occassional hangs when
the user tries to open a new editing session quickly.

Also, in the iOS app, with the change that is reverted, when closing
the document we never get the LOK_CALLBACK_UNO_COMMAND_RESULT for the
.uno:Save and thus we never get to save it properly from the system's
point of view.

This reverts commit a73590d81f.

Change-Id: Ia77fe2fd9b59d30c343ca1e10f69d5a434bc3628
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/91915
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/91965
Reviewed-by: Tor Lillqvist <tml@collabora.com>
2020-04-09 13:27:29 +02:00
Michael Meeks
668007544b Proof: generate our own key, and verify our own signatures.
Change-Id: If805c89a3b6618d6e34e7421b20077c4f0a48cb3
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/91940
Tested-by: Michael Meeks <michael.meeks@collabora.com>
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
2020-04-08 23:20:55 +02:00
Michael Meeks
d7f55b4bda Proof: verify existing RSA proof.
Change-Id: I26163d0cad3437300bb255b0d7760af6393ceffa
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/91939
Tested-by: Michael Meeks <michael.meeks@collabora.com>
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
2020-04-08 23:20:35 +02:00
Michael Meeks
f4f7b08d44 Proof: implement CAPI blob test.
Change-Id: Ifa4ddc3c5fa375606eedd932af029e4b30a740de
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/91936
Tested-by: Michael Meeks <michael.meeks@collabora.com>
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
2020-04-08 22:19:51 +02:00
Gabriel Masei
0ac330f599 Add segmentation fault metric for Kit processes
Change-Id: Ifb0de004274213ef512f601e4419f98f456c7288
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/91857
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
2020-04-08 15:06:39 +02:00
Miklos Vajna
e087a0079c ForKitProcWSHandler: remove std::enable_shared_from_this inheritance
This was added in commit 70af76e28c
(Replaced pipe with websocket based on Unix socket in communication with
ForKit, 2020-04-02), but it seems to me that the shared_from_this()
member function (which is now available, due to ineritance) is not
actually called anywhere, so this is not necessary.

Additionally, Debian 8 / gcc-4.9 has problems compiling this:

	In file included from /usr/include/c++/4.9/bits/shared_ptr.h:52:0,
			 from /usr/include/c++/4.9/memory:82,
			 from wsd/AdminModel.hpp:13,
			 from wsd/AdminModel.cpp:12:
	/usr/include/c++/4.9/bits/shared_ptr_base.h: In instantiation of ‘std::__shared_ptr<_Tp, _Lp>::__shared_ptr(std::_Sp_make_shared_tag, const _Alloc&, _Args&& ...) [with _Alloc = std::allocator<ForKitProcWSHandler>; _Args = {std::shared_ptr<StreamSocket>&, const Poco::Net::HTTPRequest&}; _Tp = ForKitProcWSHandler; __gnu_cxx::_Lock_policy _Lp = (__gnu_cxx::_Lock_policy)2u]’:
	/usr/include/c++/4.9/bits/shared_ptr.h:316:64:   required from ‘std::shared_ptr<_Tp>::shared_ptr(std::_Sp_make_shared_tag, const _Alloc&, _Args&& ...) [with _Alloc = std::allocator<ForKitProcWSHandler>; _Args = {std::shared_ptr<StreamSocket>&, const Poco::Net::HTTPRequest&}; _Tp = ForKitProcWSHandler]’
	/usr/include/c++/4.9/bits/shared_ptr.h:588:39:   required from ‘std::shared_ptr<_Tp1> std::allocate_shared(const _Alloc&, _Args&& ...) [with _Tp = ForKitProcWSHandler; _Alloc = std::allocator<ForKitProcWSHandler>; _Args = {std::shared_ptr<StreamSocket>&, const Poco::Net::HTTPRequest&}]’
	/usr/include/c++/4.9/bits/shared_ptr.h:604:42:   required from ‘std::shared_ptr<_Tp1> std::make_shared(_Args&& ...) [with _Tp = ForKitProcWSHandler; _Args = {std::shared_ptr<StreamSocket>&, const Poco::Net::HTTPRequest&}]’
	./wsd/LOOLWSD.hpp:201:97:   required from here
	/usr/include/c++/4.9/bits/shared_ptr_base.h:1096:64: error: call of overloaded ‘__enable_shared_from_this_helper(std::__shared_count<>&, ForKitProcWSHandler*&, ForKitProcWSHandler*&)’ is ambiguous

So just remove it till that inheritance is needed.

Change-Id: I74d38b90bcf06d4490feed31783c098ed831f1ee
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/91879
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Reviewed-by: Gabriel Masei <gabriel.masei@1and1.ro>
2020-04-08 13:52:35 +02:00
Tor Lillqvist
5270284701 Further re-work of document saving in the iOS app
Now, finally, I think it works as it should, knock on wood. After an
auto-save (or explicit save by tapping the button), the edited
document does show up with its auto-saved contents if you open it from
iCloud Drive or Nextcloud while it is still open in the iOS app.

What I was missing was that the document hadn't actually been saved by
the core (to the temporary copy) until we get the
LOK_CALLBACK_UNO_COMMAND_RESULT for the .uno:Save. We must call the
-[UIDocumentsaveToURL:forSaveOperation:completionHandler:] only upon
receiving that callback.

Change-Id: I10486f3bc587c871ee2644a0c097493f33baf420
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/91880
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Tor Lillqvist <tml@collabora.com>
2020-04-08 12:19:38 +02:00
Michael Meeks
a2b9fc474a Proof: re-factor - publicise some internals to make testing easier.
Also add dummy, run-every-build test to validate wopi like proofs.

Change-Id: Ic2dc647a8d61693ae87b6523aaa30632979fd5d6
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/91854
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
2020-04-08 10:58:49 +02:00
Miklos Vajna
60908ed88c admin: only kill document pids
unit-admin is currently disabled, so... how to reproduce:

Edit loleaflet/admin/src/AdminSocketOverview.js to try to kill e.g. pid
0.

Expected result:

[ admin ] WRN  Invalid PID to kill (not a document pid)| wsd/Admin.cpp:168

Change-Id: I06dda68b38096689c1b9327cefba2cbfc96805f8
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/91868
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
2020-04-08 10:23:59 +02:00
Tor Lillqvist
0930286e2d Fix problems after my 293f4913d2
It is enough to call the -[UIDocument
saveToURL:forSaveOperation:completionHandler:] only in
DocumentBroker::sendUnoSave(). And on the other hand, in
-[DocumentViewController bye] we can't want for the
LOOLWSD::lokit_main_mutex as the main queue is needed for parts of
what the saveToURL does.

Also, use a separate copy of the document as the file that is actually
edited by LO core. This matches what the Android app does. I think it
is useful to do this in order to avoid some hangs that I noticed. They
probably were caused by both LO core and the system frameworks
occasionally accessing the same document file at the same time.

Change-Id: Idb65be23a7cb6ad1288fbbd23c7471e0fb8d52f4
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/91851
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Tor Lillqvist <tml@collabora.com>
2020-04-08 00:01:30 +02:00
Gabriel Masei
70af76e28c Replaced pipe with websocket based on Unix socket in communication with ForKit
Change-Id: I80f1a4e84ca6820503966a8ee5d9958a150eac14
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/91585
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
2020-04-07 15:04:47 +02:00
Miklos Vajna
946fa38a22 admin console: fix handling of out of range kill parameter
Catch that, similar to when handling an invalid argument.

Change-Id: I7405355f0b962673069dbd33dbab8c9e3042c4bf
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/91794
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
2020-04-07 09:35:54 +02:00
Tor Lillqvist
293f4913d2 On iOS, make the document show up as modified also after auto or explicit save
It is not enough to just have the core code rewrite the document file.
We need to do the same dance as in -[DocumentViewController bye].

I wonder if it would be cleaner to copy the document file to some
temporary location when opening it, and use only that copy in Online
and core, and then after core has saved it (either for an auto-save,
an explicit save, or when closing the document) do the -[UIDocument
saveToURL:forSaveOperation:completionHandler] thing?

Change-Id: I78fec08a90424780dc6e794347a0acf2c64e1dab
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/91741
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Tor Lillqvist <tml@collabora.com>
2020-04-06 20:52:47 +02:00
Miklos Vajna
42c8417e34 admin fuzzer: improve this further, so it can find interesting paths faster
1) Don't actually kill anything with the kill command, otherwise kill(0,
SIGKILL) will kill the fuzzer itself.

2) Don't require a valid signature when authenticating with JWT, since
the private key is generated on each process startup.

3) Log when the JWT would be invalid due to an expired timestamp.

Change-Id: I0da285617e27910329c0e7ed80a6d02e86344ccf
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/91737
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
2020-04-06 12:03:39 +02:00
Miklos Vajna
fe1399fab5 JWTAuth::verify: avoid working with RTTI without a reason
The purpose of the convert() function (without arguments) is to either
return fast in case the type of the JSON value and the argument match or
do a conversion.

We generate this JSON, so we know the JSON type will be always a string
and the argument type will be a size_t, so use the variant that always
does a conversion.

(Additional benefit is that I seem to hit a false alarm with
admin_fuzzer in the old code and it goes away with this change.)

Change-Id: I40851ab3ddd46fb1515ea9f0c9f40d9ec2006de7
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/91652
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
2020-04-03 19:20:01 +02:00
Tor Lillqvist
07a3dcf651 Mention that parameters in some messages are actually positional
Change-Id: Ifeb09f96ab43784d428f6ad1cbcdbfc27e6595c9
2020-04-03 14:54:35 +03:00
Miklos Vajna
fc88a872c2 admin console: log when JWTAuth::verify() doesn't have enough tokens
This is no longer a huge problem, but it's still a good idea to return
early in that case.

Found with the recently added admin_fuzzer, when I locally disabled the
StringVector safety checks for test purposes.

(If you view the diff with -U30, then you see that we access tokens[2]
later, so if size is < 3, we should give up.)

Change-Id: I46fc531fb042cc1485a17a9e994ad37e9ff0cd80
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/91587
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
2020-04-03 09:18:18 +02:00
Miklos Vajna
a4e0a00bfe Add an initial libfuzzer based fuzzer for the admin console
Run the actual fuzzer like this:

./admin_fuzzer -max_len=16384 fuzzer/admin-data/

Change-Id: I5891df8033ff1837afce86775ee62447587f2f20
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/91504
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
2020-04-02 12:11:24 +02:00
gokaysatir
a486bad79b tdf#130568 - Add server os pretty name to help->about
Change-Id: Id6de533dfb8e34a05d348f8ae701bf3c524c9b95
2020-04-01 20:45:32 +01:00
Jan Holesovsky
120000347e Log every error we send to the JS.
So that it is easy to find it in the log.

Change-Id: I1b367db9e97d7215c46e824998e99048531acb07
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/91413
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
2020-03-31 20:15:25 +02:00
Michael Meeks
a73590d81f wsd: minimize wait when DocBroker terminates
Add checking up the stack to detect when we have clean queues
and buffers so we can exit fast.

Change-Id: I82c3843f816bbe869094c21f070774e6d034ac65
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/90358
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
2020-03-26 12:03:06 +01:00
Michael Meeks
eb8a9f9b83 Use random sub-jail paths when unit testing.
Potentially cleaning up jails used by other WSD's breaks parallel
unit testing quite badly.

Change-Id: I159b87cc36648beb40eea0e363f924eefdf6ebca
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/90942
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
2020-03-24 11:13:46 +01:00
Miklos Vajna
d26aa30cab Fix --with-support-public-key=... build
Change-Id: I4a1ecc16d7b862dae61c80d98d07c0e105c13819
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/90829
Tested-by: Andras Timar <andras.timar@collabora.com>
Reviewed-by: Andras Timar <andras.timar@collabora.com>
2020-03-20 22:05:14 +01:00
Miklos Vajna
f32c1f2feb wsd: improve lifecycle in ClientSession::onDisconnect()
Once unit-bad-doc-load completes (with success in exitTest()), sometimes
we have an error during shutdown.

The reason seems to be that ClientSession::onDisconnect() calls
DocumentBroker::removeSession(), which may delete the ClientSession, so
by time time isCloseFrame() is called, we have trouble.

Fix the problem by keeping a reference to self before calling
removeSession().

Change-Id: If5b409822563ba5a45d453329516671065d8f054
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/90681
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
2020-03-18 15:17:02 +01:00
Michael Meeks
4d9d769d95 Expose disk space and session checks via LOOLWSD class.
Change-Id: I7b135d325147694cc33946b34a29ab96b2e2b918
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/90577
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
2020-03-16 19:36:42 +01:00
Miklos Vajna
cd42700054 Rework the somewhat odd sendTextMessage() interface
It took both an std::string and a length. Take a char* and a length
instead.

Change-Id: Id37dfa67fe1baae09b69819680848a0a8a1d80ed
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/90552
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
2020-03-16 11:55:19 +01:00
Tor Lillqvist
d4e0835043 Make closing the document work again in the iOS (and Android?) app
But opening a second document now hangs.

Sigh, the plumbing in the mobile apps is so extremely fragile. But
that is to be expected when turning a multi-process structure (where
one class of processes exit as soon as they have done their job) into
a single process running forever.

Change-Id: I0fdb751f44e16efb42843189969e049bf14816f0
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/90443
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Tor Lillqvist <tml@collabora.com>
2020-03-13 00:28:19 +01:00
Tor Lillqvist
47d22d538a Fix build for MOBILEAPP
Change-Id: I0903f13438493d167c263020d923536b4de71e5d
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/90385
Tested-by: Tor Lillqvist <tml@collabora.com>
Reviewed-by: Tor Lillqvist <tml@collabora.com>
2020-03-12 17:08:19 +01:00
Ashod Nakashian
a0cdafca41 wsd: some logging improvements
Change-Id: Icf4c4845e10f44fe1518e58ea598c2d1053b40c1
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/90357
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
2020-03-12 13:23:57 +01:00
Michael Meeks
4e5f6bf9d2 re-factor: use protocol handler for document broker creation.
Change-Id: If89610c9baebc92bb49b612075118f705cefeeea
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/90343
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
2020-03-11 20:10:17 +01:00
Michael Meeks
e924625cc1 re-factor: Socket / WebSocketHandler.
Essentially we want to be able to separate low-level socket code
for eg. TCP vs. UDS, from Protocol handling: eg. WebSocketHandler
and client sessions themselves which handle and send messages
which now implement the simple MessageHandlerInterface.

Some helpful renaming too:

s/SocketHandlerInterface/ProtocolHandlerInterface/

Change-Id: I58092b5e0b5792fda47498fb2c875851eada461d
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/90138
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
2020-03-11 16:48:03 +01:00
Tomaž Vajngerl
c4fcb3eeb5 Fix build on android
Change-Id: I4cadfa38ffcaa774f6edf41a9172f1b4b5bbe896
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/90203
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
2020-03-09 11:31:30 +01:00
Miklos Vajna
a7d3efdd4e Introduce StringVector::equals()
Allows comparing tokens with C strings without a heap allocation. Do the
same when comparing two tokens from two different StringVectors.

And use it at all places where operator ==() has an argument, which is a
StringVector::operator []() result.

Change-Id: Id36eff96767ab99b235ecbd12fb14446a3efa869
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/90201
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
2020-03-09 09:46:33 +01:00
Michael Meeks
7eea5b85ab Remove unused filterHandleRequest unit test hook.
Change-Id: Id1ff6005e28bf02eb9cad3c1609f9a8079640689
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/90155
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
2020-03-07 14:26:42 +01:00
Henry Castro
7ba4e9dd23 wsd: debug: run the server with a single "lokit" process
Sometimes it is very useful to have one "lokit" process,
to focus on a 100% reproducible bug, and not worry
that server pre-spawn several processes.

Change-Id: I414a8145b53a0601a282cba9c245833f5d07f404
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/89999
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Henry Castro <hcastro@collabora.com>
2020-03-06 13:37:53 +01:00
Miklos Vajna
797c996c56 Fix -Werror,-Woverloaded-virtual warnings
Probably these were just not adapted by accident in commit
f70e627795 (WebSocket - simplify
handleMessage for now., 2020-03-05).

Change-Id: I578d95d938c0c466e9547dcda3d2b297dc347a34
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/90076
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
2020-03-06 11:31:43 +01:00
Michael Meeks
f70e627795 WebSocket - simplify handleMessage for now.
WebSocketHandler handles this complexity for us now, and for the
forseeable future. Simplify to prepare for larger re-factor.

Change-Id: I73b919885adc358cb6502a13492cdac85c34459c
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/90059
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
2020-03-05 20:28:48 +01:00
Michael Meeks
17cbb2b7b9 Session: simplify shutdown and privatize some pieces.
Change-Id: Ifbb40f6a88590bd87dbfada73fa26eb0b61705fb
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/90058
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
2020-03-05 20:22:32 +01:00
Michael Meeks
da944760a6 re-factor: move createNewSession into DocumentBroker.
Change-Id: I78f07a61fd79dfdd1c0d0ef21cf19218beec46ee
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/90025
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
2020-03-05 17:10:36 +01:00
Jan Holesovsky
48283deca5 Just try to catch everything in the getSafeConfig().
Poco::Exception is derived from std::exception, yet there were cases
where it was not caught - no idea why:

I/DEBUG   (24700):     #00 pc 000371e4  /system/lib/libc.so (tgkill+12)
I/DEBUG   (24700):     #01 pc 00013fb9  /system/lib/libc.so (pthread_kill+52)
I/DEBUG   (24700):     #02 pc 00014bd7  /system/lib/libc.so (raise+10)
I/DEBUG   (24700):     #03 pc 00011519  /system/lib/libc.so (__libc_android_abort+36)
I/DEBUG   (24700):     #04 pc 0000fca4  /system/lib/libc.so (abort+4)
I/DEBUG   (24700):     #05 pc 000126e9  /system/lib/libc.so (__libc_fatal+16)
I/DEBUG   (24700):     #06 pc 0001159d  /system/lib/libc.so (__assert2+20)
I/DEBUG   (24700):     #07 pc 00064fed  /data/app/com.collabora.libreoffice-1/lib/arm/libc++_shared.so
I/DEBUG   (24700):     #08 pc 00065183  /data/app/com.collabora.libreoffice-1/lib/arm/libc++_shared.so
I/DEBUG   (24700):     #09 pc 0006cb79  /data/app/com.collabora.libreoffice-1/lib/arm/libc++_shared.so
I/DEBUG   (24700):     #10 pc 0006c527  /data/app/com.collabora.libreoffice-1/lib/arm/libc++_shared.so
I/DEBUG   (24700):     #11 pc 0006c4ef  /data/app/com.collabora.libreoffice-1/lib/arm/libc++_shared.so (__cxa_throw+74)
I/DEBUG   (24700):     #12 pc 001be25c  /data/app/com.collabora.libreoffice-1/lib/arm/libandroidapp.so (_ZNK4Poco4Util21AbstractConfiguration7getBoolERKNSt6__ndk112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEE+208)
I/DEBUG   (24700):     #13 pc 001847fd  /data/app/com.collabora.libreoffice-1/lib/arm/libandroidapp.so (_ZN7LOOLWSD17ConfigValueGetterclERb+12)
I/DEBUG   (24700):     #14 pc 001847c3  /data/app/com.collabora.libreoffice-1/lib/arm/libandroidapp.so (_ZN7LOOLWSD13getSafeConfigIbEEbRN4Poco4Util20LayeredConfigurationERKNSt6__ndk112basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEERT_+22)
I/DEBUG   (24700):     #15 pc 00184747  /data/app/com.collabora.libreoffice-1/lib/arm/libandroidapp.so (_ZN7LOOLWSD14getConfigValueIbEET_RN4Poco4Util20LayeredConfigurationERKNSt6__ndk112basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEES1_+38)
I/DEBUG   (24700):     #16 pc 0018748b  /data/app/com.collabora.libreoffice-1/lib/arm/libandroidapp.so (_ZN7LOOLWSD10initializeERN4Poco4Util11ApplicationE+1334)
I/DEBUG   (24700):     #17 pc 001c7274  /data/app/com.collabora.libreoffice-1/lib/arm/libandroidapp.so (_ZN4Poco4Util11Application3runEv+28)
I/DEBUG   (24700):     #18 pc 00134fbf  /data/app/com.collabora.libreoffice-1/lib/arm/libandroidapp.so
I/DEBUG   (24700):     #19 pc 00134df7  /data/app/com.collabora.libreoffice-1/lib/arm/libandroidapp.so
I/DEBUG   (24700):     #20 pc 00134dc5  /data/app/com.collabora.libreoffice-1/lib/arm/libandroidapp.so
I/DEBUG   (24700):     #21 pc 000137a3  /system/lib/libc.so (_ZL15__pthread_startPv+30)
I/DEBUG   (24700):     #22 pc 00011883  /system/lib/libc.so (__start_thread+6)

Change-Id: Ica643f88d572b239b9a124e31cb4552f86439bf6
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/89715
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
2020-02-29 11:02:52 +01:00
Jan Holesovsky
09005eb1cf android: Don't even try to read these values, seem to trigger an exception.
All the code that is using them is compiled out on Android anyway.

Change-Id: Ica349135202211ecdcb095bb82aa677f2dee19ba
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/89714
Tested-by: Michael Meeks <michael.meeks@collabora.com>
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
2020-02-29 11:01:00 +01:00
Miklos Vajna
547f9ea731 Rework StringVector to have a single underlying string
This is meant to reduce lots of small allocations and instead have
pointers into the single string for the various tokens instead.

This has a few requirements, though:

1) It's no longer OK to modify the tokens, changing their length would
invalidate the start/length of other tokens. Rework
DocumentBroker::load() to avoid such mutation.

2) The iterators no longer expose zero-terminated strings, so
Poco::cat() doesn't work anymore: add an own cat() instead and use that
in e.g. ChildSession. The own cat() has the benefit that it won't read
past the end of the array if the begin index is out of bounds to add
more safety.

(This nicely works towards killing Poco usage in general.)

3) If zero-terminated strings for all individual tokens is needed, a
copy has to be made, as done in spawnProcess().

(For all of these requirements, the build fails if there are problems.)

Change-Id: Iea40e4400e630b2d669f5c72aea85cb40edf9a2c
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/89711
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
2020-02-28 18:31:37 +01:00
Miklos Vajna
b8bd1990aa Rework LOOLProtocol::tokenize() to return a StringVector object
The bulk of this commit just changes std::vector<std::string> to
StringVector when we deal with tokens from a websocket message.

The less boring part of it is the new StringVector class, which is a
wrapper around std::vector<std::string>, and provides the same API,
except that operator[] returns a string, not a string&, and this allows
returning an empty string in case that prevents reading past the end of
the underlying array.

This means in case client code forgets to check size() before invoking
operator[], we don't crash. (See the ~3 previous commits which fixed
such crashes.)

Later the ctor could be changed to take a single underlying string to
avoid lots of tiny allocations, that's not yet done in this commit.

Change-Id: I8a6082143a8ac0b65824f574b32104d7889c184f
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/89687
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
2020-02-28 16:07:56 +01:00
Miklos Vajna
d129979822 wsd: fix crash with read-only documents + uno command without param
==15956==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x0000007cd2f7 bp 0x7ffe96c7cd70 sp 0x7ffe96c7c4e8 T0)
...
    #7 0x11a9d31 in ClientSession::filterMessage(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const wsd/ClientSession.cpp:977:27
    #8 0x11925d6 in ClientSession::_handleInput(char const*, int) wsd/ClientSession.cpp:741:14
    #9 0x19395d0 in Session::handleMessage(bool, WSOpCode, std::vector<char, std::allocator<char> >&) common/Session.cpp:230:13

This seems to be a recurring pattern, I'll consider reworking
LOOLProtocol::tokenize() in a follow-up commit to have a return value
that is safer than std::vector<std::string>.

Change-Id: I0e71214a55af2e71e4787cb0dba0ddf7825bf9d9
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/89637
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
2020-02-27 17:59:59 +01:00
nienzu
51c840249e tdf#130798 admin: Use original data to create network traffic graph
Instead of using the data of rolling average, using original data would
reflect the real network traffic.

Change-Id: I3f5a277b6ee8e7d760f5623eb4aae9f6c999e10f
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/89494
Tested-by: Michael Meeks <michael.meeks@collabora.com>
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
2020-02-26 10:53:25 +01:00
Ashod Nakashian
18ab1ccaed wsd: cleanly shutdown when unittest times out
Termination flag is a very harsh way of exiting.
It works in most cases, but not when we have a
modified document. What happens is the following:

Unit-test flags for termination.
During session cleanup we have to save the modified doc.
Because save is in progress we don't 'disconnect' the view.
This leaves the view in loaded state until saving is done.
But because of the termination flag we don't wait for saving.
DocBroker sends 'exit' to child to forcefully exit.
This causes at least one assertion due to active LOKWindows (Sidebar).

Instead of the above, we flag for graceful shutdown from unittests,
and after we wait to cleanup all DocBrokers, we flag for termination.
This way, we get clean shutdown and all assertions/validations
pass, while we guarantee never to deadlock the unittests,
in case we end up waiting forever for shutdown to complete.

Change-Id: I7fc34137ea373e329795b1ed0090261c085e955a
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/89308
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
2020-02-23 21:48:07 +01:00
Ashod Nakashian
ddd3108767 wsd: logging improvements and formatting
Some multi-line log entries were missing
because we didn't flush.

Change-Id: Iabf9e6f1ffee707ff51b831a12c7990f35bb7913
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/89196
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
2020-02-23 21:46:55 +01:00
Andras Timar
01b476e7c0 add missing #include <list>
on a fresh openSUSE Leap 15.1 I got errors without this:
wsd/AdminModel.hpp:346:10: error: ‘list’ in namespace ‘std’ does not name a template type
     std::list<unsigned> _memStats;
          ^~~~
etc.

Change-Id: I19c42bd48bbcc0787a3398d1882c974ebf5bdf81
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/89298
Tested-by: Andras Timar <andras.timar@collabora.com>
Reviewed-by: Andras Timar <andras.timar@collabora.com>
2020-02-23 14:24:30 +01:00
Miklos Vajna
aefc65465b wsd: fix crash when downloadas has not enough parameters
==11898==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x0000007c4f87 bp 0x7fffe45dfe90 sp 0x7fffe45df608 T0)
==11898==The signal is caused by a READ memory access.
==11898==Hint: address points to the zero page.
    #0 0x7c4f86 in AddressIsPoisoned lode/packages/llvm-472c6ef8b0f53061b049039f9775ab127beafbe4.src/compiler-rt/lib/asan/asan_mapping.h:397
    #1 0x7c4f86 in __asan::QuickCheckForUnpoisonedRegion(unsigned long, unsigned long) lode/packages/llvm-472c6ef8b0f53061b049039f9775ab127beafbe4.src/compiler-rt/lib/asan/asan_interceptors_memintrinsics.h:31
    #2 0x816436 in MemcmpInterceptorCommon(void*, int (*)(void const*, void const*, unsigned long), void const*, void const*, unsigned long) lode/packages/llvm-472c6ef8b0f53061b049039f9775ab127beafbe4.src/compiler-rt/lib/asan/../sanitizer_common/sanitizer_common_interceptors.inc:834
    #3 0x816d38 in memcmp lode/packages/llvm-472c6ef8b0f53061b049039f9775ab127beafbe4.src/compiler-rt/lib/asan/../sanitizer_common/sanitizer_common_interceptors.inc:866
    #4 0x7f1964437595 in std::char_traits<char>::compare(char const*, char const*, unsigned long) lode/packages/gccbuild/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/char_traits.h:310
    #5 0x7f1964437595 in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::compare(unsigned long, unsigned long, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const lode/packages/gccbuild/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/basic_string.tcc:1391
    #6 0x18e206d in LOOLProtocol::getTokenString(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&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&) common/Protocol.cpp:141:19
    #7 0x117cc0a in ClientSession::filterMessage(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const wsd/ClientSession.cpp:940:13
    #8 0x116b832 in ClientSession::_handleInput(char const*, int) wsd/ClientSession.cpp:741:14
    #9 0x18f70d0 in Session::handleMessage(bool, WSOpCode, std::vector<char, std::allocator<char> >&) common/Session.cpp:230:13

Change-Id: I0c7da6c02ac62bf0bc99557517fc7c517917046c
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/89229
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
2020-02-22 12:18:34 +01:00
Miklos Vajna
57a35bb96c Add an initial libfuzzer based fuzzer
- target ClientSession::_handleInput(), since crashing there would bring
  down the whole loolwsd (not just a kit process), and it deals with
  input from untrusted users (browsers)

- add a --enable-fuzzers configure switch to build with
  -fsanitize=fuzzer (compared to normal sanitizers build, this is the only
  special flag needed)

- configuring other sanitizers is not done automatically, either use
  --with-sanitizer=... or the environment variables from LODE's sanitizer
  config

- run the actual fuzzer like this:

  ./clientsession_fuzzer -max_len=16384 fuzzer/data/

- note that at least openSUSE Leap 15.1 sadly ships with a clang with
  libfuzzer static libs removed from the package, so you need a
  self-built clang to run the fuzzer (either manual build or one from
  LODE)

- <https://chromium.googlesource.com/chromium/src/testing/libfuzzer/+/refs/heads/master/efficient_fuzzing.md#execution-speed>
  suggests that "You should aim for at least 1,000 exec/s from your fuzz
  target locally" (i.e. one run should not take more than 1 ms), so try
  this minimal approach first. The alternative would be to start from the
  existing loolwsd_fuzzer binary, then step by step cut it down to not
  fork(), not do any network traffic, etc -- till it's fast enough that
  the fuzzer can find interesting input

- the various configurations start to be really complex (the matrix is
  just very large), so try to use Util::isFuzzing() for fuzzer-specific
  changes (this is what core.git does as well), and only resort to ifdefs
  for the Util::isFuzzing() itself

Change-Id: I72dc1193b34c93eacb5d8e39cef42387d42bd72f
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/89226
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
2020-02-22 12:18:22 +01:00
Aron Budea
dff1d32624 Default redlining_as_comments config to false
For better performance, many comment boxes reduce performance in
browser.

Change-Id: If041c3d147ee7512d90f41a4a1bfe7a1ff8646a9
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/89065
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Tested-by: Michael Meeks <michael.meeks@collabora.com>
2020-02-20 04:59:07 +01:00
Mike Kaganski
098c0a5752 Check that absolute URI is passed to addWopiProof
Change-Id: I28385f330064645dc2c30a3c3180df2a297b2e53
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/89021
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2020-02-19 15:35:26 +01:00
Mike Kaganski
6eda59123a Proof key: make sure public exponent is exactly 4 bytes
It seems that Poco returns 3-byte public exponent (0x010001) as
3-element vector, and MS CAPI blob must include 4-byte exponent

In Poco code (Crypto/src/RSAKeyImpl.cpp), its convertToByteVec
uses OpenSSL's BN_bn2bin, which returns big-endian byte order
(see OpenSSL's crypto/bn/bn_lib.c). That is returned from Poco's
RSAKey::modulus() and RSAKey::*Exponent() unchanged, so treat
them accordingly.

Change-Id: I37f5fb9a310d42c7f346429c39611b25dd5bba2f
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/88989
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2020-02-19 10:19:55 +01:00
Mike Kaganski
c55afd2575 Don't drop trace log on error
Change-Id: I4839b02f01156e433de095395f1cb034e9aa9745
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/88716
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
2020-02-18 17:30:35 +01:00
Mike Kaganski
99f0480460 Proof: URI must be absolute and converted to uppercase
Also access token is already passes decoded to GetProofHeaders,
so don't decode it second time.

Change-Id: I7c4404462a9dd9f53e4e82684b1fcae1aeecee73
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/88736
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2020-02-18 17:30:19 +01:00
Mike Kaganski
25a1d35467 Read proof key from source directory in debug builds
Change-Id: I3de5ec1d6993fdba8430f40c6c93327e90a151c2
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/88672
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2020-02-18 16:29:54 +01:00
Ashod Nakashian
40fd469611 wsd: minor cleanup
Change-Id: I5b589d6cdb74f7f3a0c96ca2086500f6975a94b9
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/88369
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
2020-02-18 15:02:46 +01:00
Michael Meeks
faee2bdb24 Revert "Fix removal of kit procs when they are blocked"
This reverts commit 3046c5748b.

This breaks mobile apps for now. Apparently the 'close'
forces a different ordering than expected on the Child.
2020-02-13 00:33:05 +00:00
Gabriel Masei
3046c5748b Fix removal of kit procs when they are blocked
Change-Id: Ifa2a2a56a305e33bb07ad622fce14f0e8b3e83eb
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/88464
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Tested-by: Andras Timar <andras.timar@collabora.com>
2020-02-12 16:28:10 +01:00
Michael Meeks
39311fdae3 remove poco Environment call.
Change-Id: I967a42aa3b8a3b9fc44b3dffedef98adc4b94724
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/88198
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Michael Meeks <michael.meeks@collabora.com>
2020-02-07 16:39:55 +01:00
Mike Kaganski
2504c88c43 Don't use Poco buffer when creating a proof
I need this to better control the byte order of values in the proof

Change-Id: I8a21c20af4cc3157c893d870f73cc2afa7910ff4
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/88076
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Tested-by: Mike Kaganski <mike.kaganski@collabora.com>
2020-02-06 20:21:31 +01:00
Mike Kaganski
aaa9443eae Only warn on absent proof RSA key, don't log error
This reimplements commit bfb16d8831

Change-Id: I834a45ba4fcb939093b179f316176df790926c4e
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/88096
Reviewed-by: Andras Timar <andras.timar@collabora.com>
Tested-by: Andras Timar <andras.timar@collabora.com>
2020-02-06 16:05:40 +01:00
Marco Cecchetti
a46fa588b1 calc: formula input bar: adding support for text selection handles
Change-Id: I6bc276945a7fd33f1358a3aa82ce0e7f45237771
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/88090
Reviewed-by: Marco Cecchetti <marco.cecchetti@collabora.com>
Tested-by: Marco Cecchetti <marco.cecchetti@collabora.com>
2020-02-06 15:58:36 +01:00
Mike Kaganski
bfb16d8831 Turn some errors to warnings, and drop unneeded stderr output
Change-Id: I63de580480f983e8179546fae6217641fa370135
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/88088
Reviewed-by: Andras Timar <andras.timar@collabora.com>
Tested-by: Andras Timar <andras.timar@collabora.com>
2020-02-06 12:36:55 +01:00
Jan Holesovsky
ad32888d7c mobile: Unify the mutex usage that protects the main lokit thread.
Effectively both approaches were doing the same thing, let's unify to
the iOS way to minimize the platform-specific code.

Change-Id: I11290410a536c26db054ffcb87e3b64cc2a11c07
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/84589
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Jan Holesovsky <kendy@collabora.com>
2020-02-06 09:44:26 +01:00
Andras Timar
4fa8e4ee83 typo: shuting -> shutting
Change-Id: Ia33113b0c624b60479f41c8580e9b3d8d17812f4
2020-02-05 14:47:25 +01:00
Ashod Nakashian
da0f3a950a wsd: per-user cookies
Cookies may be passed from the client to the storage,
in which case each user may have its own unique set
of cookies. These cookies are now preserved in the
ClientSession, which is per connection, and are then
passed to the storage to use when communicating with
the WOPI-like backend.

(cherry picked from commit 6022faf3cc9b622b490c3f8ca91efbff8e542414)

Change-Id: Ic2e13fa541a5ee01b7383939bbbf7d46ea75684b
2020-01-28 18:10:14 +01:00
Miklos Vajna
6add8295bf test: remove documentation about no longer working CPPUNIT_TEST_NAME variant
This is not needed, the commandline to run the test is printed on
failure.

Change-Id: Ia4da4344ede4ad8c1627a5560f1bc1264f4203c7
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/87288
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
2020-01-24 00:09:34 +01:00
Miklos Vajna
9f91b01633 wsd: fix Android build
Don't just rename the variable, also make sure we get the FD before we
reset our local reference to it.

Change-Id: I676f148874831eaf9f37bdcde1216c58f89229e5
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/87244
Reviewed-by: Jan Holesovsky <kendy@collabora.com>
Tested-by: Miklos Vajna <vmiklos@collabora.com>
2020-01-23 11:18:46 +01:00
Michael Meeks
c9cfde6d72 wsd: use port number after, rather than before allocating it.
Particularly printing it on the console, and passing it to the kit.

Change-Id: I158f97b7b219c44c885939d71af2e5e8283be4c2
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/87227
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
2020-01-23 00:39:19 +01:00
Pranam Lashkari
a019c93d90 Resolved: Server crash when link opened in new tab
When trying to open a link normally from help->Online help
nothing happens but the popup is closed.

When trying to open a like forcefully in new tab
from help->online help it crashes the server.

Change-Id: I7e0944ebe521002625a84e155e379ed7e25d2309
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/85466
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
2020-01-22 23:23:51 +01:00
Miklos Vajna
9a92cd2415 Fix an UB in the DocumentBroker dtor
The problem is that both the DocBrokers map and the instance returned by
Admin::instance() are static, so there it's not safe to assume that by
the time the DocumentBroker dtor runs, the static Admin instance is
still alive. Still, the DocumentBroker dtor calls Admin::instance().

Fix this by clearing the DocBrokers map in LOOLWSD::cleanup(), which is
used exactly to destroy statics in a controlled order.

Sanitizers output was:

wsd/DocumentBroker.cpp:497:23: runtime error: member call on address 0x0000024a5ba0 which does not point to an object of type 'Admin'
0x0000024a5ba0: note: object is of type 'SocketPoll'
 00 00 00 00  50 21 45 01 00 00 00 00  b8 5b 4a 02 00 00 00 00  05 00 00 00 00 00 00 00  61 64 6d 69
              ^~~~~~~~~~~~~~~~~~~~~~~
              vptr for 'SocketPoll'
    #0 0xa10af3 in DocumentBroker::~DocumentBroker() wsd/DocumentBroker.cpp:497:23
...
    #17 0x7fa27622ddc9 in exit (/lib64/libc.so.6+0x38dc9)
    #18 0x7fa276215f90 in __libc_start_main (/lib64/libc.so.6+0x20f90)
    #19 0x670189 in _start /home/abuild/rpmbuild/BUILD/glibc-2.26/csu/../sysdeps/x86_64/start.S:120

SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior wsd/DocumentBroker.cpp:497:23 in

(Seen during make check CPPUNIT_TEST_NAME="unit-each-view".)

Change-Id: I02ad44deb9de06d9973216428c640248ea2512ce
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/87174
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
2020-01-22 09:19:05 +01:00
Mike Kaganski
0c0510cccf Implement proper proof-key value attribute
Change-Id: I3f2ad960ce6d3dad4d0b064492355b5643f345c8
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/87148
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
2020-01-21 19:28:32 +01:00
Miklos Vajna
a6af954b62 wsd: fix a typo in JWTAuth::cleanup()
Change-Id: I2c88403de12e2011746964b05a0c7e239dcbfd1b
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/87151
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
2020-01-21 17:39:09 +01:00
Michael Meeks
9126a641a9 test: switch to using ClientPortNumber to allow parallelism.
Change-Id: Ifef3bce1b217605000300b240ea74df4d264e0df
2020-01-21 15:07:54 +00:00
Michael Meeks
8f91659ae0 test: dung out redundant LOOL_TEST_CLIENT_PORT.
And cleanup other related oddities.

Change-Id: I2d179a2ece6a8553e10e406ad4e5da08a2ff58e5
2020-01-21 15:07:54 +00:00
Michael Meeks
9dfac6dab1 test: switch to parallel tests based on Unit framework.
Increase a few timeouts, bin old-style standalone unit tests,
fix a number of bugs.

Change-Id: Ia3d59466ecb9a9443807ba3445d04dd5f77e3dba
2020-01-21 15:07:54 +00:00
Michael Meeks
0599db3576 copyFile: de-poco-ize and handle EINTR and short writes.
Change-Id: I2046881c786a9f31f45c53f282de9ddd9a9cebcf
2020-01-21 15:07:54 +00:00
Michael Meeks
aadf5af77b reduce verbosity of FileServer trace logging.
Change-Id: I5a57e91742be504bcb2e51b45f6890420e52bb91
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/87134
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
2020-01-21 14:39:21 +01:00
Miklos Vajna
2c9e1319d9 Fix a -Werror,-Wrange-loop-analysis warning
wsd/Storage.cpp:451:21: error: loop variable 'header' of type 'const std::pair<std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char> >' creates a copy from type 'const std::pair<std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char> >' [-Werror,-Wrange-loop-analysis]

Change-Id: I90a57333b0807f3457d5b1082097426a3bf9678d
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/87055
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
2020-01-20 10:08:09 +01:00
Michael Meeks
e6a3364e93 Move file url anonymization down from LOOLWSD into FileUtil.
Change-Id: I415c73b10621d5c7c942367bbf38a3bbd9bf8f27
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/87024
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
2020-01-18 20:05:35 +01:00
Michael Meeks
8cca6dcac8 Cleanup JWTAuth token before shutdown.
valgrind had some exciting double-free action on unclean shutdown.

Change-Id: Id7dd3d8ff60387ae51521bd2c74e4d6bcc30ff2e
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/87025
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
2020-01-18 19:26:10 +01:00
Michael Meeks
1c754d5b11 Revert "Serve a decidedly unpretty clipboard download page"
This reverts parts of commit da455c486a.

Unfinished; also stream size calculation cannot have worked.

Change-Id: I39635fe5165b82dd36095d58cfefff4920ce3a35
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/86845
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
2020-01-16 17:21:38 +01:00
Michael Meeks
6305cc70fa postMessage tests - advertise them, and do some cleaning.
Set the iframe's src in a script so we can pass on a filename cleanly.
add a postMessage: sample URI at the end of 'make run'
Move some of the more obvious pieces into framed.doc.html.

Change-Id: I2bd8215f083bcb16369421ed88acb198808c1fdb
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/86787
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Jan Holesovsky <kendy@collabora.com>
2020-01-15 11:01:41 +01:00
Michael Meeks
b5f58fbe8c postMessage CSS checking improvements.
Ironically our attempts to double-check message origin against our
parent was blowing a security exception.

Instead send the list of origins we will accept from WSD, and
check them ourselves (as well as the browser check).

Why make it so hard to check that a postMessage comes from an
ancestor frame ?

Change-Id: I1311be3e1d68a31cfdc96b45a5eb5dd7f26e7ea9
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/86788
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Alexandru Vlăduţu <alexandru.vladutu@1and1.ro>
Reviewed-by: Jan Holesovsky <kendy@collabora.com>
2020-01-15 10:56:27 +01:00
Jan Holesovsky
0a35e432ff android: When the mobile-wizard is open, the Back button should go a level up.
Without this, we were closing the document, which was very annoying.

Change-Id: I1e841da28c92c0e01284c2d7e2d4dbc6762bfffd
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/86779
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
2020-01-14 17:44:28 +01:00
Ashod Nakashian
af58a9e761 wsd: whitespace
Change-Id: Id8185dab66f95676be2db8908d0f12c5284174fb
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/86321
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Jan Holesovsky <kendy@collabora.com>
2020-01-07 11:47:04 +01:00
Michael Meeks
9cef0f385d watermarking: create SessionMap template to canonicalize views.
Use a fully reliable uniqueness check, rather than a hash, and get
simpler ids as a bonus. Fetch view data from the session itself
rather than passing it in too.

Change-Id: Ibcd625156b5a98eb280e35d6537b5c8c026d0197
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/86150
Reviewed-by: Mert Tümer <mert.tumer@collabora.com>
Tested-by: Mert Tümer <mert.tumer@collabora.com>
2020-01-06 13:52:29 +01:00
Marco Cecchetti
35831935d8 wsd: disable unsupported code on mobile
Change-Id: I5d51a536e32bdf3262f3d39dda8ddb3152fa4460
Reviewed-on: https://gerrit.libreoffice.org/85633
Reviewed-by: Marco Cecchetti <marco.cecchetti@collabora.com>
Tested-by: Marco Cecchetti <marco.cecchetti@collabora.com>
2019-12-20 20:32:42 +01:00
Henry Castro
9290981013 wsd: debug: add env variable "PAUSEFORDEBUGGER" to attach debugger
It is painful to check and search manually the PID to attach the LOKit
process when exists several pre-spawned waiting to load a document.

This patch helps to attach the debugger when the LOKit process is about
to load a document then send the "signal SIGUSR1" to resume it.

Change-Id: I3b15bd522c6ef3ef57dc3453b457dcf91f2661b9
Reviewed-on: https://gerrit.libreoffice.org/85430
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Tested-by: Henry Castro <hcastro@collabora.com>
Reviewed-by: Henry Castro <hcastro@collabora.com>
2019-12-20 19:57:47 +01:00
Miklos Vajna
d0fee8c6ad These can be made const
Change-Id: I952a7566176bda727f8c2e9618d41bfb7bb1240f
Reviewed-on: https://gerrit.libreoffice.org/85197
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
2019-12-16 09:24:08 +01:00
Michael Meeks
5d5fb42715 Typo fix.
Change-Id: I4698a00a8646366bcf30aabd997c31996a58d0e0
2019-12-14 16:19:48 +00:00
Andras Timar
97ee22a8ff fix error: declaration of ‘load’ shadows a member of 'this' [-Werror=shadow]
Change-Id: I4bd4fb3ae6f01c0d03d622f90e1dfb872c396494
2019-12-13 16:05:52 +01:00
Jan Holesovsky
863111c952 mobile: Fix build.
Change-Id: Ie0f08a984b9333ca65d0fd52c71e358b7fd5f771
Reviewed-on: https://gerrit.libreoffice.org/85018
Reviewed-by: Jan Holesovsky <kendy@collabora.com>
Tested-by: Jan Holesovsky <kendy@collabora.com>
2019-12-12 09:57:44 +01:00
Michael Meeks
948b424abb convert-to: wait for load to complete before attempting the save.
Change-Id: Iee3a8a6720bbc29fc4e113bf705f405b840e1e45
Reviewed-on: https://gerrit.libreoffice.org/85009
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Tested-by: Michael Meeks <michael.meeks@collabora.com>
2019-12-12 07:42:42 +01:00
Michael Meeks
83e02ab38b Add a time limit for badly behaved / huge document conversions.
Handles problems with load, save, and lingering DocumentBrokers.

Change-Id: I6079cba3a4fa2a84c303b3a8669d94863a04f474
2019-12-12 03:38:50 +00:00