Commit Graph

554 Commits

Author SHA1 Message Date
Alexander Larsson
ff3f459e67 Add flatpak_oci_registry_get_uri 2017-03-29 17:14:19 +02:00
Alexander Larsson
23b2eb6383 OCI: Verify that loaded OCI blobs have the correct checksum 2017-03-27 15:02:55 +02:00
Alexander Larsson
82aad1ccb1 Correctly find system unmaintained extensions
We should not terminate the extension search just because
an earlier directory succeeds. Even non-existant directories
succeed, and anyway we should continue searching even if it
wasn't empty, because multiple subdir extensions may match.

Fixes https://github.com/flatpak/flatpak/issues/654
2017-03-27 11:18:16 +02:00
Colin Walters
2618a19716 Import ostree's compiler warnings, fix up callers
In ostree I maintain what I consider a "baseline" set of compiler
warnings that should *always* be fatal for a modern C project.

I noticed while working on a previous patch that a `-Werror=format`
warning wasn't fatal.

There are a few that are really, really important like
`-Werror=missing-prototypes`. I also take some like `-Werror=misleading-indentation`
which already caught some bugs.  See also https://lwn.net/Articles/678019/
2017-03-27 10:42:36 +02:00
Colin Walters
64fd2c2a8d Bump libglnx, use new glnx_throw(), fix callers
One benefit here becomes immediately obvious - `flatpak_fail()` was lacking
`G_GNUC_PRINTF` which meant we missed a lot of type checking. Fix up the
callers.
2017-03-27 10:42:36 +02:00
Alexander Larsson
3385c9dc5c Fix some warnings reported by clang 2017-03-15 10:17:26 +01:00
André Klitzing
567802749c Fix some issues with musl
* Use realpath instead of canonicalize_file_name
* Add missing include
2017-03-15 10:14:39 +01:00
Alexander Larsson
248a603e6a build: Allow dbus proxy access if explicitly given
If you do something like:
 flatpak build --talk-name=org.foo.Bar appdir
Then we now spawn a dbus proxy for the app.
However, we don't do this by default, even if the
runtime or the app metadata allows this, because
we want builds to normally be disconnected from
the build host.
2017-03-14 16:20:33 +01:00
Alexander Larsson
49b5304589 Update OCI support to latest version of spec
This is a major change in the OCI support, as the format of the OCI image
registries changed. Instead of now having a "ref" file for each image
in the repo it has a single index json file, where the ref name is now
a per-image annotation.

This allows us to support OCI much better, as we can now use the actual
flatpak ref as the OCI ref name, and we can find all the flatpak refs
in a remote.

So, with this you can just use:
 flatpak remote-add --oci remote-name URL

and then you can use the regular flatpak operations on the remote.
2017-03-13 14:31:36 +01:00
Georges Basile Stavracas Neto
d73090cc96 Split extra-data setup and fetch
By splitting the extra-data setup - where we set the number of
extra-data downloads and auxiliary information - and download -
where we actually fetch the extra-data - we can have more precise
progress reports.
2017-03-08 15:37:28 +01:00
Alexander Larsson
7d1a8f69f6 appstream: Don't add runtime to flatpak bundle tag for runtimes 2017-03-08 12:31:44 +01:00
Alexander Larsson
640a02315b extensions: Support multiple versions
This means an extension point can include extensions of multiple
(specified) versions. This is useful for e.g. the GL extensions,
where we want a single extension for all the essentially unversioned
GL extensions (like the nvidia one) that is used by all the
runtimes.
2017-03-06 14:36:20 +01:00
Alexander Larsson
3122d1c014 flatpak_list_extensions: Break out code into helper
This is a minor restructure to make the code more readable
and extensible.
2017-03-06 14:36:20 +01:00
Richard Hughes
d6f4ea424d Allow specifying an ISO-8601 timestamp when using build-export
This allows us to build reproducable repo summaries, for instance in self tests.
2017-03-06 11:38:26 +01:00
Alexander Larsson
62286cf779 Support runtime-less extra-data
This is going to be needed for the nvidia driver to solve
https://github.com/flatpak/flatpak/issues/595
2017-02-28 18:10:06 +01:00
Alexander Larsson
78b5c2fbf5 Fix error check when loading configuration 2017-02-28 11:06:06 +01:00
Alexander Larsson
9d9bd184c7 zero-mtime: Handle error when enumerating directory 2017-02-28 11:02:32 +01:00
Alexander Larsson
d24c5f1423 run: Handle error when enumerating /etc 2017-02-28 11:00:01 +01:00
Alexander Larsson
4db1e74090 utils: Fix flatpak_bundle_load typo
If we failed to look up the app metadata we would
clear out a different out argument instead.
2017-02-28 10:46:56 +01:00
Alexander Larsson
b2b6dd3af2 Avoid possible null dereference
If the link fails to resolve the return value will be NULL, so we shouldn't use
it before checking for NULL.
2017-02-28 10:44:54 +01:00
Alexander Larsson
e1e27559d1 utils: Fix list_unmtainained_refs
There was a stray goto out that caused it to only look at the first
element in the system dirs list.
2017-02-28 10:41:29 +01:00
Mario Sanchez Prada
d0b5b51076 Initialize g_autofree string to NULL, not to crash when early returning
Otherwise, anytime we fail in ostree_repo_write_metadata() will cause
an invalid free to happen, and flatpak to crash.
2017-02-23 14:27:22 +00:00
Alexander Larsson
cc03a2b94b Don't remove origin remotes if some other ref uses it
This fixes https://github.com/flatpak/flatpak/issues/586
2017-02-23 13:52:35 +01:00
Ray Strode
a82708cb10 run: propagate wildcard xauth entries to app bundle
At the moment, flatpak applications are only given FamilyLocal family
xauth cookies from the Xauthority file.  This is so, the sandboxed
application doesn't inadvertently get access to displays on other
computers.

But FamilyLocal isn't the only xauth family that's local.  FamilyWild
entries can be local as well.

Furthermore, FamilyWild entries are preferable to FamilyLocal entries
when found, because they don't break if the system hostname is changed.

This commit makes FamilyWild xauth entries get propagated in the same
way as their FamilyLocal counterparts.
2017-02-22 14:47:14 +01:00
Alexander Larsson
2c71298d53 builder: Its break_hardlink, not unbreak_hardlink 2017-02-22 09:43:57 +01:00
Alexander Larsson
082efe8951 Properly quote all commandlines we print
Fixes https://github.com/flatpak/flatpak/issues/236
2017-02-21 18:56:11 +01:00
Alexander Larsson
d27799518d Fix no-systemd-user warning (it doesn't affect sandboxing anymore) 2017-02-21 15:41:43 +01:00
Alexander Larsson
50c9812a56 utils: Remove unused/broken autorm_rf 2017-02-21 11:50:41 +01:00
Alexander Larsson
5a3c7feb15 builder: Unbreak hardlinks when eu-stripping
Otherwise this breaks with rofiles-fuse if the build produces
hardlinked installed files. For instance, as done by mesa.
2017-02-15 19:22:14 +01:00
Alexander Larsson
8c131be4f6 utils: Add missing Ostree autoptr types 2017-02-15 16:09:48 +01:00
Mario Sanchez Prada
86bf88d89f Allow cancelling the downloading process for extra data
So far, the installation of external apps can only be cancelled
before flatpak starts downloading the extra data, as there's no
cancellable being passed to g_input_stream_read_async().

This fixes that problem, making it possible to cancel installs
from GNOME Software regardless of the installation stage.
2017-02-14 09:01:16 +01:00
Mario Sanchez Prada
2e1740297c Report progress for extra data downloads, as we do for OSTree pulls
Otherwise, clients such as GNOME Software won't be able to report
any progress once the flatpak application has been downloaded and
we enter the stage to download the extra data.
2017-02-14 09:00:57 +01:00
Mario Sanchez Prada
ca952b0f21 Use the thread's default context to download extra data, not a new one
Otherwise, all the progress reporting for the extra data being downloaded
won't work, as the main context used by OstreeAsyncProgress will not be
the same than the one from the nested main loop used to download this.
2017-02-14 09:00:57 +01:00
Alexander Larsson
521e7e6a37 Don't user user namespaces when bubblewrap is setuid
It turns out that it is impossible for to get ptrace capabilities
for child user namespaces in the current kernel if the user
namespace is created as root, which is what happens when bwrap
is setuid root (see https://github.com/flatpak/flatpak/issues/557
for details).

This is very problematic, as ptrace rights controls access to
/proc/$pid/root which is what we base the detection of peer
app id and rights on for portals.

For now, we disable user namespaces (except for the case of
unprivileged user namespaces, where it is necessary and works).
2017-02-13 15:03:00 +01:00
Alexander Larsson
08ea3baf49 builder: Download files and archives directly to disk, don't keep them in memory.
This works much better for larger sources.
2017-02-09 12:26:05 +01:00
Alexander Larsson
bf316c1a82 builder: Compute SHA256 while downloading archives 2017-02-09 12:17:10 +01:00
Alexander Larsson
763a686d87 dri: Fix nvidia driver with shared network
If we have network access, then nvidia talks to the xserver
and for some reason it then also needs /dev/nvidia-modeset.
So, lets add that to the dri device list.
2017-02-08 16:43:14 +01:00
Alexander Larsson
02202b9e76 utils: Add flatpak_copy_bytes
This copies data from one fd to another.
2017-02-07 16:39:23 +01:00
Alexander Larsson
2e453048e0 extensions: Support enable/install-if=active-gl-driver
Only use/download this extension if it matches an active gl driver.
2017-02-03 09:49:05 +01:00
Alexander Larsson
d4d15c7211 Initial flatpak_get_gl_drivers() implementation
This is supposed to list all the currently loaded "non-standard" gl drivers.
If FLATPAK_GL_DRIVERS is set, then that is used, otherwise it looks
for an nvidia driver and if so, uses that, and always adding "default"
at the end which is meant to resolve to a stable mesa fallback build, as
well as "host" which can be used if you have a host-side driver
as an unmaintained extension.
2017-02-03 09:48:16 +01:00
Alexander Larsson
160f3a9820 extensions: Handle priorities with merge-dirs 2017-02-03 08:17:22 +01:00
Alexander Larsson
c88f1aa835 extensions: Support merge-dirs=list..
This causes the listed directories to become symlink farms
into all the subdirectory extensions.
2017-02-02 13:56:34 +01:00
Alexander Larsson
5e1d456b8b extensions: Support subdirectory-suffix=foo
If directory is "foo" and the extension id ends with ".ext" and
subdirectory-suffix is "sub" then the extension point will
be "/usr/foo/ext/sub" rather than just "/usr/foo/ext".

This is very useful when the extension point naming scheme is
"reversed". For instance, this happens for the /usr/share/themes directory.
An extension point for a gtk3 theme would be in /usr/share/themes/$NAME/gtk-3.0,
which could be achived by using subdirectory-suffix=gtk-3.0.
2017-02-01 19:59:12 +01:00
Alexander Larsson
a3da0b3da8 extensions: Add add_ld_path property
If your extension points set this, then each extension will have
the corresponding subdirectory added to LD_LIBRARY_PATH.

We also support a priority property in the ExtensionOf group
in the extensions themselves to set the search order.
2017-02-01 19:46:25 +01:00
Alexander Larsson
7f8ad5b3a1 extensions: Make extension tmpfs requirement independent on order
If we sort, or subset the extensions we use, then we can't just
set need_tmpfs on the first one, instead do the checking
for the first one when we're applying the extensions.
2017-02-01 19:42:57 +01:00
Alexander Larsson
475dcb178a Support extra-data for runtime extensions too
This is very interesting for e.g. the nvidia drivers
2017-01-30 17:00:53 +01:00
Mario Sanchez Prada
bfd43c1f98 Check if symlink target for /etc/localtime exists in the runtime
On unmonitored systems (if the session helper is not available), we
currently decide whether to create a symlink or a read-only bind mount
for /etc/localtime based on whether that's a symlink in the host or
not, but we don't check whether that symlink would be reachable in
the sandboxed environment, which might lead to bad situations.

This patch adds some extra checks relying on GFile's API to check
whether that symlink would be reachable before making the final
decision: if it's not, then do a bind mount despite of the file
being a symlink in the host.

https://github.com/flatpak/flatpak/issues/409
2017-01-30 14:35:04 +01:00
Mario Sanchez Prada
1d7357616b Don't ignore OSTree errors when fetching the extra-data sources
In extract_extra_data(), flatpak currently returns TRUE whenever
flatpak_repo_get_extra_data_sources() returns NULL, which is correct
most of the times since that's usually caused by the extra-data
finish-args argument not being present.

However, that operation relies on OSTree's ostree_repo_load_variant()
too, which could fail for unrelated reasons. And in those cases flatpak
would still keep returning TRUE here even in cases where the extra-data
sources could be there, but an error happened while retrieving it.

This seems to be a bug leading to unlikely -yet possible- situations,
where the user would end up with an "external app" like Spotify reported
to be succesfully installed but without the files/extra directory, which
is useless.
2017-01-30 12:25:39 +01:00
Alexander Larsson
84aed615da run: Fix e.g. --filesystem=xdg-config/foo without :create
Fixes https://github.com/flatpak/flatpak/issues/463
2017-01-27 10:43:59 +01:00
Alexander Larsson
bc5ea57226 Run: Make sure all mounted sources are read-only
It turned out that some sources where bind-mounted read-write
which should have been read-only:

 * Extensions
 * Fonts
 * resolv.conf
 * localtime
 * machine-id

Many of these are not generally writable by the user, but
some are, which is pretty bad. For instance if the an
app is user-installed it will be able to write to its
locale data.

We fix this by using --ro-bind where needed.
2017-01-26 18:19:46 +01:00