Repository navigation
Polkit hints - #2384
Polkit hints#2384matthiasclasen wants to merge 5 commits into
Conversation
69aa2f1 to
8d5fb1e
Compare
|
Seems we lost the protecion against downgrades: |
|
☔ The latest upstream changes (presumably f3f7417) made this pull request unmergeable. Please resolve the merge conflicts. |
|
This is very frustrating to debug
Any hints ? |
0649bb1 to
bd64f93
Compare
|
This took all afternoon to figure out: two boolean parameters were swapped. Booleans - just say no :( |
This is to avoid multiple polkit dialogs, regardless of transaction ordering. FlatpakTransaction calculates the 'strongest' op it has, and passes the hints accordingly. FlatpakInstallation doesn't pass hints, since it does individual operations. The system helper uses the hints to determine which PolicyKit permission to request. Since the policy typically has 'keep' set, this mean that the following operations in the same transaction will be able to reuse the permission obtained for the first one.
I realized that these messages are a bit confusing, with keep permissions and implications. We end up asking a question about one ref, but then use the permission we optained to operate on other refs. This will get a bit worse with the new hints, so go back to more generic messages that don't talk about the details. The ultimate goal here is less messages, anyway.
The Deploy method takes an 'update' flag from the caller and picked the permission to check based on that, which is not safe. Instead, we can check ourselves if the ref we are given is already installed (in which case it is an update, or a reinstall). After this change, the update flag is ignored by the system helper.
gtk-doc complains if parameter names don't match between headers and doc comments, so make them match, for a quieter build.
There was a bunch of handle methods which forgot to do this manually, so call the flatpak_dir_set_source_pid() method right when we create the FlatpakDir object.
bd64f93 to
794042f
Compare
| /* Can't install already installed app */ | ||
| g_dbus_method_invocation_return_error (invocation, FLATPAK_ERROR, FLATPAK_ERROR_ALREADY_INSTALLED, | ||
| "%s is already installed", arg_ref); | ||
| return TRUE; |
There was a problem hiding this comment.
The API kinda relies on flatpak_dir_install() returning these errors, so this is a behaviour change. I think we need to move the checks to the flatpak_dir_use_system_helper() part of flatpak_dir_install/update.
There was a problem hiding this comment.
The flow just changed a bit here, due to us no longer paying attention to what the caller said about this being an update or an install, with the UPDATE flag. Instead, we now look at the ref we got, and check whether it has a deploy and then we go:
has-deploy && !reinstall -> this is an update
else -> this is an install
previously, we had a case like
has-deploy && update flag not set -> report 'already installed' error
this just doesn't happen anymore, since we don't look at the flag, so no chance for the caller to get us into this inconsistent situation
The api change here is that we took a bit of redundancy (and potential for error cases) out of the api, by removing the update flag.
There was a problem hiding this comment.
Well, my issue is rather with callers of for instance flatpak_dir_install() where, if he app was already installed it would return a FLATPAK_ERROR_ALREADY_INSTALLED error, whereas it now returns G_DBUS_ERROR_INVALID_ARGS. Similarly flatpak_dir_update() with no previous update used to return NOT_INSTALLED, and now succeeds with deploying the pulled app.
However, I looked at the higher level callers of these (libflatpak and flatpak-transaction) and they all do early checks for these error cases anyway, so its not really a problem.
There was a problem hiding this comment.
right, I guess that is true. both flatpak_dir_install and flatpak_dir_update call the same Deploy underneath, so having it fail for the one but not the other seems a bit odd - now the system-helper just does what its asked to do: deploy the ref.
| { | ||
| /* Can't update not installed app */ | ||
| g_dbus_method_invocation_return_error (invocation, FLATPAK_ERROR, FLATPAK_ERROR_NOT_INSTALLED, | ||
| "%s is not installed", arg_ref); |
There was a problem hiding this comment.
similarly, this case here just doesn't happen anymore, where we had the caller claim that this is an update, but there is in fact no deploy
|
📌 Commit 794042f has been approved by |
I realized that these messages are a bit confusing, with keep permissions and implications. We end up asking a question about one ref, but then use the permission we optained to operate on other refs. This will get a bit worse with the new hints, so go back to more generic messages that don't talk about the details. The ultimate goal here is less messages, anyway. Closes: #2384 Approved by: alexlarsson
The Deploy method takes an 'update' flag from the caller and picked the permission to check based on that, which is not safe. Instead, we can check ourselves if the ref we are given is already installed (in which case it is an update, or a reinstall). After this change, the update flag is ignored by the system helper. Closes: #2384 Approved by: alexlarsson
gtk-doc complains if parameter names don't match between headers and doc comments, so make them match, for a quieter build. Closes: #2384 Approved by: alexlarsson
There was a bunch of handle methods which forgot to do this manually, so call the flatpak_dir_set_source_pid() method right when we create the FlatpakDir object. Closes: #2384 Approved by: alexlarsson
|
☀️ Test successful - status-papr |
Adding hints that let transactions get away with just a single polkit dialog even when they update a runtime first, then install an app.