Commit Graph

447 Commits

Author SHA1 Message Date
Richard Hughes
2002bd5046 trivial: Fix a compile failure with new GLib versions
GLib now 'helpfully' includes type_traits in gmacros.h -- which now explodes
when compiling with a C++ compiler.
2021-03-21 20:18:34 +00:00
Norbert Kamiński
76e19930a8 fwupd port for BSD distros
Signed-off-by: Norbert Kamiński <norbert.kaminski@3mdeb.com>
2021-03-19 17:05:09 +00:00
Richard Hughes
a5966f7085 trivial: Codespell fixes 2021-03-19 16:42:33 +00:00
Richard Hughes
d94286b9de Allow enabling plugins only matching a specific HwId
At the moment plugins are doing this a few different ways; either looping
through the HwIds manually (e.g. flashrom) or setting a custom flag that is
checked in fu_plugin_setup (e.g. uefi-recovery).

Define a standard 'Plugin' HwId quirk to simplify plugins.
2021-03-02 18:19:45 +00:00
Richard Hughes
b3f9841924 Support more than one protocol for a given device
Devices may want to support more than one protocol, and for some devices
(e.g. Unifying peripherals stuck in bootloader mode) you might not even be able
to query for the correct protocol anyway.
2021-03-01 16:14:36 +00:00
Richard Hughes
078beafb2d Add a new internal flag to opt-in to GUID matching
It is far too easy to forget to set FWUPD_DEVICE_FLAG_NO_GUID_MATCHING for new
plugins, and without it it all works really well *until* a user has two devices
of the same type installed at the same time and then one 'disappears' for hard
to explain reasons. Typically we only need it for replug anyway!

Explicitly opt-in to this rarely-required behaviour, with the default to just
use the physical and logical IDs. Also document the update behavior for each
plugin to explain why the flag is being used.

This allows you to have two identical Unifying plugged in without one of them
being hidden from the user, at the same time allowing a HIDRAW<->USB transition
when going to and from bootloader and runtime modes.

This removes the workaround added in 99eb3f06b6.

Fixes https://github.com/fwupd/fwupd/issues/2915
2021-02-25 15:47:25 +00:00
Richard Hughes
7b2621c3de trivial: Incorporate by merging the device flags
If any flags are set in the baseclass (e.g. FuDevice) then incorporating with
a FuUdevDevice or FuUefiDevice is not going to merge the flags.
2021-02-23 14:33:30 +00:00
Richard Hughes
f722b30205 libfwupd: Fix adding multiple flags to devices
Ignore the request if _all_ the new flags are already set, not just any of them.
2021-02-22 22:48:56 +00:00
Richard Hughes
3f94eabe69 trivial: Use fwupd_device_add_flags() to set a single flag 2021-02-22 22:48:56 +00:00
Richard Hughes
5eca890f93 trivial: Do not assume the running system has LVFS enabled for the tests
This is not true for RHEL, and so 'ninja dist' fails on any RHEL workstation.
2021-02-16 09:19:46 +00:00
Richard Hughes
0b6907e0bb trivial: Fix warning from clang about unused variable 2021-02-08 12:53:32 +00:00
Richard Hughes
4d7bcaace5 trivial: Fix warning when compiling without libcurl 2021-02-08 12:53:12 +00:00
Richard Hughes
01a30aa6de Add support for oss-fuzz 2021-02-08 09:17:03 +00:00
Richard Hughes
9b3f7aba82 trivial: Remove unused -Dlink_language support 2021-02-07 16:59:57 +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
4d8163c2ee trivial: Fix up a gtk-doc warning for a new symbol 2021-01-30 16:14:21 +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
5bb9cf9392 Fix a crash when using fwupdtool
The docs for `fwupd_device_get_children()` make it very clear that only the
parent should be assigned. Also add a warning to `fwupd_device_add_child()`
explaining it is for internal daemon use only.
2021-01-27 15:48:43 +00:00
Richard Hughes
5d534970cb trivial: Show a warning if the child device gets unref'd from the parent
Should not happen, but bugs will be bugs.
2021-01-27 15:48:43 +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
a378c2902b trivial: Add a GObject property for update-state
This allows us to use ::notify when required.
2021-01-13 09:13:05 +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
cb408c3dee libfwupd: Never iterate a foreign GMainContext
From Philip's guide: "Never iterate a context created outside the library,
including the global-default or thread-default contexts. Otherwise, GSources
created in the application may be dispatched when the application is not
expecting it, causing re-entrancy problems for the application code."
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
92bfc1b6a8 trivial: Do not hard-depend on newer GLib versions 2021-01-08 09:10:32 +00:00
Richard Hughes
a3c6e8a8bd trivial: Fix -Dcurl=false with latest code 2021-01-08 09:10:29 +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
cf100293b5 Do not export useless device attributes to the client
That giant uint64_t isn't looking so big now, and we'll want to add even more
to it in the future. Split out some private flags that are never useful to the
client, although the #defines will have to remain until we break API again.
2021-01-06 14:36:23 +00:00
Richard Hughes
f1c79a8eae trivial: Fix a warning generated by new versions of meson
This fixes:

    DEPRECATION: Library fwupd was passed to the "libraries" keyword argument of
    a previous call to generate() method instead of first positional argument.
    Adding fwupd to "Requires" field, but this is a deprecated behaviour that
    will change in a future version of Meson.
2021-01-05 17:47:23 +00:00
Richard Hughes
104459bd10 Check the AMI test key if not installed for HSI-1
Fixes https://github.com/fwupd/fwupd/issues/2695
2021-01-05 17:09:02 +00:00
Richard Hughes
eddaed0c11 Allow specifying more than one VendorID for a device
Asking the user for the UID mapping isn't working very well, as it requires lots
of manual handholding. It also doesn't work very well when the device vendor
does not actually have a PCI ID or if the vendor has split into two entities.

Just use the OUI address as an additional VendorID and match any of the device
IDs against any of the metadata-supplied values.
2021-01-04 22:30:20 +00:00
Richard Hughes
3252573ac7 synaptics-prometheus: Fix flashing a fingerprint reader that is in use
The fprint daemon only keeps the device open for 5 seconds and then releases it,
which seems like a small window to hit.

But! We're asking the user to authenticate with the same device we're about to
upgrade so a different part of the stack woke up the hardware just before we're
about to deploy an update onto it.

Just retry a few times to make sure the device is idle. Use a flag to prevent
accidentally causing regressions in other plugins.

Fixes https://github.com/fwupd/fwupd/issues/2650
2021-01-04 21:52:10 +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
2e5c1d15bc Do not hardcode building shared libraries
Respect the -Ddefault_library meson define.
2021-01-04 15:26:28 +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
7d5a4f391b libfwupd: Use G_GNUC_WARN_UNUSED_RESULT for methods that should be checked 2021-01-04 15:24:35 +00:00
Richard Hughes
9619514508 trivial: One more <string.h> missing include 2020-12-15 10:02:59 +00:00
Richard Hughes
93867eda8e Allow linking with the CXX linker
This is required by oss-fuzz, for non-obvious reasons!
2020-12-14 20:34:20 +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
a14de30153 trivial: Require <string.h> for strlen() and memcpy() 2020-12-14 16:49:03 +00:00
Richard Hughes
68f565c441 Don't assume we have memfd_create() 2020-12-14 13:09:47 +00:00
Richard Hughes
39e391e046 Fix compile warnings when using -Db_sanitize=undefined 2020-12-14 08:33:41 +00:00