Commit Graph

5267 Commits

Author SHA1 Message Date
Mazen Asef
65912f27fe app: Allow locales to be stored in the extra-languages key
In order to configure gnome-software to show specific apps in one region
without showing to all language speakers, we allow the storage of full
locales on the extra-languages key. However, these locales are ignored when
calling flatpak_installation_get_default_languages, so locales will be reduced
to their language identifier (eg. en_IN locale will be returned as 'en', and
az_Latn_AZ will be returned as 'az'). In order to get the full locales, we can
call flatpak_installation_get_default_locales instead, which can return languages
and locales.
2019-10-16 16:25:06 -03:00
Philip Withnall
1e589c1b74 github: Add malcontent (parental controls) support to CI build
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-10-03 13:54:37 +02:00
Philip Withnall
7c9d609399 system-helper: Tweak documentation for parental controls
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-10-03 13:54:37 +02:00
Philip Withnall
62b0d3f4f1 common: Bump version numbers for new parental controls API
The PR was written before 1.5.0 was released, but was then merged after
1.5.0 was released — so bump the version numbers to 1.5.1.

See https://github.com/flatpak/flatpak/pull/2797.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-10-03 13:54:37 +02:00
Alexander Larsson
c4e6c32f68 Remove old CI system 2019-10-03 11:42:33 +02:00
Philip Withnall
c40223267c error: Add a ‘permission denied’ error code
This will be used for parental controls, and potentially other reasons
for denying installation of an app.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-10-03 10:42:04 +02:00
Philip Withnall
de1759e2b4 utils: Add missing D-Bus error serialisation
FLATPAK_ERROR_REF_NOT_FOUND was missing its serialisation for sending
over D-Bus.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-10-03 10:42:04 +02:00
Philip Withnall
d9d3ab9030 ci: Build with malcontent enabled
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-10-03 10:42:04 +02:00
Philip Withnall
9758968cc4 dir: Support filtering app installs/upgrades by user’s OARS settings
Use the user’s OARS filter to prevent installation or upgrade of
apps which have more extreme content than the user is allowed to see.

This uses libmalcontent to load the user’s enforced OARS filter, which
describes the extremeness of each type of content the user is allowed to
see. If an app they are trying to install exceeds the filter value in
any OARS section, installation is disallowed and an error is returned.

libmalcontent stores the parental controls policy per-user in
accountsservice, which enforces access control on the policies.

The app filter is also allowed to prevent app installation entirely,
which overrides the OARS values. This is independent from the app-install
polkit action, which determines whether an unprivileged user may install
an app system-wide. Being stored in accountsservice, the new boolean is
also easier to set per-user without having to programmatically write a
polkit JS policy file which handles multiple users (and parse it back
again).

The parental controls checks are done at deploy time, either in the
`flatpak` process (for user repositories) or in the
`flatpak-system-helper` (for system repositories). The checks use
content rating data extracted from the app’s AppData XML and stored in
the `FlatpakDeploy` cache. The checks are passed through polkit (even
for user repositories) so that users can get an admin override to
install apps which would otherwise be too extreme. This uses the new
`org.freedesktop.Flatpak.parental-controls` polkit rule.

The checks have to be done at deploy time, as that’s when the AppData
XML for the app is parsed. The downside of this arrangement is that an
app must be entirely downloaded before the parental checks can be done.
This won’t be much of an issue on normal desktops, however, since we can
assume that gnome-software will check an app’s appropriateness before
showing it to the user in the first place.

Parental controls are not enforced for non-apps/runtimes, which includes
the ostree-metadata and appstream/* refs.

One thorny issue is that flatpak unit tests may be run in an environment
with no system D-Bus available to connect to (a Jenkins instance, for
example), which means the call to `mct_manager_get_app_filter()` in
`flatpak_dir_check_parental_controls()` fails.

So this commit skips the parental controls check if the system bus is
unavailable and the environment variable
`FLATPAK_SYSTEM_HELPER_ON_SESSION` is set, since the testlibrary already
sets that variable so that the system-helper will be started on the
session bus.

The feature can be tested using something like:
```
   $ malcontent-client set philip \
       violence-realistic=none app/org.freedesktop.Bustle/x86_64/stable
   App filter for user 1000 set
   $ flatpak run org.freedesktop.Bustle
   error: Running app/org.freedesktop.Bustle/x86_64/stable is not allowed by the policy set by your administrator
   $ flatpak --user install flathub io.github.FreeDM
   error: Failed to install io.github.FreeDM: Installing app/io.github.FreeDM/x86_64/stable is not allowed by the policy set by your administrator
```

Includes work by André Magalhães and Umang Jain.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-10-03 10:42:04 +02:00
Philip Withnall
8bd8bdcbcc flatpak-dir: Add content rating support to deploy data
This will be used in upcoming commits to enforce parental controls on
app installations.

We extend version 2 of the deploy data format because it has not
appeared in a release yet.

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

https://github.com/flatpak/flatpak/pull/2797
2019-10-03 10:42:04 +02:00
Philip Withnall
4113ffa007 flatpak-installed-ref: Add support for storing app content ratings
This will be used by upcoming commits to filter app installation by
content rating.

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

https://github.com/flatpak/flatpak/pull/2797
2019-10-03 10:42:04 +02:00
Philip Withnall
0e53094645 flatpak-appdata: Add support for extracting app content ratings
This will be used in upcoming commits to enforce parental controls on
app installations.

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

https://github.com/flatpak/flatpak/pull/2797
2019-10-03 10:42:04 +02:00
Philip Withnall
ab5c0968e6 flatpak-run: Add parental controls support for filtering apps
Prevent the user from running a flatpak app if that app is filtered by
the parental controls applied to the user.

If flatpak is running as a system user (UID < 1000), ignore failure to
load the app filter. This could happen if a flatpak is run in the
gnome-initial-setup session, before the user’s account is created.

Includes contributions by André Magalhães.

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

https://github.com/flatpak/flatpak/pull/2797
2019-10-03 10:42:04 +02:00
Philip Withnall
c16d6f9166 common: Split LIBADD onto multiple lines and sort alphabetically
Also sort CFLAGS alphabetically. This will reduce the likelihood of
merge conflicts in future. This assumes the libraries and CFLAGS are
independent of each other.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-10-03 10:42:04 +02:00
Alexander Larsson
da66eddd26 Post release version bump to 1.5.1 2019-10-03 10:02:17 +02:00
Alexander Larsson
72d7d456e4 Update pofiles for release 1.5.0 2019-10-03 09:38:18 +02:00
Alexander Larsson
9e9c202afa Fix distcheck 2019-10-02 17:33:08 +02:00
Alexander Larsson
c6a20dcfd5 NEWS: Update for release 2019-10-02 16:55:45 +02:00
Alexander Larsson
47d6ea12b5 tests: Remove leftover debug stuff 2019-10-02 16:53:58 +02:00
Alexander Larsson
a24a30ed17 NEWS: Import from 1.4 branch 2019-10-02 16:39:47 +02:00
Alexander Larsson
930b3d673d Fix detection of exported dbus-services with dbus-broker
Rather than unlinking and symlinking the new value we symling into
a temporary name and then atomically renames on top of the (possibly)
pre-existing file.

This has two advantages. First it is atomic, whereas the previous code
could end up removing the old code without creating the new one, and
secondly this will generate a move inotify event which is what dbus-broker
uses to detect changes in the services file directory.

Fixes https://github.com/flatpak/flatpak/issues/3145
2019-10-02 16:38:24 +02:00
Alexander Larsson
65bbd6c761 update-portal: Update docs
Mention permission issue and progress guarantees.
2019-10-02 14:57:11 +02:00
Alexander Larsson
4eb213a39a update-portal: Add tests with changed permission errors 2019-10-02 14:57:11 +02:00
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