Commit Graph

133 Commits

Author SHA1 Message Date
Richard Hughes
76cafb29b7 Fix a critical warning when downloading files
The call to g_proxy_resolver_get_default() is (transfer none) and so unref'ing
it causes GLib to get very upset. Also, move it to be per-FwupdClient rather
than per-request as it can be expensive to call in the PAC-runner case.
2021-04-30 11:19:09 +01:00
Richard Hughes
89d45a0d91 trivial: Standardize on introspection for @error and @cancellable
Also standarize on `Returns:` for the result.
2021-04-28 16:19:50 +01:00
Richard Hughes
fdd507957a Switch from libproxy to GProxyResolver
GProxyResolver will use libproxy only when required. TIL.
2021-04-28 15:52:45 +01:00
Richard Hughes
f992fb75cd Use libproxy to get the system proxy setting for a given URL 2021-04-26 16:30:13 +01:00
Richard Hughes
a5966f7085 trivial: Codespell fixes 2021-03-19 16:42:33 +00:00
Richard Hughes
4d7bcaace5 trivial: Fix warning when compiling without libcurl 2021-02-08 12:53:12 +00:00
Richard Hughes
6de10e118c Allow downloading firmware from IPFS
Only a small amount of the firmware on the LVFS will be available. The user
can use --ipfs on the command line for testing, or change the system-wide
default in /etc/fwupd/daemon.conf.

The IPFS daemon and command line client will need to be installed manually.
2021-02-01 19:33:31 +00:00
Richard Hughes
7715dead97 trivial: Fix bogus -Wunused-variable warning 2021-01-30 15:49:20 +00:00
Richard Hughes
382524d82f trivial: Fix potential crash when doing crazy things
Fix the asan crash when feeding the value back into itself, e.g

    fu_firmware_set_version (firmware, fu_firmware_get_version (firmware));
2021-01-28 14:13:59 +00:00
Richard Hughes
e1abefb788 trivial: Use fwupd_client_download_bytes2_async() when installing releases 2021-01-26 20:32:32 +00:00
Richard Hughes
633ff10772 libfwupd: Add fwupd_client_install_release2_async()
We forgot to include FwupdClientDownloadFlags when adding the original method
fwupd_client_install_release() -- and we want to use additional download flags
for operations in the future.
2021-01-26 18:01:33 +00:00
Richard Hughes
ddeceb419f Allow allow downloading from a list of possible URLs 2021-01-26 18:01:09 +00:00
Richard Hughes
b8dfaccce7 libfwupd: Add fwupd_release_add_location()
The metadata might want to pass more than one location URI to the client, for
instance if the file is available from more than one HTTP mirror.

Use the noun of location to match the AppStream <artifact> naming; this is the
last place where LVFS AppStream diverges from the official specification and
it would be good to bring fwupd back into line -- although the LVFS will have
to write both elements for a very long time.

See https://www.freedesktop.org/software/appstream/docs/chap-Metadata.html

Also: we're not changing the format of the `Uri` GVariant key to preserve both
forward and backwards compatibility of the library. We can remove it when we
next break API.
2021-01-26 14:26:06 +00:00
Richard Hughes
6ed25f557c Never iterate the global default main context 2021-01-11 09:13:46 +00:00
Richard Hughes
9047aaccd4 trivial: Actually emit progress events
CURLOPT_NOPROGRESS defaults to 1L...
2021-01-10 16:25:42 +00:00
Richard Hughes
3f7ee4d5a1 libfwupd: Return the progress information using the correct GMainContext
We don't want the (shared) progress notifications going to the thread-default
GMainContext by default as this changes behaviour (ABI?) with older libfwupd
versions.

If the client really does want progress notifications to go to a different
GMainContext they it can call fwupd_client_set_main_context() with the desired
context, e.g. g_main_context_get_thread_default() or g_main_context_new().

This has the intended side effect of returning progress and state notifications
to the main thread, which is typically (but not always) the thread that created
the FwupdClient object.
2021-01-08 16:48:34 +00:00
Richard Hughes
5511dbccf0 libfwupd: Fix a tiny memory leak when using fwupd_client_connect() 2021-01-08 16:48:34 +00:00
Richard Hughes
fb36f226ed libfwupd: Set the daemon status correctly after connect() 2021-01-08 16:48:34 +00:00
Richard Hughes
2c1f08d874 libfwupd: Do not allow multiple threads to create the GDBusProxy
When using the sync API entrypoints like fwupd_client_get_devices() these call
into fwupd_client_connect() to ensure the proxy is set up. This is not thread
safe and chaos ensues if you call two sync functions from different threads,
like GNOME Software does at startup...

Use a mutex to protect access to this shared resource.

Original test code from Philip Withnall, slightly tweaked by me. Thanks!
2021-01-07 16:39:08 +00:00
Richard Hughes
5c9b1fcc81 Only include the start year in the copyright header
The end year is legally and functionally redundant, and more importantly causes
cherry-pick conflicts when trying to maintain old branches. Use git for history.
2021-01-07 14:48:16 +00:00
Richard Hughes
f9fe19f7f6 Make libcurl optional for fuzzing
For fuzzing we want to exclude libcurl support as it depends on other very heavy
libraries like OpenSSL or libtasn which make the fuzzing binary much larger if
linked statically.
2021-01-04 16:22:36 +00:00
Richard Hughes
6a489a9eaf trivial: Add missing calls to g_return_val_if_fail() 2021-01-04 15:24:35 +00:00
Richard Hughes
c0d4c09a02 Lower libcurl requirement further still
This allows us to build on Ubuntu 16.04!
2020-12-14 16:50:30 +00:00
Richard Hughes
698099f643 trivial: Remove several unused variables 2020-12-08 20:06:46 +00:00
Richard Hughes
00640f42f2 Lower the CURL version required to fix build in RHEL
Some vendors really really want 1.5.x in newer RHEL versions, but the version
of curl is too old. Add #ifdefs so that we can emulate (somewhat imperfectly)
the 'new' CURLU functonality.
2020-12-07 14:17:22 +00:00
Tim Gates
88dc597125 docs: fix simple typo, rumtime -> runtime
There is a small typo in libfwupd/fwupd-client.c.

Should read `runtime` rather than `rumtime`.
2020-12-07 11:13:22 +00:00
Richard Hughes
95a5fb2e2f Allow setting the GMainContext when used for sync methods
Use the 'default' main context by default so that we still get the signals
delivered via g_object_notify() but allow the library user to specify an
alternate GMainContext as required.

Using g_main_context_push_thread_default() works for PackageKit as signals are
returned using g_signal_emit() which is synchronous, and so doesn't use the
main context at all.

Use the same style of API which we did for libgusb all those years ago instead.
2020-12-04 07:58:05 +00:00
Richard Hughes
ced512c71f Only parse the signature if the remote is JCat
This fixes a regression from 2f49da7f4e where we
tried to parse the GPG .asc file as a JcatFile even although the remote had
Keyring=gpg (which is the default for ODM accounts on the LVFS) which returned
the cryptic 'Invalid compressed data' message.

The workaround for 1.5.2 is to change the local remote.conf from 'Keyring=gpg'
to 'Keyring=jcat' and to save the file.
2020-11-29 07:24:33 +00:00
Richard Hughes
cf575bd783 trivial: Fix several nonprefixed bare errors 2020-11-25 14:13:25 +00:00
Richard Hughes
23f9cca6b4 trivial: Fix regression on uploading reports without a signature 2020-11-20 10:44:54 +00:00
Richard Hughes
173d389fa5 Register the SoupSession gtype when required
This allows old gnome-software clients to work with new fwupd versions.
2020-11-19 19:39:37 +00:00
Richard Hughes
3a73c342ba Switch from libsoup to libcurl
The former drags on glib-networking and then gsettings-desktop-schemas, which
add over 5Mb to the minimal IoT and CoreOS composes. Everything already uses
libcurl (even NetworkManager!) and so this is an easy way to reduce image size.
2020-11-19 19:39:37 +00:00
Richard Hughes
eba28b6520 libfwupd: Add fwupd_client_get_user_agent()
If we set a property, we should probably have a way to read it back...
2020-11-17 21:10:10 +00:00
Richard Hughes
42577728bb Only download the remote metadata as required
Moving to the async libfwupd library design meant this optimization was lost.
2020-11-17 12:14:30 -06:00
Richard Hughes
8087b2c9e0 trivial: Set the 'downloading' state when starting the download
For small files we might not get progress callbacks and so we stay in IDLE
status forever.

Fixes https://github.com/fwupd/fwupd/issues/2522
2020-10-27 19:36:18 +00:00
Richard Hughes
7bcb8d4385 Export FwupdPlugin so we can convey enumerated system errors to the end user
For instance, we can tell the user that UEFI UpdateCapsule is disabled in the
system firmware, or that efivarfs is not mounted. This is much better than
creating "dummy" devices which are really just hacks around the problem because
no better API existed. THe dummy devices cause as many problems as they solve.

Plugins have to set FWUPD_PLUGIN_FLAG_USER_WARNING if a warning should be shown
to the user, and only one warning will be shown of each failure type.

It is expected that GUI clients like gnome-software and gnome-firmware would use
this API to notify the user the localized message for why firmware updates are
not being shown.

Fixes https://github.com/fwupd/fwupd/issues/2456
2020-10-13 15:56:49 +01:00
Richard Hughes
27b399ce27 libfwupd: Actually use the JCat file to select the metadata file
This recent regression was caused when porting libfwupd to the async model.

Fixes https://github.com/fwupd/fwupd/issues/2360
2020-10-07 15:38:08 +01:00
Richard Hughes
6450d0deb4 Add FwupdInstallFlags of _IGNORE_CHECKSUM, _IGNORE_VID_PID and _IGNORE_POWER
The FWUPD_INSTALL_FLAG_FORCE flag has really unclear semantics, and ignoring a
file CRC, checksum or model ID should only be done when using fwupdtool actually
debugging a plugin or firmware parser.

Use the existing --force flag when we want a "gentle nudge" like reuploading
previously processed reports.
2020-10-07 13:15:09 +01:00
Richard Hughes
5bbf013879 Add a --allow-branch-switch to fwupdmgr
This allows us to turn off the tests like version format differences and
checking for downgrades.
2020-10-07 13:15:09 +01:00
Richard Hughes
7c8a830659 libfwupd: Add async versions of the library for GUI tools
Rather than force the GUI to interact with fwupd using threads, provide
async versions so thay can be run without blocking the UI thread.
2020-09-03 15:46:57 +01:00
Richard Hughes
f0735f4583 trivial: Fix a logic thinko spotted by Coverity 2020-09-01 14:14:02 +01:00
Richard Hughes
93ba041ce2 trivial: Use @self in FwupdClient to modernize the object 2020-08-27 08:03:16 +01:00
Daniel Campello
722f532781 fwupd-remote: Download remote firmware on local remote
This changes allows for downloading firmware from a remote server
pointed from a local remote manifest.xml.gz file

Change-Id: Id00870f9c2817d48d6d301d2b6d229ba1ca6045a
2020-08-12 20:09:17 +01:00
Richard Hughes
3120683143 Allow blocking specific firmware releases by checksum
Fixes https://github.com/fwupd/fwupd/issues/2280
2020-08-10 17:14:15 +01:00
Richard Hughes
a99b5adfb6 trivial: Export fwupd_client_ensure_networking()
This is required when the calling application needs the low-level soup-session
with the user agent set correctly rather than using the helper methods like
fwupd_client_download_bytes().

This is what GNOME Software needs to handle the GsApp progress completion.
2020-07-23 13:00:39 +01:00
Richard Hughes
f4c55d888e libfwupd: Add fwupd_client_install_release()
This allows us to remove a lot of copy-and-paste code in GNOME Software.
2020-07-09 20:57:00 +01:00
Richard Hughes
02d94d3139 libfwupd: Add fwupd_client_install_bytes()
Sometimes you do not have a filename and just a blob of memory.
2020-07-09 20:57:00 +01:00
Richard Hughes
59f871deda libfwupd: Move GUnixInputStream-creating functions to common code
We'll need to use them from other methods soon.
2020-07-09 20:57:00 +01:00
Richard Hughes
d528571971 libfwupd: Add fwupd_client_refresh_remote()
This takes care of downloading the correct files and allows remotes to be
refreshed from other CLI and GUI tools without copying large chunks of code.

This also allows us to download the metadata without writing two temp files
to the users cache directory. Although not security sensitive, it's probably
not a good idea if we can avoid it.
2020-07-09 20:57:00 +01:00
Richard Hughes
71ba813a71 libfwupd: Add fwupd_client_update_metadata_bytes()
Sometimes the data is coming from a blob of memory and not a cached file, so
use a memfd to create a file descriptor that can be passed to the daemon.
2020-07-09 20:57:00 +01:00