Commit Graph

65 Commits

Author SHA1 Message Date
Alexander Larsson
a4b2068bbc portal: Support application self-updates
This allows an application to request it to be updated to the latest version.

The updates are done out-of-process by re-spawning the portal (via
/proc/self/exe) and proxying the relevant events over a socket pair, in
order to avoid any long term stability or memory requirements from
running the update operation.
2019-10-02 14:57:11 +02:00
Alexander Larsson
e719463adf Bump the version of the flatpak portal interface to 2
Also mention this in the create monitor docs.
2019-10-02 14:57:11 +02:00
Matthias Clasen
fe0b8aa860 portal: Add updates monitoring
Add update monitoring to the flatpak portal.
No support yet for triggering updates.
2019-10-02 14:57:11 +02:00
Alexander Larsson
26ad9154c3 Add flatpak in docker seccomp profile
This is a docker seccomp profile that allows you to run flatpak
inside a docker container, given some special requirements:

 * The host kernel must support unprivileged user namespaces
   (Supported by e.g. fedora and ubuntu kernels)
 * The seccomp profile must be used
   (--security-opt seccomp=flatpak-docker-seccomp.json)
 * flatpak is run as a reguler user, not root, in the container
 * The full host /proc must be visible in the container
   (-v=/proc:/host/proc)

The last one is a bit weird, but the regular /proc in docker
is mounted with some cover-over mounts, and this makes the kernel
disallow mounting a new procfs for the pid namespace. Adding
in a full copy of the host fs causes this to be allowed.

Closes: #2867
Approved by: alexlarsson
2019-04-30 06:20:56 +00:00
Ryan Gonzalez
7185a00c85 transaction: Add end-of-lifed-with-rebase signal and add_rebase()
end-of-lifed-with-rebase runs earlier in the transaction system than end-of-lifed, meaning it can modify the transaction for rebasing.
The new flatpak_transaction_add_rebase() function can then be used to apply the rebase if wanted.

Closes: #2775
Approved by: alexlarsson
2019-04-12 08:59:35 +00:00
Umang Jain
c9d0705ae9 system-helper: Add CancelPull helper method
If there is a pull failure in a child repo created on revokefs-fuse
mount, there is no way to go back to the system helper and notify
it to cleanup. Therefore, CancelPull is required on the pull failure
error path, so that the ongoing pull can be cleaned up nicely and
prevent any dangling mounts and subprocesses.

Closes: #2657
Approved by: alexlarsson
2019-04-09 09:18:15 +00:00
Umang Jain
cad8d8a599 system-helper: Integrate --system pull with revokefs-fuse
This adds a new helper method "GetRevokefsFd" which is responsible
for spawning the backend part of the revokefs filesystem. It takes care
of creating a cache location for the backing directory in repo/tmp.
This cache location is transferred over D-Bus to the client with the
other end socket fd.

The client on receiving the socket fd creates a mountpoint directory and
spawns the revokefs-fuse filesystem. It then creates a child repo for the
pull. In any case of failure, it fallbacks on the current code path
(which causes temporary duplication of files on disk).

The backing dir itself and all files written to it by the revokefs-fuse
backend process are owned by the "flatpak" user. After the pull in the
child repo is completed, it's ownership is then canoncalized with owner=root
and permissions as per bare-user-only in Deploy().

Now we have fulfilled all the criteria to hardlink the child repo into
the system one and avoid duplication. See [1].

If there is existing cache directory available in repo/tmp, it will be
mounted using revokefs-fuse for the current pull. Hence, it is possible
to recover the previous partial pull which might have failed due to some
error.

[1] https://github.com/ostreedev/ostree/pull/1776

Closes: #2657
Approved by: alexlarsson
2019-04-09 09:18:15 +00:00
Matthias Clasen
f28e8af968 Fix xml syntax in org.freedesktop.portal.Flatpak.xml
A bit concerning that this does not break the build.
It did break the docs build in xdg-desktop-portal.

Closes: #2602
Approved by: mwleeds
2019-01-16 04:26:46 +00:00
Matthias Clasen
64e6764137 session-helper: Drop the unused RequestMonitor api
Nothing is using this now that we have RequestSession.
No need to carry this round.

Closes: #2533
Approved by: alexlarsson
2019-01-11 13:05:58 +00:00
Matthias Clasen
62332f9389 portal: Improve docs
I could not work out at all how exposing files works,
until I looked at the code. Put enough details in the
docs to spare the next person this fate.

Closes: #2437
Approved by: alexlarsson
2018-12-17 08:29:52 +00:00
Matthias Clasen
9a1febd981 portal: Suport a watch-bus flag
This behaves just the same as the watch-bus flag that
was reently added to HostCommand.

Closes: #2439
Approved by: alexlarsson
2018-12-17 08:16:42 +00:00
Matthias Clasen
1ba30f7ef1 system-helper: Add flags to all methods
Some methods were missing a flags argument. This
will be a problem in the future, when we want to
pass a no-interaction flag to all methods. Therefore,
add an empty flags enum for every method that is lacking
one now.

This is an api change for the system-helper interface.

Closes: #2370
Approved by: alexlarsson
2018-12-03 12:52:17 +00:00
Alexander Larsson
0b6a66013c OCI: Use system helper to generate summary for OCI remotes
The OCI support relies on downloading a json index and converting it
to a ostree-style summary, which we the use in all sorts of operations
in the client code. Currently this happens in the user code, which means
that it will fail (due to permissions) in the system installation case.

We could do the conversion as the user, but when eventually installing
something the system-helper will anyway do this download and
conversion, so that would only double the work and risk things going out
of sync. Also, the OCI index is not gpg signed, so we can't realy on
downloads done as the user.

So, the solution done here is to add a GenerateOciSummary
system-helper call which we use instead of directly generating the
oci summary.

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

Closes: #2363
Approved by: matthiasclasen
2018-12-01 00:16:08 +00:00
Matthias Clasen
331a883b7b Clarify object paths and bus names for portals
These portals are under their own bus name and
object path, clarify this in the docs. For the
document portal, this is just a sync-up with
the master copy in the xdg-desktop-portal repo.

Closes: #2074
Approved by: alexlarsson
2018-09-05 06:58:34 +00:00
Matthias Clasen
47cc37f174 Sync the document store interface description
There have been some minor edits in the official version
of this in xdg-desktop-portal. Sync up the version here.

Closes: #2064
Approved by: alexlarsson
2018-09-03 10:41:44 +00:00
Matthias Clasen
1831ac1974 Flatpak portal: Documentation improvement
Explain what exposes are allowed.

Closes: https://github.com/flatpak/flatpak/issues/1955

Closes: #2029
Approved by: alexlarsson
2018-08-28 07:50:13 +00:00
Alexander Larsson
7b8e9ea4a1 dbus xml: Delete -- from docs
Apparently -- is not valid XML, so a nonbreakable space was added, but
that breaks gdbus-codegen, so lets just drop the dashes totally.

Closes: #1988
Approved by: alexlarsson
2018-08-20 13:17:40 +00:00
Matthew Leeds
8292732e65 Add a system-helper UpdateSummary method
This system-helper method will allow flatpak to update the ostree repo
summary while running as a non-root user that's in the "sudo" group.
This will allow the `flatpak create-usb` command to work without
requiring the user to first run `sudo ostree summary -u`, and without
requiring the system to have `core.auto-update-summary` set to true in
the ostree repo config. This is also much more efficient than
`core.auto-update-summary` because it allows us to only update the
summary when we need it rather than after every transaction.

Generating the summary basically just involves traversing the repo to
enumerate all the refs and putting this information into a file, so I
don't think there are security concerns with allowing it to happen
without authentication.

Closes: #1945
Approved by: alexlarsson
2018-08-08 14:42:16 +00:00
Alexander Larsson
0d19e60ce3 system-helper: Add EnsureRepo operation
This is used to create the /var/lib/flatpak repo if
needed so that other later operations work. We have
some partial support for it not working in various
operations (using the allow_empty argument) but
this is in no way complete. For example, this
can easily happen if you have a per-user installation
but no system one and then you run flatpak install
with no --user, then it will try to figure out
which one to use and die.
2018-07-07 16:37:44 +02:00
Matthias Clasen
848dd88a34 Fix a copy-paste error
RevokePermissions revokes permissions, not grants them.

Closes: #1837
Approved by: alexlarsson
2018-06-29 11:52:40 +00:00
Matthias Clasen
a8cca2ebe1 Add the permission store interface
This adds the xml interface definition for
org.freedesktop.impl.portal.PermissionStore.
Subsequent commits will use this interface.

Closes: #1837
Approved by: alexlarsson
2018-06-29 11:52:40 +00:00
Alexander Larsson
b4bb890516 session-helper: Add new more generic helper start method
This does the same as RequestMonitor, but returns the status via a
a{sv} so that its more extensible.

Closes: #1757
Approved by: alexlarsson
2018-06-07 12:25:21 +00:00
Alexander Larsson
3e47247425 Batch running triggers
This moves the triggers from out of flatpak_install/update/uninstall
and instead calls them manually at all the sites that call this.

This allows FlatpakTransaction to only run the triggers once for the
entire operation.

Closes: #1743
Approved by: alexlarsson
2018-06-01 11:41:56 +00:00
Matthias Clasen
18e9aae7a3 portal: Document the interface
Document the flatpak portal in the same style as
other portals are.

Closes: #1619
Approved by: alexlarsson
2018-04-27 11:03:34 +00:00
Alexander Larsson
11ef9999b6 Add flatpak portal
This listens to org.freedesktop.portal.Flatpak and lets flatpak
sandboxes do flatpak specific things.

Initially this only allows access to "Spawn", which lets you start a
new copy of the current or latest version of the calling app,
optionally with sandboxing.

This allows the app to re-start itself with the latest version after
an update, and the sandboxing is useful for apps that want to manually
sandbox part of themselves.

You can also expose one or more subdirectories of
~/.var/app/$appid/sandbox/ to the app, read-write or read-only. This is
useful to communicate with the sandbox.
2018-04-04 17:25:59 +02:00
Alexander Larsson
f2a6c1db8d Remove document portal
This is now in xdg-desktop-portal. We keep a version of the document
portal dbus XML so that we avoid weird build dependencies.

Flatpak itself is technically not dependent on the document portal,
but it is very much recommended that you use it.

Closes: #1398
Approved by: alexlarsson
2018-02-09 09:23:26 +00:00
Jan Grulich
c226288dd6 Document portal: implement add_named_full() function
This is a convenient function which can be used with flags, adding option to return
real path of the file we are trying to open in case the sandboxed app has access
to it. It also registers this file automatically to document store so there is no
need to call grant_permission() afterwards.

Closes: #1335
Approved by: alexlarsson
2018-01-25 09:22:21 +00:00
Jan Grulich
a7c0d4ce56 Add DBus annotations
Closes: #1332
Approved by: alexlarsson
2018-01-23 09:30:19 +00:00
Alexander Larsson
b18d1c2321 Add system-helper support for configuring language.
Closes: #1123
Approved by: alexlarsson
2017-10-20 20:06:38 +00:00
Sam Spilsbury
d0af046a2f system-helper: Add PruneLocalRepo method
We might want to prune the repo from within the library or
the command line and may not be in a privileged context, so
we'll need to jump through the system helper to prune the refs.

Closes: #1034
Approved by: alexlarsson
2017-09-28 15:39:05 +00:00
Sam Spilsbury
3f91b4d883 system-helper: Add RemoveLocalRef helper function
This depends on the modify-repo privilege

Closes: #1034
Approved by: alexlarsson
2017-09-28 15:39:05 +00:00
Matthias Clasen
5d610b9ddd document store: Document as-needed functionality of AddFull
Mention the new flag and its functionality in the portal API
documentation.
2017-05-29 09:43:35 -04:00
Matthias Clasen
9564da53f8 Small documentation improvements
Add some missing newlines, and document that
AddFull was added in version 2.
2017-05-22 09:26:42 +02:00
Alexander Larsson
6ce8521b64 document-portal: Add AddFull() operation
This allows you to add multiple paths at the same time, plus
grant an app access to it, plus it returns the fuse mount path.

This allows you to avoid a lot of roundtrip in common cases.
2017-05-19 17:01:46 +02:00
Alexander Larsson
bda7575e79 Add version property to all dbus interfaces 2017-05-19 14:38:22 +02:00
Alexander Larsson
9896005ad0 remote-modify: Implement --update-metadata as a system-helper method
We download the summary and send it to the system helper, it verifies
the checksum and applies the changes, with the same polkit permissions
required as for an app update (i.e. typically none).

This allows us to update metadata automatically, without permission
requests.
2017-05-09 13:25:21 +02: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
719616f086 Add support for multiple installations in the system helper
Allow passing an extra string parameter specifying the ID of a
system installation to refer to it, or an empty string for the
default one.
2016-12-17 00:32:50 +00:00
Alexander Larsson
41443313ca session-helper: Move HostCommand to its own interface 2016-09-06 15:30:38 +02:00
Alexander Larsson
c8df0e6208 SessionHelper: Add calls to spawn processes on the host
This lets any client, possibly in a sandbox if it has access to the
session helper, spawn a process on the host, outside any sandbox.

Clearly this is not something you typically want a sandboxed app to
do. However, it is sometimes very useful when using flatpak mainly
for distribution. For instance, an IDE needs to use this to launch a
flatpak build operation inside the sandbox. (Because otherwise recursive
calls to flatpak will not work.)
2016-09-05 21:41:14 +02:00
Matthias Clasen
86d7dd73f9 Document the permission store API
Add doc comments to the xml.
2016-07-12 00:00:45 -04:00
Matthias Clasen
6743d0122c Document the document portal API
Add doc comments to the XML.
2016-07-11 23:19:48 -04:00
Matthias Clasen
8bada3a819 document portal: Add a more api
We want to let the flatpak command show more information.
These functions will not be allowed from inside the sandbox
to prevent leaking information to sandboxed applications.
  Lookup: go from a file (handed in via an fd) to a document id
  Info: return origin and permissions for an id
  List: return information about all exported documents
2016-06-16 15:04:28 -04:00
Alexander Larsson
e769af8661 system-helper: Handle installing bundles 2016-06-03 16:04:10 +02:00
Alexander Larsson
1504f7bd7f system-helper: Support add/modify/delete of remotes 2016-05-13 16:23:43 +02:00
Alexander Larsson
5407b8efc6 system-helper: Support uninstall 2016-05-12 21:23:36 +02:00
Alexander Larsson
1877f0be8d system-helper: Add support for updating appstream branch 2016-05-11 10:35:24 +02:00
Alexander Larsson
28b549156a Split out permission store from session helper
This is now available as org.freedesktop.impl.portal.PermissionStore
2016-05-09 14:07:22 +02:00
Alexander Larsson
8abbc0186e Rename everything but the on-disk location to flatpak 2016-05-09 11:11:55 +02:00
Alexander Larsson
b2b05e1175 update/install: Handle deploy using the system service 2016-04-25 18:59:17 +02:00