Commit Graph

2383 Commits

Author SHA1 Message Date
Alexander Larsson
37d809ff9f 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.

(cherry picked from commit fef8743f26)

Closes: #1115
Approved by: alexlarsson
2017-10-19 09:04:50 +00:00
Alexander Larsson
25c151fbd9 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.

(cherry picked from commit 1ee74fc5ea)
2017-09-13 14:58:51 +02:00
Alexander Larsson
5a0dc27522 dbus-proxy: Make wildcard rules match deeply
For instance, org.my.App.* will now match org.my.App.foo.bar, and even
org.my.App, where it would previously only match org.my.App.foo.

This makes a lot of sense, because it allows you to structure the
subset of the dbus namespace you're granted how you please, and
there is no real security problem with this.

It also matches how arg0namespace works in dbus matches and how the
proposed dbus-implemented filterin works in:
https://bugs.freedesktop.org/show_bug.cgi?id=101902
2017-09-05 12:14:34 +02:00
Alexander Larsson
be8dca2024 dbus-proxy: Forbid old-style eavesdropping 2017-09-05 12:14:34 +02:00
Alexander Larsson
0723efdcc8 Manually copy summary for update and appdata too
Origin: backport, 0.9.6, commit:67ffd9a0b6f2f76de8aa08e6eb00505e48c48cbd
2017-06-28 12:17:43 +02:00
Alexander Larsson
8249593482 install: Manually save summary[.sig] in cache repo
With the latest ostree, pull --mirror does not mirror the
summary for partial pulls, so system-wide installs fail. We
fix it by manually updating the summary.

Origin: backport, 0.9.6, commit:e987d92ad03981895a2a60db4f82420a12cd6cb7
2017-06-28 12:17:43 +02:00
Alexander Larsson
f76f500236 common: Store the summary signature in the cache too
We will need this later

Origin: backport, 0.9.4, commit:b06e38073a17dc2e67a7774768100f6cc9769791
2017-06-28 12:17:43 +02:00
Simon McVittie
3ba6e122e1 test-run: Allow org.test.Setuid to install, as long as it's not setuid
libostree attempts to strip the setuid and setgid bits from file
permissions in user-mode checkouts, which, if successful, would make
Flatpak's check for setuid ineffective and unnecessary. In versions
older than 2017.7 this was not consistently applied, making commits
2c8e241 and 02a299f necessary to defeat CVE-2017-9780 (see #845).

libostree 2017.7 removes setuid and setgid bits more thoroughly
as a result of fixing https://github.com/ostreedev/ostree/issues/633
in PR https://github.com/ostreedev/ostree/pull/903, which means that
this test fails when linking flatpak 0.8.x to libostree 2017.7.

Signed-off-by: Simon McVittie <smcv@debian.org>
2017-06-28 12:17:43 +02:00
Alexander Larsson
fd186307b5 Update pofiles 0.8.7 2017-06-20 15:32:55 +02:00
Alexander Larsson
c7ca5250f7 Update version to 0.8.7 2017-06-20 15:24:15 +02:00
Alexander Larsson
c15adead49 Update NEWS for release 2017-06-20 15:23:59 +02:00
Alexander Larsson
2c8e2417de Ensure we don't install world-writable dirs or setuid files
This is solved in a much nicer way on master, using new ostree
APIs. However, here we take a brute-force approach of scanning
all staged files and ensuring we don't have any files or
directories with invalid modes before committing the transaction.

If any bad permissions were found we delete the entire staging
directory.
2017-06-19 19:47:53 +02:00
Colin Walters
02a299f5c0 dir: Ensure ~/.local/share/flatpak is 0700
This goes into a big old topic about Unix homedir permissions; it's not uncommon
for general purpose OS vendors to have homedirs be 0755. In that case,
applications need to ensure confidentiality for data requiring it (classically
e.g. `~/.ssh`) by making the dirs `0700`.

While most of the data in the flatpak per-user dir probably isn't confidential
(debatably) we have a different issue; if container content includes suid or
world-writable files/dirs, then having that data accessible to other users
is obviously problematic.

We're going to fix flatpak/ostree to not create files with those modes
to begin with, but this simple fix closes off the attack route for
the per-user directory.

A different fix will be necessary for the system-wide repo.

See: https://github.com/flatpak/flatpak/pull/837
(cherry picked from commit daf36ba2af)
2017-06-19 19:25:52 +02:00
Colin Walters
714a70338d dir: Ensure we return on pull error to avoid error-overwrites
Looking at the git history, this code originally retried on
some cases for pull, then stopped doing so, then a later commit
added code after it, which made it incorrect.

Just do an early return again and drop the `res` variable.

(cherry picked from commit 4714f55ebd)
2017-06-19 19:25:52 +02:00
Alexander Larsson
22c878d1e5 tests: Increase timeouts waiting for file notification
For whatever reason .5 seconds was not enough time for me
to get a file notification message, so increase it to 1 sec.
2017-06-19 19:25:52 +02:00
Alexander Larsson
1433c2960e Bump version to 0.8.6 0.8.6 2017-06-05 14:53:13 +02:00
Alexander Larsson
bbfcd4b304 Update NEWS for release 2017-06-05 14:52:58 +02:00
Alexander Larsson
b3599a4b8f Update pofiles 2017-06-05 14:46:29 +02:00
Simon McVittie
d513b03752 flatpak-dir: Check for variant containing string correctly
g_variant_get_type_string() is like g_dbus_message_get_signature(),
not like G_VALUE_HOLDS_STRING(). Use g_variant_is_of_type() to get
the equivalent of G_VALUE_HOLDS_STRING(). This was correct on master,
but went wrong during backporting to 0.8.x.

Signed-off-by: Simon McVittie <smcv@debian.org>
2017-06-04 18:20:09 +02:00
Alexander Larsson
beaa1fc3c9 run: Allow --filesystem=xdg-*/subdir:ro
We previously required the directory to be writable to expose
it in the app-specific directory. However, the file was already
made visible in the regular location, and it was explicitly requested
by the app, so not allowing it to be there read-only makes no sense.

In particular, this allows KDE apps to use
--filesystem=xdg-config/kdeglobals:ro to allow apps to pick up global
configurations such as theme, etc, in a safe way.

(cherry picked from commit 1d9fe6fbf3)
2017-06-01 11:07:12 +02:00
Alexander Larsson
ac357d76b1 run: Allow regular files for --filesystem=xdg-config/path
KDE needs this to put ~/.config/kdeglobals into the sandbox

(cherry picked from commit 75d884046d)
2017-06-01 11:07:11 +02:00
Alexander Larsson
c376cb1af0 Minimal backport of rewrite-url and gpg-keys remote metadata support
This backports the minimal support for migrating a remote to
a new url/gpg-key from master (see commit 21778f1075
and 7a4c82529e).

The support is manual (you must run flatpak remote-modify --update-metadata) and
only supports the client-side consuming parts. You have to use the 0.9.x
series to update the server-side repository.
2017-05-31 10:40:50 +02:00
Alexander Larsson
888743b362 dbus-portal: Fix return value type of filtered NameHasOwner
Fixes https://github.com/flatpak/flatpak/issues/817

(cherry picked from commit bd22ff8d42)
2017-05-31 10:00:23 +02:00
Jonas Ådahl
304c127348 run: Handle non-default WAYLAND_DISPLAY
WAYLAND_DISPLAY can be other than "wayland-0" for various reasons, such
as using a custom Wayland display server or the session display server
using a custom display name.

Note that for xdg-desktop-portal to support showing portal windows, the
xdg-desktop-portal service MUST use the same WAYLAND_DISPLAY.

(cherry picked from commit a1ff20ca0e)
2017-05-31 09:58:05 +02:00
Alexander Larsson
414d699621 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.

(cherry picked from commit e7ad74c398)
2017-05-31 09:57:23 +02:00
Alexander Larsson
6265200c83 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

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.

This is based on what we do in master (commit
e8369a69ef), but that also
allows mimetypes and gnome shell provider files. These were made safe
using by rewriting during exports, but that code is not backported.
2017-05-31 09:55:02 +02:00
Matthias Clasen
5e82a7b11a Add a marker to rewritten desktop files
Add X-Flatpak=$app to rewritten desktop files.
Desktop files have multiple consumers, and this
makes it easier for them to know what to do.

(cherry picked from commit 66e91f55e8
 and e75cff6bb5)
2017-05-31 09:51:15 +02:00
Alexander Larsson
d6af6b72c8 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-31 09:44:48 +02:00
Alexander Larsson
2bdc160d20 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.

(cherry picked from commit f28d318cc9)
2017-05-31 09:43:43 +02:00
Alexander Larsson
25d92d40c8 Unset TMPDIR in the sandbox
Its quite possible that a custom TMPDIR is not mapped
in the sandbox, and /tmp is per-app anyway, so it doesn't
really make sense to use the custom one.

Fixes https://github.com/alexlarsson/spotify-app/issues/41

(cherry picked from commit 6711b56794
 and 7f7387ce5e)
2017-05-31 09:42:44 +02:00
Balázs Úr
dbd030c160 [flatpak-0.8.x] Updated Hungarian translation 2017-05-15 09:15:13 +02:00
Alexander Larsson
a925df9e4a Update pofiles 0.8.5 2017-04-03 14:15:18 +02:00
Alexander Larsson
1f86f955b7 Update version to 0.8.5 2017-04-03 14:07:32 +02:00
Alexander Larsson
098db9d040 Update NEWS for release 2017-04-03 14:07:07 +02:00
Alexander Larsson
426189ab89 Handle uris better when detecting .flatpak[repo,ref] suffix
We fully parse the argument as (possibly) a uri, which means
we can handle an argument like:
 https://git.gnome.org/browse/gnome-apps-nightly/plain/gnome-builder.flatpakref?h=stable

Which doesn't work with a simple has_suffix call.
This is important because the flatpak.org site now references
these kinds of uris.

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

(cherry picked from commit 0dcc7332f7)
2017-04-03 13:46:31 +02:00
Alexander Larsson
b30a731ca4 update: Only allow downgrades if a commit is explicitly specified
If you run "flatpak update" then we will never update to
a commit that is older than the currently installed one. This
protects against a man-in-the-middle attack that would otherwise
let the attacker downgrade to a previously signed version that
may have some vulnerability.

(cherry picked from commit 3ff6d312de)
2017-04-03 13:44:28 +02:00
Alexander Larsson
f34398a4ec system-helper: Fix check for downgrade
We never want the system-helper to downgrade. If you want to run
not-the-latest version you need to be "real root". However, the
check for this was broken, as it compared the new commit with the
new commit, which was always ok. Instead check the timestamp
on the new commit with the current one.

(cherry picked from commit 266b9cb6f0)
2017-04-03 13:44:24 +02:00
Alexander Larsson
07c8997a43 dbus-proxy: Fix leak in setup phase
Sometimes we get an EAGAIN error in the due to the socket being
nonblocking. In the setup phase we just allocated the new buffer
and this causes a leak. Free it in this case.

(cherry picked from commit 6a63a905bf)
2017-04-03 13:44:16 +02:00
Alexander Larsson
8f2755cd47 dbus-proxy: Fix leak of get_arg0_string return value
In one place this was not freed. This converts both current
callers to g_autofree to make it consistent.

(cherry picked from commit a87c15da87)
2017-04-03 13:44:16 +02:00
Alexander Larsson
9d04e5dc98 dbus: proxy fix leak in get_arg0_string
g_variant_get_child_value returns a new reference, so we have to free
it.

(cherry picked from commit 0c05d48aca)
2017-04-03 13:44:16 +02:00
Alexander Larsson
f1e94adfa7 dbus-proxy: Fix use-after free in header parsing
The header returned from parse_header contains references
to the buffer it was used to parse from, and in some
cases we dereference these headers after freeing the buffer.
For instance this happens when we're filtering a message, and
then we later look at the destination to figure out what
kind of error to send back.

I couldn't find any cases where this would let the client
do anything other than return a different error value, but
this is still possibly a security issue.

(cherry picked from commit 18a45712cc)
2017-04-03 13:44:16 +02:00
Alexander Larsson
a19a706f56 dbus-proxy: Make Buffer refcounted
This will be needed to fix some user-after-free issues.

(cherry picked from commit 557f9231a2)
2017-04-03 13:44:16 +02:00
Colin Walters
0082bd53e6 utils: Prepare for libostree 2017.4 defining autocleanups
See: https://github.com/ostreedev/ostree/pull/756
2017-04-03 13:44:00 +02:00
Alexander Larsson
1018d05cda Stop using ostree trivial-httpd
This isn't always available in recent ostree.
This work is based on https://github.com/flatpak/flatpak/pull/658 and
fixes https://github.com/ostreedev/ostree/pull/723
2017-04-03 13:43:56 +02:00
Alexander Larsson
ea04835008 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

(cherry picked from commit 82aad1ccb1)
2017-04-03 13:30:43 +02:00
Alexander Larsson
98d770ab59 Re-fix typo
(cherry picked from commit d7f2bf000e)
2017-04-03 13:29:24 +02:00
Alexander Larsson
c78f91b296 Update minimal automake to 1.13.4
It doesn't build on the current minimum of 1.11.
Fixes https://github.com/flatpak/flatpak/issues/621

(cherry picked from commit afc2dd3d75)
2017-04-03 13:27:56 +02:00
Alexander Larsson
bc84c98fff Bump glib dependency to 2.44
This is required for e.g. G_DECLARE_FINAL_TYPE, and most current
distros have this now.

This fixes https://github.com/flatpak/flatpak/issues/622

For distributions that want to build against older glib, see
the issue above, it has patches to make that work.

(cherry picked from commit dcccb3c807)
2017-04-03 13:27:52 +02:00
Alexander Larsson
7e18ec30b2 Update potfiles 0.8.4 2017-03-10 11:01:34 +01:00
Alexander Larsson
224d706a83 Bump version to 0.8.4 2017-03-10 10:43:30 +01:00