Commit Graph

2372 Commits

Author SHA1 Message Date
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
Alexander Larsson
a9b8ba5f42 Update NEWS 2017-03-10 10:43:07 +01:00
Alexander Larsson
f09d6b3aa6 profile: Don't add flatpak to XDG_DATA_DIRS if its already there 2017-03-10 10:42:44 +01:00
Georges Basile Stavracas Neto
5bb3c05e14 Fix comment
(cherry picked from commit 556782ac06)
2017-03-10 10:20:27 +01:00
Georges Basile Stavracas Neto
753e487fbf Improve progress calculation
When calculating the progress of a flatpak installation,
it considers the extra-data and OSTree pull as different
operations and that makes the progress to go back and
forth between 0% and 100%.

Consumers of this API, like GNOME Software, end up having
a bad experience reporting the progress of a Flatpak app
instalation.

Fix that by using a set of heuristics to improve the process,
splitting the operation in parts that can be tracked (or at
least estimated).

(cherry picked from commit d74956c23a)
2017-03-10 10:20:24 +01:00
Georges Basile Stavracas Neto
a0b3f74587 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.

(cherry picked from commit d73090cc96)
2017-03-10 10:20:21 +01:00
Alexander Larsson
efa282f9ea appstream: Don't add runtime to flatpak bundle tag for runtimes
(cherry picked from commit 7d1a8f69f6)
2017-03-10 10:20:18 +01:00
Elvis Angelaccio
e536497d3f Append flatpak data dirs if XDG_DATA_DIRS is already set (#611)
* Append flatpak data dirs if XDG_DATA_DIRS is already set

Otherwise it will be impossible to run flatpak apps from desktop menus.
This issue can happen if another app (e.g. snapd) wants to add custom
folders to XDG_DATA_DIRS through /etc/profile.d

If XDG_DATA_DIRS is empty or unset, define it as before.

Fixes #606

(cherry picked from commit a9acdc0532)
2017-03-10 10:20:14 +01:00
Matthew Leeds
870ee12a74 doc: Make manpages consistent with --help output
For a few commands the options aren't fully documented. This commit
makes the manpage documentation (almost) match the options shown
when you run "<command> --help" on the command line.

(cherry picked from commit 2d07f7d455)
2017-03-10 10:19:52 +01:00
Matthew Leeds
c6417dbb81 doc: Fix typos
(cherry picked from commit d9272ab120)
2017-03-10 10:19:52 +01:00
Matthew Leeds
541d8ff1b0 doc: Fix example for flatpak-info command
(cherry picked from commit 4817421289)
2017-03-10 10:19:52 +01:00
Alexander Larsson
69d32a6331 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.

(cherry picked from commit 640a02315b)
2017-03-06 14:37:53 +01:00