Commit graph

3893 commits

Author SHA1 Message Date
Tor Lillqvist
bb36ca79d4 Attempt to handle unauthorized WOPI usage better
Use the previously unused UnauthorizedRequestException for this, and
throw a such in StorageBase::create() when the WOPI host doesn't match
any of those configured.

In a developer debug build, without access to any real WOPI
functionality, you can test by setting the FAKE_UNAUTHORIZED
environment variable and attempting to edit a plain local file:
URI. That will cause such an exception to be thrown in that function.

Catch that UnauthorizedRequestException in
ClientRequestHandler::handleGetRequest(), and send an 'error:
cmd=internal kind=unauthorized' message to the client. Handle that in
loleaflet in the same place where the 'error: cmd=internal
kild=diskfull' message is handled, and in the same fashion, giving up
on the document.

Actually, using exceptions for relatively non-exceptional situations
like this is lame and makes understanding the code harder, but that is
just my personal preference...

FIXME: By the time StorageBase::create() gets called we have already
sent three 'statusindicator:' messages ('find', 'connect', and
'ready') to the client. We should ideally do the checks we do in
StorageBase::create() much earlier.

Also consider that ClientRequestHandler::handleClientRequest() has
code that catches UnauthorizedRequestException and
BadRequestException, and tries to set the HTTP response in those
cases. I am not sure if that functionality has ever been exercised,
though. Currently, we upgrade the HTTP connection to WebSocket early,
and only after that we check whether the WOPI host is authorized
etc. By that time it is too late to return an HTTP response to the
user. If that even is what we ideally should do? If not, then we
probably should drop the code that constructs HTTP responses and
attempts to send them.

Also, if I, as a test, force an HTTPResponse::HTTP_BAD_REQUEST to be
sent before the HTTP connection is upgraded to WebSocket, loleaflet
throws up the generic "Well, this is embarrassing" dialog anyway. At
least in Firefox on Linux. (Instead of the browser showing some own
dialog, which I was half-expecting to happen.)
2016-10-17 19:34:04 +03:00
Tor Lillqvist
b29ae3c032 Sort lines for clarity 2016-10-17 19:34:04 +03:00
Pranav Kant
8ab4682a71 loolwsd: Fix handling of CPPUNIT_TEST_NAME in external test-suite
Doing a plain CPPUNIT_TEST_NAME='somettest' make check will
result in executing all the tests in external test suite. This is
a problem when one wants to execute only internal tests (unit-*
ones) as test harness first executes those followed by all of the
tests in external test-suites.

Lets execute all the tests only when no CPPUNIT_TEST_NAME is
provided, and ignore when it is provided but no match is found.

Change-Id: I7e40b6f3124e6965a86cfb6395d246df3b5c17ba
2016-10-17 21:21:54 +05:30
Pranav Kant
be1e49715c loolwsd: Bring this test back to life
There doesn't seem to be any failure on this test anymore.
Consecutive 20 runs of this test gives no failure, so lets enable
it again.

Change-Id: I77ddd1c36d18162bdc75fd24d51c1a2df22f749d
2016-10-17 18:34:22 +05:30
Pranav Kant
38e8a38034 loolwsd: Fix admin remove doc after unloading the session
Change-Id: Ia512d5b4c5f0e230542caed6cebc242e3a345430
2016-10-17 18:34:22 +05:30
Pranav Kant
d4fbc92023 loolwsd: Fix admin console document add
Change-Id: I987f26b4aae2c4ea8ef65919f570576ef8c5d2a7
2016-10-17 18:34:22 +05:30
Pranav Kant
1c2c03fcb6 loolwsd: Query docbroker for load duration after loading the doc
addSession() now also loads the document, so querying docbroker
for load duration before it doesn't make any sense.

Change-Id: I3c60bef5e2054878ba695b8f76b6800cdedffe8d
2016-10-17 18:34:22 +05:30
Tor Lillqvist
9ced5ffdd5 Log how we are actually exiting the test when calling exitTest()
unit-admin fails every time for me at the moment. Make it at least a
bit easier to figure out what is going on.
2016-10-17 13:42:02 +03:00
Marco Cecchetti
e61d8aaa5f loleaflet: handle EMPTY invalid tiles msg with part in the payload
Change-Id: I73e363f51101c8e4e258131ea1692a7709d6a544
Reviewed-on: https://gerrit.libreoffice.org/29964
Reviewed-by: Marco Cecchetti <mrcekets@gmail.com>
Tested-by: Marco Cecchetti <mrcekets@gmail.com>
2016-10-17 10:39:41 +00:00
Pranav Kant
cd92dc277b loolwsd: Remove this leftover duplicate comment
Change-Id: I243e2fd745b4b0c70cec79deefffcb5b8f7d2548
2016-10-17 15:25:20 +05:30
Tor Lillqvist
fdb16a5d52 Add comment to hopefully avoid others being confused like I was 2016-10-17 12:44:58 +03:00
Ashod Nakashian
cb09f50d8c loolwsd: static variables must start with uppercase per the style guidelines
Change-Id: I1e8105983f98cc0cd15448e6d9cb1e6fca36ca9d
Reviewed-on: https://gerrit.libreoffice.org/29955
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-10-16 22:14:45 +00:00
Ashod Nakashian
72fb908086 loolwsd: limit test documents and connections to the config
...if configured with limits.

Change-Id: Ic148f725c58485ea88f62ddf7b4ac47b3b43ff04
Reviewed-on: https://gerrit.libreoffice.org/29951
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-10-16 22:14:30 +00:00
Ashod Nakashian
d266d124df loolwsd: argument cleanup
Pass std::string instead of char* and length where
a string is always constructed anyway. Also cleaner
and safer code.

Change-Id: I1c9341e2c81bbdb7adeb29d3fba59849b2617e95
Reviewed-on: https://gerrit.libreoffice.org/29954
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-10-16 22:14:00 +00:00
Ashod Nakashian
60bfda4609 loolwsd: loose coupling between ClientSession and DocumentBroker
Change-Id: I5bd1c51a8f1110923db052d0712f9f204db5d4af
Reviewed-on: https://gerrit.libreoffice.org/29953
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-10-16 22:13:31 +00:00
Ashod Nakashian
d857b3dbbb loolwsd: add the ClientSession to the Broker last
This avoids early connection failures causing the
session to linger in the Broker indefinetely.

Change-Id: Ibe2b5b386ed1cd6e12e68735bff60b15957188cf
Reviewed-on: https://gerrit.libreoffice.org/29952
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-10-16 22:12:43 +00:00
Ashod Nakashian
5ba6ce1a33 loolwsd: fix and cleanup HTTPWSError unittests
Change-Id: Ib730c8b3c1eac56bd24c97b62bc12060e437205f
Reviewed-on: https://gerrit.libreoffice.org/29950
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-10-16 22:11:58 +00:00
Ashod Nakashian
f113d9c9c7 loolwsd: fix and improve kit crash unittest
Change-Id: Icd50faab8c8453d8df39253b75d887d315bda6d1
Reviewed-on: https://gerrit.libreoffice.org/29949
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-10-16 22:11:39 +00:00
Ashod Nakashian
de7cda7891 loolwsd: improve child cleanup and forking
Change-Id: I437216d87b6fa15e567e102ed875b22ef03351b2
Reviewed-on: https://gerrit.libreoffice.org/29948
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-10-16 22:11:18 +00:00
Ashod Nakashian
4f4472ffa6 loolwsd: shutdown client sockets and cleanup when kit dies
Change-Id: I4d59553d744a8075d4d873ff520d9f3e417521b3
Reviewed-on: https://gerrit.libreoffice.org/29947
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-10-16 22:10:43 +00:00
Ashod Nakashian
4c967ec0c8 loolwsd: correct the test document name
Change-Id: I4efe1e36a70b62154a5e0dd70d42ee0a6c98cf6f
Reviewed-on: https://gerrit.libreoffice.org/29946
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-10-16 22:10:06 +00:00
Ashod Nakashian
57c5e55a4d loolwsd: trap signal handler to prevent premature exit
When upon cleanup we segfault we want to avoid
forcible exit using _Exit(). This was done by
an unconditional wait (sleep).

This patch changes that mechanism into a latch
(mutex) that traps the exit when the sig handler
is invoked, therby preventing exit as long as
necessary for the sighandler to finish.

Change-Id: Ifc8e972be12645a1b310d4cb4e3a4172afc31327
Reviewed-on: https://gerrit.libreoffice.org/29945
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-10-16 22:09:49 +00:00
Ashod Nakashian
4ca15894df loolwsd: only forkit cleans up the jail directory
No need to do a partial cleanup in the kit
when forkit recycles the disk. This avoid
both programatic errors (as the comments in
the removed code explains) as well as hammering
the disk from multiple processes.

By leaving all disk cleanup to forkit we
guarantee safety and that only one process
does disk cleanup, and sequentially at that.

N.B. Kit processes are still responsible for
setting up the jail and the LO binaries etc.
So disk IO is not strictly sequential from a
single process.

Change-Id: Ia6768ab87df71a83a6676c3d52da3d6797f717fc
Reviewed-on: https://gerrit.libreoffice.org/29944
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-10-16 22:09:02 +00:00
Ashod Nakashian
c1ee1f5102 loolwsd: stop ChildProcess WS on TerminationFlag
Change-Id: I303dedb8254a9b815dd0b2c5d0a62cc5345af062
Reviewed-on: https://gerrit.libreoffice.org/29943
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-10-16 22:08:15 +00:00
Ashod Nakashian
67437c6076 loolwsd: all timeouts in milliseconds
Change-Id: Ic5db4e13b2caba53fcbeea0bfdb10d112f2d5a18
Reviewed-on: https://gerrit.libreoffice.org/29942
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-10-16 22:08:00 +00:00
Ashod Nakashian
d4214c555f loolwsd: kill waitBridgeCompleted and AvailableChildSessions
Change-Id: I26eac76135d35ea17ac7e6d2697df81ad07a1d73
Reviewed-on: https://gerrit.libreoffice.org/29941
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-10-16 22:06:21 +00:00
Ashod Nakashian
7043b95f4d loolwsd: fix convert-to after removing Prisoner WS
Change-Id: I652a9fffa267e01043262eb25d3c2e19bf9eb447
Reviewed-on: https://gerrit.libreoffice.org/29940
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-10-16 22:06:05 +00:00
Ashod Nakashian
35fcaa1592 loolwsd: don't join unjoinable thread and contain exceptions
Change-Id: I309153c3c05a152e4ef3bbbbd5a0948bcc589c9c
Reviewed-on: https://gerrit.libreoffice.org/29939
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-10-16 22:05:32 +00:00
Ashod Nakashian
d98e019994 loolwsd: kill priosoner connection listener
Change-Id: Ica69c80fc9094c1139d05eaf08b9c1fa6b222347
Reviewed-on: https://gerrit.libreoffice.org/29938
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-10-16 22:04:53 +00:00
Ashod Nakashian
b44d71f0ae loolwsd: no need to create prisoner WS anymore
Change-Id: Iaebac49f47353a6848fd2232a1838e4eaadaeefc
Reviewed-on: https://gerrit.libreoffice.org/29937
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-10-16 22:04:31 +00:00
Ashod Nakashian
75c99ed9b6 loolwsd: cleanup child process WS interface
Change-Id: I30d74fc25434301145da292711fe5e33972ac876
Reviewed-on: https://gerrit.libreoffice.org/29936
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-10-16 22:03:56 +00:00
Pranav Kant
9ebd7a15e2 loolwsd: Improved loolwsd -> storage communication
Reduces the number of WOPI calls made during a document load. Earlier
effort was made in edfd3266f8
This commit cleans up and uses better approach for the same.

Other than that, access token of each session is now correctly
used when interacting with the storage. Earlier, we used to
use the same access token for each upload to storage which means
that irrespective of who clicked the save button, changes to the
document were only made on behalf of one person (of whom the
access token is used). This is fixed now.

Also includes minor cleanup left and right.

Change-Id: Id32702ff02aea4f63b7cc6afa9f62664807bb57d
Reviewed-on: https://gerrit.libreoffice.org/29931
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-10-16 22:02:25 +00:00
Ashod Nakashian
2ca592d0ac loolwsd: log the username, Core View-ID, and WSD Session-ID together
This helps debugging and tracing issues as this single log
entry links the three most important pieces together:
the user, how Core references the user's view to a
given document, and how WSD references the same.

Change-Id: I7bf88504b43eed85d40e6f8bc9c3bad713f372da
Reviewed-on: https://gerrit.libreoffice.org/29935
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-10-16 22:02:07 +00:00
Pranav Kant
07f10570cc loolwsd: Add wopiloadduration - time taken to interact with WOPI host
Change-Id: Ia2d763ef721128450bf402a61d0e0f3e75701441
2016-10-16 23:01:50 +05:30
Pranav Kant
7cacaa070d loolwsd: Make this const
Change-Id: Ieb1be92323061110798da23f066a5be0e8314472
2016-10-16 23:01:46 +05:30
Henry Castro
1d40b1eb79 loleaflet: fix mouse over text that it changes re-size cursor 2016-10-14 14:46:46 -04:00
Marco Cecchetti
78e707393e loleaflet: handle EMPTY invalid tiles msg with part in the payload
Change-Id: I84ae55440b540dc027bddf341994d34d411f2a3a
Reviewed-on: https://gerrit.libreoffice.org/29826
Reviewed-by: Marco Cecchetti <mrcekets@gmail.com>
Tested-by: Marco Cecchetti <mrcekets@gmail.com>
2016-10-14 13:26:16 +00:00
Pranav Kant
edfd3266f8 loolwsd: Reuse storage object; kill superfluous WOPI calls
This reduces the number of fileinfo calls made to storage. These calls can
be expensive in storage such as WOPI where loolwsd needs to
interact with another server to get the file information. Use the
same storage object once created so that fileinfo can be
cached and returned quickly for subsequent such calls.

3 GetFileInfo WOPI calls are now merged into 1.

Change-Id: I56c3d23d3d6d7dc3a4b42433f51304dac28a12e8
2016-10-14 17:18:58 +05:30
Pranav Kant
66fa578fb3 loolwsd: No need of passing URI again to getFileInfo
Lets use the internal URI stored in storage object.

Change-Id: I2bfefc8d41db86a940060fadaa8629e50ed14d7c
2016-10-14 17:18:45 +05:30
Pranav Kant
e4466b418b loolwsd: Storage class: std::string -> Poco::URI
This saves us from encoding/decoding mess of URIs. Poco::URI is
flexible enough and can give encoded or decoded version whenever
required, so lets avoid storing the URI in std::string where we
have no information about whether its encoded or not.

Change-Id: I4a6979e13b20d9f56fc5a0baa630cb1b35ca33b0
2016-10-14 17:18:45 +05:30
Tor Lillqvist
3757125b23 Use same indentation and whitespace style as in other source files
Only whitespace changes in this commit.
2016-10-14 13:10:15 +03:00
Tor Lillqvist
c628b00c3e Add Emacs mode line and license blurb here, too 2016-10-14 13:05:09 +03:00
Tor Lillqvist
650ab54d00 Log fatal errors as such 2016-10-14 13:02:58 +03:00
Tor Lillqvist
0e047c8a1a Add Log API for the 'FATAL' priority
To be used only for truly fatal configuration or resource errors when
the lool service cannot continue functioning at all.

Add also a sysfatal() variant that appends the strerror(errno)
message, like syserror().
2016-10-14 12:52:03 +03:00
Henry Castro
9d89989b99 loleaflet: remove unused query string 2016-10-13 17:03:48 -04:00
Henry Castro
a0a87276f9 loolwsd: fix media type 2016-10-13 16:54:27 -04:00
Tor Lillqvist
c8d5c279b9 Move comment 2016-10-13 23:49:27 +03:00
Andras Timar
cb4fb86794 loleaflet: add Insert - Comment to Calc menu 2016-10-13 12:58:04 +02:00
Tor Lillqvist
213c7c6d09 Catch by const ref
That's what we do everywhere else, not reason to do differently in
these two places.
2016-10-13 12:00:54 +03:00
Miklos Vajna
4104e341f5 Remove unused using declarations
And a few other minor fixes. No need to create an std::string object
when a char number is enough, nor need to copy an object when passing it
by reference is enough.

Change-Id: I3d6aba20ffce781532ea77fe079ce64378db6e12
2016-10-13 08:20:04 +02:00