766 Commits

Author SHA1 Message Date
Alexander Larsson
40126c3e6f Fix crash when installing extra-data
We pass FLATPAK_RUN_FLAG_NO_A11Y_BUS_PROXY when running the
sandboxed apply_extra_data script, because otherwise we run into
a crash due to the lack of an .flatpak-info file (and also, because
it is not needed).
2017-09-14 08:55:30 +02:00
Alexander Larsson
1ee74fc5ea Expose host icons readonly in sandbox
Icons are really only a bunch of pngs, and the icon theme specification
has been stable since forever and never broke ABI. So, exposing the
host fonts should be pretty safe, comparable to the fonts that we
already expose.

This ends up being kind of important since a lot of things pick up the
icon theme from the host. In particular, it means that libXcursor can pick up
the correct cursor icons for the current cursor theme.
2017-09-13 14:54:49 +02:00
Alexander Larsson
4e97018bc6 Properly check the tmp dir mode
This was using a boolean && instead of a bitwise mask. Reported
by covertity.
2017-09-13 12:11:51 +02:00
Alexander Larsson
0b1e45c47f Add comment about why we're allowing xa.ref discrepancies sometimes
See https://github.com/flatpak/flatpak/pull/1013 for discussion.
2017-09-13 11:56:59 +02:00
Cosimo Cecchi
643f9d6e14 dir: relax requirements around xa.ref matching deployed commit
In case the summary file is GPG-signed, we already have other better
ways of verifying expectations around the installed ref.
If the deployed branch does not match xa.ref, simply warn instead of
aborting.

Based on a patch by Dan Nicholson <nicholson@endlessm.com>
2017-09-13 11:45:00 +02:00
Matthew Leeds
037a13cde0 completion: Make filename completions smarter
Many flatpak commands only work on *.flatpak or *.flatpakref files, so
the bash auto completion showing every file is distracting and
unnecessary. This commit makes flatpak only show relevant files when
possible by using the "-G globpattern" compgen option.
2017-09-12 16:14:43 +02:00
Jelle van der Waa
68ad3c84c1 Fix segfault on flatpak update
When ret is NULL object_path is filled with garbage and causes a
segfault g_dbus_proxy_new_for_bus_sync.
2017-09-12 16:12:05 +02:00
Alexander Larsson
2882897474 Fix Unknown argument --none=* errors from dbus proxy
There was a hardcoded value for the dbus policy enum values in the
code that caused problems with the new filtered policy.

Fixes https://github.com/flatpak/flatpak/issues/990
2017-09-04 08:37:08 +02:00
Alexander Larsson
de4b6840d2 Initial work on accessiblity support
This creates a dbus proxy for the a11y bus and sets AT_SPI_BUS_ADDRESS in the
environment to the filtered bus.

The app is only allowed to send a very limited amount of messages to
org.a11y.atspi.Registry on the bus, and nothing else.

This requires a patch to at-spi2-core to read the address from
AT_SPI_BUS_ADDRESS:
     https://github.com/flatpak/freedesktop-sdk-images/blob/1.6/at-spi2-core-address-env-var.patch

Fixes https://github.com/flatpak/flatpak/issues/79
2017-09-01 15:36:29 +02:00
Alexander Larsson
f9eebd7a54 run: Share the same dbus proxy for session and system bus 2017-08-31 16:55:46 +02:00
Alexander Larsson
fef8743f26 run: Always create a fontconfig cache dir in the app dir
Otherwise fontconfig falls back to a shared ~/.fontconfig dir
which means caches are not per-app, and is not necessarily accessible.
2017-08-31 16:10:08 +02:00
Alexander Larsson
0de2978a4d run: Allow calling personality with the current personality
Ideally we should also allow 0xffffffff, which is "read the current state",
but that doesn't seem possible with the current libseccomp.
2017-08-30 15:37:55 +02:00
Alexander Larsson
8f5e47fda5 run: Always set personality (to clear weird states) 2017-08-30 15:37:32 +02:00
Alexander Larsson
8b5aebafb9 Put system child repos in /var/tmp
As discussed in https://github.com/flatpak/flatpak/issues/975, it is
better to have the temporary repos for installing into the system repo
outside the home directory. This helps in the case when the home
directory is on a different filesystem. In particular it is more
likely to be on the same partition as the system repo in /var/lib.

There are multiple advantages if the two repos are on the same filesystem:
 * Less chance of filling up the space on a filesystem that is not
   the final target.
 * It is possible to use fs operations like reflink or copy_file_range to
   optimize the copies from the temporary repo to the system repo.
 * The home directory is more often on NFS or other weird filesystem
   type.
2017-08-30 14:07:54 +02:00
Alexander Larsson
0da103748a flatpakref: Add new SuggestRemoteName key support
If a flatpakref has this set, for instance:

 SuggestRemoteName=gnome-apps

Then flatpak install will ask if you want to configure
this as a "real" remote, rather than an origin remote (which
will only install that app).

This is useful when creating flatpakref files for remotes
that have multiple applications in them, such as e.g. flathub
or the gnome nightly builds. However, it should not be
set of one-application repositories.
2017-08-28 18:17:58 +02:00
Alexander Larsson
4178fbdc09 update-repo: Ensure we commit the appstream data with canonical permissions 2017-08-28 11:39:17 +02:00
Alexander Larsson
bad89eddeb Clean up the AccountService call by using g_autoptr 2017-08-25 14:54:45 +02:00
Alexander Larsson
2a661fd448 Fix regression in --devel
Commit 489bfddfb mistakenly ended a line with a comma instead of a semicolon which
caused --devel to break.
2017-08-25 14:44:57 +02:00
LinXuan Jiang
4fc222ac3b Get language list from AccountsService's dbus (#973)
* Get language list from AccountsService's dbus

Fixes issue #950

When xa.languages is not set in repo config, system installs will
get language list from AccountsService's dbus.
2017-08-25 14:25:09 +02:00
Alexander Larsson
706d13895e Inherit min-percent-free-space from system repo into child repo
This way you can at least work around the free space check in *some*
way.
See https://github.com/flatpak/flatpak/issues/975
2017-08-23 11:13:45 +02:00
Alexander Larsson
0305628758 common: Fix up error reporting for local extra data
Report the actual error message if we failed to read the file.
2017-08-21 10:40:20 +02:00
Manuel Quiñones
9e38de1556 extra-data: Support reading from local directory
Lookup extra-data files as
~/.local/share/flatpak/extra-data/SHA256/FILENAME, Similar to files
downloaded in the .flatpak-builder directory.

For now, if a corresponding file exists, assume it's the full download
and read bytes from it.  Then proceed to do the same checks as for the
bytes downloaded by Soup.

In the future this directory could be used to support resumed downloads
by storing partial downloads.
2017-08-21 10:33:15 +02:00
Alexander Larsson
18451644ff Update to latest libglnx (and fix some callers) 2017-08-18 15:34:29 +02:00
Philip Withnall
154187f4f1 common/dir: Refactor handling for pull options
Factor out the pull options which are common to the collection-based and
non-collection-based code paths. This should make the code a little
easier to read.

This introduces no functional changes.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-08-18 14:23:03 +02:00
Philip Withnall
bf537b3034 common: Ensure ostree-metadata pulls are cached
When the summary file is updated, it’s kept in a local cache, so that
parts of flatpak can refresh it at will without network impact. We need
the same for the ostree-metadata ref, which stores the repository’s
metadata when collection IDs and P2P are used.

Implement that by comparing the checksum of the ostree-metadata ref from
the summary file and from the local repository. If they differ, it’s
almost certainly going to be because the summary file is advertising a
more up-to-date ostree-metadata ref, which we should pull. If they don’t
differ, there’s no need to try and update the ref. Therefore, this
chains off the caching of the summary file.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-08-18 14:23:03 +02:00
Philip Withnall
dd63bdbd61 common: Prevent pulling ostree-metadata unless gpg-verify is true
Add a sanity check and error message which prevents pulling the
ostree-metadata ref (the repository metadata) unless GPG verification is
enabled, as it needs to be signed to be trusted.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-08-18 14:23:03 +02:00
Philip Withnall
0bbf8f3d21 common: Clarify some error and debug messages in flatpak-dir.c
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-08-18 14:23:03 +02:00
Philip Withnall
642a5a81a1 lib/remote: Add getter/setter for collection IDs
This isn’t really used internally, but will be used by gnome-software
for when it configures new flatpak remotes.

This is new public API, but is only declared if compiling with
--enable-p2p.

Includes some basic smoketests.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-08-18 14:23:03 +02:00
Philip Withnall
e5e52b4b79 common/utils: Allow collection-id to be updated from repo config
In order to provide a transition path for repositories to add collection
IDs to themselves and propagate those collection IDs to clients’ remote
configurations, add another repo config key which controls whether the
repository’s collection ID is published. If xa.collection-id is set in
the repo’s published metadata, the client will update its configuration
to the given ID — but only if no ID is set already. This is a one-time
transition to prevent malicious repositories from remotely changing the
user’s configuration to associate their remote with a well-known
collection ID they don’t own.

Add a test for this.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-08-18 14:23:03 +02:00
Philip Withnall
36c8fdb4a4 common/dir: Support updating collection-id from remote configuration
To allow staged deployment of collection-ID-based repositories,
introduce the code to update a local repository configuration to add a
collection ID to it, based on updated metadata from the remote (as is
currently supported for other configuration keys).

As a security measure, this only allows updating the collection ID from
an empty to a non-empty value. We do not allow collection IDs to be
renamed (or a malicious repository owner could bypass the user’s manual
verification of the collection ID by changing it after the user has
configured an unrelated remote).

The idea is that most repositories should remain without collection IDs
for now, and use this mechanism to set their collection IDs in future,
once the functionality is more stable.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-08-18 14:23:03 +02:00
Philip Withnall
d3f1dccae2 common/dir: Drop an unnecessary wrapper function
This introduces no functional changes.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-08-18 14:23:03 +02:00
Philip Withnall
e972201061 common/dir: Propagate errors from invalid configurations
Rather than silently ignoring them. Note that invalid configurations
are distinct from missing configuration keys.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-08-18 14:23:03 +02:00
Philip Withnall
358e204fb3 common/dir: Handle NULL out parameter correctly when getting config
ostree_repo_get_remote_option() requires the out parameter to be
non-NULL.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-08-18 14:23:03 +02:00
Philip Withnall
bc0f90764e common/dir: Fix error handling for flatpak_dir_lookup_repo_metadata()
It can return FALSE with an error set, or FALSE without one set, which
indicates the key was not found.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-08-18 14:23:03 +02:00
Philip Withnall
bc46274ae4 common/dir: Verify commit bindings when pulling from an untrusted repo
When pulling from a local, untrusted repo (i.e. one which the user
downloaded into, and we want to pull into the trusted system repo),
verify the collection ID and ref bindings in the commit metadata for
each commit.

This is something which is normally done by libostree, but since we’re
rewriting the commit manually, we’re bypassing that part of the pull()
code path.

This is an inlined version of the check from verify_bindings() in
libostree.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-08-18 14:23:03 +02:00
Philip Withnall
c4819af5a0 common: Support collection IDs for related refs and extensions
Add support for collection IDs to the code which finds and pulls
related refs and other extensions.

Currently, related refs must have the same collection ID as the parent
ref — this is the most likely scenario anyway. In future, it should be
possible to extend the code to support pulling related refs from other
collections.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-08-18 14:23:03 +02:00
Philip Withnall
26eb76637d common/utils: Add collection ID support for appstream/* branches
Also add collection and ref binding metadata to the generated appstream
commits, so they can be verified when using unsigned summary files.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-08-18 14:23:03 +02:00
Philip Withnall
b9986a7979 common/dir: Add some FIXMEs for future improvements to collections
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-08-18 14:23:03 +02:00
Philip Withnall
e9765b82cf common/dir: Remove an unused method
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-08-18 14:23:03 +02:00
Philip Withnall
2143e5984a common/dir: Factor out a helper function to get a remote’s collection ID
We need to consistently handle the case where the collection ID is set
to the empty string (and treat it the same as if it were unset). Best
done in a helper function.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-08-18 14:23:03 +02:00
Philip Withnall
a220fd3cd3 app/repo: Load repository metadata from ostree-metadata ref if possible
Newer repositories will store metadata there, rather than in the summary
file (although the summary file will still be updated where possible for
backwards compatibility).

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-08-18 14:23:03 +02:00
Philip Withnall
024d835460 common: Support unsigned summary files and separate repo metadata
In order to eliminate some race conditions around updating the
summary{,.sig} file on the server, and to decouple signing the summary
from signing commits, and to support peer to peer mirrors of content
from multiple upstream collections: add support for unsigned summary
files.

This relaxes the requirement for gpg-verify-summary=true iff
collection-id is set in a remote’s local configuration. It depends on
some pending libostree changes to verify the ref for each commit using
the commit’s signed metadata. See
https://github.com/ostreedev/ostree/issues/983.

Metadata storage has moved from the summary file to a new
ostree-metadata well-known branch on each repository, since this can be
signed for each update and for each collection separately. If the
collection-id is set in a remote’s local configuration, flatpak will
retrieve all repository metadata from this branch rather than from the
summary file. If collection-id is unset, it will ignore this branch and
continue to use the summary file, which will continue to be updated (and
externally signed as summary.sig) for backwards compatibility.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-08-18 14:23:03 +02:00
Philip Withnall
ae7d960372 common: Support collection IDs in flatpak{ref,repo} and bundle files
These are loaded from the ref/repo/bundle metadata and added to the new
remote configuration.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-08-18 14:23:03 +02:00
Philip Withnall
b5860e8f2a common/utils: Add flatpak_repo_set_collection_id() helper method
It will be used by builtins-repo-update in a following commit to allow
updating the collection ID for an upstream repo.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-08-18 14:23:03 +02:00
Philip Withnall
30a5cf8136 common: Support collections in check_for_updates() and forward the results
Search for updates on peer to peer sources as well as the internet in
check_for_updates(), and pass the resulting OstreeRepoFinderResult array
to the pull() calls, so a consistent set of checksums are pulled.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-08-18 14:23:03 +02:00
Philip Withnall
0d6455aa5f common/dir: Support new experimental libostree API for finding remotes
This adds support in flatpak-dir.c for using the new libostree API for
finding remotes dynamically for a given set of refs, if flatpak is
configured with --enable-p2p.

The new code paths are only taken if the repository is configured with
a collection ID set.

These changes by themselves aren’t sufficient for full P2P support, as
all the infrastructure for downloading summary files and finding refs
needs to be modified in the following commits.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-08-18 14:23:03 +02:00
Alexander Larsson
4e15d9a5f8 common: Add GSubprocessFlags to flatpak_spawnv
This is useful to e.g. hide stderr
2017-08-18 10:56:15 +02:00
Alexander Larsson
85ba1f75eb Require ostree 2017.10
This includes a change in how ostree reports missing gpg signatures
which makes the test-suite pass. Additionally that change requires
us to change how we detect such missing gpg signatures in one place.

We could try to support both versions, but the easiest fix is to just
require the latest ostree.
2017-08-15 18:41:44 +02:00
Philip Withnall
cd2a555675 common/dir: Clarify the nullability of some variables
flatpak_decompose_ref() can fail, but in this situation we know it won’t
since find_matching_refs() checks it for us and hence guarantees that it
only returns decomposable refs. Add some assertions to make this clearer
and to shut Coverity up.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-08-15 12:28:28 +01:00
Philip Withnall
c157719616 common/dir: Avoid a potential NULL pointer dereference
Everywhere else that index->manifests is used, it’s checked for being
NULL beforehand, which probably means that, sometimes, it might be NULL.
Let’s check that here too.

Coverity issue: 1452432

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-08-15 12:27:28 +01:00