1281 Commits

Author SHA1 Message Date
Alexander Larsson
a94eea8cc7 build-update-repo: Add appstream2 to the metadata cache
The old "appstream" is there already, and this allows us to get
things like download size info for it.

Closes: #2182
Approved by: alexlarsson
2018-10-04 06:58:23 +00:00
Alexander Larsson
35b92d7237 Support --allow=canbus for AF_CAN access
This fixes https://github.com/flatpak/flatpak/issues/2176

Closes: #2179
Approved by: alexlarsson
2018-10-03 14:31:30 +00:00
Kalev Lember
1a827c0469 transaction: Return G_IO_ERROR_CANCELLED when cancelled
Instead of FLATPAK_ERROR_ABORTED, return G_IO_ERROR_CANCELLED when the
passed in GCancellable gets cancelled. This makes it possible to cancel
updates in gnome-software without getting a generic "Aborted due to
failure" error popup.

Closes: #2178
Approved by: alexlarsson
2018-10-03 13:56:49 +00:00
Alexander Larsson
89e2b6679c Don't expose host /dev/shm with --device=all (fixing debian problems)
--device=all really means the device nodes, we should not expose the host
shared memory objects.

This change incidentally fixes issues with --device=all on debian (#2136)
where /dev/shm is a symlink to /run/shm, which doesn't exist in the sandbox.

Closes: #2160
Approved by: alexlarsson
2018-10-03 13:56:44 +00:00
Umang Jain
8da2c64fa1 dir: Fix parameter naming for consistency
Closes: #2173
Approved by: alexlarsson
2018-10-03 09:02:13 +00:00
Robert McQueen
8bd22682f7 installation: nitpicks
Make the new _run_triggers function appear correctly in GtkDoc and cross-link.

Closes: #2164
Approved by: alexlarsson
2018-10-02 06:22:27 +00:00
Matthias Clasen
868552cb1f Fix localization
On the library side, we need to include gi18n-lib in order
to use dgettext for _().

Closes: #2163

Closes: #2150
Approved by: alexlarsson
2018-10-02 06:21:49 +00:00
Matthias Clasen
e9bf1c3f75 Replace a warning with an error
It is not really nice to have g_warnings pop out of
the library left and right, they should be replaced
by proper errors as far as possible. This is a small
start.

Closes: #2150
Approved by: alexlarsson
2018-10-02 06:21:49 +00:00
Matthias Clasen
56d975f8c4 Add a few more error codes
Add FLATPAK_ERROR_INVALID_DATA and use if for cases where
the incoming data for an update or install is faulty, and
add FLATPAK_ERROR_UNTRUSTED, FLATPAK_ERROR_SETUP_FAILED and
FLATPAK_ERROR_EXPORT_FAILED to cover more error conditions.

Closes: #2150
Approved by: alexlarsson
2018-10-02 06:21:49 +00:00
Matthias Clasen
5b9d8e5ab8 Translate more error messages
As a rule of thumb, if we use a FlatpakError, the message
is probably worth translating.

Closes: #2150
Approved by: alexlarsson
2018-10-02 06:21:49 +00:00
Matthias Clasen
38eebef90c Avoid flatpak_fail in ref parsing
Add an error code for invalid refs, and use it when
composing or decomposing refs.

Closes: #2150
Approved by: alexlarsson
2018-10-02 06:21:49 +00:00
Matthias Clasen
9d0fbdd0b4 FlatpakContext: Avoid flatpak_fail
flatpak_fail is a convenient shortcut, but falls short
for actual error reporting. Use proper G_OPTION_ERROR
error codes here.

Closes: #2150
Approved by: alexlarsson
2018-10-02 06:21:49 +00:00
Matthias Clasen
df4df62d04 Fix a typo
Its bwrapinfo.json, not brwapinfo.json

Closes: #2150
Approved by: alexlarsson
2018-10-02 06:21:49 +00:00
Robert McQueen
33cfa59af6 installation: tidy doc comments on new API additions
Closes: #2162
Approved by: alexlarsson
2018-10-01 14:43:09 +00:00
Robert McQueen
00fcc65157 installation: fix inverted logic in new _NO_TRIGGERS flag
Philip Withnall wins today's gold star.

Closes: #2162
Approved by: alexlarsson
2018-10-01 14:43:09 +00:00
Matthias Clasen
2290099ead Add a new utility function for finding deploys
flatpak_find_deploy_for_ref_in is a variation of
flatpak_find_deploy_for_ref that allows to restrict
what installations to search in.

Closes: #2158
Approved by: alexlarsson
2018-10-01 13:05:12 +00:00
Robert McQueen
041ae7bd99 installation: add _run_triggers function
Closes: #2161
Approved by: alexlarsson
2018-10-01 12:29:50 +00:00
Robert McQueen
3dea58b53b installation: add _NO_TRIGGERS flags to install/update/uninstall ops
Closes: #2161
Approved by: alexlarsson
2018-10-01 12:29:50 +00:00
Robert McQueen
b881d9576f dir: use g_utime in flatpak_dir_mark_changed
Avoids an un-necessary fsync() call of an empty file.

Closes: #2161
Approved by: alexlarsson
2018-10-01 12:29:50 +00:00
Matthias Clasen
14cd84fa68 Be stricter about exports
We were exporting files in subdirectories of all the common
directories. This only really makes sense for icons. For
desktop files, D-Bus service files and mime types, we should
only export from the exact directory itself.

Note that this makes us no longer support the obsolescent
vendor-prefix convention of the desktop entry spec, which was
only relevant for KDE4 and breaks app-id matching.

Closes: #2142

Closes: #2152
Approved by: alexlarsson
2018-10-01 11:26:34 +00:00
Andreas Zuber
c102bd2b50 common: fix the "can't mkdir parents" error
This fixes the “bwrap: Can't mkdir parents for /var/run/user/1000/.dbus-proxy/: No such file or directory” error. This error occurs on systems where the path in the XDG_RUNTIME_DIR variable contains a symlink under var, for example /var/run → /run.

The reason for the error is that bubblewrap was called both with “--bind /var /var” and “--bind /var/run/user/1000/.dbus-proxy/ /var/run/user/1000/.dbus-proxy/”. This leads to the destination path already existing but with “/var/run” being a symlink. Bubblewrap then tries to make sure the mount point is present in the sandbox and creates all the dirs with its parents, which fails for “/var/run/user” because its parent is a symlink.

This fix simply resolves the path used for the runtime dir before it adds it to the bind parameter.

Closes: #2137
Approved by: alexlarsson
2018-10-01 11:12:07 +00:00
Matthias Clasen
24d70fee0a ref: Document thread-safety
State that FlatpakRef objects are immutable and
can thus be used freely across threads.

Closes: #2141
Approved by: alexlarsson
2018-09-27 07:29:18 +00:00
Matthias Clasen
8132978169 installation: Document thread-safety
Based on my understanding of the matter, we claim
that FlatpakInstallation api is threadsafe.

This commit rewords things a bit, to more strongly
recommend FlatpakTransaction as the preferred API
for the tasks that it covers.

Closes: #2141
Approved by: alexlarsson
2018-09-27 07:29:18 +00:00
Matthias Clasen
22f12aa7b7 transaction: Document thread-safety
Based on my understanding of the matter, we claim
that FlatpakTransaction api is threadsafe.

Closes: #2141
Approved by: alexlarsson
2018-09-27 07:29:18 +00:00
Matthias Clasen
7ea96906dc transaction: Flesh out the docs
Explain why 'transaction' is really a misnomer.

Closes: #2141
Approved by: alexlarsson
2018-09-27 07:29:18 +00:00
Matthew Leeds
3ac63fdcdf common: Fix wording of missing runtime error 2018-09-26 13:53:56 -07:00
Matthew Leeds
48ceed70be Replace xa.collection-id with ostree.deploy-collection-id
Currently Flatpak reads a repo metadata key called "xa.collection-id" to
decide whether to configure a collection ID on a remote. This commit
drops support for xa.collection-id and replaces it with
ostree.deploy-collection-id, which is a key defined by OSTree but so far
only implemented here.

The reason for the change is so that collection IDs can only be deployed
to users running recent versions of Flatpak and OSTree. The current
situation is that Endless wants to deploy collection IDs (and therefore
support for doing USB updates) to users, but servers such as Flathub
can't safely set xa.collection-id in their metadata, because many users
are still using old versions of Flatpak and OSTree[1] which would hit
various bugs[2][3][4] on the P2P code paths that are enabled by
collection IDs. Defining a new key means that only users running
recent (as-yet-unreleased) versions of Flatpak and OSTree will pay
attention to it and deploy the collection ID, leaving the users on old
versions unaffected.

The reason this metadata key is being defined at the level of OSTree
instead of Flatpak, is that OSTree may want to implement it in the
future.

The functionality of deploying a collection ID by setting the
"deploy-collection-id" key in the config on the server side (which in
turn causes ostree.deploy-collection-id to be set) is already covered by
the unit tests in test-update-remote-configuration.sh; this commit just
tweaks them to use the new key.

Another solution I proposed to this problem was to have a key
"eos.collection-id" which would only be understood by the Endless fork
of Flatpak, and use that temporarily until enough people are running
recent versions of Flatpak, at which point "xa.collection-id" can be
used. But this solution (abandoning xa.collection-id upstream) allows us
to avoid that migration step and leave users on old versions of Flatpak
completely unaffected.

[1] https://ahayzen.com/direct/flathub.html#downloadsbyflatpakstacked
[2] https://github.com/ostreedev/ostree/commit/e4e6d85ea
[3] https://github.com/flatpak/flatpak/commit/5813639f
[4] https://github.com/flatpak/flatpak/commit/5b21a5b7
2018-09-19 17:23:08 -07:00
Alexander Larsson
d16b393a34 bundles: Fix leak
The collection id check that was added leaks if we were able
to read the collection-id, but then it was ignored.

Closes: #2093
Approved by: alexlarsson
2018-09-13 09:53:25 +00:00
Matthew Leeds
e4befb12ac common: Better handle NULL collection IDs
Currently if you install from a flatpak bundle that doesn't have a
collection ID set or from a flatpakref file that has the CollectionID
key set to the empty sting, you end up with an invalid configuration on
the origin remote created. This is because the collection_id parameter
of flatpak_dir_create_origin_remote() is set to the empty string, not
NULL, and create_origin_remote_config() then only checks for NULL when
deciding whether to set gpg-verify-summary to true or false. Then
because there's no collection ID configured but gpg-verify-summary is
set to false, you get the error "Can't pull from untrusted non-gpg
verified remote" when trying to pull related refs or update the app.

This commit fixes the bug by checking for the empty string when the
collection ID is read from a bundle or ref file, and collapsing that
into NULL.

Closes: #2081
Approved by: alexlarsson
2018-09-12 07:07:13 +00:00
Matthias Clasen
129031a2e2 Stop exporting flatpak_run_gc_ids()
No longer used outside flatpak-run.c
2018-09-03 11:54:19 -04:00
Matthias Clasen
336f887289 Add an instance api
This is made to let gnome-software enumerate all
running instances and get the same information
about them that flatpak ps provides.

For now, we keep it private. It will become library
api once we open new development
2018-09-03 11:54:19 -04:00
Alexander Larsson
bdec0f97ac lib: Strip gdbus error info from all passed on errors
Whenever we forward some error from a lower level dbus call to the
caller of the library we strip the extra gdbus error info via a call
to g_dbus_error_strip_remote_error(). We do this, because callers of
libflatpak has no idea that there were remote calls involved, so they
will not do this themselves.

Closes: #2070
Approved by: alexlarsson
2018-09-03 10:51:59 +00:00
Matthias Clasen
c284777d61 Add more api docs for libflatpak
Bring the library docs much closer to completion.

Closes: #2053
Approved by: alexlarsson
2018-09-03 10:31:51 +00:00
Matthew Leeds
8ba74182bc installation: Fix a mistake in the docs 2018-08-31 10:34:54 -07:00
Matthias Clasen
b3c07c5397 Add private api to remove an override file
This uses the same logic as the other override
functions to determine where the file is.

Closes: #2041
Approved by: alexlarsson
2018-08-29 14:58:15 +00:00
Matthias Clasen
c3e0471133 Tell bubblewrap to write info
Create a bwrapinfo.json file and tell bubblewrap
to write its 'info' there. For now, this just contains
the child-pid. More may appear over time.

Closes: #2039
Approved by: alexlarsson
2018-08-29 14:46:47 +00:00
Alexander Larsson
e2a79a275d Fix build with glib < 2.50
G_PID_FORMAT was added in glib 2.50, but pids are always %d on linux,
so we can avoid using it.

Closes: #2042
Approved by: alexlarsson
2018-08-29 07:21:26 +00:00
Matthew Leeds
e9d9f54ab8 common/installation: Search dynamic remotes for appstream2 also
Flatpak has API called flatpak_installation_list_remotes_by_type() which
can list dynamic (LAN/USB) remotes that mirror configured remotes in an
installation. It does this by searching them for the appstream/<arch>
ref, such as appstream/x86_64. But Flatpak now supports
appstream2/<arch> as a way to provide the appstream data as uncompressed
XML, and it's possible that a USB created with `flatpak create-usb` (or
a LAN peer) only has the appstream2 ref available for a certain
collection ID. So this commit changes
list_remotes_for_configured_remote() so that it looks for both
appstream/<arch> and appstream2/<arch>, which makes
flatpak_installation_list_remotes_by_type() robust to that scenario.
2018-08-28 10:05:18 +02:00
Matthias Clasen
2d26cc07c2 Export flatpak_run_gc_ids()
Currently, we only remove stale instance directories
when a new instance ID is allocated. A future 'flatpak ps'
command will want to remove stale instances before
enumerating them, so make this function available.

Closes: #2023
Approved by: alexlarsson
2018-08-27 14:25:15 +00:00
Matthias Clasen
95e5b394c2 Save a pid for running sandboxes
Store the pid of the bwrap process which gets spawned or exec'ed
by flatpak inside the instance directory. This can be useful
for others, such as gnome-software, or a future 'flatpak ps'
command.

We write the pid to a file named 'pid'. It will get cleaned
up together with the instance directory.

Closes: #2023
Approved by: alexlarsson
2018-08-27 14:25:15 +00:00
Matthias Clasen
06e8830377 Keep the .flatpak-info file accessible
The information in this file is of interest to other
users outside the sandbox, like gnome-software, or
a possible future 'flatpak ps' command.

We use the already existing instance directory, and
put the file at /run/user/$UID/.flatpak/$INSTANCE/info

The existing logic for cleaning up instance directories
will clean up the file.

Closes: #2023
Approved by: alexlarsson
2018-08-27 14:25:15 +00:00
Alexander Larsson
b8d594e390 OCI summary generation: Fix generation of summary on 32bit
The "t" variant type is guint64, so we must cast "0" to it when using
it in a varargs.

Closes: #2024
Approved by: alexlarsson
2018-08-27 14:07:55 +00:00
Patrick Griffis
738c11324a Add /proc to blacklist
This doesn't make sense to ever be in the sandbox

Closes: #2008
Approved by: alexlarsson
2018-08-27 11:06:56 +00:00
Will Thompson
b0f8736467 installation: document nullability of some arch/branch params
I've inferred this by walking through the code, which ultimately calls
one of flatpak_build_[app|runtime]_ref() which both implement these
defaults.

Closes: #1995
Approved by: alexlarsson
2018-08-27 10:57:16 +00:00
Will Thompson
9cc72ed08f transaction: improve cross-refs for signal parameter docs
Closes: #1995
Approved by: alexlarsson
2018-08-27 10:57:16 +00:00
Will Thompson
04846e24b2 transaction: fix signal parameter documentation
I guess these predate the creation of FlatpakTransactionOperation.

Closes: #1995
Approved by: alexlarsson
2018-08-27 10:57:15 +00:00
Will Thompson
a710f36e31 transaction: validate refs
Without this, it's not safe to use 'pref': if there are no slashes in
'ref', 'pref == 0x1', and any attempt to dereference it later in the
function will crash.

Closes: #1995
Approved by: alexlarsson
2018-08-27 10:57:15 +00:00
Will Thompson
6e270190c8 transaction: add docs & introspection annotations
Without explicit annotation, all optional parameters are assumed to be
mandatory, and 'const gchar **locales' is assumed to be a scalar string
input parameter (rather than an array or an in/out) for some reason.

Closes: #1995
Approved by: alexlarsson
2018-08-27 10:57:15 +00:00
Will Thompson
ae269ba390 transaction: add NULL guards in API entry points
Closes: #1995
Approved by: alexlarsson
2018-08-27 10:57:15 +00:00
Will Thompson
61107c56ce transaction: don't critical in finalize if initable_init() failed
If no installation path is specified at construct time, or if it doesn't
exist, priv->dir will be NULL even after initable_init() has been
called.

Closes: #1995
Approved by: alexlarsson
2018-08-27 10:57:15 +00:00