Commit graph

603 commits

Author SHA1 Message Date
Pranav Kant
1ea87b627e wsd: Arrange exception handling a bit
Remove incorrect usage of std::uncaught_exception and handle
StorageConnectionException later.

Change-Id: I15ecd46b51e8ed33649fe876d46ce3d5fbae07cc
2017-05-22 11:04:26 +05:30
Ashod Nakashian
4e6fee5407 Hide connecting spinner on authorization failure
Also, fix regression resulting in "This is embarrassing..."
instead of "Unauthorized..." message.

Change-Id: If6219bfbc445b186bb4064b3f20a0ccd2854d617
Reviewed-on: https://gerrit.libreoffice.org/37893
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-05-22 07:06:50 +02:00
Ashod Nakashian
407c538f04 Correctly send termination reason to clients
Fixes the case when the client reconnects on idle
disconnection (because it never got the 'close: idle'
message).

Also, show informative message to users in this case
instead of grey screen.

Change-Id: Ia2e1f2ffefe6d35dd1552e7cc44e490aab86c600
Reviewed-on: https://gerrit.libreoffice.org/37891
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-05-22 07:05:28 +02:00
Ashod Nakashian
bdd8b715dd wsd: include cleanup
Change-Id: I9f28ee329e318043c31c899d3a07cd3139d838f0
Reviewed-on: https://gerrit.libreoffice.org/37890
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-05-22 07:04:24 +02:00
Ashod Nakashian
873cbcbe91 wsd: logging corrections
Change-Id: I35c52494137ea174c218bf936bc2440634036e3e
Reviewed-on: https://gerrit.libreoffice.org/37889
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-05-22 07:03:47 +02:00
Pranav Kant
f47936a2da ENABLE_DEBUG has values either 0 or 1, otherwise its always defined.
Change-Id: I0253dc2d83c11888e79ddb991b065eb62bbbd805
2017-05-20 12:18:29 +05:30
Pranav Kant
aed840ea04 Didn't mean to truncate this string literal
Otherwise getStatus() returns an integer which increments the char*

Change-Id: I189addb60a02de14085b1501c75362b13dcb3ae2
2017-05-19 21:04:03 +05:30
Pranav Kant
bcf958c500 wsd: Fail gracefully when storage misbehaves
When WOPI's CheckFileInfo or GetFile responds with status code other
than HTTP 200, show a message to the user indicating some problem in the
storage.

Currently, we open an empty document if storage doesn't return a
document which surely is not correct.

Mention the storage server address when asking user to contact the
server administrator to be more friendly.

Change-Id: I15f0489f36db8689b43d42f6b691fdd21815e4fa
2017-05-19 20:53:42 +05:30
Pranav Kant
2e9e6a753d Bin unused Exception class
Change-Id: I961af47f6c112b6d9bb2e9d4ad184e162377506f
2017-05-19 16:14:41 +05:30
Jan Holesovsky
9db41725f4 Revert "wsd: use WOPI host instance ID to support hostname aliases"
Turns out this introduces two calls to the CheckFileInfo which is not really
what we should be doing; instead, let's do a kind of cannonicalization in the
WOPI host directly.

This reverts commit ec2fd0844f.

Change-Id: I311bf8a45b706ed9a4d8cd00db0a990ac6d461b4
2017-05-19 10:34:38 +02:00
Pranav Kant
4ef373ce5f wsd: Echo back port number in CSP too if found in Referer header
Otherwise, WOPI implementations that use non-standard ports get CSP
voilation errors in the browsers because Poco's URI::getHost() method
strips the port number from the host.

No harm in mentioning the port number always even if its a standard one,
so always use Poco::URI::getPort() to append the port to the frame
ancestor.

Change-Id: I9e7a7021b38f717e14af3d389e30f24ecaf6d122
2017-05-18 23:10:49 +05:30
Pranav Kant
46acd74d83 Document LOOL_SERVE_FROM_FS
Change-Id: I10d71979366f61839f2aedaf6886fa5f03132004
2017-05-17 23:31:26 +05:30
Jan Holesovsky
02dbc82631 wsd: Don't set Content-Disposition for SVGs, the browser must handle them.
Otherwise the presesntation mode downloads them instead of showing.

Change-Id: If2c9785aa5ef6bbb65e911b834c77ea83da281e7
Reviewed-on: https://gerrit.libreoffice.org/37716
Reviewed-by: Jan Holesovsky <kendy@collabora.com>
Tested-by: Jan Holesovsky <kendy@collabora.com>
2017-05-17 16:30:35 +02:00
Pranav Kant
1717bfbc0b Silence -Werror=unused-parameter in non-debug builds
Change-Id: Ib4c91e52d4ac78b3bafe3d078e41c79b50ca87a8
2017-05-17 16:43:31 +05:30
Pranav Kant
8a02e7a8fa wsd: Debugging environment vars to debug storages
Also, extend the LOOLProtocol::tokenize to accept a custom delimeter.

Change-Id: I7f789e703c5c8d2ad325b3dd149ba888c722f5f3
2017-05-17 16:30:33 +05:30
Pranav Kant
1449d81671 wsd: Don't filter out 'save' command
Fallback from 1cb75cbcb8

Change-Id: I47c8a470e5f4ab4d48859365d4435ae79c5fa82d
2017-05-17 10:29:53 +05:30
Ashod Nakashian
ec2fd0844f wsd: use WOPI host instance ID to support hostname aliases
The docKey creation moved to Storage where we first
invoke WOPI (if/when it's a WOPI-hosted doc and WOPI enabled)
and see if the user has access to the document at all.
If they do, we expect the server to give us a
unique ID to use for identifying the host regardless
of hostname aliases.

If a unique ID is not returned (i.e. empty or missing)
we use the hostname and port in its place as fallback.
This will break hostname aliases, but it will still work.

Change-Id: I407b0087395f9df6ad9cc6e037570487999be4a4
Reviewed-on: https://gerrit.libreoffice.org/37697
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-05-17 04:18:31 +02:00
Aditya Dewan
f94b42d9a8 tdf#107762 admin-console: memory graph in 'Analytics' tab now working
Change-Id: I6a0ee82e813e80344eaf6ddb7d46eebed98ca5bb
Reviewed-on: https://gerrit.libreoffice.org/37672
Reviewed-by: pranavk <pranavk@collabora.co.uk>
Tested-by: pranavk <pranavk@collabora.co.uk>
2017-05-16 17:52:53 +02:00
Pranav Kant
1cb75cbcb8 wsd: Save wrapper over .uno:Save
Document broker needs to know when the save request is sent and when the
save finished. It uses these parameters to avoid shutting down document,
in the document broker main polling loop, if save is already going on.
But direct .uno:Save commands issued from
loleaflet precludes document broker to keep track of it - in this case a
.uno:Save command issued from loleaflet followed by closing the
session will prevent saving the document to storage, if document is huge
enough and LO core takes a bit of time to save it. A save wrapper
command, 'save', ensures that document broker is aware of all such save
requests (_saveRequestTime member variable) and doesn't close the
document until we completely save it (to storage and other cleanups).

Change-Id: I5ec73d45adff23b2e7543e93dfd0624a5e5af46d
2017-05-15 11:41:52 +05:30
Ashod Nakashian
47c01440ba wsd: logs
Change-Id: I286c4c7415b114f51f3258bd6d50f8e103ea6c75
Reviewed-on: https://gerrit.libreoffice.org/37611
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-05-15 05:14:55 +02:00
Ashod Nakashian
6e63c80763 wsd: handle WOPI access failure
Show the user that authorization failed.

Change-Id: Iad63c11ac2033eee80062ecd43dff76f776924c3
Reviewed-on: https://gerrit.libreoffice.org/37610
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-05-15 05:14:30 +02:00
Ashod Nakashian
7cff4fb08a wsd: fix server shutdown
Thread-affinity checks must be inhibited
not just on Socket, but on the SocketPoll as well,
before destroying DocumentBroker instances.

Also, properly initialize the inhibit statics.

Change-Id: I2ced1554d477f0c3faf09bda74034cbae99e4ce1
Reviewed-on: https://gerrit.libreoffice.org/37608
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-05-15 05:10:31 +02:00
Ashod Nakashian
d267b86bbd wsd: include version in http agent strings
And move the WOPI agent string to Common.hpp.

Change-Id: Ife679705bcd6914ddd45ad50446e690fb22dd317
Reviewed-on: https://gerrit.libreoffice.org/37607
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-05-15 05:10:06 +02:00
Jan Holesovsky
95e892168c wsd: When connecting new sessions, always use the original URI...
...but in combination with the appropriate session's access_token to always
authenticate against the same instance of the WOPI host.

Change-Id: Ic94dfa8fcb226a2d134272b22edc1f8f76c24e34
2017-05-12 18:07:23 +02:00
Ashod Nakashian
a15e32137f extend discovery.xml with pdf and image formats
Change-Id: I201eb276b4de29239c7dd99954abcc39e6027aff
Reviewed-on: https://gerrit.libreoffice.org/37430
Reviewed-by: pranavk <pranavk@collabora.co.uk>
Tested-by: pranavk <pranavk@collabora.co.uk>
2017-05-12 06:49:33 +02:00
Michael Meeks
473c511cc0 DumpState: include SSL & termination settings.
Change-Id: I14d1d79d5ab1650661c493d8965cf41ac84c17c1
2017-05-12 03:06:49 +01:00
Michael Meeks
29b92444b1 Stream dumpHex output to an output stream.
Also output debug directly to stderr to avoid std::cerr re-direction.

Change-Id: Ib2a0eaa3514ef88d7fe8d8fbb3706925aabf3346
2017-05-12 03:06:49 +01:00
Marco Cecchetti
024e786e85 calc: added an address input field
Change-Id: Ic030724e392693847a195b5e53866b40ebad7435
Reviewed-on: https://gerrit.libreoffice.org/37359
Reviewed-by: pranavk <pranavk@collabora.co.uk>
Tested-by: pranavk <pranavk@collabora.co.uk>
2017-05-11 17:55:23 +02:00
Ashod Nakashian
954a37a06c Configurable timeouts
Timeouts to dimming the doc in the browser
are now configurable from WSD and is relayed
to loleflet as expected.

Out of focus timeout is now 60 seconds.

Change-Id: I8452e30976f6a81b0c3bb3ba5774daa244c1640c
Reviewed-on: https://gerrit.libreoffice.org/37489
Reviewed-by: pranavk <pranavk@collabora.co.uk>
Tested-by: pranavk <pranavk@collabora.co.uk>
2017-05-11 08:01:30 +02:00
Pranav Kant
e8ff268992 wsd: Use hostname and port in doc key too
... to avoid different WOPI hosts using same loolwsd instance sharing a
file because the path of the file (file id etc.) is same in both of
WOPI hosts.

Though, having hosts + port in doc key engenders the possibility of
opening the same file as two if the WOPI host is accessed using
different aliases but that is much less of a concern than security bug
mentioned in previous paragraph.

Change-Id: Iaa2f880edce952925a85e56ed8eba99514e19751
Reviewed-on: https://gerrit.libreoffice.org/37400
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Tested-by: Jan Holesovsky <kendy@collabora.com>
2017-05-10 17:02:47 +02:00
Jan Holesovsky
25224666a7 Revert "Implement File -> Download As -> Plain text (.txt)."
Actually it is enough to do Ctrl-a Ctrl-c, no need to have a special Download
As -> Plain text.

This reverts commit 1c13d5523f.
2017-05-10 15:01:01 +02:00
Jan Holesovsky
6d8aa453ab wsd: Handle a non-empty, but broken frame ancestor with 'deny' too.
Change-Id: I61b6e5c7cbe7f36ecd780865a613b7a240cf7b99
2017-05-10 14:46:21 +02:00
Michael Meeks
495d6da532 Reset ownership before executing the socket move.
Change-Id: I98532e59ef9c78a6cc1eb25a5a8535c4e2d9b15d
2017-05-09 13:02:23 +01:00
Michael Meeks
1fc176fb05 Restore some clean exists during requests - avoiding exceptions.
Change-Id: I89bb82f85341fcd87daf34d19f30031d1c6d1366
2017-05-08 13:15:44 +01:00
Pranav Kant
624fc5c5de wsd: Use HTTP Referer and then WOPISrc for frame ancestor
This is required in those setup where the document is not served from
the same host user is currently connected to. Use the Referer[sic]
header to set the frame ancestors and if they are absent, fallback to
WOPISrc value provided by the WOPI host.

Change-Id: Ia63a213d10aca2df56a2884e07322c1cd8056ff8
2017-05-08 15:32:43 +05:30
Michael Meeks
0088c14850 Allow env-var to affect serving from the FS only in debug mode.
Change-Id: I5e5d176295807af4de3e802ca02a0e1a1c17646e
2017-05-08 09:51:28 +01:00
Ashod Nakashian
3aec6e1227 wsd: build fix due to merge error
Change-Id: Ib1d7ce1b880c71b0b2fd8262a92e7e965211653e
Reviewed-on: https://gerrit.libreoffice.org/37375
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-05-08 05:23:46 +02:00
Ashod Nakashian
7d823787bb wsd: configurable idle document timeout
When a document is idle (no activity from
any views) for this timeout duration, the
document is saved and unloaded to minimize
resource consumption.

Change-Id: If6f09136ae40c7e84180fc8c8adbf6db8396d292
Reviewed-on: https://gerrit.libreoffice.org/37374
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-05-08 05:00:56 +02:00
Ashod Nakashian
9798eafb8c wsd: random jail paths instead of pid
Jail paths are now generate from a PRNG
instead of using the PID of the kit process.

The PRN is converted to base-64 and used
as the directory name where a given
kit is jailed.

Change-Id: I8e4bc35d9ccdfdae0e542ab707c417cd29ad52f3
Reviewed-on: https://gerrit.libreoffice.org/37372
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-05-08 04:59:12 +02:00
Michael Meeks
9e45fb30d7 SocketDisposition: push it down the stack, and cleanup around that.
Dung out overlapping return enumerations. Move more work into 'move'
callbacks at a safer time, etc.

Change-Id: I62ba5a35f12073b7b9c8de4674be9dae519a8aca
2017-05-05 18:37:26 +01:00
Jan Holesovsky
1c13d5523f Implement File -> Download As -> Plain text (.txt).
Change-Id: I446f73a3110312cbaab1ce1053aee854b421e71c
2017-05-05 18:24:23 +02:00
Pranav Kant
052dec41be wsd: New environment variable to not serve from memory
Its quite time consuming having to restart loolwsd everytime you make
changes in loleaflet.

Change-Id: I5cc8c5af96e758309d21598c0f23fad9082130bd
2017-05-05 15:24:21 +05:30
Ashod Nakashian
c31bf89976 wsd: trace file cleanups
Change-Id: I72ccbb9f01d4e27b59d88cca9da05c1472008825
Reviewed-on: https://gerrit.libreoffice.org/37130
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-05-02 06:12:49 +02:00
Michael Meeks
68b844eb5c Initialize Poco's SSL-ness; the WOPI Storage code still uses it. 2017-04-27 18:47:35 +01:00
Michael Meeks
cda55f3a21 Various cleanups & improvements to file-serving.
Use what we read at startup as the complete set of files to serve.
Trace log filenames as we read them.
Simplify and accelerate path related checks via the hash.
Kill leak with get_current_dir_name and use the correct path.
2017-04-27 15:02:16 +01:00
Aditya Dewan
be4ebb9b1f Migrated from deflate to gzip
Change-Id: I64aec9305fe74b6cdcfe15e2f67f9d38cfd6d99a
2017-04-27 15:02:16 +01:00
Michael Meeks
fc8563e778 Add LOOL_DELAY_SOCKET_MS env. var to simulate latency. 2017-04-27 10:13:58 +01:00
Michael Meeks
faf24f7888 SocketDisposition - controls socket movement & lifecyle.
It is important that moving sockets between polls happens in a
safe and readable fashion, this enforces that.
2017-04-25 22:49:08 +01:00
Michael Meeks
c8d1c18cb5 Revert "wsd: correctly remove request from socket buffer"
This reverts commit c851c3e93b.
2017-04-25 22:49:08 +01:00
Pranav Kant
0c34857527 Bin superfluous object
Poco::DateTime is enough to create an object representing the current
date time, no need to create a timestamp first.

Change-Id: Ib95b43c1f7ae4993a6d9f7ec6da1234ac2bf59aa
2017-04-25 11:30:15 +05:30