Commit Graph

5960 Commits

Author SHA1 Message Date
Phaedrus Leeds
daec27e36e sideload-repos-systemd: Dist service unconditionally
Add flatpak-sideload-usb-repo.service.in to EXTRA_DIST regardless of if
the --enable-auto-sideloading configure option was passed. This allows
building a tarball without that option and then building from the
tarball with the option.

This matches what is done in system-helper/Makefile.am.inc with
flatpak-system-helper.service.in.

Picked from https://github.com/endlessm/flatpak/pull/228

(cherry picked from commit f1383c10be)
2020-08-21 13:14:16 +02:00
Simon McVittie
d33c322c35 exports: Try harder to export usrmerge symlinks as symlinks
In applications with --filesystem=host or --filesystem=host-os, the
library directories in /run/host/usr and /run/host/lib* can be used
like a sysroot to inspect the host's library stack, regardless of
whether the host system has undergone the "/usr merge" or not. This is
particularly relevant for Steam's pressure-vessel container tool,
which imports graphics drivers from the host system, or for potential
future work on using host graphics drivers via libcapsule in Flatpak
apps.

The original implementation of this feature assumed that the /usr merge
always creates symbolic links /foo -> /usr/foo or /foo -> usr/foo, for
some value of foo. However, Arch Linux uses a variation of multilib
in which /usr/lib contains 64-bit libraries, and has a non-matching
symbolic link /lib64 -> usr/lib (instead of a chain of symlinks
/lib64 -> usr/lib64 -> lib). Similarly, Arch uses /sbin -> usr/bin
and /usr/sbin -> bin, instead of a chain of symlinks
/sbin -> usr/sbin -> bin.

This led to Flatpak ignoring the symlink and treating it like a directory,
so the host /usr/lib would be bind-mounted on both /run/host/usr/lib and
/run/host/lib64. This is *mostly* equivalent, but whether a directory
is a symlink or a real directory sometimes matters, for example when
evaluating relative symlinks that contain ".."  components; so try harder
to preserve symlinks as symlinks.

Fixes: 08d65c54 "exports: If --filesystem=host, provide /run/host/lib etc."
Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit 12e3dc051f)
2020-08-21 13:14:16 +02:00
Matthew Leeds
64ecc6f4c5 system-helper: Support setting 'masked' config key
This fixes the following error when the "flatpak mask" command is used
with the system-helper: "error: Unsupported key: masked"

(cherry picked from commit 73644b00c9)
2020-08-21 13:14:16 +02:00
Ryan Gonzalez
a3b562eaa8 portal: Make the SpawnStarted code more robust
An interesting side effect of #3770 was that the portal would loop
forever, waiting for a process to come up every 100ms. This isn't really
ideal; of course, *ideally* nothing would hang, but in practice this
can happen in unusual cases, and spamming the logs every 100ms when it
does isn't terribly ideal.

Now, if the process is not running after around 2 seconds, the repeat
timer is changed to a full second. This isn't perfect, but it would help
prevent bizarre problems becoming even more problematic.

(cherry picked from commit 6d3b30dc9a)
2020-08-21 13:14:16 +02:00
Julian Andres Klode
f4c3ea5e97 Fix argument order of clone() for s390x in seccomp filter
clone() is a mad syscall with about 4 different argument orders. While
most of them agree that argument 0 is flags, s390 and s390x have the
flags argument second - A0 is the child stack pointer there.

[smcv: Add an explanatory comment; also test __CRIS__ for completeness]

Bug-Debian: https://bugs.debian.org/964541
Bug-Ubuntu: https://launchpad.net/bugs/1886814
Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit 8ba141c38f)
2020-08-21 13:14:16 +02:00
Matthew Leeds
0f45ac336d dir: Validate locally configured collection IDs
Currently if the user configures a collection ID on a remote which is
incorrect, either because it doesn't match the one configured server
side or because the server doesn't have one configured at all, Flatpak
will not notice the issue and happily still pull from the remote. This
is new since 1.7.1; before that such a problem would be caught because
the server wouldn't provide the ostree-metadata ref for the configured
collection ID.

This commit catches such errors by checking commit metadata, as we
already do for the ref binding metadata. Otherwise such a mismatch would
prevent successful offline distribution of the apps/runtimes provided by
the remote.

The impetus for this is to keep an eos-updater unit test passing with
Flatpak 1.8.x:
"/updater/install-flatpaks-pull-to-repo-error-if-collection-id-invalid"

(cherry picked from commit 1bf5f2ed9e)
2020-08-21 13:14:16 +02:00
Philip Withnall
06f2dd1e84 Merge pull request #3730 from flatpak/fix-1.8.x-branch
Fix flatpak-1.8.x branch to contain 1.8.1
2020-07-09 09:49:41 +01:00
Alexander Larsson
2e9776f209 Update pofiles for release 1.8.1 2020-07-03 14:20:12 +02:00
Alexander Larsson
1101bbc8c0 Bump NEWS and version to 1.8.1 2020-07-03 12:26:14 +02:00
Alexander Larsson
656bf9da21 run: Fix --no-session-bus
This fixes #3636

(cherry picked from commit dfb36db79d)
2020-07-03 10:18:08 +02:00
Ryan Gonzalez
1af91dee36 run: Don't use userns2 if same as userns
When --device=all is *not* passed to Flatpak, --dev is passed to bwrap,
which causes it to use an intermediate user namespace to mount devpts
because it can only be mounted as UID 0. Therefore, when expose-pids
is used, Flatpak will pass both --userns *and* --userns2 to handle
the presence of the intermediate namespace.

However, when --device=all *is* passed, there is no intermediate
namespace. Thus, setns(userns2) will fail with EINVAL. In order to
handle this, --userns2 is no longer passed if the namespace is
identical to that passed via --userns.

Fixes #3722.

(cherry picked from commit 9833b90019)
2020-07-03 10:18:08 +02:00
Daniel Șerbănescu
1092fdf512 Added Romanian Translation.
(cherry picked from commit 509ce6bd74)
2020-07-03 10:18:08 +02:00
Alexander Larsson
259cb6e42f transaction: Don't fail if install returns ALREADY_INSTALLED
We already verify that the ref is not installed on add_ref(), so we
did check for "user error". If the transaction either raced with some
other process, or the install from the install-authentitcator signal
that should not be treated as an error.
2020-06-30 16:32:38 +02:00
Alexander Larsson
6c5c4bff29 transaction: No need to authenticate when an op just is a redeploy 2020-06-30 16:32:38 +02:00
Alexander Larsson
6168fb2e79 transaction: Avoid authentication for no-op updates
Ensure we normalize ops before requesting authentication so we
can trust the op->skip value to be set for no-op updates (which
don't need authentication).
2020-06-30 16:32:38 +02:00
Alexander Larsson
8e631f120b transaction: Break out some code for reuse
This moves the operation normalization code to the
flatpak_transaction_normalize_ops() helper function.
2020-06-30 16:32:38 +02:00
Alexander Larsson
b3dff7aa97 Add 1.8 branch to CI 2020-06-30 11:21:38 +02:00
Piotr Drąg
94ddda6a25 Update Polish translation 2020-06-30 09:07:44 +02:00
Matthew Leeds
2558b086d7 dir: Fix wrong extension refspecs
Currently Flatpak only supports extensions which come from the same
remote as the thing being extended; for discussion on this see
https://github.com/flatpak/flatpak/issues/861

However in general it isn't clear from the metadata what remote provides
an extension. For example com.endlessm.apps.Platform//5 defines the
extension org.freedesktop.Platform.VAAPI.Intel (inherited from
org.freedesktop.Platform) which can be found on flathub not eos-sdk. So
we don't want to add an extension refspec to the transaction if the
current remote is not the one that actually provides it. In
flatpak_dir_find_remote_related_for_metadata() this invariant is
maintained because we check if the ref exists in the remote before
adding it with add_related(). However in
flatpak_dir_find_local_related_for_metadata() we check for existing
deploy data but omit checking that the deploy origin matches the origin
passed in, and in that case can accidentally add an incorrect refspec to
a transaction. So this commit adds the missing origin check.

One way to reproduce this issue is with this command, having both the
Endless platform and the VAAPI extension already installed:
$ flatpak update --no-pull com.endlessm.apps.Platform//5
Looking for updates…
error: Refspec 'eos-sdk:runtime/org.freedesktop.Platform.VAAPI.Intel/x86_64/1.6' not found

This issue also affects GNOME Software which does a no-deploy
transaction followed by a no-pull transaction (this issue occurs in the
latter) and is treated as fatal causing updates not to be applied.
However it only happens in some niche circumstances, because
flatpak_transaction_add_op() will only use the first remote passed to it
if called more than once for the same ref from different remotes. This
is normally fine; refs generally only come from one remote. But it does
mean this issue only occurs if the extension in question was not already
added to the transaction with a correct origin.
2020-06-30 09:07:19 +02:00
AsciiWolf
c3d0a15e3c Update Czech translation 2020-06-27 18:05:42 +02:00
Alexander Larsson
828785c9f4 Update pofiles for release 1.8.0 2020-06-24 17:04:46 +02:00
Alexander Larsson
ec59cd6b5e Bump version to 1.8.0 2020-06-24 14:28:38 +02:00
Alexander Larsson
679f544d1f Update NEWS for release 2020-06-24 14:28:27 +02:00
Alexander Larsson
dc4e198766 run: Always expose host /usr/share/zoneinfo (if possible)
Instead of relying on the runtime tzdate we now always expose the host
/usr/share/zoneinfo in that location and make /etc/localtime a regular
symlink to it. This means applications that parse the content of the
localtime symlink will work, and additionally it means that we're
guaranteed that the host configure timezone exists (and works with)
the tzdata in the app.

This unfortunately means we no longer make the localtime an indirect
file via the session helper, and thus that localtime configurations
are static over the lifetime of an app sandbox. However, I don't
think there is a workable solution to this.

This fixes https://github.com/flatpak/flatpak/issues/3338
2020-06-23 09:37:30 +02:00
Matthew Leeds
5a646117c9 Don't mention $FLATPAK_RUN_DIR in docs
We only want the run dir to be overridable in unit tests because we
depend on it being /run/flatpak in flatpak-create-sideload-symlinks.sh,
so don't mention it in the flatpak man page.
2020-06-23 09:37:10 +02:00
Matthew Leeds
9caf664fab Add systemd units to sideload from hotplugged USBs
Currently with the sideload implementation of offline updates you have
to manually create a symlink to your USB drive to sideload from it,
which is a regression compared to the previous implementation which
scanned all mounted filesystems in OstreeRepoFinderMount in libostree.
So this commit adds a few systemd units and a bash script so that any
time a USB drive is plugged in and automatically mounted by udisks, a
symlink to it is created in /run/flatpak/sideload-repos. When the drive
is unplugged the symlink is removed.

However this solution still has a lot of moving parts, so we may want to
instead have libflatpak use GVolumeMonitor and find the mounted
filesystems itself; see https://github.com/flatpak/flatpak/issues/3705

Fixes https://github.com/flatpak/flatpak/issues/3490
2020-06-23 09:37:10 +02:00
Matthew Leeds
e84b75629d Allow sideload-repos to link to the root of a USB
Currently we only support links in /var/lib/flatpak/sideload-repos,
/run/flatpak/sideload-repos, etc. to be actual ostree repos, but this
commit makes it so you can also link to the root directory of a USB,
and Flatpak will check the subpaths "ostree/repo", ".ostree/repo", and
".ostree/repos.d" for compatibility with "flatpak create-usb". This will
allow the logic in the following commit to be much simpler, where we're
linking to hot-plugged drives in a script run by systemd.

Note that we still only allow actual repos in the other places where a
sideload path can be specified, such as the --sideload-repo CLI option.
2020-06-23 09:37:10 +02:00
Matthew Leeds
1bdd381007 test-oci-registry.sh: Fix filename in assertion 2020-06-22 11:05:53 +02:00
Matthew Leeds
e230d3c830 test-oci-registry.sh: Use RuntimeRepo= key
This is needed now that we emit a warning when it's not present.
2020-06-22 11:05:53 +02:00
Matthias Clasen
d95d614e89 Warn if RuntimeRepo is missing
This is making the flatpakref file less portable,
so we should warn to give developers a hint that
this is a possible problem.

Closes #2120
2020-06-22 11:05:53 +02:00
Léo Stefanesco
5efdea3b61 Fix flatpak enter when there is no middle user ns 2020-06-22 11:00:11 +02:00
Alexander Larsson
05573fb7b0 tests/test-auth.sh: Tests auto-install of authenticator 2020-06-22 10:51:36 +02:00
Alexander Larsson
620157ba12 tests: Allow specifying app id and app branch for updated apps 2020-06-22 10:51:36 +02:00
Alexander Larsson
b5a9903efc cli: Automatically install authenticator as needed 2020-06-22 10:51:36 +02:00
Alexander Larsson
f1f2c4844c transaction: Add install-authenticator signal
If a transaction requires to install an authenticator before it can
continue this signal will be emitted, allowing you to create a new
transaction to install the required authenticator.
2020-06-22 10:51:36 +02:00
Alexander Larsson
c63645f038 dir: Change find_remote_auto_install_refs to get_remote_auto_install_authenticator_ref
We only ever returned this one ref anyway, and we want to use it in were
its *only* for the authenticator.
2020-06-22 10:51:36 +02:00
Alexander Larsson
7c3a85bf43 Don't install gdm env file by default
As mentioned in https://github.com/flatpak/flatpak/pull/3679 and
https://github.com/flatpak/flatpak/issues/3678 it is causing issues,
and the systemd generators we have should be fine for most uses
anyway.

If a distros need it the gdm file can easily be re-enabled with
--enable-gdm-env-file.
2020-06-22 10:50:25 +02:00
Matthew Leeds
0444b6fa25 Merge pull request #3695 from flatpak/sideload-docs
Update documentation for sideload-repos
2020-06-19 15:44:42 -07:00
Matthew Leeds
6397200247 Update documentation for sideload-repos
It is no longer a config option; it was changed to be a directory.
2020-06-18 13:51:16 -07:00
Matthew Leeds
2d2a05621a dir: Fix an error path in pull_untrusted_local
GError conventions require we set the error pointer on error code paths.
2020-06-17 09:49:03 +02:00
Matthew Leeds
a167252492 transaction: Add assertions to catch unset GError issues
Per the conventions around using GError, failure code paths must set a
GError if a non-NULL pointer is passed for that parameter. And in case
the error is left unset it leads to an assertion failure (and crash) in
flatpak_installation_list_installed_refs_for_update(); see
https://github.com/endlessm/flatpak/pull/224

So add assertions to the failure code paths in
flatpak_transaction_real_run() to catch such mistakes earlier and make
the resulting crash stack trace more useful, since it points closer to
where the problem is. This could be implemented with the "goto out;"
idiom but I don't think that's a good idea in this case because in the
latter half of the function we have to do some cleanup before returning.
2020-06-17 09:43:05 +02:00
Matthew Leeds
85a1dca8d7 configure.ac: Fix --with-systemd help string 2020-06-15 10:08:53 +02:00
Matthew Leeds
bd04b09f9b create-usb: Include partial commits
Commits 32194f2d2 and b8d2196c2 made create-usb detect partially
installed commits and omit them except when --allow-partial is specified
(and in the case of extensions of related refs omit them
unconditionally). The reasoning was that if on the other computer using
the USB for an installation you need a different subpath of a commit
(such as a different language of a locale extension), the installation
will fail. But in most real world cases the users on both ends will
speak the same language so it will not often be an issue.  Also, if you
are offline and have only your own language's subpaths for your locale
extensions, it makes sense to put them on the USB because you have no
way to get the full locale extension and the receiver probably wants the
same subpath as you.

The way "flatpak create-usb" is most often used in Endless is via
gnome-software which calls it under the hood. So while we could have it
pass --allow-partial that would not accomplish much; it doesn't solve
the problems above.

For the online case we may want to attempt to download the full locale
extensions before copying to the USB, but that is for a later commit.

Fixes https://github.com/flatpak/flatpak/issues/3491
2020-06-15 10:08:34 +02:00
Matthew Leeds
0552c4cbe4 create-usb: Add missing --allow-partial check
We were checking for --allow-partial in the other two places we handle
partial commits but not here.
2020-06-15 10:08:34 +02:00
Piotr Drąg
34d6d3c96f Update POTFILES.in 2020-06-11 16:01:52 +02:00
Alexander Larsson
0fdec95fe0 OCI: Also look for the docker media type when looking manifests
We handle both types, so look for both.
2020-06-11 15:57:39 +02:00
Alexander Larsson
03e858a59e remote-info: Use right subject when listing --log 2020-06-10 15:18:12 +02:00
Alexander Larsson
c1524724af Update pofiles for release 1.7.3 2020-06-10 09:45:13 +02:00
milotype
8eddebf09b Update Croatian
update and some minor corrections
2020-06-10 09:00:07 +02:00
Matthew Leeds
e83ff0ca85 transaction: Don't add deps or related for skipped ops
Currently in the FlatpakTransaction implementation we add dependencies
and related refs for each operation in the transaction regardless of if
it's skipped or not. This is an issue in the case of an
end-of-life-rebased ref because in that case if the user agrees a new
install operation is added for the new ref, an uninstall operation is
added for the end-of-lifed ref, and the update operation for the
end-of-lifed one is marked as to be skipped. Then the dependencies of
the end-of-lifed ref get added to the transaction and ultimately after
all the sorting is done you end up with duplicate operations. In the
case of having org.gnome.tetravex installed, "flatpak update" yields a
transaction which uninstalls org.gnome.tetravex.Locale twice and errors
out on the second time (in addition to uninstalling org.gnome.tetravex
and installing org.gnome.Tetravex and org.gnome.Tetravex.Locale).

Fix the issue by skipping operations marked as to be skipped when adding
dependencies and related refs to the transaction.
2020-06-10 08:59:52 +02:00