Commit Graph

5244 Commits

Author SHA1 Message Date
Alexander Larsson
05df609e75 update portal: Don't allow self-updates if new permissions are needed
In this case we report a NotSupported error (not permission denied, because
that is used for other things).
2019-10-02 14:57:11 +02:00
Alexander Larsson
13be8b6365 common: Add flatpak_context_adds_permissions()
We want to use this in the update portal to catch the case
when some new permission was added and disallow self-updates in this case.
2019-10-02 14:57:11 +02:00
Alexander Larsson
ade1b299e7 tests: Test masking in updates portal
If the app is masked it should neither report updates or update
itself. Test this.
2019-10-02 14:57:11 +02:00
Alexander Larsson
1eb68628ba update-portal: Don't report updates for masked refs 2019-10-02 14:57:11 +02:00
Alexander Larsson
ea67fd8bb0 Export (private) flatpak_installation_get_dir()
We'll need this for the update portal work.
2019-10-02 14:57:11 +02:00
Alexander Larsson
d942b47b64 tests: Remove some unused code in update-portal test 2019-10-02 14:57:11 +02:00
Alexander Larsson
714f13a6a0 tests: Test self-update via the update-portal
We test a successful update, a null update and a failed update.
2019-10-02 14:57:11 +02:00
Alexander Larsson
91d9fe9c60 tests: Add simple testing portal backend and wire it up to the tests
This only supports the AccessDialog call, and always just allows
everything. Still, it tests the entire codepath for authentication.
2019-10-02 14:57:11 +02:00
Alexander Larsson
a95cf667a1 update-portal: Clean up details in progress reporting
Always report op/n_ops as their last values.
Ensure we never send op >= n_ops
Ensure we always send one and only one 100% running status (== op done)
2019-10-02 14:57:11 +02:00
Alexander Larsson
00921c2dba update-portal: Don't send weird glib encoded errors
If we don't have a registred dbus error, just send a generic
org.freedesktop.DBus.Error.Failed.
2019-10-02 14:57:11 +02:00
Alexander Larsson
a87aaac4b1 update-portal: Allow overriding portals directory
Allow overriding $datadir/xdg-desktop-portal/portals using the
$XDG_DESKTOP_PORTAL_DIR env var. We will need this in the test suite when
we want to pass in our own (faked) portal implementation.
2019-10-02 14:57:11 +02:00
Alexander Larsson
21bc4fc29b update-portal: Use error_message, not error-message
All other places use underscores instead of dashes.
2019-10-02 14:57:11 +02:00
Alexander Larsson
6cb11631c5 update-portal: Don't fail if permission store not available
This downgrades g_warning to g_info, so that we don't fail if the
permission store is not available, which will happen in the test-suite.
2019-10-02 14:57:11 +02:00
Alexander Larsson
a36f33d8ee update-portal: Ensure we close any stray fds when forking update child 2019-10-02 14:57:11 +02:00
Alexander Larsson
a0c46c1ea2 update-portal: Remove unnecessary handle arg from Progress signal
There is no need to pass the handle, that is already available to the
reciever as the object path of the signal.
2019-10-02 14:57:11 +02:00
Alexander Larsson
930919d7b1 update-portal: Emit progress on right interface and object path 2019-10-02 14:57:11 +02:00
Alexander Larsson
c15c1946ff test: Add test for update-portal monitoring
We add socat to the test runtime, and then we use that to run a
test app outside the sandbox as if it was inside.

The testcase connects creates a monitor and ensure we properly get signals
for updates.
2019-10-02 14:57:11 +02:00
Alexander Larsson
82328bee85 portal: Add option for poll frequency
We want to use these to get a quick turnaround in the tests.
2019-10-02 14:57:11 +02:00
Alexander Larsson
a4b2068bbc portal: Support application self-updates
This allows an application to request it to be updated to the latest version.

The updates are done out-of-process by re-spawning the portal (via
/proc/self/exe) and proxying the relevant events over a socket pair, in
order to avoid any long term stability or memory requirements from
running the update operation.
2019-10-02 14:57:11 +02:00
Alexander Larsson
e719463adf Bump the version of the flatpak portal interface to 2
Also mention this in the create monitor docs.
2019-10-02 14:57:11 +02:00
Matthias Clasen
fe0b8aa860 portal: Add updates monitoring
Add update monitoring to the flatpak portal.
No support yet for triggering updates.
2019-10-02 14:57:11 +02:00
Matthias Clasen
8ca4addc73 Find portal implementations properly
Share the portal implementation loading code
from xdg-desktop-portal, so we can select the
Access backend propertly.
2019-10-02 14:57:11 +02:00
Alexander Larsson
ae574f2a14 dir: flatpak_dir_get_by_path()
This automatically picks up whether the path is a system or user installation.
We'll need this in the update portal.
2019-10-02 14:57:11 +02:00
Alexander Larsson
32ec943adf CI: Store individual test logs also on failure (not just cancel)
This way we can get more detail on the failed test.
2019-10-02 14:57:11 +02:00
Alexander Larsson
93c314d46b CI: Install socat 2019-10-02 14:57:11 +02:00
Alexander Larsson
8ab48d5198 tests: Fix whitespace in makefile 2019-10-02 14:57:11 +02:00
Alexander Larsson
8832e7c7d1 Make test output a bit less noicy
This gets rid of some unnecessary spew that happens in every
test run and just makes the logs harder to read.
2019-10-02 14:57:11 +02:00
Matthias Clasen
ea8ecdbeb9 eol: Use the right ref in the confirmation message
We were using the old ref here, instead of the new
one, when asking whether to go ahead.

Closes: https://github.com/flatpak/flatpak/issues/3139
2019-10-02 14:56:44 +02:00
Alexander Larsson
b3272f156c Update: Don't update an extension if it is an extension and the base is masked
For example, if org.the.App or org.the.Platform is masked that means
we don't want to get any updates to it. Its very likely that we also
don't want updates to extensions of this app or runtime. For example,
we definately don't want to update the .Locale or .Debug extensions.
2019-10-02 11:18:02 +02:00
Alexander Larsson
84eb154e83 Track extension-of in deploy data
This tracks for installed apps if they are extensions of some
ref. This will be useful later to avoid updating extensions of
masked apps.
2019-10-02 11:18:02 +02:00
Alexander Larsson
d91660fe2a Work around deadlocks in g_spawn by manually clo-exec:ing fds
As per https://gitlab.gnome.org/GNOME/glib/merge_requests/490
there is a bug in glib < 2.60 where g_spawn_* can sometimes deadlock
due to using malloc in the child func to close fds.

We work around this in places where the code is (potentially) threaded
by passing glib flags to leave fds alone and then do a very naive
(but safe) fd cloexec loop ourselves.
2019-09-30 12:15:36 +02:00
Alexander Larsson
9c715096aa man: Reference flatpak-mask.1 from flatpak.1 2019-09-30 10:52:06 +02:00
Alexander Larsson
02b542789a Add manpage for flatpak mask 2019-09-30 10:52:06 +02:00
Alexander Larsson
178845d6d6 mask: Support masking of updates
In addition to just masking auto-downloads, masking now also means
pinning of the currently installed version of an already installed ref.
2019-09-30 10:52:06 +02:00
Alexander Larsson
2c7fab39b0 Add flatpak_dir_ref_is_masked helper 2019-09-30 10:52:06 +02:00
Alexander Larsson
f9fad17b51 Add flatpak mask command
This commands lets you selectively disable auto-download of extensions
based on patterns. With this we can have extensions that install
by default, yet still allow the user to not have them re-installed
each time flatpak update is run.

This fixes https://github.com/flatpak/flatpak/issues/3090
2019-09-30 10:52:06 +02:00
Alexander Larsson
9f6fc5591c common: Export glob_to_regexp util and make it handle empty parts as *
This means you can use "org.foo.bar//stable" instead of "org.foo.bar/*/stable"
which is similar to what other APIs do.

We want to use this for masking extensions too, thus the export.
2019-09-30 10:52:06 +02:00
David Hewitt
c601a808a8 transaction: Annotate enums with their type
This allows the introspection data to be generated with the correct type for each of these properties, instead of just `int`. This should improve the quality of the documentation as well as bindings generated from the introspection data.
2019-09-30 10:22:26 +02:00
Alexander Larsson
161a13951b Add flatpak install --or-update operation
This allows you to ensure that a particular app/runtime is installed
and with the latest version in a single operation, which is useful
for instance in automatic use, like CI systems.
2019-09-27 09:07:13 +02:00
Matthew Leeds
593f0e563b doc/flatpak-create-usb: Clarify how to install from USB 2019-09-27 08:53:04 +02:00
Matthew Leeds
584a531a58 Merge pull request #3135 from wjt/3134-NULL-dereference-in-list_installed_refs_for_update
installation: don't dereference possibly-NULL array
2019-09-26 10:17:57 -07:00
Will Thompson
a732de2a28 installation: don't dereference possibly-NULL array
If the installation contains 1 or more installed refs, but none of those
refs have a remote with a collection ID, then 'results' will be NULL but
'installed' will be non-NULL. Since
c29e686246, 'results[0]' is used in this
situation – a NULL pointer dereference. There is an existing 'results !=
NULL' check inside the body of this loop, but this is too late.

Check whether 'results' is NULL before dereferencing it.

Fixes #3134.
2019-09-26 08:47:47 -07:00
Alexander Larsson
aaac533ca4 Add action that checks for autosquash commits in pull requests
We want to block merging for these, to ensure that you autosquash
before merging.

Ideally we'd like automatic (or at least via a bot) autosquashing, but
that is not currently possible.
2019-09-26 13:00:22 +02:00
Alexander Larsson
a046843fea Trigger CI on pull_request too
But, only to a limited subset of branches
2019-09-25 16:43:50 +02:00
Alexander Larsson
266e12e432 Use github actions for CI 2019-09-25 13:07:46 +02:00
Matthias Clasen
bbd4bedecc Take char width into account for formatting
When formatting text for terminal output, take
character width into account.

Fixes https://github.com/flatpak/flatpak/issues/2910

Closes: #3124
Approved by: alexlarsson
2019-09-23 08:39:49 +00:00
Kukuh Syafaat
1f7cbf2c4a Update Indonesian translation
Closes: #3125
Approved by: matthiasclasen
2019-09-21 14:32:30 +00:00
Matthew Leeds
96822b21e5 dir: Fix a typo in a comment 2019-09-20 13:02:06 -07:00
Alexander Larsson
0a3963b479 Only define GLIB_VERSION_MIN_REQUIRED if we detect a new glib
Otherwise the build failed on older glib version, but with this setup
we still disable all the GTimeVal deprecation warnings.

Closes: #3122
Approved by: alexlarsson
2019-09-20 13:58:46 +00:00
Alexander Larsson
a641bb76b2 Don't use deprecated g_type_class_add_private API
Instead use G_DEFINE_TYPE_WITH_PRIVATE like we do in other places already.

Closes: #3119
Approved by: alexlarsson
2019-09-19 16:53:11 +00:00