Commit Graph

706 Commits

Author SHA1 Message Date
Matthias Clasen
261ff03b63 Merge pull request #907 from smcv/metadata
Document all metadata groups and keys
2017-07-07 17:50:15 -04:00
Matthias Clasen
db0a9a0658 Merge pull request #903 from pwithnall/warning-fixes
Fix compiler warning flags and (accordingly) quite a few compiler warnings
2017-07-07 16:50:45 -04:00
Simon McVittie
6839fee009 common: Clarify what flatpak_context_load_metadata, save_metadata do
Signed-off-by: Simon McVittie <smcv@collabora.com>
2017-07-07 16:08:35 +01:00
Simon McVittie
489bfddfb3 common: Add and use constants for flatpak-metadata(5) groups and keys
This makes it easier to avoid typos, and also makes it easier to see
what groups and keys are in use. In the header file, they are
clustered according to the group in which the keys are used.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2017-07-07 16:06:21 +01:00
Owen W. Taylor
0853089457 OCI: Update org.opencontainers.ref.name to org.opencontainers.image.ref.name
This annotation was changed in later versions of the OCI Image specification.
(See https://github.com/projectatomic/skopeo/issues/369#issuecomment-310158211)
2017-07-06 17:07:08 -04:00
Philip Withnall
f47a696392 build: Add AM_* variables to all per-target special variables
For example, add $(AM_CFLAGS) to mumble_CFLAGS. Since $(WARN_CFLAGS) is
only added to $(AM_CFLAGS), this fixes the lack of inclusion of the
compiler warning flags in the compilation of half of flatpak.

Note that $(AM_*) variables are only used by automake if a more specific
(per-target) special variable is not defined instead. So if you define
mumble_CFLAGS, AM_CFLAGS will not be used for that target unless
explicitly included in mumble_CFLAGS.

See
https://www.gnu.org/software/automake/manual/html_node/Flag-Variables-Ordering.html.

Do the same for $(AM_LIBADD), $(AM_LDFLAGS), etc. These are not
currently defined, but it’s good practice to include them in
mumble_LIBADD (etc.) just in case they’re defined in future. Hopefully
their inclusions will be cargo-culted to any new targets which are
added, retaining full coverage of the code base.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-07-06 15:05:58 +01:00
Philip Withnall
c6011083a2 common/dir: Drop unused variable
This was accidentally introduced in a8ad3927 in advance of the LAN/USB
changes from PR #884 which will actually use it.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-07-04 13:43:26 +01:00
Simon McVittie
8e03e7b719 build: Re-run gdbus-codegen if the Makefile changes
Changes to the Makefile could include changes to the options passed
to gdbus-codegen, which would invalidate the output.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2017-06-30 21:21:06 +02:00
Simon McVittie
f4c4abfb1e build: Only run each instance of gdbus-codegen once
A rule of the form

    foo.c foo.h: foo.in
        some-generator --output=foo foo.in

is essentially equivalent to writing the same rule once for each target:

    foo.c: foo.in
        some-generator --output=foo foo.in
    foo.h: foo.in
        some-generator --output=foo foo.in

In a parallel build, this can result in some-generator being run more
than once with the same inputs and outputs, leading to unpredictable
results if the outputs are overwritten in-place by two parallel copies
(particularly if the generator does not use the standard atomic-writing
trick of writing out a temporary file and renaming it over the top of
the intended name, which gdbus-codegen does not).

gdbus-codegen happens to write the .h file before the .c file, so
use the real build rules to generate the .c file, and consider the
.h file to be a side-effect.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2017-06-30 21:21:06 +02:00
Philip Withnall
55ca5a9662 common/dir: Factor out body of update_remote_configuration_for_summary()
This will make it easier to add another version in upcoming commits
which gets the updated configuration from another source (an
ostree-metadata branch).

This commit introduces no functional changes.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-06-30 16:06:50 +02:00
Philip Withnall
07607e3e00 common/dir: Factor out common code to get and load the summary file
There was already a convenience method for this,
fetch_remote_summary_file(), but it wasn’t used uniformly throughout the
file. This introduces no functional changes.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-06-30 16:06:50 +02:00
Philip Withnall
a8ad392750 common/dir: Factor out common code for getting repo metadata
There are several places which query keys in the metadata in the summary
file. Factor out a common function to do that, and write it in such a
way that it could be extended to read the metadata from somewhere else
in future (the plan being that metadata will move to an ostree-metadata
branch rather than the summary file).

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-06-30 16:06:50 +02:00
Philip Withnall
c0837b8179 common: Split out self and repo arguments for a static function
This introduces no functional changes; it will simplify upcoming
commits.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-06-30 10:17:34 +02:00
Philip Withnall
e3cac586bb common: Use bulk OstreeAsyncProgress API for setting keys
This results in one ‘changed’ signal emission rather than several at
once.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-06-26 16:42:54 +02:00
Simon McVittie
f71167e7ec One more try at not distributing gdbus-codegen-generated sources
Signed-off-by: Simon McVittie <smcv@debian.org>
2017-06-21 16:08:37 +02:00
Alexander Larsson
821851dcb2 flatpak_dir_read_latest: Return NULL, not FALSE on error 2017-06-21 10:23:20 +02:00
Alexander Larsson
67ffd9a0b6 Manually copy summary for update and appdata too 2017-06-19 15:01:19 +02:00
Joaquim Rocha
00802cc710 Re-create the cache repo if it is not bare-user
We need to re-create the cache repo if it has not been previously
configured as bare-user, so it avoids permissions related issues.
2017-06-19 14:34:43 +02:00
Joaquim Rocha
bfea681ad1 Force the cache repo to use the bare-user mode
Unless forced by the FLATPAK_OSTREE_REPO_MODE env var, we default cache
repos to bare-user mode. Otherwise it can lead to permissions problems
because, e.g. if the system repo is configured as a "bare" repo, then
the cache repo will be too and this will lead to fchown calls even if
the user is non-privileged.
2017-06-19 14:34:43 +02:00
Alexander Larsson
a21a8e0465 run: Fix use-after-free in case you were exporting the same path twice 2017-06-19 14:32:48 +02:00
Alexander Larsson
e987d92ad0 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.
2017-06-19 13:09:33 +02:00
Alexander Larsson
87081cc47d Unless forced via FLATPAK_OSTREE_REPO_MODE user bare-user for cache repo
This way we don't break if some commit is not canonical when we
import to the system repo.
2017-06-19 12:56:02 +02:00
Alexander Larsson
66e60be49d Default to bare-user-only repo
This means we work on systems without xattrs
Old installations keep using bare-user, and you can use
FLATPAK_OSTREE_REPO_MODE=user to force it.
2017-06-16 12:20:49 +02:00
Colin Walters
1e07f79b57 Use new libostree APIs to reject world-writable/suid content
This uses the new libostree APIs that landed recently to ensure
that we reject any files with mode outside of `0775` for system
helper pulls, and we also mask directory modes during checkout.

However, this does *not* fix up any already downloaded content.
For that, one could uninstall/reinstall; or a future patch could
do a one-time fixup pass.

Note that I am not aware of a way for flatpak applications to escalate their
privileges directly with this flaw; the bubblewrap `PR_SET_NO_NEW_PRIVS` turns
of setuid. However, in combination with code execution on the host via another
mechanism (e.g. unsandboxed app), a setuid app injected could be used to gain
full host privileges.

At this time we're not aware of any flatpak content exploiting this issue.

Closes: https://github.com/flatpak/flatpak/issues/845
2017-06-15 16:40:17 +02:00
Colin Walters
daf36ba2af 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
2017-06-08 17:00:20 +02:00
Colin Walters
4714f55ebd 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.
2017-06-08 09:42:40 +02:00
Philip Withnall
8daef223bb utils: Fix minor formatting issue in gtk-doc comment
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-06-06 19:42:54 +01:00
Philip Withnall
a664fd136a dir: Fix a minor memory leak
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-06-06 19:42:54 +01:00
Alexander Larsson
1d9fe6fbf3 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.
2017-06-01 11:03:20 +02:00
Alexander Larsson
75d884046d run: Allow regular files for --filesystem=xdg-config/path
KDE needs this to put ~/.config/kdeglobals into the sandbox
2017-06-01 10:50:22 +02:00
Alexander Larsson
e69237f792 Handle app ids with dashes when ignoring locale/debug.
org.foo.foo-bar extensions become org.foo.foo_bar.Locale, etc, so
we need to handle this properly.
2017-05-30 18:07:46 +02:00
Alexander Larsson
475dde6263 run: Add debug sprew for all bwrap arguments 2017-05-30 13:40:40 +02:00
Alexander Larsson
d8000183f6 extra-data: Print exit status if apply_extra_data script fails 2017-05-30 11:12:37 +02:00
Alexander Larsson
4a54450400 documents: paths in the apps dir ar always accessible
When using the as-needed flag in AddFull, we need to consider
the files in the target apps app-specific dir also accessible.

Fixes https://github.com/flatpak/flatpak/issues/815
2017-05-26 13:05:43 +02:00
Patrick Griffis
1775eab41c run: Handle file paths when forwarding uris
Ideally it would always be a URI but it seems in real usage you
do get normal paths.
2017-05-24 13:19:39 +02:00
Alexander Larsson
e75cff6bb5 export: Store the app id in the X-Flatpak key
We need this, because it may not correspond 100% to
the desktop file id, as flatpak allows suffixes if you
want multiple desktop files in one app.
2017-05-24 12:02:42 +02:00
Alexander Larsson
71408adbb3 Don't error out when updating metadata for disabled remotes 2017-05-24 11:42:18 +02:00
Alexander Larsson
e89facde7f deploy: Ensure xa.ref, if set, is correct 2017-05-23 11:41:58 +02:00
Alexander Larsson
c8659e4530 progress: Update at 300msec on the CLI
Writing things on the console every 100msec doesn't really
make any sense, the progress bar is not finegrained enough
and you can't read the text that fast anyway.
2017-05-23 10:18:35 +02:00
Alexander Larsson
23399ddc35 Use the CLI progress for update --appstream too 2017-05-22 17:01:14 +02:00
Alexander Larsson
1f77af15cb common: Add flatpak_context_load_for_app helper
This looks for an installed app, using the current
one, and loads its permissions and overriders
(ignoring the ones from the runtime).

This is useful if you want to know the permissions
for an application by name, such as in the
document portal.
2017-05-22 13:12:01 +02:00
Alexander Larsson
2023ca03c2 common: Add flatpak_find_current_ref helper 2017-05-22 13:12:01 +02:00
Alexander Larsson
8cd7a0ab31 common: Expose FlatpakExports
This will be needed for the document portal to be able to
detect what directories an app has access to.
2017-05-22 13:11:58 +02:00
Alexander Larsson
4f828942f7 Update to latest libglnx and use the new GLnxTmpFile API 2017-05-22 09:08:49 +02:00
Alexander Larsson
6c5ee01d01 complete: Don't read outside string
Sometimes the shell_cur value given to us by bash
is longer than expected, so don't step outside the
string in this case.

Fixes https://github.com/flatpak/flatpak/issues/764
2017-05-19 12:52:39 +02:00
Alexander Larsson
67a9d9dfec OCI: Properly initialize all used progress fields
Its not a fatal error to try to read uninitialized ones
so this needs to be done.
2017-05-19 11:51:00 +02:00
Alexander Larsson
ae4a7d62af builder: More GLnxTmpfile fixes 2017-05-19 11:41:09 +02:00
Alexander Larsson
d52329e926 Update to a libglnx that has GLnxTmpfiles fixed 2017-05-19 11:30:48 +02:00
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