summaryrefslogtreecommitdiff
path: root/lib
AgeCommit message (Collapse)AuthorFilesLines
2022-11-30Expose transaction sender as read-only propertyMatthias Klumpp3-2/+81
This is useful for debugging purposes, as it allows resolving the unique D-Bus name into a PID and then into the calling program to display. It makes it a lot easier to figure out which process is calling PackageKit repeatedly.
2022-11-10pk-client: Factor out parsing of UpdateDetail signalPhilip Withnall1-39/+54
This introduces no functional changes, but will make subsequent changes easier. Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-10pk-transaction: Add UpdateDetails signalPhilip Withnall1-0/+14
Like the `Packages` signal added a few commits previously, the `UpdateDetails` signal is a plural version of the existing `UpdateDetail` signal. This has reduced the number of signals emitted during starting up gnome-software from 632 `UpdateDetail` signals (for a corresponding number of pending dnf updates) to 1 `UpdateDetails` signal. The new signal is only used if the client sets the `supports-plural-signals=true` hint on a transaction. Otherwise the old `UpdateDetail` signal will be used. This means the new signal is backwards-compatible. If the hint is set, the new signal will be used in parallel with the old one, with some operations or backends using the old signal, and some using the new one. The content of the signals will not be duplicated (i.e. if `UpdateDetails` is emitted for N updates, there will not also be N `UpdateDetail` signal emissions in parallel). The new signal is currently only implemented for the dnf backend. Other backends can implement it at their leisure. Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-10pk-transaction: Add Packages signalPhilip Withnall1-0/+27
This has reduced the number of signals emitted during starting up gnome-software from 5711 `Package` signals, to 66 `Packages` signals (one per transaction). The signal is used only if the client sets the `supports-plural-signals=true` hint on a transaction. Otherwise the old `Package` signal will be used. This means the new signal is backwards-compatible. If the hint is set, the new signal will be used in parallel with the old one, with some operations or backends using the old signal, and some using the new one. The content of the signals will not be duplicated (i.e. if `Packages` is emitted for N packages, there will not also be N `Package` signal emissions in parallel). The new signal is currently only implemented for the dnf backend. Other backends can implement it at their leisure. Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-09-27trivial: Silence compiler warningMatthias Klumpp1-3/+2
2022-09-27apt: Generate logging output properlyMatthias Klumpp1-0/+4
2022-05-31pk-client: Fix default value of cache-age propertyPhilip Withnall1-1/+1
`pk_client_init()` sets the default value to `G_MAXUINT` but the `GParamSpec` setup didn’t also use that value. This probably introduces no functional changes, but it makes the code not contradict itself. Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-09-15pk-offline: Add flags to D-Bus invoking methodsMilan Crha3-7/+132
That's currently to be able to set whether the method should be interactive or not. The old functions call the methods as non-interactive. Closes https://github.com/PackageKit/PackageKit/issues/504
2021-07-28pk-task: Add specific error code when user declined interactionMilan Crha2-1/+3
To make it easier to know, in the code, that the user declined the interaction on the task and react on it properly, rather than checking a generic error code and the error message, which can eventually change in the future.
2021-06-29PkClient: Improve thread safety on an operation cancellationMilan Crha1-701/+338
The PkClient operates in two stages. The first is an "active" stage, which makes one or more D-Bus calls. The second is a "passive" stage, when it is waiting for the "Finished" D-Bus signal from the daemon. The cancellation can come in any time. This change keeps the cancellation up to the D-Bus calls during the first stage and actively stops the waiting during the second stage. As the GCancellable is cancelled in a different thread, and any D-Bus call is also done and its result delivered in that thread default main context, rather than in the main context when the PkClientState had been created, the PkClientState is switched to a GObject descendant, to be able to benefit from the GWeakRef, which can avoid use-after-free easily. The GDBusProxy callbacks can be schedules in the middle of the object free, thus the added callbacks also benefit from the GWeakRef usage. All of this helps to better cover the PackageKit daemon disappear during an ongoing call to it. Closes https://github.com/PackageKit/PackageKit/issues/489
2021-05-20PkDetails: Add 'download-size' propertyMilan Crha3-0/+39
This can be used to distinguish the download size and whether the package is already downloaded; use this in the dnf backend.
2021-05-20PkPackage: Add update severity propertyMilan Crha5-2/+85
This can be used by backends, to provide an update severity for the package.
2021-05-13pk-client: Fix a possible use-after-free under pk_client_cancel_cb()Milan Crha1-3/+0
When cancelling a transaction, even if it fails, the associated transaction still receives its async callback, thus also frees the 'state' structure. That means, when the cancel fails, it should not free the 'state'. This can be reproduced by a race condition between cancelling the operation by the caller and delivery of the 'Cancel' D-Bus call. The call order is: - the caller cancels the 'state->cancellable_client' cancellable - the PkClient executed the 'Cancel' D-Bus method for this operation - before the 'Cancel' D-Bus call is finished the operation finishes, freeing the 'state' as well - the 'Cancel' D-Bus method call is finished, possibly with an error like "Transaction is already finished". As the 'state' is already freed, trying to free it causes a use-after-free error and an application crash. Signed-off-by: Richard Hughes <richard@hughsie.com>
2021-05-13pk-client: State's cancellable_client not unreffedMilan Crha1-4/+4
The state::cancellable_client holds a passed-in cancellable variable, which is reffed. This was never unreffed in the code. Signed-off-by: Richard Hughes <richard@hughsie.com>
2021-05-13pk-client: Correct 'cancellable' use in pk_client_repair_system_async()Milan Crha1-1/+2
Two problems: a) the 'state->cancellable' is not a new cancellable like in every other place; b) the passed-in cancellable is supposed to be set into 'state->cancellable_client', because on that cancellable is the signal disconnected, aka the disconnect won't work for this function. Signed-off-by: Richard Hughes <richard@hughsie.com>
2021-05-01pk-client: Fix a leak on calling set_locale() a second timePhilip Withnall1-0/+1
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-05-01pk-client: Avoid spurious GObject::notify signal emissionsPhilip Withnall1-0/+16
If the property value doesn’t actually change, there’s no need to emit the `notify` signal. Note that I didn’t see this happening in practice — this fix is only as a result of reading the code. Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-05-01pk-client: Fix a typo in a documentation commentPhilip Withnall1-1/+1
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-03-20packagekit-glib2: Cancel a transaction if calling Cancel failsPhilip Withnall1-3/+7
If calling the `Cancel()` D-Bus method on a transaction fails, cancel the client-side state anyway, to prevent the client from waiting forever on a response which is unlikely to come. Spotted in https://gitlab.gnome.org/GNOME/gnome-software/-/issues/1118. Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-03-20packagekit-glib2: Cancel a transaction if the daemon disappearsPhilip Withnall1-1/+30
Most of the time, when using a `GDBusProxy`, and the service you’re talking to disappears, you’ll get notified — the async D-Bus call you’re making will return an error. However, due to PackageKit’s design for handling long-running operations, there are long periods between a transaction being created, and emitting its `Finished` signal, when no D-Bus calls are pending. If the daemon crashes during one of these periods, there is currently no way for the packagekit-glib2 client code to notice until it tries to make another D-Bus call on the same `GDBusProxy` instance, and that might never happen — it might wait for the `Finished` signal forever. Avoid that by connecting to `notify::g-name-owner`, which is emitted on `GDBusProxy` if the daemon crashes. It changes value from the unique name of the service, to `NULL`. When that happens, abort the transaction state in the client with an error. This should stop gnome-software hanging indefinitely if PackageKit crashes during a transaction. In particular, if this happens a few times during consecutive refresh operations, gnome-software can eventually run out of worker threads, and become unresponsive entirely. (See https://gitlab.gnome.org/GNOME/gnome-software/-/issues/1118.) The same will likely be true of other clients which use packagekit-glib2. Equivalent changes don’t seem to be needed in `pk-control.c` (which also uses `GDBusProxy`), because all of its D-Bus operations appear to maintain no state outside of individual method calls. Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-02-09Fix multilib conflicts in generated pk-enum-types.hKalev Lember2-3/+3
Avoid using full filename in comments as that can be different on different arches if the build directory differs, leading to multilib conflicts. Instead just use @basename@, which is always the same. https://bugzilla.redhat.com/show_bug.cgi?id=1915259
2021-01-12trivial: Fix a few Meson warningsHEADmasterMatthias Klumpp2-2/+0
2021-01-11Fix all compiler warningsMatthias Klumpp6-12/+12
2020-01-20meson: Add missing header files to gnome.generate_gir()Rico Tzschichholz1-1/+7
This restores the original build of the GIR with automake.
2020-01-13trivial: Actually install pk-version.hRichard Hughes1-0/+2
2020-01-10trivial: Always include <config.h>Richard Hughes2-6/+2
2020-01-10trivial: Remove the I_KNOW_THE_PACKAGEKIT_GLIB2_API_IS_SUBJECT_TO_CHANGE ↵Richard Hughes2-5/+0
requirement
2020-01-10Port to the meson build systemCorentin Noël10-347/+357
With much help from Martin Blanchard <tchaik@gmx.com> too, thanks to all. https://wiki.gnome.org/Initiatives/GnomeGoals/MesonPorting
2020-01-10trivial: Downgrade another warning in daemon self testsRichard Hughes1-1/+1
2020-01-10trivial: Fix critical warning in daemon self testsRichard Hughes1-1/+2
2019-07-04packagekit-glib2: Use $XDG_RUNTIME_DIR/debconf-socket if it existsJulian Andres Klode1-0/+10
Reuse debconf-socket in user runtime dir if it exists, as long as we are not using debconf-kde or the current terminal, as socket-activation does not work for the former, and we cannot use the current terminal from the socket-activated helper...
2019-07-04packagekit-glib2: Export pk_client_create_helper_argv_envp()Julian Andres Klode2-5/+6
This allows us to build an external client helper binary that uses this function to build argv and evnp.
2019-07-04packagekit-glib2: Extract pk_client_helper_start_with_socket()Julian Andres Klode2-5/+52
Extract pk_client_helper_start_with_socket() out of the function pk_client_helper_start() so we can start a client helper for an existing socket. This will allow us to get a socket from systemd in a socket-activated service, for example.
2019-07-04packagekit-glib2: Add pk_client_helper_is_active()Julian Andres Klode2-0/+31
This function enables code to check whether a client helper has accepted connections. A connection is considered active if one of its sources has not been removed yet, even if it's just blocking waiting for data.
2019-07-04pk-client-helper: Do not dereference argument before checking itJulian Andres Klode1-2/+6
Stop dereferencing client_helper before validating it in public functions.
2018-12-04trivial: Add missing config.h includeKalev Lember1-0/+2
2018-12-01lib/python/packagekit/Makefile.am: Use the detected PYTHON versionJavier Jardón1-1/+1
This will fix compilation in system where only the "python3" executable exists
2018-11-25common: Handle quoted strings in /etc/os-releaseKalev Lember1-3/+12
This should fix /var/cache/PackageKit/"8.0"/ on RHEL 8.0 to not have quotes in it.
2018-09-21Never assert when an interactive TTY is not availableRichard Hughes1-2/+3
Also, fd==0 is unlikely, but valid. Do the right thing in finalize().
2018-08-29Remove some dead codeRobert Ancell1-14/+0
2018-05-21Fix issues with debconf helper not working:Robert Ancell1-223/+194
- Fix buffer overflow writing nul character on the end of debconf reads - Register IO callbacks on the thread main context - not the default context (broken in ac3b14be9e) - Always accept incoming socket connections to avoid busy loop - Fix loops from incorrect handling of various input error cases - Close helper stdin when socket closes - was causing debconf UI to remain open and unresponsive - Use standard IO priority to avoid busy loops - Reliably clean up socket file on finalize
2018-05-17Fix usage of FALSE when it should be NULLRobert Ancell1-2/+2
2018-05-15De-register callbacks on PkClientHelper finalize.Robert Ancell1-28/+55
These could otherwise trigger on a deleted object.
2018-03-03Fix g_object_ref() type cast warnings with glib 2.56Kalev Lember3-8/+8
In glib 2.56, g_object_ref() checks that we're assigning the return value to a variable of the same type we're passing in.
2018-02-19Rename "Software Sources" to "Software Repositories"Kalev Lember4-4/+4
This renames a few strings to match gnome-software terminology change in https://gitlab.gnome.org/GNOME/gnome-software/commit/3bbf72c079ba6f4b864b7cd223e0cc5592380e2a
2018-01-10Fix missing PK_STATUS_ENUM_RUN_HOOK in pk-enum.cDaniel Nicoletti1-0/+1
2018-01-10client: Fix an invalid read when cancelling races with FinishKalev Lember1-5/+1
Don't try to debug print state->tid in cancelled callback as state may have already been destroyed at that point. https://bugzilla.gnome.org/show_bug.cgi?id=789438
2017-10-25offline update: Save transaction role to the offline results fileKalev Lember4-0/+43
This lets gnome-software handle distro upgrade and regular update results differently.
2017-09-20docs: Update section descriptionRobert Ancell1-1/+1
2017-09-20docs: Add missing docstringsRobert Ancell4-8/+60