Commit graph

23 commits

Author SHA1 Message Date
Ashod Nakashian
b6da68b0f7 systemplate: do not soft-link to host filesystem in the jail
Files soft-linked from the jail will reference those in the
chroot and not the real/root filesystem. We can only get
away with hard-links in this case. Failing that, we must
copy the file and check at runtime. Hard-linking most
commonly fails due to cross-device linkage, which is
prohibited.

Change-Id: I4d43fd2ac47c42edd59de9baba5b38a78c879f6e
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/101417
Tested-by: Andras Timar <andras.timar@collabora.com>
Reviewed-by: Andras Timar <andras.timar@collabora.com>
2020-08-26 18:00:18 +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
Ashod Nakashian
bc8da0cb33 wsd: support read-only systemplate
For various reasons, systemplate may be read-only
or under a different owner and therefore impossible
to update the dynamic files in it.

To support such a scenario, we first link the
eight dynamic files in /etc when creating systemplate.
If this fails, we copy the files.

When creating jails, we always check that all the
dynamic files are up-to-date. If they are, nothing
further is necessary and we bind-mount, if enabled
and possible.

However, if the dynamic files are not up-to-date,
we disable bind-mounting and force linking
the files in the jails. Failing that, we copy them,
which is not ideal, but allows us to ensure the
dynamic files are up-to-date as we copy them too.

Ideally, the dynamic files in question would be
hard-link (or at least soft-linked) in systemplate
at creation. From then on we would bind-mount
the jails and everything would work perfectly and
no files would need updating. This patch is fallback
for when this scheme fails, which should be exceedingly
rare anyway, but which still ensures correct operation.

Change-Id: I09c6f057c49396579aaddb1b8bf4af0930dd4247
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/100834
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Tested-by: Jenkins
Reviewed-by: Andras Timar <andras.timar@collabora.com>
2020-08-17 13:51:56 +02:00
Ashod Nakashian
d6259d6a54 wsd: support parallel systemplate setup
When tests are run in parallel, they will all
compete to update and set up the systemplate
directory, which has a handful of files that
need to be up-to-date. This is a source of errors.

Normally, these files are linked (hard- or soft-
link, whichever succeeds). With linking, we
only need to worry about the initial setup,
as the files will never be out-of-date from
then on. However, when linking fails, we need
to copy the files, and update them (by copying
over fresh versions of the files, if necessary)
every time a new kit is forked. Copying over
is tricky, as it's not atomic. To make it
atomic, we copy the files to the destination
directory under a temporary (random) name,
and then rename to the final name (which is
atomic, including replacing the target file,
if it exists).

No such race exists in production, where there
is (or should be) but one instance of loolwsd
(which does the initial setup) and forkit
(which updates systemplate before forking
new kit instances).
This is an issue with parallel tests only.

Change-Id: I6ba1514d00a84da7397d28efeb6378619711d52f
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/97785
Tested-by: Jenkins
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
2020-07-07 19:05:23 +02:00
Ashod Nakashian
5c9988f2e3 wsd: faster jail setup via bind-mount
loolmount now works and supports mounting and
unmounting, plus numerous improvements,
refactoring, logging, etc..  When enabled,
binding improves the jail setup time by anywhere
from 2x to orders of magnitude (in docker, f.e.).

A new config entry mount_jail_tree controls
whether mounting is used or the old method of
linking/copying of jail contents. It is set to
true by default and falls back to linking/copying.
A test mount is done when the setting is enabled,
and if mounting fails, it's disabled to avoid noise.

Temporarily disabled for unit-tests until we can
cleanup lingering mounts after Jenkins aborts our
build job. In a future patch we will have mount/jail
cleanup as part of make.

The network/system files in /etc that need frequent
refreshing are now updated in systemplate to make
their most recent version available in the jails.
These files can change during the course of loolwsd
lifetime, and are unlikely to be updated in
systemplate after installation at all. We link to
them in the systemplate/etc directory, and if that
fails, we copy them before forking each kit
instance to have the latest.

This reworks the approach used to bind-mount the
jails and the templates such that the total is
now down to only three mounts: systemplate, lo, tmp.

As now systemplate and lotemplate are shared, they
must be mounted as readonly, this means that user/
must now be moved into tmp/user/ which is writable.

The mount-points must be recursive, because we mount
lo/ within the mount-point of systemplate (which is
the root of the jail). But because we (re)bind
recursively, and because both systemplate and
lotemplate are mounted for each jails, we need to
make them unbindable, so they wouldn't multiply the
mount-points for each jails (an explosive growth!)
Contrarywise, we don't want the mount-points to
be shared, because we don't expect to add/remove
mounts after a jail is created.

The random temp directory is now created and set
correctly, plus many logging and other improvements.

Change-Id: Iae3fda5e876cf47d2cae6669a87b5b826a8748df
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/92829
Tested-by: Jenkins
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
2020-07-01 05:42:43 +02:00
Michael Meeks
b0403c7d45 Copy linked /etc/localtime (and also timezone) into the systemplate.
Change-Id: I77fc24aa0f2fc94ee889a87bc10332c85ea57808
2019-10-25 11:24:33 +01:00
Andras Timar
1dbc88a32b Fix domain name resolution from jail by adding required libs to systemplate
Originally all was good, then ad21717498
removed these files from jail, therefore name resolution broke, then
ac7d67f43e added back libnss_* libs from one location, which
happened to work on developer's computer, then 4e5528e5f8,
b4f15c714a, and 9c0ab72155
added back etc/hosts etc/nsswitch.conf etc/resolv.conf that were also needed for proper
name resolution, finally this patch adds some more possible locations of Name Service
Switch (NSS) libs, therefore it makes sure that the required libnss_* shared libs
are found e.g. on Debian based systems. Also, testing with libreoffice/online docker image
has shown that libresolv.so.2 is also required in systemplate for name resolution, although
on some other systems it was not needed (preload?).

This fixes two bugs:
1) Linked images in documents were not displayed on certain systems
2) Insert image from WOPI host did not work on certain systems

Change-Id: I5d09a65341050f0f729bdbc46977c0f686ac023c
Reviewed-on: https://gerrit.libreoffice.org/64426
Reviewed-by: Andras Timar <andras.timar@collabora.com>
Tested-by: Andras Timar <andras.timar@collabora.com>
2018-12-02 18:32:34 +01:00
Andras Timar
052c033e92 tdf#121429 PDF writing needs NSS libs in systemplate (2)
Change-Id: I3724114867986a7ff2494b6b360b1680d7661bcc
2018-11-22 14:28:21 +01:00
Andras Timar
9606c29d64 tdf#121429 PDF writing needs NSS libs in systemplate
Change-Id: I478058168d8288a1e9bced66ba58b1bb26e556bb
Reviewed-on: https://gerrit.libreoffice.org/63721
Reviewed-by: Andras Timar <andras.timar@collabora.com>
Tested-by: Andras Timar <andras.timar@collabora.com>
2018-11-21 21:59:40 +01:00
Andras Timar
9c0ab72155 typo: missing backslash
Change-Id: I194420d64a2541000e6bc7eb52d3cec8883e32d4
2018-11-01 17:25:44 +01:00
Andras Timar
b4f15c714a Fix networking in the chroot (again)
Change-Id: I60a6f5f99577e4336b1ec117e28650d677ed7d63
2018-11-01 17:17:40 +01:00
Andras Timar
4e5528e5f8 /etc/resolv.conf can be a symlink
Change-Id: I23396e598306b7c8ab1498962ab5c09150c6795b
Reviewed-on: https://gerrit.libreoffice.org/62674
Reviewed-by: Andras Timar <andras.timar@collabora.com>
Tested-by: Andras Timar <andras.timar@collabora.com>
2018-10-30 21:33:03 +01:00
Jan Holesovsky
ac7d67f43e Fix networking in the chroot.
The needed files were not copied, and consequently the hostname
resolution did not work in the chroot.

Change-Id: Id3dccc4f70cd1deeddb83c8e672f240e06748e34
2018-08-03 05:22:03 +02:00
Andras Timar
6c42c2bc91 redirect stderr of find to /dev/null, non existing search paths can be ignored
Change-Id: Icf2a77f8cd78da2f9d4ff7adc11308cb96464e65
2018-06-15 15:04:25 +02:00
Michael Meeks
ad21717498 Avoid copying most code into the chroot jail.
Last lingering bits are the xpdfimport import support and
some horrors required for NSS.

This requires a reasonably new core.

Change-Id: I2e08b841668722af0e3b947cf2b06687cca73b53
2018-03-28 16:38:10 +01:00
Michael Meeks
501d36824b Clean up un-used pcf fonts from the systemplate to shrink it.
Also drop ~/docs/ copying for devs - too generic a name.

Change-Id: Ib9416e23fa7f09ec923e03551c6c7b85bc3defe3
2018-03-10 13:50:43 +00:00
Andras Timar
61a2d94f2b copy system hyphenation dictionaries to systemplate
Change-Id: Ie7e5a2644436d5de61f65b2d8ec5201471100787
2017-10-30 11:01:14 +01:00
Andras Timar
017f82a84d no error if systemplate dir is existing
Change-Id: I10aba648688ba92150efa41449190a3ba425f03c
Reviewed-on: https://gerrit.libreoffice.org/42663
Reviewed-by: Andras Timar <andras.timar@collabora.com>
Tested-by: Andras Timar <andras.timar@collabora.com>
2017-09-22 17:10:26 +02:00
Andras Timar
478e803819 add xpdfimport dependencies (e.g. system libpoppler) to systemplate
Change-Id: Iedb77cc0eed107899b15d3d471edcfa0f655d176
2017-07-31 19:39:50 +02:00
Samuel Mehrbrodt
0b129c05a9 Find libpng on Ubuntu also
Change-Id: Ib0ed1b26ddac1aca6381650c85e17a4b1a6d017f
Reviewed-on: https://gerrit.libreoffice.org/35749
Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
Tested-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
2017-03-27 10:03:07 +00:00
Henry Castro
6e7f8b860d script: remove POCO libraries from systemplate
This is no longer need it
2017-01-05 17:05:08 -04:00
Henry Castro
8fdee3fca8 script: copy additional documents
This is only for debugging purpose
2016-12-16 23:38:32 -04:00
Michael Meeks
cca657c8f2 Apply the pre-branch rename script to re-organize the source. 2016-11-25 09:58:48 +00:00
Renamed from loolwsd/loolwsd-systemplate-setup (Browse further)