Commit Graph

658 Commits

Author SHA1 Message Date
Colin Walters
bcced9adc7 Bump libglnx, port to new tmpfile API
I think the new tmpfile here is a lot better; there were places in flatpak where
we weren't doing "unlink on failure" etc.
2017-05-19 09:27:03 +02:00
Alexander Larsson
05aa9e4eb3 Remove unused variable 2017-05-19 09:24:51 +02:00
Alexander Larsson
1c46cfe45d progress: Tweak metadata part of download
We artificially limit the metadata phase to the first 20 metadata
objects, because otherwise that phase takes too long time, as it
downloads content at the same time.
2017-05-18 15:36:34 +02:00
Alexander Larsson
435091e5cf progress: Simplify the progress calculations
For the delta case we can get perfect results by just ignoring
the counts and relying on the sizes. However, this needs a
recent ostree that supports the fetched-delta-part-size field.

For the object case we keep using the object average size
to estimate a size which we can compare with the extra data
size.
2017-05-18 15:14:42 +02:00
Alexander Larsson
fbd5452aac progress: Use the new atomic progress API
We read everything at once, which means we will not
race against the download thread possibly updating the
values.
2017-05-18 12:28:57 +02:00
Georges Basile Stavracas Neto
6924658f59 Improve progress report calculation
Now that we have access to the total extra-data download size,
we can have much more precise progress reports by summing up
all the download sizes from OSTree and extra-data.

This patch makes the progress report callback use the extra-data
sizes, as well as calculate the average size (in bytes) of the
content.

flatpak/flatpak#609
2017-05-18 09:02:02 +02:00
Alexander Larsson
e7ad74c398 run: Fix race condition in app identification
There is a race condition in how the portals detects the peer app-id.
If we manager to open /proc/$pid/root, and then openat(fd,
".flatpak-info"), but the process dies inbetween the two, then the
.flatpak-info read-only bind mount (and all other mounts in the
namespace except the root one) is unmounted, so we will find
and empty .flatpakinfo file.

We fix this race by storing the contents in a regular file, but
also as a readonly bind mount on top of it.

For typical dbus portals the pid is the dbus proxy though, and in
that case the app can't modify the file, so we make it just
a file there instead of file + bind-mount.
2017-05-17 15:06:03 +02:00
Georges Basile Stavracas Neto
222c525910 dir: Report progress more frequently
Flatpak relies on OSTree to report the progress, and
OSTree's progress report frequency fallbacks to 1 second.

Recently, however, OSTree received support for setting
custom update frequencies. Since it relies on GVariant
options, if the user has an older OSTree, it'll simply
be ignored.

This patch, then, makes Flatpak report progress every
100ms rather than the default value of 1 second.

flatpak/flatpak#609
2017-05-12 16:16:03 +02:00
Alexander Larsson
3e9bc8ba7a Rewrite exported mimetype files
We only allow globs, not magic matches, and we drop the glob
priority to a very low level (weight=5) which means that its
hard for app-installed mimetypes to override the system installed
ones. That should make exporting mimetypes pretty safe.
2017-05-11 18:16:13 +02:00
Alexander Larsson
050fe4e795 exports: Fix up exporting of dbus service files
The relative paths for the symlinks in the table was wrong.
2017-05-11 17:20:32 +02:00
Alexander Larsson
2ebf672866 Disable exported search providers by default
Installing a search provider is a minor security issue, as it
can see all that you search for in the desktop, so we rewrite
these so that they are always disabled by default. The user
can then chose to enable it if he wants.
2017-05-11 16:04:45 +02:00
Alexander Larsson
e8369a69ef install: Limit the exported file to a whitelist
Instead of exporting any files we add a whilelist
of directories that get exported:

 share/applications
 share/icons
 share/dbus-1/services
 share/gnome-shell/search-providers
 share/mime/packages

This avoids potentially installing some kind of file that the
host system reads and interprets in a risky way.

Applications and dbus services are safe because we rewrite them.
Icons are safe as long as the image loaders are, and if they are
not we have worse problems.
Search providers and mime formats are somewhat problematic, and
follow-up commits will rewrite these to be safer.
2017-05-11 15:28:19 +02:00
Alexander Larsson
373d2155ec deploy: Verify that xa.metadata in the commit matches the deployed file
We may have made decisions based on the permissions listed in the
metadata in the (signed, thus trusted) commit. However, at runtime
we actually look at the metadata file that is deployed. Make sure
these are the same by comparing them when we deploy.
2017-05-11 14:13:44 +02:00
Alexander Larsson
98e749202a update: Fix update for partial commits with system-helper
When we're pulling via the system-child repo we don't inherit
the commitpartial state from the parent, so we didn't know a
commit was partial, so the full contents was not downloaded.
This fixes updating a partial install to the same commit, but
with different subsets.
2017-05-11 13:58:46 +02:00
Alexander Larsson
b5c66a7689 update: If resused ostree repo fails, blow it away and create new
This happened to me because I had some leftover from a test run
that failed. But could happen for other reasons.
2017-05-11 13:57:43 +02:00
Alexander Larsson
529c3bbaf1 deploy: Append the subdirs to the checkout dir
This allows us to easily move between different partial
installs of the same commit id.
2017-05-11 12:43:30 +02:00
Alexander Larsson
093b60c157 deploy: Uncouple active link from checksum
We don't guarantee that the active link is identical to the
checksum anymore. If you really need the checksum you have
to look at the deploy data.

This is mainly changing the names from "checksum" to "active_id"
in the code that touches the active link, except the case where
we're undeploying after an update. We then use the old active
link value rather than the old commit id as the undeploy id.

This will allow us to have partial deploys with different names
than the full or differently partial deploy.
2017-05-11 12:40:36 +02:00
Alexander Larsson
af7195e6ae update-metadata: silently ignore for non-signed system-helper case
We can't really verify the new updates in the system helper for
the non-signed case, so just ignore it.
2017-05-11 11:10:02 +02:00
Alexander Larsson
2fa6e2fe97 build-update-repo: Use the size/metadata info in the commit object
If the data is already there, there is no need to re-calculate it.
2017-05-11 10:09:39 +02:00
Alexander Larsson
1e5ffa926a Add workaround to flatpak_repo_collect_sizes for uncommited objects
It turns out the underlying call ostree_repo_query_object_storage_size
doesn't work for staged objects, so we work around this by actually
loading the object, walking back to the original unix input stream
and fstat:ing the fd from that.
2017-05-11 10:09:39 +02:00
Matthias Clasen
029a5e38e1 Remove unused variables
clang flags these.
2017-05-11 08:38:32 +02:00
Alexander Larsson
644bb1cd41 common: Break out the flatpak progress calculator to a helper method. 2017-05-10 17:24:48 +02:00
Alexander Larsson
96cdf9acfc Don't use gdbus-codegen autoptr generation
This requires a glib more recent than what we want, so just do it
manually.
2017-05-10 17:22:05 +02:00
Matthias Clasen
66e91f55e8 Add a marker to rewritten desktop files
Add X-Flatpak=true to rewritten desktop files.
Desktop files have multiple consumers, and this
makes it easier for them to know what to do.
2017-05-10 11:54:19 +02:00
Alexander Larsson
7a4c82529e Support build-update-repo --redirect-url=
When clients install/update they will see this property in the
(signed) summary and update the url in the config, making this
essentially a permanent redirect.
2017-05-09 17:02:00 +02:00
Alexander Larsson
21778f1075 Add support for adding new gpg keys via signed summary 2017-05-09 16:43:20 +02:00
Alexander Larsson
0bf1b31256 update_remote_configuration_for_summary: Never use system-helper
The system-helper support now happens at the higher level
in update_remote_configuration, so there is no need for this.
2017-05-09 16:33:47 +02:00
Alexander Larsson
fe09ffaa03 Optimize flatpak_summary_match_subrefs
This is called a lot during update, so we rewrite it to
avoid splitting up each ref in the summary file.
2017-05-09 15:18:13 +02:00
Alexander Larsson
d3a7dce117 Use flatpak_variant_bsearch_str to lookup in summary cache
This is a lot faster than the linear probe of g_variant_lookup.
2017-05-09 15:17:07 +02:00
Alexander Larsson
a058c5cbf2 Optimize flatpak_variant_bsearch_str
Rather than parsing a get_child string we just access
the right child and type.
2017-05-09 15:15:54 +02:00
Alexander Larsson
44cf5076fa update: Split update into check_for_update and update
This way we can avoid printing "updating foo" for every
app even if there is no update.
2017-05-09 14:08:27 +02:00
Alexander Larsson
864f2def12 transaction: Always update metadata for remotes on update/install
All remotes involved in an update are updated before starting
transaction.
2017-05-09 13:25:21 +02:00
Alexander Larsson
9896005ad0 remote-modify: Implement --update-metadata as a system-helper method
We download the summary and send it to the system helper, it verifies
the checksum and applies the changes, with the same polkit permissions
required as for an app update (i.e. typically none).

This allows us to update metadata automatically, without permission
requests.
2017-05-09 13:25:21 +02:00
Alexander Larsson
f7c2fd0c30 common: Drop verbose log of using cached summary
This is just to common and is making -v useless
2017-05-09 13:25:21 +02:00
Alexander Larsson
b06e38073a common: Store the summary signature in the cache too
We will need this later
2017-05-09 13:25:21 +02:00
Alexander Larsson
e428ee47fc common: Add flatpak_dir_update_remote_configuration_for_summary 2017-05-09 13:25:21 +02:00
Alexander Larsson
b106fd9c67 remote-modify: Never update explicitly set values
Whenever you explicitly specify some value (e.g. for
title or default-branch) we set a $KEY-is-set option
to True, and if that is set we never automatically update it.
2017-05-09 13:25:21 +02:00
Alexander Larsson
62598840d1 common: Remove unused flatpak_dir_install_or_update 2017-05-09 13:25:21 +02:00
Alexander Larsson
6c1ebbcd1a install: Handle no-static-delta in --user installs too 2017-05-09 13:25:21 +02:00
Alexander Larsson
1a49029f9d Move caches to ~/.cache
The system-cache (summaries and temporary repos for downloads) are moved
from ~/.local/share/flatpak/system-cache to
~/.cache/flatpak/system-cache (or wherever XDG_CACHE_HOME is) because
this is the proper location for caches.

Fixes https://github.com/flatpak/flatpak/issues/767
2017-05-04 17:29:30 +02:00
Alexander Larsson
4d2d07d033 Expose host /etc/hosts and /etc/host.conf
These are local network configuration, very much similar to
resolv.conf, so should also be exposed.

Fixes https://github.com/alexlarsson/spotify-app/issues/42
2017-05-04 13:08:25 +02:00
Alexander Larsson
858a4b6044 build: Kill sandbox when flatpak build dies
This ensures that no processes from the build lives
past the return of the build itself, which might
accidentally happen.

We still allow apps to stay around after the regular
flatpak run command finished though, as this is sometimes
done on purpose.
2017-05-04 10:53:48 +02:00
Alexander Larsson
f28d318cc9 run: Handle the case where /tmp on the host is a symlink
If the app explicitly grants access to the host /tmp (for
instance telegram) then when this is being exposed as a symlink
in the sandbox we get an error because /tmp already exists
as a dir, which we create very early on.

It doesn't really make sense to keep /tmp as a symlink in
the sandbox anyway, so we just special case this and mount
the symlink target as /tmp.
2017-05-04 10:34:40 +02:00
Alexander Larsson
7f7387ce5e build: Fix fallout from the TMPDIR unset
We need to handle the NULL in the default_exports array
also when creating a minimal environment for the build.
Otherwise TMPDIR was set to (null).
2017-05-04 10:12:03 +02:00
Alexander Larsson
93e13a42ec run: Only forward as document if the target app can't see the file 2017-05-03 18:23:30 +02:00
Alexander Larsson
5a373a9cf9 run: Clean up the exports handling code
This doesn't really change anything but renames a few functions and
introduces a FlatpakExports struct that is uses instead of the caller
open-coding a hashtable
2017-05-03 15:48:39 +02:00
Alexander Larsson
1797611c90 run: Properly handle canonicalization in file exports
Always canonicalize filesystem arguments for exposing and
hiding and use the canonical form in all places.
2017-05-03 14:40:59 +02:00
Alexander Larsson
296b7774d3 run: Use flatpak_has_path_prefix instead of hand rolling
Instead of manually adding a slash at the end of the prefix
matches, use the proper helper
2017-05-03 14:39:12 +02:00
Alexander Larsson
f228577377 run: Handle forwarding uris better
We need to know if we're forwarding uris or files, because
if we're doing uris we need to pass on non-file uris as-is.
So, we enclose uris with "@@u @@" instead.

This also properly (un)escapes the file uris
2017-05-03 13:53:39 +02:00
Matthias Clasen
5013601c41 Don't get the doc mount path twice
We already call GetMountPoint in add_document_portal_args.
Lets keep the result around and reuse it in add_rest_args,
stead of calling it again.
2017-05-03 13:27:52 +02:00