Commit graph

1251 commits

Author SHA1 Message Date
Tor Lillqvist
9d35b956d9 bccu#1399: Initial code for auto/idle save
Just a skeleton, actual saving not yet implemented. Also, not sure
the logic when to trigger save is as intended.

Note that no separate timer classes or objects are used. The existing
watpid/sleep loop that wakes up once every two seconds currently is
used. If that loop is re-factored to be less silly, the auto/idle save code
must be implemented differently.
2016-03-22 20:27:38 +02:00
Tor Lillqvist
418fc3f203 Use SSL here, too 2016-03-22 20:06:44 +02:00
Tor Lillqvist
0677c4abc9 No need for the DocumentBroker map to be in the LOOLWSD class
It can be a simple static variable in LOOLWSD.cpp. It is not used
anywhere else.
2016-03-22 18:47:05 +02:00
Tor Lillqvist
6b505e561f Bin unneeded #include 2016-03-22 18:45:22 +02:00
Tor Lillqvist
744c4143c2 Indentation nit-pick 2016-03-22 18:41:14 +02:00
Tor Lillqvist
1222d7ff6d Linux surely always has WCOREDUMP defined 2016-03-22 18:11:06 +02:00
Tor Lillqvist
a68f0b89e3 Improve wording in log message 2016-03-22 17:58:37 +02:00
Tor Lillqvist
e1d5f991e8 Get rid of weird looping behaviour
When no child process has died, I don't see the point in calling
waitpid() eleven times in quick succession (with WNOHANG), doing
nothing else, and then sleeping for a bit. Let's call waitpid() just
once, and sleep only if the return value indicates that no child
process has died.
2016-03-22 17:52:50 +02:00
Tor Lillqvist
913ed1114a Sort #include and 'using' lines 2016-03-22 17:25:35 +02:00
Pranav Kant
06bc5cf33e Update READMEs for SSL and Admin panel
Change-Id: I7b511071ab286474b35f40f40839aa2c44fa53f1
2016-03-22 16:09:22 +05:30
Miklos Vajna
7ccb2c0a13 loolwsd: fix -Werror,-Wunused-private-field 2016-03-22 08:08:44 +01:00
Pranav Kant
1cfca1766c loolwsd: Add information about admin panel to README
Change-Id: Ic163eec1bdcae4f4b3fcc107c990f43e4b724c19
2016-03-22 01:02:45 +05:30
Pranav Kant
7f371958ae SSL everywhere
Use same port (9989) for all client connections. This includes
admin panel, static file serving and normal client websocket
connections.

Change-Id: Idcfd7dd8925523c36e884717c41a3b6a827f6ff3
2016-03-22 00:05:29 +05:30
Pranav Kant
7b763f0aff loolwsd: Allow specifying custom file server root
By default, use git directory root.

Change-Id: I4ee1173c43f313de3abb1732e6a7401169896189
2016-03-22 00:05:29 +05:30
Pranav Kant
06f1c874d6 loolwsd: Use JWT authentication to access admin console
File server serves the admin html file after successfull
authentication, and sets the cookie in client which would be sent
for all subsequent connections by client to connect to admin websocket.

Change-Id: I0ee3bbfca7eefc428020d29612374410556b1e27
2016-03-22 00:05:29 +05:30
Pranav Kant
4699e98c30 loolwsd: FileServer class to serve static contents
Only purpose, at the moment, is to create
Poco::HTTPRequestHandler which would be passed on the serving
handling the static file requests.

Change-Id: I97c3fc0c73da077d3efee919416098b880c9c2ad
2016-03-22 00:05:29 +05:30
Pranav Kant
4dd14c0024 loolwsd: SSL infrastructure
... and use SSL for client connections. Also fix our test suite
to use HTTPS now.

Change-Id: Id396a7c2d1830da8d3b0ce446522403363ac17c1
Reviewed-on: https://gerrit.libreoffice.org/23395
Reviewed-by: Tor Lillqvist <tml@collabora.com>
Tested-by: Tor Lillqvist <tml@collabora.com>
2016-03-22 00:05:26 +05:30
Tor Lillqvist
9a66e75e83 Revert "loolwsd: SSL infrastructure"
This reverts commit fb9c9a9ec7.
2016-03-21 16:52:55 +02:00
Tor Lillqvist
1ba4d27aba Revert "loolwsd: FileServer class to serve static contents"
This reverts commit 8f435d6e7e.
2016-03-21 16:52:54 +02:00
Tor Lillqvist
3ccce7d4ca Revert "loolwsd: Use JWT authentication to access admin console"
This reverts commit a0d3c5f3e4.
2016-03-21 16:52:53 +02:00
Tor Lillqvist
09d3c5f230 Revert "loolwsd: Allow specifying custom file server root"
This reverts commit a5f8ba44a2.
2016-03-21 16:52:46 +02:00
Pranav Kant
a5f8ba44a2 loolwsd: Allow specifying custom file server root
By default, use git directory root.

Change-Id: I4ee1173c43f313de3abb1732e6a7401169896189
2016-03-21 16:33:47 +02:00
Pranav Kant
a0d3c5f3e4 loolwsd: Use JWT authentication to access admin console
File server serves the admin html file after successfull
authentication, and sets the cookie in client which would be sent
for all subsequent connections by client to connect to admin websocket.

Change-Id: I0ee3bbfca7eefc428020d29612374410556b1e27
2016-03-21 16:32:41 +02:00
Pranav Kant
8f435d6e7e loolwsd: FileServer class to serve static contents
Only purpose, at the moment, is to create
Poco::HTTPRequestHandler which would be passed on the serving
handling the static file requests.

Change-Id: I97c3fc0c73da077d3efee919416098b880c9c2ad
2016-03-21 16:31:41 +02:00
Tor Lillqvist
9d85937a55 We need Poco 1.7.1 now after fb9c9a9ec7
At least Poco::Net::Context::Params is new in Poco 1.7.
2016-03-21 16:28:33 +02:00
Pranav Kant
fb9c9a9ec7 loolwsd: SSL infrastructure
... and use SSL for client connections.

Change-Id: Id396a7c2d1830da8d3b0ce446522403363ac17c1
Reviewed-on: https://gerrit.libreoffice.org/23395
Reviewed-by: Tor Lillqvist <tml@collabora.com>
Tested-by: Tor Lillqvist <tml@collabora.com>
2016-03-21 14:05:10 +00:00
Pranav Kant
14823f29b4 loolwsd: JWT Auth - Generation and verification of JWT tokens
Change-Id: If97fa52866f8d1d8976bd1a7340e2dac07e56c03
2016-03-21 15:56:00 +02:00
Pranav Kant
eeb22ce59d loolwsd: Move the authorizationCode to specialized OAuth class
To make room for other classes deriving from AuthBase that do not
require any authorization code, such as JWT authentication.

Change-Id: I69a35dd6f775badd7377949df2ca326c910d4021
2016-03-21 15:54:53 +02:00
Miklos Vajna
2563b3c848 loolwsd: add missing prefix in Admin 2016-03-21 08:59:15 +01:00
Tor Lillqvist
7bc2690497 More members can be private 2016-03-20 21:52:27 +02:00
Tor Lillqvist
26ccae2ac6 Add vim mode line 2016-03-20 21:52:27 +02:00
Tor Lillqvist
e55df2d021 The jailed processes are not "loolwsd" in any sense any more 2016-03-20 21:52:27 +02:00
Miklos Vajna
7a19ff3190 loolwsd: add Log::info() calls for paste 2016-03-18 18:08:41 +01:00
Henry Castro
979b4298b4 loolwsd: update discovery.xml 2016-03-17 19:48:34 -04:00
Andras Timar
638460381e package and deploy discovery.xml 2016-03-17 15:24:09 +01:00
Andras Timar
2b31359346 chmod -x 2016-03-17 15:22:35 +01:00
Henry Castro
3f93cdc1d1 Revert "loolwsd: read WOPI scheme, hostname from config values"
This reverts commit ad980bee02.
2016-03-16 19:58:44 -04:00
Henry Castro
ad980bee02 loolwsd: read WOPI scheme, hostname from config values 2016-03-16 16:45:20 -04:00
Henry Castro
8a6cfdf961 loolwsd: load default configuration files 2016-03-16 15:52:01 -04:00
Miklos Vajna
05f19cd7de loolwsd: fix -Werror,-Wunused-private-field 2016-03-16 09:11:56 +01:00
Henry Castro
bda64dbf2b loolwsd: fix get host from request 2016-03-15 19:16:58 -04:00
Tor Lillqvist
8fda553844 The /dev/random and urandom problem was a red herring
I had been using a file system mounted with nodev to test loolwsd.
2016-03-15 22:24:58 +02:00
Henry Castro
8a2bd1127b loolwsd: WOPI, handle request discovery 2016-03-15 11:35:59 -04:00
Henry Castro
ac09d89505 loolwsd: add libPocoXML 2016-03-15 11:22:45 -04:00
Andras Timar
213e678193 loolwsd: add DocumentBroker.hpp to dist 2016-03-15 13:25:00 +01:00
Jan Holesovsky
6b15dfd552 loolwsd, loleaflet: Rename 'connectionclose' to 'disconnect'. 2016-03-15 10:32:28 +01:00
Jan Holesovsky
2c1664b9d5 loolwsd, loleaflet: Let the server know when we are closing the session.
This is to distinguish the deliberate close of connection, and timeout,
connection drop, or forced close.

When the last session is closed non-deliberately, force a save so that the
edits are not lost.
2016-03-15 09:46:37 +01:00
Andras Timar
345f136145 loolwsd: fix -Werror,-Wshadow 2016-03-14 10:33:11 +01:00
Ashod Nakashian
981e83ece6 loolwsd: fixed convert-to (POST) tests
Change-Id: I6d48971b9daf0beaa16defa0b5f4dfb94575713c
Reviewed-on: https://gerrit.libreoffice.org/23228
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-03-14 03:18:03 +00:00
Ashod Nakashian
cc0a607185 loolwsd: fix tests to pass URL in GET request
Change-Id: Ia4027bfccca49f48feee52c9e4d86505cae02aa1
Reviewed-on: https://gerrit.libreoffice.org/23227
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-03-14 03:17:46 +00:00
Ashod Nakashian
66cd6cd5c3 loolwsd: improved DocumentBroker lifetime and thread handling
Change-Id: Ic8e16f0ec6b273165f7ba4e9b8d95003503530a6
Reviewed-on: https://gerrit.libreoffice.org/23226
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-03-14 03:17:24 +00:00
Ashod Nakashian
e0b14c0e22 loolwsd: give Broker the docKey, not URL
And reject connections with no doc URL.

Change-Id: I11490be6aaea6a4ca2d66d8d2c8d6b52e1e48a04
Reviewed-on: https://gerrit.libreoffice.org/23225
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-03-14 03:17:04 +00:00
Ashod Nakashian
c42ea2ea13 loolwsd: avoid complaining when killing exited child
Change-Id: If819cc2171d241d9e059f2b563cc8f6b8161d304
Reviewed-on: https://gerrit.libreoffice.org/23224
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-03-14 03:16:07 +00:00
Ashod Nakashian
f2eec85b2a loolwsd: jailId ought be random, but must be PID
Ideally, we will have a randomized path for the jails.

Unfortunately, this will make it harder to cleanup
after an ungraceful exit of a child, including recovery
of docs etc.

Having a PID for the jailId makes this issue easier by
implicitly implying the jail path for a given child.

To prevent security leaks, we should at least randomize
the doc directory within the jail, as such:

/chroot/<pid>/user/docs/<rand>/

For now we use jailId=pid=rand.

Change-Id: I948fba0aaef725c9c059780df0a184a86569d898
Reviewed-on: https://gerrit.libreoffice.org/23223
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-03-14 03:15:04 +00:00
Ashod Nakashian
29e9ba68c3 loolwsd: removed unnecessary childId, which is in the child URL
Change-Id: Ibea2cd73657446ad4660400a0a9a38b376499df5
Reviewed-on: https://gerrit.libreoffice.org/23222
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-03-14 03:14:43 +00:00
Ashod Nakashian
1aa7a6cf05 loolwsd: simplified DocumentBroker::create
Change-Id: Ia97be0861c7c178859d695ae5e2862e88cb3ca77
Reviewed-on: https://gerrit.libreoffice.org/23221
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-03-14 03:14:11 +00:00
Ashod Nakashian
0b18a67da2 loolwsd: DocumentBroker cleanup
Change-Id: Iedf2e0afd3c63d24b96ce1c7923c90d86d82bc13
Reviewed-on: https://gerrit.libreoffice.org/23220
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-03-14 03:13:53 +00:00
Ashod Nakashian
38c4acd5f0 loolwsd: moved document loading outside of MasterProcessSession
Change-Id: I8ecce82abcae6d0f07b86c188c91913ff9ca115a
Reviewed-on: https://gerrit.libreoffice.org/23219
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-03-14 03:13:37 +00:00
Ashod Nakashian
c6b47cc437 loolwsd: removed superfluous getJailPath
Change-Id: Iff11ea791866f31a47cf0d0b1d1fb06d18f5be40
Reviewed-on: https://gerrit.libreoffice.org/23218
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-03-14 03:13:02 +00:00
Ashod Nakashian
c0cf48f5ac loolwsd: jailRoot moved in DocumentBroker
Change-Id: Ic9dfce0cb0f2f87fae9a918df500c89673f15716
Reviewed-on: https://gerrit.libreoffice.org/23217
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-03-14 03:11:47 +00:00
Ashod Nakashian
bb16272e11 loolwsd: DocumentStoreManager -> DocumentBroker
Renamed DocumentStoreManager to DocumentBroker and
restructured the handshake process.

Currently, at first client connection to a given doc
a DocumentBroker is created to serve as the clearing house
of all client-side activities on the document.

Prime goals is loading and saving of the document, but
also to guarantee race-free management of the doc.

Each doc has a unique DocKey based on the URL (the path,
without queries). This DocKey is used as key into a map
of all DocumentBrokers. The latter is shared among
MasterProcessSession instances.

Change-Id: I569f2d235676e88ddc690147f3cb89faa60388c2
Reviewed-on: https://gerrit.libreoffice.org/23216
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-03-14 03:10:08 +00:00
Ashod Nakashian
8ef45a975e loolwsd: child URI now includes docKey
Change-Id: I62b91fee98fd853c84c3c5cbb48e65e5c9788ef0
Reviewed-on: https://gerrit.libreoffice.org/23215
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-03-14 03:09:14 +00:00
Ashod Nakashian
8d108a03b8 loolwsd: childId -> jailId
Change-Id: I56af542e6cf1d9cfd493b5033441d2c6a9edee2f
Reviewed-on: https://gerrit.libreoffice.org/23214
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-03-14 03:07:00 +00:00
Ashod Nakashian
019aed134e loolwsd: using random jailId
Change-Id: Ie9501e4346a124994270ca1fac61869ed04b9b72
Reviewed-on: https://gerrit.libreoffice.org/23213
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-03-14 03:06:29 +00:00
Ashod Nakashian
64d2ff98b8 loolwsd: document saving and restructuring
Change-Id: Ia4c644d07a16ba5284e9cdfaf7b838134fbf640b
Reviewed-on: https://gerrit.libreoffice.org/23212
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-03-14 03:06:13 +00:00
Ashod Nakashian
1268507bf0 loolwsd: child WS URL format changed
The current format is more flexible and standard.

/loolwsd/child?sessionId=xxx&jailId=yyy

The sessionId is the client-specific connection ID (which
 is originally passed to the child via the Broker.

The jailId is the PID of the child.

Change-Id: I69c88e84114f9678addf795896ca2da15ca1221b
Reviewed-on: https://gerrit.libreoffice.org/23211
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-03-14 03:05:38 +00:00
Ashod Nakashian
2a11e1840a loolwsd: improved creating kit sessions
Change-Id: Icc49dc37296fcc87928fc5d4fa4a6a18c3413deb
Reviewed-on: https://gerrit.libreoffice.org/23210
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-03-14 03:04:56 +00:00
Ashod Nakashian
0d8fcf5699 loolwsd: logging
Change-Id: I9a4dc248aca87983e3d7d3ace0071e5bbf92e688
Reviewed-on: https://gerrit.libreoffice.org/23209
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-03-14 03:04:17 +00:00
Ashod Nakashian
52d9e2033c loolwsd: improved WopiStorage with working PutFile
Change-Id: I2bba701ca0c89783851757e91e9336a64f6f6c52
Reviewed-on: https://gerrit.libreoffice.org/23208
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-03-14 03:03:30 +00:00
Ashod Nakashian
e014b0b22f loolwsd: Storage passed to DocumentStoreManager
Change-Id: Ifa7787dea5f558f166d02467c253375df88ae408
Reviewed-on: https://gerrit.libreoffice.org/23207
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-03-14 03:02:23 +00:00
Ashod Nakashian
f1007266e1 loolwsd: DocumentStoreManager shared by MasterProcessSession instances
Change-Id: Id7ada60387cafdf742690dbf345bb1e703b2ca76
Reviewed-on: https://gerrit.libreoffice.org/23206
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-03-14 03:01:48 +00:00
Ashod Nakashian
9bf88691c6 loolwsd: DocumentStoreManager maintains Storage instance
Change-Id: I0c86a7a7a3bb8d52a3f83570ccb4eded42ef4090
Reviewed-on: https://gerrit.libreoffice.org/23205
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-03-14 03:01:07 +00:00
Ashod Nakashian
73bde2b5d2 loolwsd: moved DocumentURI into own file and renamed to DocumentStoreManager
Change-Id: I5948ae532f0fd5917b99369733ec5ea36da2e437
Reviewed-on: https://gerrit.libreoffice.org/23204
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-03-14 03:00:35 +00:00
Ashod Nakashian
0ee9119bc7 loolwsd: refactored DocumentURI creation
Change-Id: Icc1043fdc717f057c97d2b00a5cfc399ee15aa79
Reviewed-on: https://gerrit.libreoffice.org/23203
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-03-14 02:59:49 +00:00
Pranav Kant
ea29196fed loolwsd: Periodic memory usage subscription
By default, queries and stores the total memory usage in
AdminModel every 5 seconds, and caches the last 100 such values.
Both cache size and interval can be changed by simple commands
from the clients.

Change-Id: I86cf8228d0129dc8aab0a03856c12dfeb240b169
2016-03-13 19:40:13 +05:30
Pranav Kant
d0006ae5d8 loolwsd: Wait for client threads to finish
Well, it was already there.
e7f75a3e56 was though correct
introduced it again. Remove duplicate such call.

Change-Id: Iddacbee53aaec58340db489e7830af75354aee34
2016-03-13 19:37:08 +05:30
Pranav Kant
2c3739bdc2 loolwsd: Fix a memory leak
Change-Id: I9a48c2846f74cb7cee8430dd4e72ba0580a7e7f2
2016-03-13 01:09:52 +05:30
Henry Castro
2e49729ff4 loolwsd: coding style minor correctness 2016-03-10 15:42:01 -04:00
Miklos Vajna
f6cae2ee2c loolwsd: fix -Werror,-Wshadow 2016-03-10 17:17:32 +01:00
Pranav Kant
3731f0c0d7 loolwsd: Avoid unnecessary copying
Change-Id: Iff888e5ff4577f20fae63a7b62ab1481ea2d71ed
2016-03-10 18:01:04 +05:30
Ashod Nakashian
237e0c0e9a loolwsd: minor cleanups and const correctness
Change-Id: Ic3b26e1fbf5feba1667bc3dc1737d037590a5928
Reviewed-on: https://gerrit.libreoffice.org/23109
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-03-10 04:24:30 +00:00
Ashod Nakashian
e8214c1d2a loolwsd: refactored Storage classes
Change-Id: I3cc3aa2c1ddf70b8d2f3489aa4047f6470c93eb2
Reviewed-on: https://gerrit.libreoffice.org/23108
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-03-10 04:23:16 +00:00
Ashod Nakashian
05f8757f1d loolwsd: colored logs enabled automatically in tty
It is desirable to have colored logs when running loolwsd
in a terminal, but not redirecting its output to a file.

Outputting to a terminal is now detected and colored logs
are automatically enabled.

To force colored logs in files as well, define
LOOL_LOGCOLOR in the environ. The output color codes
can then be processed using, f.e., `less -r`.

Change-Id: I09fbee4441f210d814ac5ad23dd99d1c33b560b7
Reviewed-on: https://gerrit.libreoffice.org/23080
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-03-09 13:27:15 +00:00
Ashod Nakashian
cef1d842f9 loolwsd: added user-agent and response header logging to WOPI GetFile
Change-Id: Ia7fba845d67b27c25accb8515a44c57eed112a9b
Reviewed-on: https://gerrit.libreoffice.org/23054
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-03-09 02:36:52 +00:00
Ashod Nakashian
e5fcdb890e loolwsd: corrections to file and wopi URI handling
Change-Id: I7389a30931be01a40714167039055a758187bd82
Reviewed-on: https://gerrit.libreoffice.org/23053
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-03-09 02:34:10 +00:00
Ashod Nakashian
978147df55 loolwsd: refactored path manipulation in Storage.
Change-Id: I320c5638353b03df4fd0be612bb66c26e4f498a3
Reviewed-on: https://gerrit.libreoffice.org/23052
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-03-09 02:33:39 +00:00
Ashod Nakashian
18a224b413 loolwsd: Color logs can be enabled by defining LOOL_LOGCOLOR envar
Change-Id: I12a38562f05c5d0b5d1c970a4b67240167322daf
Reviewed-on: https://gerrit.libreoffice.org/23051
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-03-09 02:32:47 +00:00
Ashod Nakashian
6c69519562 Storage is used to manage files locally
Change-Id: Id50eca8fe1136777ca99c60d78c15e1a47397993
Reviewed-on: https://gerrit.libreoffice.org/23049
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-03-09 02:31:47 +00:00
Pranav Kant
afb7e7dcff loolwsd: Make clients subscribe to commands
... for which they want to be notified.

Needed to add some missing header files to Storage and Auth class
because of conflict raised when LOOLWSD.hpp is included in
Admin.cpp

Change-Id: Ia1c8ed82f8cd979eaf93267ae5dfa347acf895f4
2016-03-08 15:14:14 +05:30
Pranav Kant
76542d8d52 loolwsd: Add total memory, total active docs, total active users
Further changes/refactoring to make it possible:
* Add broker pid to Admin class
* Move getMemoryUsage for process to Util
* Change variable name to accurately reflect *active* items
  _nViews -> _nActiveViews, etc.

Change-Id: I4c9206c49ab829b73ebfe226874bfbbcc8f95342
Reviewed-on: https://gerrit.libreoffice.org/22989
Reviewed-by: Tor Lillqvist <tml@collabora.com>
Tested-by: Tor Lillqvist <tml@collabora.com>
2016-03-08 09:34:51 +00:00
Pranav Kant
e366aa8e0b loolwsd: Support for killing children
Change-Id: Iab62a7e0dab7732f552a1b5f9eb5f67a5b96d74a
Reviewed-on: https://gerrit.libreoffice.org/22991
Reviewed-by: Tor Lillqvist <tml@collabora.com>
Tested-by: Tor Lillqvist <tml@collabora.com>
2016-03-08 09:33:12 +00:00
Pranav Kant
e7f75a3e56 loolwsd: Wait for all admin client threads to finish
Otherwise the process could terminate while admin sessions are still
being served.

Change-Id: Id91d0989e264e8294827e8e2ad8dd2d44b6006ec
Reviewed-on: https://gerrit.libreoffice.org/23021
Reviewed-by: Tor Lillqvist <tml@collabora.com>
Tested-by: Tor Lillqvist <tml@collabora.com>
2016-03-08 09:08:16 +00:00
Tor Lillqvist
e8a5ba1b29 _bShutdown is always false 2016-03-08 09:45:23 +02:00
Tor Lillqvist
e7e1ef58ae Cosmetics: Sort and prune #include and 'using' lines 2016-03-08 09:44:04 +02:00
Tor Lillqvist
61ee1ae842 Use std::getenv() instead of Poco::Environment::get()
Much simpler.

Also, don't duplicate the code informing that LD_BIND_NOW or
LOK_VIEW_CALLBACK are not set. Not that I understand why we need to
inform about that? If the "normal" thing should be that they are set,
why don't make it so by default then?
2016-03-08 09:16:01 +02:00
Tor Lillqvist
7d89cfa6f0 Clean up #includes and usings.
Include and use 'using' only for what is actually used. Sort the
include and 'using' lines.
2016-03-07 20:00:35 +02:00
Tor Lillqvist
9947633550 Catch IOException from sendTextFrame() in LOOLSession::disconnect()
Otherwise the uncaught exception will terminate the loolkit process
unexpectedly, which surely messes things up.
2016-03-07 20:00:35 +02:00
Tor Lillqvist
06c6a7e1a6 Try harder to avoid deadlock
I occasionally saw a deadlock when running 'make check' where one
thread holds the ChildProcessSession::Mutex and wants the _mutex for a
Document, while another thread holds that _mutex and wants the
Mutex. In particular, it is the Document::onUnload() that wants the
_mutex. So avoid the deadlock by having Document::onUnload() first
take the ChildProcessSession::Mutex.
2016-03-07 20:00:13 +02:00
Tor Lillqvist
9f67eecadd Improve exception logging
Always try to identify *where* we caught the exception. It is not that
useful to have half a dozen places that all just log "Exception:".
2016-03-07 18:36:01 +02:00
Tor Lillqvist
8fc4f1d95f 10 seconds is a bit short 2016-03-07 17:44:54 +02:00
Tor Lillqvist
d27e798e0f It is not only a 'segfault' that is handled here 2016-03-07 17:44:11 +02:00
Tor Lillqvist
80c6a91d5d Don't call setcap on loolkit before we have built it
On the other hand, loolwsd does not need capabilities any more.

Also update the comment to match reality, and explain in more detail
what is going on.
2016-03-07 13:10:45 +02:00
Tor Lillqvist
636fafa3b6 We use a recursive mutex, so no need to drop and re-take around documentLoad()
The callbacks from documentLoad() are made in the same thread.

Sure, as such it is not a good thing to use recursive mutexes. If we
switch back to non-recursive mutexes, we will have to stop taking the
lock in callbacks from documentLoad(), i.e. make sure we know those
functions aren't used elsewhere, in places where a lock would be
needed. Or something.

If a client session closes just after sending a load message to load a
document, and another session then fairly immediately connects and
sends a load message for the same document, the latter session gets
handled by the same kit process. Also, the same Document object is
apparently used. In that kit process, the first documentLoad() might
easily still be in progress. The handler for the new session still
calls onLoad(), too, and as the first onLoad() had dropped the lock
for the duration of the documentLoad() call, the new onLoad can take
the lock and call documentLoad(), too, while the first documentLoad()
call in the other thread still is in progress. This leads to
interesting problems.
2016-03-07 12:57:18 +02:00
Tor Lillqvist
0194e8d577 Use assert()
It is loolwsd that spawns loolbroker so we control what arguments it
gets, so no need to give verbose errors if our own code is
inconsistent. That is what assert() is for.
2016-03-07 12:57:18 +02:00
Miklos Vajna
0fc711c9a1 loolwsd: fix -Werror=maybe-uninitialized 2016-03-07 09:51:22 +01:00
Miklos Vajna
6ef8312357 loolwsd: fix -Werror,-Wshadow 2016-03-07 09:09:32 +01:00
Tor Lillqvist
80d9610432 Update from LO master 2016-03-04 12:09:14 +02:00
Tor Lillqvist
6859c85543 Factor out function to get the symbolic name for a LibreOfficeKitCallbackType 2016-03-04 11:49:46 +02:00
Tor Lillqvist
28fd1ace0c Make it clearer in the logging which callback is which 2016-03-04 11:32:25 +02:00
Ashod Nakashian
743311af21 loolwsd: added wopi storage manager
Change-Id: Ia28fb3d42c43387432e0b183a1bcf6b0924da820
Reviewed-on: https://gerrit.libreoffice.org/22885
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-03-04 03:06:28 +00:00
Ashod Nakashian
c980ece8bc loolwsd: preparing for wopi storage
Change-Id: Iae1bd042d84603cf81115789df40f50e8dc20d16
Reviewed-on: https://gerrit.libreoffice.org/22884
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-03-04 03:04:43 +00:00
Pranav Kant
ada6a74dc0 loolwsd: Basic layout and interaction with AdminModel
Admin web sessions are added as subscribers to AdminModel. Live
notification fill up the AdminModel, and notifies to
subscribers, if present any. AdminModel can also be queried to
fetch any previous data since the start of the server including
expired documents/views with timestamps for analysis.

There is lot of stuff that can be added in future. This commit
just lays the foundation of appropriate classes.

Change-Id: Ifcf6c2896ef46b33935802e79cd28240fd4f980e
Reviewed-on: https://gerrit.libreoffice.org/22869
Reviewed-by: Tor Lillqvist <tml@collabora.com>
Tested-by: Tor Lillqvist <tml@collabora.com>
2016-03-03 18:30:33 +00:00
Pranav Kant
c1ca746f66 loolwsd: Make notify pipe accessible from child processes
Change-Id: Id91a38c2997cfb359aff0a42d000e9659653598b
Reviewed-on: https://gerrit.libreoffice.org/22830
Reviewed-by: Tor Lillqvist <tml@collabora.com>
Tested-by: Tor Lillqvist <tml@collabora.com>
2016-03-03 18:28:40 +00:00
Pranav Kant
85c6467344 loolwsd: Move Admin class to separate header
As a test, add command to fetch documents from AdminModel.

Change-Id: I3cb7097ba7dde049f3b2478fe7b6b6c309da1d92
Reviewed-on: https://gerrit.libreoffice.org/22781
Reviewed-by: Tor Lillqvist <tml@collabora.com>
Tested-by: Tor Lillqvist <tml@collabora.com>
2016-03-03 18:26:55 +00:00
Tor Lillqvist
2103fe2515 Revert "We use a recursive mutex, so no need to drop and re-take around documentLoad()"
Turns out the callbacks from documentLoad() are in general done on
another thread, not necessarily the same one that did the
documentLoad() call. Not sure why it happened to be the same thread
for me, but oh well. Need to fix the problem described in
3671abf89b in some other way then.

This reverts commit 2fab757462.
2016-03-03 18:37:23 +02:00
Pranav Kant
1908613951 loolwsd: Factor out pipe reading polling logic
Change-Id: I7c06c68031ea14147130d21376ab348bdc672a7f
Reviewed-on: https://gerrit.libreoffice.org/22820
Reviewed-by: Tor Lillqvist <tml@collabora.com>
Tested-by: Tor Lillqvist <tml@collabora.com>
2016-03-03 16:23:21 +00:00
Tor Lillqvist
69a6167f0e Use better test names 2016-03-03 17:31:13 +02:00
Tor Lillqvist
06f56e646d Test harder 2016-03-03 17:14:15 +02:00
Tor Lillqvist
2fab757462 We use a recursive mutex, so no need to drop and re-take around documentLoad()
The callbacks from documentLoad() are made in the same thread.

Sure, as such it is not a good thing to use recursive mutexes. If we
switch back to non-recursive mutexes, we will have to stop taking the
lock in callbacks from documentLoad(), i.e. make sure we know those
functions aren't used elsewhere, in places where a lock would be
needed. Or something.
2016-03-03 17:14:15 +02:00
Jan Holesovsky
2590cd186e loolwsd: LOK_CALLBACK_PARTS_COUNT_CHANGED was removed from the API. 2016-03-03 11:13:34 +01:00
Jan Holesovsky
b442680d90 loolwsd: Update the bundled LOK headers. 2016-03-03 11:08:25 +01:00
Pranav Kant
c5aa122fcb loolwsd: Create notification pipe
... and Admin and AdminModel containing all the required data
that we need to expose to Admin panel.

Admin processor will keep listening to any data on this
notification pipe and update AdminModel accordingly.

Change-Id: I0dd6f07ae60158733c34d17f53a35def70600513
Reviewed-on: https://gerrit.libreoffice.org/22780
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-03-03 03:34:47 +00:00
Tor Lillqvist
d55ba592b4 Log also when the syncChildren() is done
It does quite a lot of work that can produce very many lines of log,
so it is good to be able to quickly find when that is done when
perusing a log file.
2016-03-02 16:51:53 +02:00
Tor Lillqvist
bf63df227b The payload can be null
It is always null at least for LOK_CALLBACK_STATUS_INDICATOR_FINISH.
2016-03-02 16:41:49 +02:00
Tor Lillqvist
fa0fd3303d Avoid logging \r\n here, too 2016-03-02 14:55:04 +02:00
Tor Lillqvist
38ddcf5243 Don't log the CR LF at the end of a response 2016-03-02 13:12:27 +02:00
Tor Lillqvist
02913dcbfc Use std:: consistently for cstdlib functions 2016-03-02 08:47:13 +02:00
Tor Lillqvist
73282c50d6 Make preinit the default. Turn off with LOK_NO_PREINIT 2016-03-02 08:26:15 +02:00
Tor Lillqvist
78579b3e57 Don't pretend to support non-Linux here either 2016-03-01 18:30:07 +02:00
Tor Lillqvist
d5292541bd Revert "Also chown the random devices to root:root and chmod to 666"
Not needed after all. It was a red herring. The device files work fine
even if not owned by root:root and with mode 664. The actual problem
was that I used a file system mounted with nodev when testing loolwsd.

This reverts commit 509314d559
2016-03-01 18:24:55 +02:00
Tor Lillqvist
4f701d5d84 Avoid aligning equal signs on sequential lines in a few arbitrary places
If we would use such style, we would need to do it consistently.
2016-03-01 17:28:47 +02:00
Tor Lillqvist
a959e99004 Make declaration of writeFIFO() match definition 2016-03-01 17:17:14 +02:00
Tor Lillqvist
8bc05765bf Make writeFIFO() return total number of bytes written if successful
That is probably what was the intent. As originally written, in case
the function encountered partial writers, and had to do several
write() calls, only the number of bytes written by the last one was
returned.

Luckily the actual return value of writeFIFO() is not used
anywhere. It is just tested for being negative.

Still there is the problem that if at first one or several write()
calls succeed but don't write the whole buffer, and then a write()
fails, the caller has no way to know that the buffer has been
partially written. But that is hopefully highly theoretical and there
is no sane way to handle such a situation anyway.
2016-03-01 17:15:40 +02:00
Tor Lillqvist
dc305b2b08 Don't confuse Poco::Util::Application::ExitCode and EXIT_SUCCESS/FAILURE
The getChildStatus() and getSignalStatus() functions returned the
latter, still the returned values were compared against
Poco::Util::Application::EXIT_OK. (Sure, both Poco's
Application::EXIT_SUCCESS and stdlib.h's EXIT_OK are zero, but that
doesn't mean one should mix them up.)

Also add two comments pondering the meaning of the code.
2016-03-01 16:49:12 +02:00
Tor Lillqvist
f560c64471 Document where LOOLExitCode comes from 2016-03-01 16:34:32 +02:00
Tor Lillqvist
248703c6f7 Bin leftover declaration of variable that is not defined anywhere 2016-03-01 16:28:56 +02:00
Tor Lillqvist
ec33f7b96a Don't use pre-increment when there is no need
We are not interested in the variable being assigned an incremented
value. Its value is not used any more. We are just interested in the
value of the variable plus one. Using pre-increment gives the wrong
impression.

Sure, this is nit-picking.
2016-03-01 15:53:35 +02:00
Tor Lillqvist
673b08bb81 We know that there is a = in the arg as we found a string that includes it
No need to to test again whether it is found. Also, std::strchr()
works fine.
2016-03-01 15:50:39 +02:00
Tor Lillqvist
f8aad3d31f Use the std:: versions of C standard library functions
As mentioned in the coding style part of README.
2016-03-01 15:44:22 +02:00
Tor Lillqvist
cdb0c08bb8 Let's be consistent 2016-03-01 15:27:36 +02:00
Tor Lillqvist
9cba13a53f Let's not pretend this could ever run on non-Unix
In fact, it is Linux-specific even, and has never successfully been
run on anything else, even if I tried for fun once to build it on OS
X.
2016-03-01 15:12:01 +02:00
Tor Lillqvist
aa4fe42d24 English 2016-03-01 13:25:09 +02:00
Tor Lillqvist
0cf40c50ea Anybody interested can check git log 2016-03-01 13:11:00 +02:00
Miklos Vajna
34fc0baacc loolwsd: indentation fixes in httpwstest
This file had a consistent style up to recently, keep it that way.
2016-03-01 09:55:06 +01:00
Miklos Vajna
f46a43b5f5 loolwsd: fix -Werror,-Wunused-parameter 2016-03-01 09:53:37 +01:00
Miklos Vajna
a010c01bd7 loolwsd: fix -Werror,-Wunused-private-field 2016-03-01 09:51:09 +01:00
Tor Lillqvist
9d655cbcc0 Don't pretend this will work on anything except Linux 2016-02-29 14:25:12 +02:00
Tor Lillqvist
29a3f58f1a The loolwsd program does not need any capabilities
So don't give it any then.

Remove the --uid option and related attempts to handle running loolwsd
under sudo, to be able to debug it. Now with loolwsd not having
capabilities, it should work fine to just run it under a debugger
normally. (For the loolbroker and loolkit processes, attaching to an
already started process is the way to debug.)
2016-02-29 14:13:19 +02:00
Tor Lillqvist
f0d7438f88 Add one more thing 2016-02-29 13:06:08 +02:00
Tor Lillqvist
509314d559 Also chown the random devices to root:root and chmod to 666
Otherwise they won't work. Not that I know whether this helps
anything, really. At least the NSS crypto initialization still takes a
long time.
2016-02-29 12:15:22 +02:00
Tor Lillqvist
d489f69372 Log also capabilities before dropping 2016-02-29 12:12:18 +02:00
Tor Lillqvist
b75c6a34b0 Grammar 2016-02-26 16:53:58 +02:00
Tor Lillqvist
e7a0b4f524 Mention one more problem 2016-02-26 16:52:27 +02:00
Tor Lillqvist
188ca79a6b Always complaining 2016-02-26 13:27:20 +02:00
Tor Lillqvist
ab3169ecdc Add some more Log::info() calls
We want to be able to see exactly when document loading and password
management is done and how long it takes.
2016-02-25 16:43:51 +02:00
Tor Lillqvist
3cad8c183a Seems that 10 seconds is not enough
One has to love arbitrary retry counts and timeouts. Loading the
password-protected.ods in a loolkit process, with correct password
provided, takes 12 seconds on my machine. I think this slowness is
because the NSS code LO uses to do crypto wants to initialize its
crypto goodness in various ways that don't work so well inside a
chroot jail. Presumably it uses some wait with timeout when attempting
to do something which doesn't succeed. For instance it tries to run
netstat -in. (In an interactive LibreOffice the doc loads fairly
instantly.) Oh well.
2016-02-25 16:22:07 +02:00
Tor Lillqvist
ff7a0ac8ee Add more verbose debug output...
Debugging this crack is really hard.
2016-02-25 15:57:55 +02:00
Tor Lillqvist
d88a798469 There is no setDocumentPassword() in ChildProcessSession 2016-02-25 14:36:50 +02:00
Tor Lillqvist
4b5e799a33 Split testPasswordProtectedDocument() into three
It does three separate things, and the first two intentionally result
in errors, and the server probably disconnects after errors. Not
sure. This is horrible, horrible.
2016-02-25 11:02:35 +02:00
Tor Lillqvist
bbcc2c43da I think it makes more sense to output to std::cout here
Because that is where cppunit outputs, I am told, so less chance of
out-of-order mixing, maybe.
2016-02-25 10:31:36 +02:00
Tor Lillqvist
3f107ed8ca Add snide comment 2016-02-24 17:48:03 +02:00
Tor Lillqvist
dbd5e3877d Don't send "disconnect" frames here either
The JavaScript code does not either.
2016-02-24 17:45:20 +02:00
Tor Lillqvist
bc7decb6ca No "disconnect" message is sent by our client JS code (and that is good)
Having a separate "disconnect" message is a disgrace. There should be
no need for it. WebSocket has a perfectly fine graceful disconnect
mechanism already (CLOSE frames). The code needs to be prepared to
receive a CLOSE frame at any time. The code also needs to be prepared
for the underlying socket being bluntly closed by the other end,
without sending any WebSocket CLOSE frame. The only sane thing is to
handle a "disconnect" message in the same way as those situations
anyway, so why is it needed?
2016-02-24 17:44:17 +02:00
Tor Lillqvist
46b43602fd No colours in the log, thanks
The escape sequences just make the log harder to read in an editor.
2016-02-24 15:35:32 +02:00
Andras Timar
277f86b7e9 loolwsd: bump version after tarball 2016-02-24 14:13:56 +01:00
Andras Timar
f35e13a936 loolwsd: bump version before tarball 2016-02-24 14:10:49 +01:00
Tor Lillqvist
c25f819e83 Yoda naming avoid 2016-02-24 09:46:53 +02:00
Tor Lillqvist
72c6cb8980 No LibreOfficeKit used in this file 2016-02-24 09:46:53 +02:00
Tor Lillqvist
07dc25641d Increase stylistic consistency
Sort #includes and using statements. Use 'using' consistently for all
Poco:: types. (I am not 100% convinced that using 'using' like done
here in loolwsd was a good idea after all. But at least let's be
consistent now that we do use it.)
2016-02-24 09:45:52 +02:00
Tor Lillqvist
32dc0a3c87 Don't ever attempt to handle the payload of CLOSE frames 2016-02-23 20:03:52 +02:00
Tor Lillqvist
7320d8ca51 Bin unused 'using' 2016-02-23 20:02:54 +02:00
Tor Lillqvist
79037b687e Log received messages to stderr 2016-02-23 20:02:29 +02:00
Tor Lillqvist
fbee03cae2 Minor clarification
No need to pass the value of a variable, initialised much earlier, to
a system call when one can pass the required constant value as
such. Much clearer.
2016-02-23 17:59:52 +02:00
Miklos Vajna
7552fcd806 loolwsd: work around -Werror,-Wunused-private-field 2016-02-23 09:35:46 +01:00
Miklos Vajna
ae07c555bb loolwsd: fix -Werror,-Winconsistent-missing-override 2016-02-23 09:32:25 +01:00
Tor Lillqvist
6af8a9bbc1 Avoid 'short' and 'signed' 2016-02-23 10:22:18 +02:00
Tor Lillqvist
674ceb90b9 Add comment 2016-02-23 09:28:48 +02:00
Tor Lillqvist
c9fef1eb7e Add comment about weird use of condition variable 2016-02-23 09:09:22 +02:00
Tor Lillqvist
00e3d6ca20 Cosmetics: add a space 2016-02-22 17:09:59 +02:00
Tor Lillqvist
819d5c23c0 Use all tokens 2016-02-22 16:31:24 +02:00
Tor Lillqvist
7ced4adc5e Just use "" instead of std::string() 2016-02-22 16:30:42 +02:00
Tor Lillqvist
72ff491fb2 Cosmetics: avoid trailing space in 'disconnect' message 2016-02-22 16:27:12 +02:00
Tor Lillqvist
ef30af121a Log a bit more information 2016-02-22 13:50:14 +02:00
Tor Lillqvist
5a69177f74 We are not interested in the payload of CLOSE frames 2016-02-22 13:50:14 +02:00
Andras Timar
33f66d4686 loolwsd: add new headers to distribution tarball 2016-02-22 11:16:05 +01:00
Tor Lillqvist
b4387a535a Bin some superfluous using declarations and includes, and actually use others
Sorry, could not resist. Obviously not very important.

In retrospect, maybe it would have been better to have as policy to
*not* use any 'using Poco::Foo'. Now there is an inconsistent mix of
writing out the complete type and using a 'using'. Plus copy-pasted
long lists of 'usings'. And of course, one should never have 'using'
in an include file. Oh well.
2016-02-22 11:37:47 +02:00
Henry Castro
fa4e3bcc86 loolwsd: use kill signal SIGINT 2016-02-21 14:48:05 -04:00
Pranav Kant
6722d430a5 loolwsd: Use helper functions for document password unit test
Change-Id: Ibf921ea1834f85b9a1d81232b1a018c1936fe620
2016-02-21 20:40:05 +05:30
Henry Castro
9b729b7a43 loolwsd: remove child jail path when the lokit process dies 2016-02-21 08:45:17 -04:00
Henry Castro
d835d53ff5 loolwsd: check last child exit code 2016-02-21 08:37:55 -04:00
Henry Castro
ba47e28581 loolwsd: re-work UriToDocumentURIMap
This is not in synchronization with lokit process because
it is normal that lokit dies now.
2016-02-21 08:26:29 -04:00
Henry Castro
730ec99194 loolwsd: ensure lokit process exited successfully after close the document and views 2016-02-21 08:10:30 -04:00
Henry Castro
b646fca95d loolwsd: add lokit iddle maintenance time out 2016-02-21 08:02:31 -04:00
Pranav Kant
f729156806 loolwsd: Fix misplaced break statement
Probably due to merge conflicts, it ended up in a wrong place.

Change-Id: Ia32e18149d99e901ceaa47a4e984f9ca818d0619
2016-02-21 14:08:00 +05:30
Henry Castro
cdc0ffb0cb loolwsd: add cppunit test partscountchanged 2016-02-20 17:14:10 -04:00
Henry Castro
c2413998be loolwsd: add partscountchanged protocol 2016-02-20 16:45:40 -04:00
Pranav Kant
d05f42df08 loolwsd: Rework document password unit test
Our unit test structure changed with
7037f07a38 . Restructure this one
too.

Change-Id: I1a14dd0ab0d631fd447edf620b6c24fe3730c843
2016-02-20 03:52:22 +05:30
Pranav Kant
b71ebb8dfc loolwsd: Ask for password for multiple views also
This is possible by moving all the password handling logic to
Document container class. When a user opens a password protected
document the first time, it saves all possible data such as
password, password type etc. Upon opening the same document
again, password is matched with the cached password saved in the
document container class before allowing the new view access to
this document.

Change-Id: Id1f2b6e06de806564bf865e83fed51b01c9a0fbc
Reviewed-on: https://gerrit.libreoffice.org/22208
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-02-19 22:00:46 +00:00
Pranav Kant
631ae0f11f loolwsd: Get the first *live* connection
Sometimes there are situations when `connection` map is filled
with dead sessions. We don't want to deal with those dead ones.

Change-Id: I00dda77c39b5adbba69421eace0be0159e02505c
Reviewed-on: https://gerrit.libreoffice.org/22207
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-02-19 21:57:10 +00:00
Pranav Kant
10db02c208 loolwsd: Move document related callback logic to Document class
There are 5 LOK callbacks currently that are triggered on LOKit,
and not on LOKitDocument. These include status indicators, and
document password callbacks during document load. Lets move all
the callbacks called during document load in the Document container
itself, and keep the callbacks called after document load in the
Child session.

Change-Id: I8e43c2baaa12023b34822954dd494780ee6dd7ca
Reviewed-on: https://gerrit.libreoffice.org/22206
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-02-19 21:56:50 +00:00
Pranav Kant
a2549e3df7 loolwsd: Disconnect the child if there is no client
Don't let them hanging around, otherwise we would keep sending
messages to a dead peer (ToClient) indefinitely.

Change-Id: I9d4bb6edee351bd31f1faa30deaa4f37c3c7d031
Reviewed-on: https://gerrit.libreoffice.org/22465
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-02-19 21:56:12 +00:00
Pranav Kant
7ecde23422 loolwsd: Remove superfluous registration of callback
Our DocumentCallback is smart enough which checks all the
running connections, and send the callback notification to all of
them. Registering the callback only during the first loadDocument
call should be enough.

Change-Id: I82bcb9525814dae14def3bfb6c088337d0d0ea3c
Reviewed-on: https://gerrit.libreoffice.org/22202
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-02-19 21:55:50 +00:00
Pranav Kant
b902d80ec7 loolwsd: Add a unit test for password protected documents
Change-Id: Ia675d2750e11cb466b2e80b8f36f2ef04e0a7a09
Reviewed-on: https://gerrit.libreoffice.org/22466
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-02-19 21:55:07 +00:00
Pranav Kant
3667bef9a6 loolwsd: Handle password protected documents
Change-Id: Iceb5bb598ef1517bf640994c27bad4ca36bd72c1
Reviewed-on: https://gerrit.libreoffice.org/21894
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-02-19 21:49:45 +00:00
Ashod Nakashian
13f9b7a2db loolwsd: Storage Abstraction support
An abstract Storage abstraction class is added.
There will be a factory to instantiate concrete
implementation for a given backend.

For WebDAV and similar hosted backends, authentication
and authorization will be done by the implementation
with the help of the Auth abstraction.

Change-Id: I38ec5dad4c2c4ce16df30d65826df96751b10e2d
Reviewed-on: https://gerrit.libreoffice.org/22513
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-02-19 21:45:25 +00:00
Ashod Nakashian
d8df19d064 loolwsd: Authentication and Authorization support
An abstract class to request an access token, given
an authorization grant. The class should be
specialized for each authentication/authorization
type we support.

Currently it's not enabled in the code as it's
an early stage in developing an general API.

Change-Id: I4f2efd376d575640bd3e17c7257994020b11bbe8
Reviewed-on: https://gerrit.libreoffice.org/22512
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-02-19 21:44:55 +00:00
Miklos Vajna
e3cc05ddcd loolwsd: fix indentation 2016-02-19 08:38:02 +01:00
Henry Castro
7037f07a38 loolwsd: re-work cppunit test websoket 2016-02-18 17:12:16 -04:00
Pranav Kant
9cf0cbf3a6 loolwsd: Allow sending 'tilecombine' messages with 'timestamp'
... and revert back with this parameter in 'tile:' response
messages so that client can identify the response.

This is also required to make client-side tile benchmarking tests
work again.

Change-Id: I307aabf622b17f4dce727d1faf3c83eb566ba905
2016-02-19 00:32:03 +05:30
Pranav Kant
cabb9d7fc3 loolwsd: Add a missing command, 'tilecombine' to documentation
Change-Id: Iedefef83cefca6e88e9676a0bc810ecb766b59ee
2016-02-19 00:32:03 +05:30
Henry Castro
e9de068423 loolwsd: fixes coding style naming convention rules in Util files 2016-02-18 13:00:37 -04:00
Tor Lillqvist
3d817e914e When running against a LOK_PREINIT=1 loolwsd, for some reason we get a BOM
So skip that.
2016-02-18 18:37:02 +02:00
Tor Lillqvist
7a97e1a1bc Remove pointless duplicated information from a log line
The log lines automatically have information telling which process
they come from.
2016-02-18 18:37:02 +02:00
Henry Castro
10070b11a9 loolwsd: fixes coding style naming convention in LOOLKit.cpp 2016-02-18 12:22:30 -04:00
Henry Castro
87718e288d loolwsd: fixes coding style naming convention rules in LOOLBroker.cpp 2016-02-18 10:07:37 -04:00
Miklos Vajna
bad184ced8 loolwsd: -Werror=shadow 2016-02-18 14:45:44 +01:00
Tor Lillqvist
54a2ca8b2b Fix typo 2016-02-18 15:42:45 +02:00
Tor Lillqvist
dd33957904 Mention that the "no Hungarian prefixes" rule is ignored 2016-02-18 12:10:48 +02:00
Henry Castro
76f405af98 loolwsd: add Log::info Preinit stage OK 2016-02-17 23:56:30 -04:00
Ashod Nakashian
7aeeab46f8 loolwsd: Admin manager added with a sample stats command
Change-Id: I7d3c1a5ab573d20d285c1c184cfb88ace17991f8
Reviewed-on: https://gerrit.libreoffice.org/22430
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-02-17 15:30:02 +00:00
Tor Lillqvist
46e2446db1 Update from LO master 2016-02-17 15:28:00 +02:00
Tor Lillqvist
446035ca69 Make the loTemplate path work inside the chroot, in the preinit case
Create a corresponding symlink inside the chroot.

Now a LOK_PREINIT=1 loolwsd starts up for me successfully. (Note: I
did not say whether it actually works. I don't know yet.)
2016-02-17 15:26:43 +02:00
Pranav Kant
da729a2b74 loolwsd: Add missing callbacks
We have a new callback now in LO core.

Change-Id: I560e5e31d08cf2b9969b8c5f9614630c29ee89c6
2016-02-17 16:24:13 +05:30
Tor Lillqvist
268c48c473 Minor edit 2016-02-17 12:43:03 +02:00
Tor Lillqvist
86f1e5087c Say that running 'make check' is mandatory
(Too bad that it is broken after
9e3d5c0337f9cd1439d4b6b648eb6ac795ff792e.)
2016-02-17 12:35:15 +02:00
Andras Timar
a178d445cd loolwsd: setcap loolkit 2016-02-17 10:42:00 +01:00
Henry Castro
a607159a8a loolwsd: catch exception requestTermination 2016-02-16 17:25:51 -04:00
Henry Castro
9b4099c41c loolwsd: check if the named pipes exists 2016-02-16 17:13:14 -04:00
Henry Castro
3ad641c7bd loolwsd: check if the pipe path exists 2016-02-16 17:04:21 -04:00
Tor Lillqvist
33ecd5ea2d Introduce environment variable SLEEPKITFORDEBUGGER
Sleeps a "kit" process after fork() for the specified number of
seconds to give you time to attach it in the debugger.

Also, if set, have the parent ("broker") process wait indefinitely the
fifo to become writable.

Also clarify the informative message for SLEEPFORDEBUGGER.
2016-02-16 10:49:42 +02:00
Ashod Nakashian
90776a3c0d loolwsd: control preinit vs fork using envars and disable bind-now
Change-Id: I63dffa18da69751ab72463bb64065d235d811db5
Reviewed-on: https://gerrit.libreoffice.org/22381
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-02-15 23:18:24 +00:00
Tor Lillqvist
b276c3541c Probably we should pass loTemplate to globalPreinit(), not loSubPath
globalPreinit() does not run in a chroot as far as I see, so trying to
use loSubPath as an absolute path will not work. Probably what was
meant is loTemplate, then the libraries at least are found.
2016-02-15 22:59:03 +02:00
Tor Lillqvist
c62d612562 Clean up error reporing
If neither libsofficeapp.so or libmerged.so exist where we look for
them, say so explicitly.

Log the error message from dlerror(), too.

Log the mesage about not forking in all cases when doing that, not
just if lok_preinit is not found.

Execing is not an alternative to fork(), spawning is.
2016-02-15 22:33:56 +02:00
Henry Castro
45754cc36c loolwsd: remove unused TerminationState 2016-02-14 23:08:59 -04:00
Pranav Kant
93fdcb34c4 loolwsd: Do not unload without a successfull load
A load document operation may fail, for example, when user enters
a wrong password or no password. In such cases ToPrisoner sends a
disconnect to child. Child do not need to take any steps in this
case, such as, decrementing the view counter, because nothing was
loaded.

Change-Id: Ib71f871aa1728c6355563362987800dece1679d3
Reviewed-on: https://gerrit.libreoffice.org/22203
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-02-15 00:31:29 +00:00
Henry Castro
cdcb32f013 loolwsd: loolbroker drop capabilities 2016-02-14 14:54:04 -04:00
Henry Castro
f5c163e6da loolwsd: avoid deadlock with mutex and join 2016-02-14 14:39:02 -04:00
Henry Castro
42abb3b1a7 loolwsd: websocket shutdown receive 2016-02-14 14:32:55 -04:00
Henry Castro
72db8ed63a loolwsd: replace the random jail id for lokit process id 2016-02-13 19:01:03 -04:00
Henry Castro
75b552bf71 loolwsd: create named pipes workspace 2016-02-13 13:22:15 -04:00
Henry Castro
9e3d5c0337 loolwsd: ensure chroot jail every lokit process 2016-02-13 10:15:28 -04:00
Tor Lillqvist
8a571401c0 Use less misleadit variable name 2016-02-12 14:09:29 +02:00
Tor Lillqvist
9a15bc6c2c Zero is a valid return value from open()
Sure, it is highly likely that fd 0 is already in other use, but let's
be correct.
2016-02-12 14:01:10 +02:00
Tor Lillqvist
d19433c3b8 Bin unused macros 2016-02-12 13:31:32 +02:00
Tor Lillqvist
ce3dc628be Fix misleading comment 2016-02-12 13:26:19 +02:00
Tor Lillqvist
39bfd5a210 Look for self-copmpiled Poco also in /opt/poco
That's where I have it...

Also, make sure such self-built Poco libraries themselves get copied
into the systemplate.
2016-02-12 13:23:41 +02:00
Andras Timar
97dcfdc7e8 loolwsd: bump version after tarball 2016-02-11 22:33:44 +01:00
Andras Timar
76b72c8008 loolwsd: bump version before tarball 2016-02-11 21:55:36 +01:00
Pranav Kant
6a7a014d14 loolwsd: Remove cached 'status' command output on 'setclientpart'
Otherwise we have a problem when cached information is different than
the actual one maintained by LOKitDocument, keeping the whole
server setup in an inconsistent state.

For example, when client reloads the browser session quickly
after setting the current part (to say 3) of an opened part document.
If the reload occurs soon enough before the 'setclientpart'
message originated from the client is acknowledged by the server,
then the next reload would get the cached 'status' entry asking
the client to set 'currentpart' to something else leading to the
generation of another 'setclientpart' message. This thing would
go on, and we would run into a loop, as I have for the last few
hours.

Change-Id: Ia6260dfb772f2e3f023572aa060fd7da92b196c8
Reviewed-on: https://gerrit.libreoffice.org/22272
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-02-11 05:04:22 +00:00
Jan Holesovsky
93b65fc92f loolwsd: For the legacy loleaflet, default to the left button pressed. 2016-02-09 09:22:11 +01:00