Commit Graph

1113 Commits

Author SHA1 Message Date
Alexander Larsson
7311eff800 Fix regression with --own=name
We deleted the "filtered" policy, but forgot to delete it in one place.

This fixes https://github.com/flatpak/flatpak/issues/1761
2018-06-08 14:39:35 +02:00
Alexander Larsson
66b2ff40f7 run: Support accessing host trusted certificates
If p11-kit server is installed on the host, we spawn a copy of this, forwarding the access to the
p11-kit trust module in a read-only way.

We then (if the above worked) bind mount the socket as /run/user/$UID/p11-kit/pkcs11 in the sandbox,
which is the default socket path for the p11-kit-client module.

We also add a configuration file in /etc/pkcs11/modules/p11-kit-trust.module that makes the trust
module actually load the client module instead. This means applications automatically switch
to using the host certs for trust if possible, and use the runtime ca-certificates otherwise.

Additionally we add a config file that always disables pkcs user
config merging, because pkcs11 modules on the host are unlikely to work in a random runtime.

Closes: #1757
Approved by: alexlarsson
2018-06-07 12:25:21 +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
df3a0c444b deploy: Do required-version check on deploy too
We only checked this in transaction. This is now the recommended way to installation
via libflatpak too, but if you use the old API this check also ensures that
installation fails if the required version is too old.

Also, we add a specific error code for this so callers can check for it.

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

Closes: #1755
Approved by: alexlarsson
2018-06-04 13:30:00 +00:00
Philip Withnall
ebb9baaeac common/installation: Fix indentation in a block
This introduces no functional changes.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Closes: #1736
Approved by: alexlarsson
2018-06-04 12:22:30 +00:00
Philip Withnall
441fe25255 all: Use GMainContextPopDefault when handling thread defaults
Simplify some of the return logic when handling pushing/popping the
thread default main context by using g_autoptr(GMainContextPopDefault).

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Closes: #1736
Approved by: alexlarsson
2018-06-04 12:22:30 +00:00
Alexander Larsson
a7ea6844d8 Add new extension key autoprune-unless and propagate it to related refs
The idea is for e.g. the gl extension to have
 download-if=active-gl-driver
 autoprune-unless=active-gl-driver

And then we can automatically find and uninstall unused gl drivers.

Closes: #1754
Approved by: alexlarsson
2018-06-04 12:08:59 +00:00
Alexander Larsson
e3559ddd41 flatpak_dir_find_local_related: Fix handling of subdir extensions
We were not correctly handling the partial refs that ostree_repo_list_refs()
returned, instead assuming they were full refs.

Closes: #1754
Approved by: alexlarsson
2018-06-04 12:08:59 +00:00
Alexander Larsson
3134512111 transaction: Reorder uninstalls so apps come before the runtimes they depend on
Otherwise we will fail if we uninstall "runtime app".

Closes: #1750
Approved by: alexlarsson
2018-06-01 15:45:08 +00:00
Alexander Larsson
de5a713336 uninstall: Don't allow uninstalling a runtime with apps that need it
Closes: #1750
Approved by: alexlarsson
2018-06-01 15:45:08 +00:00
Alexander Larsson
518da832ee Deploy: Store runtime dependencies in deploy data
For applications, we extract the name of the runtime it uses
so that we quickly can look up dependencies.

Closes: #1750
Approved by: alexlarsson
2018-06-01 15:45:08 +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
Alexander Larsson
715cc173ef Transactions: Add uninstall operation and handle no-pull correctly
In the no-pull case and when uninstalling, we never want to do any network
i/o for e.g. detecting depenedencies.

Closes: #1744
Approved by: alexlarsson
2018-06-01 10:59:14 +00:00
Alexander Larsson
f93886cb65 dir: Add flatpak_dir_get_remote_state_local_only
This does no network i/o and just keeps track of remote name
and collection id. This can be used for no-pull transactions.

Closes: #1744
Approved by: alexlarsson
2018-06-01 10:59:14 +00:00
Alexander Larsson
e7c9347b49 dir: Add flatpak_dir_read_latest_commit
This reads the current commit for a ref in the local repo.
This can be used e.g. to get at the metadata for an already pulled ref.

Closes: #1744
Approved by: alexlarsson
2018-06-01 10:59:14 +00:00
Alexander Larsson
f52d90635e dir: flatpak_dir_search_for_local_dependency
This is the same as flatpak_dir_search_for_dependency, but it looks only in the local
repo for already pulled dependencies. This is useful if you're in no-pull mode.

Closes: #1744
Approved by: alexlarsson
2018-06-01 10:59:14 +00:00
Alexander Larsson
ffe1b7e349 Make various operation work without a system installation
This makes info, list, remotes, and search work if there is no
system flatpak repo. Before it failed with EPERM.

Closes: #1742
Approved by: alexlarsson
2018-05-31 19:28:16 +00:00
Matthew Leeds
516c0f40b6 common: Update flatpakinclude_HEADERS
These headers were recently added to flatpak.h, so they need to be in
flatpakinclude_HEADERS so they are installed.
2018-05-31 08:33:30 +02:00
Alexander Larsson
90bed3f461 Remove unused variable 2018-05-29 21:54:07 +02:00
Philip Withnall
d325be85f1 common: Pop the thread default main context in find_latest_rev()
The pop was missing, meaning that calling flatpak_dir_find_latest_rev()
corrupted the thread default main context stack of the caller.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-05-29 21:52:13 +02:00
Alexander Larsson
91957b5c61 transaction: strdup progress status in getter
This way we're safe from reentrant use of the progress
2018-05-29 16:37:21 +02:00
Alexander Larsson
9fe81aaf90 Transaction: Add (and use) vfuncs for signals 2018-05-29 16:37:21 +02:00
Alexander Larsson
d2e419418b transaction: Change from installation_create_transaction() to transaction_new_for_installation()
This way is nicer because then the user can derive from FlatpakTransaction
2018-05-29 16:37:21 +02:00
Alexander Larsson
143e24f3bd Transaction: Convert to derivable type 2018-05-29 16:37:21 +02:00
Alexander Larsson
9672782694 libflatpak: Update docs for library 2018-05-29 16:37:21 +02:00
Alexander Larsson
2642b55e91 libflatpak: Guard public headers for individual includes 2018-05-29 16:37:21 +02:00
Alexander Larsson
89e673ff70 Rename FlatpakTransactionError to FlatpakTransactionErrorDetails
This makes it more obvious that this is not a GError enum
2018-05-29 16:37:21 +02:00
Alexander Larsson
bd94fa48ed dir: Add remote_name to the GPG failure error messages
This makes it easier to figure out which one goes wrong.
2018-05-29 16:37:21 +02:00
Alexander Larsson
a84e6195a8 Remove newlines from GError messages
These are not supposed to be in the message, but by the person printing the error.
2018-05-29 16:37:21 +02:00
Alexander Larsson
ab514062d9 transaction: Add remote name to some error messages
This makes it more obvious where these errors come from
2018-05-29 16:37:21 +02:00
Alexander Larsson
0e4948722c Installation: Add flatpak_installation_create_transaction ()
This is the libflatpak entry point for doing transactions.
2018-05-29 16:37:21 +02:00
Alexander Larsson
bb62296785 Transaction: Move progress to FlatpakTransactionProgress object 2018-05-29 16:37:21 +02:00
Alexander Larsson
5377cdea04 Transaction: Add disable-prune option
Endless wants this for the updater.
2018-05-29 16:37:21 +02:00
Alexander Larsson
0685649763 Transaction: Move update_metadata() into transaction_run()
There is no real need to have to manually call this, we just
want it to happen automatically.
2018-05-29 16:37:21 +02:00
Alexander Larsson
13b1175bc4 Transaction: Make metadata-update a warning 2018-05-29 16:37:21 +02:00
Alexander Larsson
400fb90737 Transaction: Don't prune when its not needed
We only need to prune when an already existing ref is changed
to a new value. For example, never on install/update if no_pull, and
not on fresh install (but on reinstall).
2018-05-29 16:37:21 +02:00
Alexander Larsson
74114d947b Transaction: Move operation done to signal 2018-05-29 16:37:21 +02:00
Alexander Larsson
e9a3b5345c Transaction: Move the printing of new operations to a signal 2018-05-29 16:37:21 +02:00
Alexander Larsson
ed5e714d8f Transaction: Add remote to error signal
We're not using this atm, but it seems useful to have.
2018-05-29 16:37:21 +02:00
Alexander Larsson
e56b68e0e4 Transaction: Move eol warning to signal 2018-05-29 16:37:21 +02:00
Alexander Larsson
9b8024326b transaction: Move operation errors, aborting and skipping to CLI
We add an error signal to Transaction that the calle (cli) handles. It
decides what to do with the error and whether to continue or abort.

A new error ABORTED is returned from flatpak_run() to indicate
that it errored out because you chose to abort. We also add a new
error SKIPPED that we use to report that some operation is skipped
(due to earlier errors).

This also means we remote the stop_on_first_error argument
from flatpak_transaction_run() as this is now controlled by
the caller.
2018-05-29 16:37:21 +02:00
Alexander Larsson
95b9ce0ee5 transaction: Use g_warning for warnings 2018-05-29 16:37:21 +02:00
Alexander Larsson
fd846875a2 transaction: Move already-installed skip:ing to from FlatpakTransaction to CLI 2018-05-29 16:37:21 +02:00
Alexander Larsson
1d6b43f4d0 Transaction: Add signal for choosing a remote when needed
Also move the existing code for this into FlatpakCliTransaction
2018-05-29 16:37:21 +02:00
Alexander Larsson
7b24103321 Transaction: Mark public transaction function
To be visible in the library the public symbols have to be FLATPAK_EXTERN.
2018-05-29 16:37:21 +02:00
Alexander Larsson
be6cea486c Transaction: Split out constructor into private header 2018-05-29 16:37:21 +02:00
Alexander Larsson
10dc876323 Transaction Move code to common/ 2018-05-29 16:37:21 +02:00
Alexander Larsson
a3605d0790 Ensure we have a stable sort when listing remotes
If remotes have the same prio, sort by name. This means anything that
relies on the order at least have a consisten behaviour.
2018-05-29 16:37:21 +02:00
Alexander Larsson
905e38115c dbus-proxy: Rework to match proposed dbus filter behaviour
This reworks the dbus proxy to be more in line with the API proposed at
 https://bugs.freedesktop.org/show_bug.cgi?id=101902

In particular, it makes the filtering language more expressive. You
can now filter both calls and broadcast recieves, and filters now work
with wildcarded object paths, bus names and interfaces
(BUS_NAME_IS_SUBTREE, OBJECT_PATH_IS_SUBTREE and empty interface in
dbus API). We also more correctly track the rules for unique ids so
that filter matching work for those too (previously filters only
worked if you sent to the well known bus name, not the unique name).

In terms of implementation, things have been simplified to *only* use
Filter rules rather than tracking policies and filters separately.

Also we track all the previously known owned names for a unique id
rather than just the highest policy for it. We can then look up all
filters for it, instead of a simplified policy only check.

In terms of the CLI everything is the same, except --filter=foo has
been renamed to --call=foo, to avoid the weird conflict with the
--filter (no =..) option. We also added a similar --broadcast to
filter received broadcasts.

Closes: #1730
Approved by: alexlarsson
2018-05-29 10:23:58 +00:00
Alexander Larsson
d59e79ee79 FlatpakBwrap: Add flatpak_bwrap_add_noinherit_fd
This just keeps the fd alive until the FlatpakBwrap is freed, it
doesn't actually pass it on to the child.

We want to use this to keep a file lock held until the sandbox has
started where it takes over the lock.

Closes: #1730
Approved by: alexlarsson
2018-05-29 10:23:58 +00:00