Commit Graph

4429 Commits

Author SHA1 Message Date
Matthias Clasen
43d4fb6a3e Fix oci pull progress reporting
Comparing the code in flatpak-utils.c:progress_cb,
we need to set bytes-transferred for the total amount
of data that has been transferred so far. The value
we were setting so far, fetched-delta-part-size, refers
to the size of the objects we already have locally, and
is subtracted from the total, which explains oci progress
running backwards.

Closes: #2392

Closes: #2400
Approved by: matthiasclasen
2018-12-07 19:51:11 +00:00
Alexander Larsson
682a93646d tests: Use g_test_dbus in testlibrary
This means we pick up the built services. Also we set
FLATPAK_SYSTEM_HELPER_ON_SESSION so that the system-helper
runs on the session-bus just like in libtest.sh.

Closes: #2397
Approved by: matthiasclasen
2018-12-07 14:45:31 +00:00
Alexander Larsson
b7349aa91a Fix build with --disable-system-helper
Skip the custom polkit code then.

Closes: #2394
Approved by: alexlarsson
2018-12-07 08:21:52 +00:00
Matthias Clasen
86c10e36df Fix a parameter type mismatch
GVariant doesn't take it lightly when you are trying to extract
an ay value with an s format. This was causing critical warnings.

Closes: #2393
Approved by: alexlarsson
2018-12-07 08:01:36 +00:00
Matthew Leeds
35d0d9a246 update: Update custom installations too
Currently the update command only checks the default system and user
installations (unless overridden by a command line flag). This commit
makes it check custom installations as well, so they are not left out.

Care is taken so that an empty or broken installation doesn't cause the
whole update operation to fail.

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

Closes: #2345
Approved by: matthiasclasen
2018-12-06 22:48:42 +00:00
Matthew Leeds
7b77782b0e app: Correct default dir in the ALL_DIRS case
Some commands depend on the first directory in the list returned by
flatpak_option_context_parse() being the default system directory, which
is true for FLATPAK_BUILTIN_FLAG_STANDARD_DIRS. This commit makes the
system directory first for FLATPAK_BUILTIN_FLAG_ALL_DIRS as well, in
case any code in the future uses that flag in combination with that
assumption.

There is one user of the ALL_DIRS flag that actually wants to keep the
user directory first in the list, the run command. This is so that a
user-installed app will be run even if the same app is installed
system-wide. So this commit modifies the run command to undo this
change after calling flatpak_option_context_parse().

Closes: #2345
Approved by: matthiasclasen
2018-12-06 22:48:42 +00:00
Matthias Clasen
efa901ff39 Disable PolicyKit dialogs for --assumeyes
The flag is really meant to disable all interaction,
and this includes PolicyKit dialogs.

Closes: #2389
Approved by: alexlarsson
2018-12-06 15:24:35 +00:00
Matthias Clasen
b8cad064eb Add our own polkit listener implementation
This lets us respect the fancy output setting, and
it lets us do some other things that make it better
integrated.

Closes: #2379
Approved by: alexlarsson
2018-12-06 15:01:14 +00:00
Matthias Clasen
6d95383050 cli transaction: Improve progress handling
Arrange for progress to be done before we
ask for polkit auth, so we don't end up with
the text prompt mushed into the progress display.

Closes: #2379
Approved by: alexlarsson
2018-12-06 15:01:14 +00:00
Matthias Clasen
d44eb141c1 cli: Work on the console
Install a polkit text agent that can ask for
authorization when we are on the console.

This brings us closer to best practice for polkit use.

Closes: #2379
Approved by: alexlarsson
2018-12-06 15:01:14 +00:00
Matthias Clasen
e14af35207 system-helper: Centralize pid-setting
There was a bunch of handle methods which forgot to do
this manually, so call the flatpak_dir_set_source_pid()
method right when we create the FlatpakDir object.

Closes: #2384
Approved by: alexlarsson
2018-12-06 14:47:58 +00:00
Matthias Clasen
c685f05f8a trivial: Fix a gtk-doc warning
gtk-doc complains if parameter names don't match between
headers and doc comments, so make them match, for a quieter build.

Closes: #2384
Approved by: alexlarsson
2018-12-06 14:47:58 +00:00
Matthias Clasen
2089701206 system helper: Don't rely on the caller for updates
The Deploy method takes an 'update' flag from the caller
and picked the permission to check based on that, which
is not safe. Instead, we can check ourselves if the ref
we are given is already installed (in which case it is
an update, or a reinstall).

After this change, the update flag is ignored by the
system helper.

Closes: #2384
Approved by: alexlarsson
2018-12-06 14:47:58 +00:00
Matthias Clasen
21f845c1a7 Revise polkit messages again
I realized that these messages are a bit confusing, with
keep permissions and implications. We end up asking a
question about one ref, but then use the permission we optained
to operate on other refs. This will get a bit worse with
the new hints, so go back to more generic messages that
don't talk about the details. The ultimate goal here is
less messages, anyway.

Closes: #2384
Approved by: alexlarsson
2018-12-06 14:47:58 +00:00
Matthias Clasen
a2f57f64fd Add flags that allow to 'upgrade' permissions
This is to avoid multiple polkit dialogs, regardless
of transaction ordering.

FlatpakTransaction calculates the 'strongest' op it has,
and passes the hints accordingly. FlatpakInstallation
doesn't pass hints, since it does individual operations.

The system helper uses the hints to determine which PolicyKit
permission to request. Since the policy typically has 'keep'
set, this mean that the following operations in the same
transaction will be able to reuse the permission obtained
for the first one.

Closes: #2384
Approved by: alexlarsson
2018-12-06 14:47:57 +00:00
Matthias Clasen
c516a22e4d session-helper: Improve HostCommand life-cycle handling
Add flag that instructs the session-helper to kill
the spawned command when the caller drops off the bus.

Closes: #2326

Closes: #2365
Approved by: alexlarsson
2018-12-06 13:10:51 +00:00
Matthias Clasen
972804f222 session-helper: Validate HostCommand arguments
This is not a portal, but we should still do some
due diligence.

Closes: #2365
Approved by: alexlarsson
2018-12-06 13:10:51 +00:00
Matthias Clasen
f3f7417b16 installation: Add a no-interaction property
Allow to mark a FlatpakInstallation as no-interaction, which
will get passed to the system helper to prevent it from presenting
polkit dialogs.

We make this a property on the object, since not all relevant
methods have flags that would let us pass this information.

Closes: #2367
Approved by: alexlarsson
2018-12-05 10:16:22 +00:00
Matthias Clasen
929da90a3e dir: Add a no-interaction property
Allow to mark a FlatpakDir as no-interaction, which will
get passed to the system helper to prevent it from presenting
polkit dialogs.

We make this a property on the object since the alternative
would require plumbing the flag through tons of API all over
the code.

Closes: #2367
Approved by: alexlarsson
2018-12-05 10:16:22 +00:00
Matthias Clasen
c148c7eeec system-helper: Allow non-interactive tasks
Add a new 'no-interaction' flag to all system-helper methods
that have flags, and don't allow polkit user interaction if
it is set. This will let tools like GNOME Software do automatic
updates in the background without interrupting the user with dialogs.

For methods that don't have flags, we always allow user interaction.

Closes: #2367
Approved by: alexlarsson
2018-12-05 10:16:22 +00:00
Matthew Leeds
0cac27fd87 doc/flatpak-uninstall: Fix leftover xdg-app typo 2018-12-04 23:26:34 -08:00
Matthew Leeds
feb7552a82 system-helper: Fix a copy paste error 2018-12-04 22:29:42 -08:00
Matthias Clasen
1ea8ff705a Merge pull request #2386 from matthiasclasen/fix-tests
fix a few oversights in the recent system-helper change
2018-12-04 21:57:08 -05:00
Matthias Clasen
4c26a0d867 fix a few oversights in the recent system-helper change
1ba30f7ef1 introduced flags to system-helper methods
missing them, but some places were overlooked. This makes
the testsuite pass again.
2018-12-04 21:09:09 -05:00
Matthias Clasen
f325d5f9fb Add a update-metadata action to the polkit policy
This action is used for UpdateSummary, GenerateOciSummary and
when updating the ostree-metadata branch.

Closes: #2383
Approved by: alexlarsson
2018-12-04 15:16:49 +00:00
Matthias Clasen
49ed514ac3 Add imply annotations to the polkit policy
Arrange things so that

app-install > app-update > runtime-install > runtime-update
app-uninstall > runtime-uninstall

Closes: #2383
Approved by: alexlarsson
2018-12-04 15:16:49 +00:00
Will Thompson
97983ba377 portal, session-helper: fix typo in TIOCSCTTY comment
Closes: #2382
Approved by: matthiasclasen
2018-12-04 13:41:29 +00:00
Matthias Clasen
939b2c1429 Fix an oversight
These new checks were not meant to be commented out.

Closes: #2380
Approved by: mwleeds
2018-12-03 20:38:39 +00:00
Matthias Clasen
9f97b8d414 Fix a few tests
We were relying on the order of string lists obtained
from a keyfile. But the way the keyfile is constructed
involved iterating of hash tables, which doesn't guarantee
order.

This was causing test failures with GLib master.

Closes: #2375
Approved by: matthiasclasen
2018-12-03 20:01:49 +00:00
Matthias Clasen
754d68c74a Rename list commands
Rename permission-list and document-list to
permissions and documents, for consistency with
how we handle remotes. The old command names
are kept as hidden aliases.

Closes: #2131

Closes: #2366
Approved by: mwleeds
2018-12-03 19:46:09 +00:00
Victor Kukshiev
c3c0d6d366 fix russian translation
Closes: #2377
Approved by: mwleeds
2018-12-03 19:33:14 +00:00
Matthias Clasen
1ba30f7ef1 system-helper: Add flags to all methods
Some methods were missing a flags argument. This
will be a problem in the future, when we want to
pass a no-interaction flag to all methods. Therefore,
add an empty flags enum for every method that is lacking
one now.

This is an api change for the system-helper interface.

Closes: #2370
Approved by: alexlarsson
2018-12-03 12:52:17 +00:00
Matthew Leeds
624cc6ff0b install: Don't search noenumerate remotes
Currently if you don't specify a remote to the install command, it might
suggest that you use an origin remote like "org.gnome.Builder-origin"
which doesn't make much sense since those are tightly tied to the app
installed via bundle that created them. So this commit respects the
"xa.noenumerate" flag that is set on such remotes, so they aren't
searched for refs.

Closes: #2376
Approved by: matthiasclasen
2018-12-03 12:33:30 +00:00
Matthias Clasen
a45029907e Bump the system helper interface version
We've added a new method, so bump the version.

Closes: #2369
Approved by: matthiasclasen
2018-12-02 00:36:26 +00:00
Matthias Clasen
676b2943cf Improve flatpak-config docs
Include a list of keys.

Closes: #2360

Closes: #2364
Approved by: mwleeds
2018-12-01 01:53:53 +00:00
TingPing
e5218a5623 Also add /dev/nvidia-uvm-tools
This may sometimes be needed also.
Closes: #2358
Approved by: matthiasclasen
2018-12-01 00:31:11 +00:00
Alexander Larsson
0b6a66013c OCI: Use system helper to generate summary for OCI remotes
The OCI support relies on downloading a json index and converting it
to a ostree-style summary, which we the use in all sorts of operations
in the client code. Currently this happens in the user code, which means
that it will fail (due to permissions) in the system installation case.

We could do the conversion as the user, but when eventually installing
something the system-helper will anyway do this download and
conversion, so that would only double the work and risk things going out
of sync. Also, the OCI index is not gpg signed, so we can't realy on
downloads done as the user.

So, the solution done here is to add a GenerateOciSummary
system-helper call which we use instead of directly generating the
oci summary.

This fixes https://github.com/flatpak/flatpak/issues/2350

Closes: #2363
Approved by: matthiasclasen
2018-12-01 00:16:08 +00:00
Matthew Leeds
5266600b5f doc/flatpak-config: Improve synopsis
Make it clear that the command can be used a few different ways, and the
option used determines the needed positional arguments.

Closes: #2361
Approved by: matthiasclasen
2018-12-01 00:04:38 +00:00
Matthew Leeds
6111b81bb6 doc/flatpak-config: Fix example command
The key is "languages" not "language", and the value needs to be quoted.

Closes: #2361
Approved by: matthiasclasen
2018-12-01 00:04:38 +00:00
Owen W. Taylor
05cc3c0f66 flatpak_cache_http_uri: save downloaded files with permission 0644
Previously, downloaded files were being saved with 0600 permissions,
which prevented OCI icons downloaded by the system helper at appstream
creation time from being read by users.

Closes: #2362
Approved by: matthiasclasen
2018-11-30 23:53:10 +00:00
Patrick Griffis
9895014124 Grant access to /dev/nvidia-uvm for OpenCL/CUDA
Closes #2266

Closes: #2356
Approved by: alexlarsson
2018-11-30 07:36:41 +00:00
Matthew Leeds
701602c6ca system-helper: Use modify-repo action for metadata updates
Currently by an accident of history when the system-helper is asked to
deploy updates to the repo metadata (stored on the ref
"ostree-metadata") it uses the polkit action
org.freedesktop.Flatpak.runtime-install since the ref doesn't start with
"app/" and is therefore assumed to be a runtime. This of course doesn't
make much sense, so this commit redirects such invocations of the
"Deploy" method to the "modify-repo" action, which is a bit of a
catch-all of things the system-helper should be allowed to do. It
doesn't seem necessary to split this out into its own action, since
sysadmins probably don't need the ability to break Flatpak's expected
functionality by disabling it. See the PR for more discussion.

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

Closes: #2351
Approved by: matthiasclasen
2018-11-30 01:08:40 +00:00
Matthew Leeds
b351b1ffd9 system-helper: Correct polkit message for modify-repo
Originally the modify-repo action was only used by the RemoveLocalRef
method, which has "remote" and "ref" parameters, but now other methods
use it which don't have such parameters. So this commit modifies
flatpak_authorize_method_handler() so that we're not trying to pass
information along to polkit that we might not have, and modifies the
message shown by polkit to be more accurate.

Closes: #2351
Approved by: matthiasclasen
2018-11-30 01:08:40 +00:00
Simon McVittie
752eac6859 test-override: Skip tests that need bwrap if necessary
This requires some new mechanisms: now we're skipping individual tests,
not just whole test scripts.

There are two main reasons why autobuilder environments might not be
able to run these tests successfully, both of which apply in Debian.

Tests that rely on bwrap typically can't pass in builds that take place
in a chroot, because bwrap's use of pivot_root() assumes that the root
directory is a mount point, but a chroot will typically have an unpacked
directory somewhere below the mount point as its root.

Some autobuilder environments are also sufficiently restricted that they
can't create new user namespaces at all, as a way to harden the
autobuilder host.

As a result, Debian autobuilders can't run the majority of the Flatpak
tests. We would like to be able to continue to run the subset that don't
need bwrap, to have the best test coverage we can. For the rest we have
to rely on installed-tests (which I've wired up to Debian's autopkgtest)
rather than using build-time tests.

Signed-off-by: Simon McVittie <smcv@debian.org>

Closes: #2339
Approved by: matthiasclasen
2018-11-29 23:26:14 +00:00
Philip Withnall
0ffcd5e57f system-helper: Add default return at end of polkit rules
This is not a functional change: the default return value is equivalent
to polkit.Result.NOT_HANDLED. However, this makes the behaviour more
obvious.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Closes: #2354
Approved by: matthiasclasen
2018-11-29 23:12:16 +00:00
Simon McVittie
cd63da0cf0 testlibrary: Don't assume native architecture is x86_64
Signed-off-by: Simon McVittie <smcv@debian.org>

Closes: #2353
Approved by: matthiasclasen
2018-11-29 23:01:25 +00:00
Simon McVittie
871f103153 test scripts: Don't assume we are running on x86_64
These tests failed on other architectures.

Signed-off-by: Simon McVittie <smcv@debian.org>

Closes: #2353
Approved by: matthiasclasen
2018-11-29 23:01:25 +00:00
Simon McVittie
b8bb44ef40 testlibrary: Use an unusual architecture to test ref syntax parsing
This makes it clearer that we are not assuming that the test is running
on an x86_64.

Signed-off-by: Simon McVittie <smcv@debian.org>

Closes: #2353
Approved by: matthiasclasen
2018-11-29 23:01:25 +00:00
Kalev Lember
c915f73b41 remote: Add a way to get/set xa.main-ref
This is useful for gnome-software in order to figure out which app to
show from noenumerate remotes.

Closes: #2340
Approved by: matthiasclasen
2018-11-25 18:31:06 +00:00
Simon McVittie
8a2a32363f Fix a typo that broke installed-tests
Signed-off-by: Simon McVittie <smcv@debian.org>

Closes: #2338
Approved by: matthiasclasen
2018-11-23 13:48:10 +00:00