Commit Graph
531 Commits
Author SHA1 Message Date
Alexander Larsson 8bd07ca2a0 Support runtime-less extra-data
This is going to be needed for the nvidia driver to solve
https://github.com/flatpak/flatpak/issues/595

(cherry picked from commit 62286cf779)
2017-02-28 19:54:37 +01:00
Alexander Larsson c216d989a8 Fix error check when loading configuration
(cherry picked from commit 78b5c2fbf5)
2017-02-28 19:54:32 +01:00
Alexander Larsson 0869586e47 zero-mtime: Handle error when enumerating directory
(cherry picked from commit 9d9bd184c7)
2017-02-28 19:54:27 +01:00
Alexander Larsson 91f91b5994 run: Handle error when enumerating /etc
(cherry picked from commit d24c5f1423)
2017-02-28 19:54:23 +01:00
Alexander Larsson 4adb1c21ad utils: Fix flatpak_bundle_load typo
If we failed to look up the app metadata we would
clear out a different out argument instead.

(cherry picked from commit 4db1e74090)
2017-02-28 19:53:50 +01:00
Alexander Larsson 20b872d2ce 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.

(cherry picked from commit b2b6dd3af2)
2017-02-28 19:53:45 +01:00
Alexander Larsson d0e927a538 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.

(cherry picked from commit e1e27559d1)
2017-02-28 19:53:36 +01:00
Mario Sanchez Prada a44b6191d7 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.

(cherry picked from commit d0b5b51076)
2017-02-27 11:44:36 +01:00
Alexander Larsson 37a19ce172 Don't remove origin remotes if some other ref uses it
This fixes https://github.com/flatpak/flatpak/issues/586

(cherry picked from commit cc03a2b94b)
2017-02-27 11:43:53 +01:00
Ray Strode 24632dab0b 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.

(cherry picked from commit a82708cb10)
2017-02-27 11:43:16 +01:00
Alexander Larsson fad0ab1ca1 Fix no-systemd-user warning (it doesn't affect sandboxing anymore)
(cherry picked from commit d27799518d)
2017-02-27 11:41:10 +01:00
Mario Sanchez Prada f8c74167fd 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.

(cherry picked from commit 86bf88d89f)
2017-02-14 11:14:41 +01:00
Mario Sanchez Prada 01c5727cfa 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.

(cherry picked from commit 2e1740297c)
2017-02-14 11:14:38 +01:00
Mario Sanchez Prada da3f059485 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.

(cherry picked from commit ca952b0f21)
2017-02-14 11:14:34 +01:00
Alexander Larsson 0e8d2884d6 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).

(cherry picked from commit 521e7e6a37)
2017-02-13 15:12:44 +01:00
Alexander Larsson 860ef3a798 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.

(cherry picked from commit 763a686d87)
2017-02-08 16:44:31 +01:00
Alexander Larsson 3c8288f0e9 extensions: Support enable/install-if=active-gl-driver
Only use/download this extension if it matches an active gl driver.

(cherry picked from commit 2e453048e0)
2017-02-06 15:10:19 +01:00
Alexander Larsson 2ae9d9aaba 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.

(cherry picked from commit d4d15c7211)
2017-02-06 15:10:15 +01:00
Alexander Larsson caa41bbb7f extensions: Handle priorities with merge-dirs
(cherry picked from commit 160f3a9820)
2017-02-06 15:10:12 +01:00
Alexander Larsson bd9ff4de31 extensions: Support merge-dirs=list..
This causes the listed directories to become symlink farms
into all the subdirectory extensions.

(cherry picked from commit c88f1aa835)
2017-02-06 15:10:07 +01:00
Alexander Larsson 444f36c4cc 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.

(cherry picked from commit 5e1d456b8b)
2017-02-06 15:09:31 +01:00
Alexander Larsson 5c9b12a630 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.

(cherry picked from commit a3da0b3da8)
2017-02-06 15:01:41 +01:00
Alexander Larsson ab6915509c 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.

(cherry picked from commit 7f8ad5b3a1)
2017-02-06 14:56:10 +01:00
Alexander Larsson 10ddde03fb Support extra-data for runtime extensions too
This is very interesting for e.g. the nvidia drivers

(cherry picked from commit 475dcb178a)
2017-02-06 14:55:57 +01:00
Mario Sanchez Prada 74146cde10 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.

(cherry picked from commit 1d7357616b)
2017-02-06 14:55:47 +01:00
Alexander Larsson 7e3cd93794 run: Fix e.g. --filesystem=xdg-config/foo without :create
Fixes https://github.com/flatpak/flatpak/issues/463

(cherry picked from commit 84aed615da)
2017-01-27 10:51:06 +01:00
Alexander Larsson 7db0ac595c 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.

(cherry picked from commit bc5ea57226)
2017-01-27 10:50:55 +01:00
Alexander Larsson 6cabfad7e3 Make /etc writable when building a runtime
We make /etc just a symlink to /usr/etc when we're building a runtime
and /etc is supposed to be writable. Otherwise the bind-mount we
normally have there don't allow use to replace existing files in /etc.

(cherry picked from commit ab446ebac5)
2017-01-27 10:50:41 +01:00
Alexander Larsson 161401317e dbus-proxy: Make it work if XDG_RUNTIME_DIR not set
The socket directory then ended up in $HOME which was read-only, so
we couldn't create the socket. We solve this by putting the sockets
in a subdirectory and always making this directory writable in the
proxy.

(cherry picked from commit 0bea92bd73)
2017-01-24 09:54:11 +01:00
Matt Watson f7027edaff install: handle arch when installing from a flatpakref
Before this commit
$ flatpak install --arch someArch --from some.flatpakref
Would completely ignore the arch argument and only install for the
default flatpak architecture. Since flatpakref files don't include
an arch field, there's no reason we can't attempt to install the
arch specified on the command line.

(cherry picked from commit ee83b5a70d)
2017-01-24 09:54:11 +01:00
Juan Pablo Ugarte 73446d63b4 --device=dri added support for Mali drivers
(cherry picked from commit cc0c6354a2)
2017-01-20 15:08:47 +01:00
Alexander Larsson e190908589 Create the homedir last to avoid symlink issues
If the homedir is on a symlink (say /home -> /var/home) but the homedir
is in /home, then we shouldn't create a directory in /home because
then the symlink creation will fail. Instead we move the homedir
creation to the end, where we will create it in the symlink if needed.

This should fix https://github.com/flatpak/flatpak/issues/493

(cherry picked from commit fa6f7228886e983a5c1ff64e1d9db8ea0014ec26)
2017-01-19 15:33:51 +01:00
Alexander Larsson 21a0bd9ed3 Run: Handle dependencies when exposing symlinks
If you are exposing a symlink, say /link (-> /target) and
also a child of it, say /link/child, then we run into dependency
issues. For instance, the /link symlink is created, pointing to /target,
but then we try to to create /link/child before the /target
bind mount is setup, which will fail.

We work around this by adding a level, and the dependency of a symlink
(/target in the above case) will always be handled first. This isn't
a perfect solution, but is likely to be good enough in practice.

(cherry picked from commit 5c4c4bbe56807ce94ef2eb0cc860b1cf488371f5)
2017-01-19 15:33:47 +01:00
Alexander Larsson 1851df22e4 run: Create symlinks as relative paths to make them work during bwrap setup
During setup the new root is in /newroot, so absolute symlinks don't work.
We make them realtive so that we can resolve the symlinks during setup.

(cherry picked from commit b1dd1c3f7a865f39ef9f296e3a0f96304f96247c)
2017-01-19 15:33:43 +01:00
Alexander Larsson d24b862a50 flatpak_resolve_symlink: Properly make paths absolute
We need to use g_build_filename, g_build_path takes a separator
as the first arg, not a path!

(cherry picked from commit 896c483cac6897cef6202055ed127e37e09f5ab8)
2017-01-19 15:33:39 +01:00
Alexander Larsson e5346b7709 Don't break if exporting paths or symlinks to files in the runtime
For instance like in https://github.com/flatpak/flatpak/issues/494
if there is a /linuxrc -> /bin/busybox symlink, and /bin/busybox
is not in the runtime then we will fail creating it as a mountpoint
for the bind mount.

Fixes https://github.com/flatpak/flatpak/issues/494

(cherry picked from commit 592bea2b2e)
2017-01-19 15:33:34 +01:00
Ikey Doherty 91d4663ace Fix compiler warnings with uninitialised cleanup pointers
This change fixes GCC compiler warnings where a cleanup function was
specified on an uninitialised pointer, which in the view of GCC could
result in an errornous free of uninitialised memory, if the functions
that initialise them do not return NULL.

Signed-off-by: Ikey Doherty <ikey@solus-project.com>
(cherry picked from commit 605c7ee87b)
2017-01-19 15:33:30 +01:00
Alexander Larsson a2810186b8 appstream update: Allow component ids not ending in .desktop
This is needed for runtimes
2017-01-18 13:22:56 +01:00
Alexander Larsson 902fb71399 Use seccomp to filter out TIOCSTI ioctl
This would otherwise let the sandbox add input to the controlling tty.
2017-01-17 16:36:56 +01:00
Alexander Larsson 8152331bd0 Make sure /var/tmp is not on tmpfs
Apps may rely on /var/tmp not being in ram, for instance when
downloading large files. See for instance:

  http://0pointer.net/blog/projects/tmp.html

We make /var/tmp point to ~/.var/app/cache/tmp so that each app get
its own instane, and so that its cleared whe removing xdg-cache-dir
for the app.
2017-01-16 13:04:55 +01:00
Alexander Larsson 4e1bf67bff Print a warning if the remote metadata cache is not found 2017-01-12 10:45:44 +01:00
Joaquim Rocha 5dd952e68e Fix downloading extra data when run from a different thread
The main loop that is initiated while the extra data is being downloaded
needs a different context to be the thread-default one, otherwise the
operations just hang when running from a different thread.
2017-01-12 00:23:39 +01:00
Alexander Larsson 4c686332a3 OCI: Create all-readable layer blobs
Otherwise we can't export these via http
2017-01-11 22:37:26 +01:00
Alexander Larsson fed5cb3667 OCI: Stop using json-glib apis that don't exist in 1.0.x 2016-12-21 14:20:28 +01:00
Alexander Larsson f20e5f7823 bundles: Support dependencies and runtime-repo
If the bundle contains an origin link we can now install related
things from it, such as locale data.

You can also build the bundle with --runtime-repo=URL, where the url
points to a flatpakrepo file for a repo with runtimes. This works
similar to the RuntimeRepo= feature in flatpakref files.
2016-12-20 16:27:57 +01:00
Mario Sanchez Prada 82906a63bd Add support for the FLATPAK_CONFIG_DIR environment variable
This will be useful for testing purposes, so that we can provide
our own versions of the configuration files normally under
/etc/flatpak/installations.d.
2016-12-20 09:54:39 +01:00
Mario Sanchez Prada 15e7f14ca3 Adjusted internal representation for storage types of system installations
I set these as separate bits by mistake when there's no good reason for
them to be like that, as they are not flags that are meant to be combined,
but a list of exclusive values.
2016-12-20 09:52:03 +01:00
Alexander Larsson 5a12917a2f oci: Fix leak in flatpak_pull_from_oci 2016-12-19 14:19:41 +01:00
Alexander Larsson f92f233758 flatpak_bundle_load: Fix leak 2016-12-19 14:19:41 +01:00
Mario Sanchez Prada b704c385c8 Change file extension for installations configuration files to '.conf'
The old '.install' one was probably too specific, so let's move it to
a more generic (and common) extension before making the release.
2016-12-19 12:52:46 +01:00