Commit Graph

4415 Commits

Author SHA1 Message Date
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
Kukuh Syafaat
3564d6582d Update Indonesian translation
Closes: #2336
Approved by: matthiasclasen
2018-11-18 16:51:10 +00:00
Kukuh Syafaat
8386fbdab4 Update Indonesian translation
Closes: #2335
Approved by: mwleeds
2018-11-18 02:54:49 +00:00
Patrick Griffis
5bbdb0628e doc: Update download-if/enable-if docs
Closes: #1436
Approved by: matthiasclasen
2018-11-17 23:42:49 +00:00
Patrick Griffis
182b2674aa Add condition for XDG_CURRENT_DESKTOP checks
Firstly this changes the "download-if" and "enable-if" properties
to accept a `;` separated list of multiple conditions.

Secondly it adds `on-xdg-desktop-*` which will check against
the XDG_CURRENT_DESKTOP env var (case-insensitively).

This is done entirely for the Qt GNOME Platform so it can do this:

```
"org.kde.PlatformTheme.QGnomePlugin" : {
  "download-if": "on-xdg-desktop-GNOME;on-xdg-desktop-GNOME-classic"
}
```

Closes: #1436
Approved by: matthiasclasen
2018-11-17 23:42:49 +00:00
Matthew Leeds
5fe2a0aabe uninstall: Add support for fuzzy matching
This adds support for fuzzy matching ref names (AKA "typo helper") to
the uninstall command to mirror what the install command has. In short,
this means you can do "flatpak uninstall gedit" instead of "flatpak
uninstall org.gnome.gedit". Flatpak will prompt you to choose between
similarly named installed refs, and will only make the choice for you if
--assumeyes was used and there's only one match.

Note that this commit does have the side effect that if there are
multiple matching refs with the same ID (e.g. with different branches or
in different installations) you are prompted to choose between them.
Previously you were shown an error message.

Closes: #2330
Approved by: matthiasclasen
2018-11-17 13:00:33 +00:00
Matthew Leeds
7d35de18e4 app: Fix a couple memory leaks
Closes: #2330
Approved by: matthiasclasen
2018-11-17 13:00:33 +00:00
Erick555
ad9599d3e3 Mount common sockets as read-only
This is similar case as with x11_socket, 0af71792b4

Closes: #2333
Approved by: matthiasclasen
2018-11-16 21:18:12 +00:00
Kukuh Syafaat
322579b799 Update Indonesian translation
Closes: #2332
Approved by: matthiasclasen
2018-11-16 14:15:18 +00:00
Matthew Leeds
3f13babb5a dir: Emit better errors for invalid flatpakrepo files
Closes: #2327
Approved by: matthiasclasen
2018-11-16 14:04:48 +00:00
Alexander Larsson
fa08646371 Update pofiles for release 1.1.0 2018-11-16 14:37:22 +01:00
Alexander Larsson
03732121db Make sure we dist flatpak-instance-private.h 2018-11-16 14:34:15 +01:00
Alexander Larsson
420281414d Mention 1.2 expected release date in NEWS 2018-11-16 14:30:40 +01:00
Alexander Larsson
9fd6451fb9 Update NEWS for 1.1
This also includes the NEWS posts from 1.0.3 to 1.0.6 first
to avoid duplication and since it makes sense for users. After
all, 1.1 is released after 1.0.6 was released.
2018-11-16 14:28:16 +01:00
Alexander Larsson
35598f46a5 extra-data: Don't allow creating files with non-canonical permissions in apply_extra
When installing a flatpak with extra-data we execute the apply_extra
script from the flatpak to extract the extra data files we
created. This script runs with very little filesystem acces, but it
does have write permissions to the location that will eventually be
/app/extra in the finished flatpak. This is especially problematic for
the systemwide install case, because the script is then run as root,
so it could potentially create a setuid file there.

Such a file would not be usable inside the sandbox (because setuid is
disabled in the sandbox), but it could potentially be a problem if the
user could be tricked into running the file directly on the host. This
is the same behaviour as e.g. rpm or deb which both can install setuid
files, but we want to guarantee that flatpak is better than that.

The fix is to run the script with all capabilities dropped (bwrap
--cap-drop ALL) which removes a bunch of possible attack vectors (for
instance setting file capabilities). However, even without
capabilities, it is possible for a user to make any file setuid to the
same user, so we also need to canonicalize the permissions of all
files generated by running the script.

Additionally, while running the script we set the toplevel directory
only be accessible to the user, meaning we will not temporarily leak
any potential setuid files to other users.

Note, this commit actually goes furthen than that and completely
canonicalizes all the file permissions to be the same as those
otherwise used by flatpak. For example we fix up cases where the
script creates files writable or unreadable by non-root users.

Closes: #2323
Approved by: alexlarsson
2018-11-16 10:20:20 +00:00