Commit graph

549 commits

Author SHA1 Message Date
Ashod Nakashian
13d7d23cbe wsd: use chrono for readability and conversion safety
Change-Id: If5d478605fef0199b331d91310673a460e70d48e
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2020-12-22 11:24:13 -05:00
Ashod Nakashian
693ac2fa52 wsd: logs and const
Change-Id: Id7e4f81ab9709b62eddfa747479ab593a5ad45a2
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2020-12-22 11:24:13 -05:00
Jan Holesovsky
c44609532a Root actually has all the capabilities.
Signed-off-by: Jan Holesovsky <kendy@collabora.com>
Change-Id: If49be334cb1380daf1eaf24c7007f1b004754304
2020-12-18 23:15:57 +01:00
Gleb Popov
292aa7e9b5 Stub out hasAnyCapability for !Linux platforms.
Signed-off-by: Gleb Popov <6yearold@gmail.com>
Change-Id: I22e33cc15420747d120bd10466eb29679b66709f
2020-12-17 11:52:18 +00:00
22shubh22
458d2b4eed Remove unwanted Poco::Timestamp functions
Signed-off-by: 22shubh22 <22shubh22@gmail.com>
Change-Id: Ie042253d2b99237537bac450a4b3b673606a84a9
2020-12-16 13:16:37 +03:00
Ashod Nakashian
2bb3ebb86e wsd: don't trust modified time when comparing files
We shouldn't assume two files are different just
because one was touched recently. This is an issue
when we think systemplate is out of date when it isn't.

Since we only do this file comparison on (very) small
/etc files, it's simply safer to compare the files
when their sizes are the same, instead of assuming
that timestamps are indicative of being outdated.

Ironically, by comparing the contents we spawn
jails faster when there is nothing to update
and we can safely use bind-mount.

Change-Id: Idb2088fcb52b493c91bef92890750f1dfcfbcc25
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2020-12-15 21:00:28 +00:00
Ashod Nakashian
583c627a66 wsd: avoid single-character strings
Change-Id: I709e8e797bc5e68984823d8c46c590e109d23f18
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2020-12-09 17:19:58 +01:00
Ashod Nakashian
8298fdb2d6 wsd: cosmetic and consts
Change-Id: Ibb4bb7c527f68786bd6288b407008a3e3a7b2e17
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2020-12-09 17:19:58 +01:00
Ashod Nakashian
ba4e52e7b9 wsd: log: overload chrono duration to simplify logging
Also, makes the logging of units much less error prone.

The overloaded streaming operators are temporary as
they are provided in C++20. The ones here (though
incomplete) are fashioned after the C++20 specs.

Change-Id: Ieb499282ccb6e63fa939ba07bed3e5a4fbef1bd0
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2020-12-08 09:26:41 +00:00
Ashod Nakashian
47630f826e wsd: use steady_clock for measuring time interval
chrono::system_clock can go back in time.
For time interval measurements, where we don't
care about the local time, a monotonic clock
should be used.

This avoids the server uptime jumping around
with daylight saving (or indeed by regular
synchronization with an atomic clock), among
other cases.

Change-Id: I09f9b24c82d19439348a2e66cad9e9de7d755208
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2020-12-08 09:26:41 +00:00
Jan Holesovsky
d9708437b2 Compare string the c++ way + clarify the message for the user.
Signed-off-by: Jan Holesovsky <kendy@collabora.com>
Change-Id: I32c4667380301853b1a89b35fc0480849f75b14c
2020-11-30 11:24:31 +01:00
Miklos Vajna
10c1885a83 fuzzer-clientsession
The fuzzer ran out of memory, 955443527 bytes (79%) of the used memory
was this map.

Change-Id: I2dd84a094d3dd3d98618667e3c78591e2193bce2
Signed-off-by: Miklos Vajna <vmiklos@collabora.com>
2020-11-30 10:17:43 +01:00
Ashod Nakashian
c74a17545e wsd: log something sensible when a dynamic file is missing
Change-Id: I9af5e0f9de8431f5a639710483a79d3944d4c683
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2020-11-29 19:27:23 -05:00
Ashod Nakashian
b87495a791 wsd: test: add Buffer test and minor cosmetics
Change-Id: Ie4ac80984523ecd32fd81238496253b6a4015692
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2020-11-29 19:27:23 -05:00
Michael Meeks
5fb3a7d8bd Remove obsolete locking and conditions around MessageQueue
Should no longer be needed since the unipoll transition.

Change-Id: Ie534cad7da0cfa54099175a86bc28dd16c738890
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2020-11-24 12:32:45 +01:00
Ashod Nakashian
d4857b603b wsd: cleanup temp incoming directories after use
The temporary directories created for convert-to
and insertfile are used only once and should be
cleaned up to avoid clutter.

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

Change-Id: Ie1fd5b4749788ff4407f2cc886d405258f65f97a
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2020-11-23 21:29:34 -05:00
Ashod Nakashian
f60753a951 wsd: misc cleanup
Change-Id: Ief6cbc40ef2f7d98b0b76477109332676dab45b2
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2020-11-22 22:26:36 -05:00
Ashod Nakashian
f665816812 wsd: getTempFilePath -> getTempFileCopyPath
These helpers are for testing only. They should
ideally be moved to the test helpers, but because
of dependency on the FileDeleter in FileUtil they
remain in FileUtil.

Change-Id: I93c7e08823edec8f6a53419f0a6596f3255f23f9
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2020-11-22 22:26:36 -05:00
Ashod Nakashian
3724ab4e35 wsd: centralize temporary directory helpers in FileUtil
Change-Id: I9b55d0b8d4c55a68af4baa7e638627de6c73b64d
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2020-11-22 22:26:36 -05:00
Ashod Nakashian
054ab5f61f wsd: specialize thread ID serialization
On non-Linux systems we should default to std:🧵:id
which needs to be serialized using ostream interface.

While Util::getThreadId does specialize for Linux, the
code using it doesn't always handle the different return
types.

While std:🧵:id is the standard interface to the
thread ID, using such abstraction has proven to be costly
when converting the thread ID on each and every log via
ostringstream (due to the cost of memory allocation).
In practice Linux is the primary and so far only platform,
so the getThreadId is optimized for it. Other systems
can either use the default std:🧵:id, or can also
specialize as necessary.

Change-Id: I91cf279a8fdff12636a534957db5069dee51bd65
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2020-11-21 19:49:46 -05:00
Gleb Popov
854065200c Do not try to convert std:🧵:id to integer value.
This is not allowed by the standard and libc++ is more stricter than libstdc++ on that matter.

Luckily, the conversion is used to turn it into a string, so just use stringstream to convert the thread::id directly.

Signed-off-by: Gleb Popov <6yearold@gmail.com>
Change-Id: Iea1a844a086b7fe7ed4703fd06e1d538d5d0bc43
2020-11-21 19:49:46 -05:00
Ashod Nakashian
3382dad05c wsd: const correctness and string ctor instead of literal
Change-Id: Id6b9ca28b09d11344d47099a2244e189afe14841
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2020-11-19 10:12:38 +00:00
mert
5418b4b19b Make AutoSpellChecking option state remembered on first start
Change-Id: I25823025e35ba6f580b03834979fb0bea616bcc1
Signed-off-by: mert <mert.tumer@collabora.com>
2020-11-17 14:55:31 +03:00
Gleb Popov
f7faaad790 Replace all __linux in CPP conditions with __linux__.
Signed-off-by: Gleb Popov <6yearold@gmail.com>
Change-Id: If3e213b1cf1f3c4ab960276fc6edfb71f9416420
2020-11-17 09:21:45 +00:00
Gleb Popov
aa97476f07 Util.cpp: Do not call setpriority for thread handles on non-Linux systems.
Change-Id: I50cdc429cd606e261c70219e51587a54a269b082
Signed-off-by: Gleb Popov <6yearold@gmail.com>
2020-11-16 14:02:23 +00:00
Gleb Popov
3930ea86a3 FileUtil.cpp: Fix building on FreeBSD.
Change-Id: Ifed1e69284724c702b53c5fbf6940c821421cdbb
Signed-off-by: Gleb Popov <6yearold@gmail.com>
2020-11-16 14:02:23 +00:00
Gleb Popov
414dd5de58 Seccomp.cpp: Fix building on FreeBSD.
Change-Id: Ie492e1f184bf1a2255a7ab03a9d61ecdca116560
Signed-off-by: Gleb Popov <6yearold@gmail.com>
2020-11-16 14:02:23 +00:00
Gleb Popov
a90bbc9223 Log.cpp: Extend #ifdef conditional to FreeBSD case.
Change-Id: I8aa4a7da9e43a606e1555a1751dd5d710d290ce8
Signed-off-by: Gleb Popov <6yearold@gmail.com>
2020-11-16 14:02:23 +00:00
Ashod Nakashian
cb4beaca34 wsd: avoid the using keyword and use C++ size_t
size_t in C and in C++ are not necessarily the same
type. The C++ size_t is in the std namespace. Since
we do include many C headers, and indeed some C++
runtime headers do define size_t for backwards
compatibility, it's easy to mix and match the two
types.

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

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

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

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

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

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

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

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

Change-Id: I63dc30f9a047e3f889fd339b6aaf392b9fef37b9
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2020-11-14 19:56:09 +03:00
Ashod Nakashian
b5921288de wsd: comment typo
Change-Id: Ie75ae1cc73791af2e8f52b7ccab438b7adbd795e
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2020-11-11 08:14:42 +01:00
Ayhan Yalçınsoy
c1b8a64fce Remove Poco/TimeStamp.h left-over
Change-Id: I78f76266a50f799306dcfd8ec996db54784acfd8
Signed-off-by: Ayhan Yalçınsoy <ayhanyalcinsoy@pisilinux.org>
2020-10-26 03:30:32 +03:00
Ashod Nakashian
2af764bcb8 mount: handle /dev directory creation failure
Change-Id: I053cb17418daa086f0ac47961dd9880e2a5845af
2020-10-20 09:54:19 +02:00
Ashod Nakashian
50943eeea2 wsd: gracefully warn when /dev/random cannot be created
Change-Id: I5a9c291da48c4a1446057247f9b8400f9010b9dc
2020-10-19 07:34:26 +02:00
Ashod Nakashian
f9402ea965 mount: handle symlinks and improve updating systemplate
We should have no symlinks in the jail whatsoever, except
those we create to files known to exist in the jail.

Unfortunately, some systems have some of the /etc files
as symlinks. When we create hard-links to these files,
they can't be accessed from the jail, since the path
they point to isn't replicated in systemplate and jails.

First change here is to always link to the source file or,
when copying, to copy the source rather than a symlink.

Next, to detect modifications, we compare not just the
size and timestamp, but also the contents. This way we
can be certain that any modification will be detected.

Finally, when we copy at least one file in the
systemplate/etc directory, we flag it by creating the
'copied' file. This way we have a reliable indicator
and don't need to second guess if the files are
hard-linked or copied.

We also avoid some noisy errors when we fail to update
systemplate when it's read-only by first checking
if systemplate is writable or not and insue a friendly
log instead.

Change-Id: Ie8c3e70ea4ec19ee098309f8666c00639fa7319b
2020-10-19 07:34:26 +02:00
Pranam Lashkari
a992cfcd23 wsd: correction in conversion from timestamp to ISO8601
closes #168

Change-Id: Ibdb1aa72a6961d4707c2336382cc593c984d3615
2020-10-16 04:27:53 +05:30
Miklos Vajna
11897f2db7 Introduce Util::make_unique()
In the old code, if the evaluation first allocates the memory for the
raw pointer, then calls firstLine() and an exception is thrown before
the std::unique_ptr construction, then the memory is leaked. Using
make_unique() has the benefit of avoiding this problem.

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

Change-Id: Iaf3d8051a8a0627a57fdf1196bde7d5f8612fcff
2020-10-08 09:53:37 +02:00
Ashod Nakashian
eb122ec0a0 wsd: allow URIs without access_header or access_token
URIs may or may not have authorization data specified
via access_header or access_token query parameters.

In the event that the host doesn't have such needs
(for example authrorization could be performed by
some other means), we should accept the request
and still go ahead and make the WOPI request
all the same.

This patch effectively reverts the changes from
a019c93d90 which threw
an exception when the authorization method was
undefined. Since there was an assertion to warn
programmers that something is amis, now we simply
log the fact in trace mode and move on.

A new unit-test is added and another one that
expected the now-removed exception has been modified.

Change-Id: I26cc2514d7465b344037a6e32b777c0fe0ba9a2c
2020-10-07 08:13:29 -04:00
Andrea Gelmini
9d01540680 Fix typos
Change-Id: I7d487f32ca43e19023760ef3c6bb1683607f93d1
2020-10-07 12:51:08 +02:00
Andrea Gelmini
b2360fec3a Removed duplicated include
Change-Id: Id6ba6e769b3c0ec5493ee32e2abbc00e441388ec
2020-10-07 12:48:04 +02:00
Andras Timar
0002fdfd6c fix license headers
Change-Id: I8623770b32d278a45357dc7f757fabfadd2b4af7
2020-10-01 11:56:43 +02:00
Gabriel Masei
95c9c58f5b remove .uno:ModifiedStatus message from deduplication mechanism
This fixes the following issue in Online:

When a save is performed while a cell is still edited the save icon
does not reflect the correct state of the document: it shows that
the document is dirty although it is not.

This works only in conjunction with the following commit from core:
-lok: remove .uno:ModifiedStatus message from deduplication mechanism-

Change-Id: Ie671097ef2b206c8801a5bdfc2b908ee260951fb
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/103084
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Jan Holesovsky <kendy@collabora.com>
2020-09-21 14:51:10 +02:00
mert
115bb1b652 Fix unable to open password protected documents on mobile
Change-Id: Ifd67cb6f3640784176abfe483f0364c1dfe4b5d9
Signed-off-by: mert <mert.tumer@collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/102388
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Andras Timar <andras.timar@collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/102729
2020-09-15 15:14:40 +02:00
gokaysatir
1951fdbd42 lool: php proxy simulation.
Change-Id: I5ea5515e317242f2ad2abd3209ce0241d64b631b
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/97820
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Tamás Zolnai <tamas.zolnai@collabora.com>
2020-09-09 15:50:10 +02:00
Hillwood Yang
215a76e213 Support ppc64
Change-Id: I28c44b6ccc58cd49cc9c45e19e92047cabcc185d
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/102071
Tested-by: Jenkins
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
2020-09-07 18:19:55 +02:00
Gülşah Köse
845554a6a3 Revert "wsd: parse headers with Poco::MessageHeader"
This reverts commit dbc562d9ab.

tst-05694-05694 2020-08-26 12:59:14.343136 [ unittest ]
ERR Invalid HTTP header [def]: Malformed message:
Field name too long/no colon found| ../common/Util.cpp:980

Following part of the code tests a request with corrupted http header:
    Authorization auth2(Authorization::Type::Header, "def");
    Poco::Net::HTTPRequest req2;
    auth2.authorizeRequest(req2);
    LOK_ASSERT(!req2.has("Authorization"));

Poco library throws exception.

Change-Id: Ic31a80c0e1e325de27c23059e2bcb3f00d39ad16
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/101887
Tested-by: Jenkins
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Gülşah Köse <gulsah.kose@collabora.com>
2020-09-01 23:17:03 +02:00
Ashod Nakashian
9f5bd85008 wsd: use a shared threadname suffix for each document
The use of a common threadname suffix in the WSD and Kit
processes is intentional. It is designed to help filter
for a single document's logs across both processes.

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

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

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

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

(This reverts 2a16f34812)

Change-Id: Ic6fe2f9425998824774d2644fe4362e75dea6b88
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/101261
Tested-by: Jenkins
Tested-by: Tor Lillqvist <tml@collabora.com>
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Tor Lillqvist <tml@collabora.com>
2020-08-26 17:47:50 +02:00
Ashod Nakashian
29a5a1f1e9 wsd: move jail setup to the script to support readonly systemplate
We now gracefully fallback to copying when/if systemplate
is readonly.

The bulk of the change is to support proper cleanup in
both cases.

First, we had to move as much of the jail bootstrapping
into the loolwsd-systemplate-setup script, so systemplate
will be as complete as possible before it is locked down.
Next, we needed to update the jail with graceful fallback
to linking/copying upon failure. For that, the jail setup
logic in Kit.cpp has been reworked to support not just
update failures, but also more comprehensive mounting
failures as well.

Finally, jail cleanup now is seamless. To support proper
cleanup when we had mounting enabled but had to fallback,
we mark jails that aren't mounted so we can 'rm -rf' the
contents safely and without fear or causing undue damage
(as unlikely as that is, technically we wouldn't want to
rm systemplate files, if mounting read-only had failed).

There are a few minor refactorings of JailUtil to make
it cleaner and more robust.

Change-Id: Iac34869cb84f45acf64fbbc46d46898367b496d2
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/101260
Tested-by: Jenkins
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Andras Timar <andras.timar@collabora.com>
2020-08-25 07:58:30 +02:00