Commit graph

563 commits

Author SHA1 Message Date
Tor Lillqvist
5e8be7005b Bin unused function
Change-Id: I9217193534bbed8f55faaa105b603e1560b1519a
Signed-off-by: Tor Lillqvist <tml@collabora.com>
2021-01-21 16:12:55 +02:00
Michael Meeks
4e92b5a697 Special case opacity to avoid arithmetic where possible.
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Change-Id: I37a72bc966424ca1b4c30b31d9fcf88d15c11789
2021-01-16 12:18:24 +00:00
Michael Meeks
673c3cfb98 Remove un-used _isLoading and ScopeGuard.
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Change-Id: I0f7536023cbbef52087c3110565d046dd1ab8835
2021-01-13 16:55:35 +00:00
Shubham Goyal
3a3867e1c6 Resolve #805 : Remove Mutex lock
Signed-off-by: Shubham Goyal <22shubh22@gmail.com>
Change-Id: I80da9d085590e67c0998ce971225a8c9903c0bb7
2021-01-13 16:55:35 +00:00
Ashod Nakashian
15b6ddccd0 wsd: test: move inherited filterSendMessage to onFilterSendMessage
This allows the UnitBase class to handle the messages
and dispatch to convenient handlers. This simplifies
the implementation of unit-tests and makes the
parsing more centralized than it is now.

Change-Id: Ice8f169ecfd12d49ee7cbd4fb9021a163b14f4ba
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-01-13 08:07:06 -05:00
Ashod Nakashian
1fb968ac08 wsd: test: remove redundant wakeupWorld and log the exit status
And introduce passTest and failTest to log a reason
and be more informative when reading logs.

Change-Id: I5090793b802a29135de8ea3783a457e189cc7df3
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-01-13 08:07:06 -05:00
Andras Timar
2dc31a7648 check if we run in a container
* and fix error reporting: we do not abort every time when loolforkit
  is invoked with incorrect user name

* and better readability of the conditions

Signed-off-by: Andras Timar <andras.timar@collabora.com>
Change-Id: Idc9db40c00d41c95160db130eb324c487f14de17
2021-01-12 22:24:28 +01:00
Michael Meeks
317dffb817 Optimize copy of jails to hard-linking with new capability.
In some cases we cannot do a fast bind-mount of the files we want
in our jail since we don't have cap_sys_admin for loolmount inside
eg. docker.

Thus we need to fallback to hard-linking, however various security
systems namespace parts of our tree, such that link() fails with
EXDEV even across the (apparently) same file-system.

As such we need to assemble a copy of what we want to hard-link
close to our jails. However, this needs to be owned by root / the
system to avoid having writable files shared between jails. Hence
we need cap_chown in addition to cap_fowner, to get ownership right
and then hard-link.

Change-Id: Iba0ef46ddbc1c03f3dc7177bc1ec1755624135db
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2021-01-04 15:05:36 +00:00
Ashod Nakashian
01138d7ae0 wsd: save errno before invoking any other functions
Most C and Posix API clobber errno. By failing to save
it immediately after invoking an API we risk simply
reporting the result of an arbitrary subsequent API call.

This adds LOG_SYS_ERRNO to take errno explicitly.
This is necessary because sometimes logging is not done
immediately after calling the function for which we
want to report errno. Similarly, log macros that log
errno need to save errno before calling any functions.
This is necessary as the argements might contain calls
that clobber errno.

This also converts some LOG_SYS entries to LOG_ERR
because there can be no relevant errno in that context
(f.e. in a catch clause).

A couple of LOG_ macros have been folded into others,
reducing redundancy.

Finally, both of these log macros append errno to the
log message, so there is little point in ending the
messages with a period.

Change-Id: Iecc656f67115fec78b65cad4e7c17a17623ecf43
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2020-12-29 11:40:17 +00:00
Ashod Nakashian
0072a4080e wsd: test: log timeout better
Change-Id: I3643a2bad8611d1f6402615435295717eb2e93c1
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2020-12-28 12:04:53 -04:00
Ashod Nakashian
d2e29d592a wsd: test: httpcrashtest drain using the getErrorCode helper
Reading the messages using a different helper means
we may miss (=consume without checking) the close frame.

Change-Id: I93a529723ba8d2b516319d54496c56c7e6d7da27
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2020-12-28 12:04:53 -04:00
Ashod Nakashian
96c9e03b88 wsd: test: catch and fail WSD tests when exceptions are thrown
Change-Id: Ifaabb6387d86c5a80e00cd5de34093520a1e9d66
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2020-12-28 12:04:53 -04:00
Ashod Nakashian
7972ded44f wsd: test: log test assertions
Change-Id: Ibf9274b1812f70f54ccd4e7be991b08a11f36c86
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2020-12-28 12:04:53 -04:00
Ashod Nakashian
3b4add03ef wsd: test: store the current test name in UnitBase
Change-Id: Iaf521f6a99dcd6e6465769aed7f3757332e04f7d
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2020-12-28 12:04:53 -04:00
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