Commit Graph

624 Commits

Author SHA1 Message Date
Sergii Dmytruk
8d5784192f Fix formatting in fu_common_get_block_devices ()
Signed-off-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com>
2021-06-07 11:19:17 +01:00
Richard Hughes
e1519f394e trivial: Do not change ABI when -Dudev=false 2021-05-26 16:00:32 +01:00
Richard Hughes
1b86f9836b trivial: Automatically call PkBackend::setup() when required
This reduces the amount of boilerplate in the self tests.
2021-05-25 17:17:45 +01:00
Richard Hughes
dfb46d9b56 trivial: Add fu_backend_get_devices() for future use 2021-05-25 17:17:45 +01:00
Richard Hughes
76602389ff Export FuBackend into libfwupdplugin for future use 2021-05-25 17:17:45 +01:00
Richard Hughes
560132b0d0 trivial: Fix typo preventing FreeBSD compile 2021-05-25 12:44:55 +01:00
Richard Hughes
79bbcd792a Store the BSD kernel cmdline string in the failure report
Also split out a kenv helper into common code.
2021-05-25 06:31:46 +01:00
Richard Hughes
d1bf0f439b trivial: Do not show a warning when building the libfwupdplugin introspection
If new enough add Xmlb into the libfwupdplugin GIR includes.
2021-05-22 14:16:42 +01:00
Richard Hughes
3cb08d81c5 trivial: Remove unused variable from self tests 2021-05-21 15:34:21 +01:00
Norbert Kamiński
80ba3f07f2 fu-smbios.c: Add kenv support
Signed-off-by: Norbert Kamiński <norbert.kaminski@3mdeb.com>
2021-05-18 14:32:07 +01:00
Richard Hughes
99f40fa7a7 Add a FuI2cDevice to abstract I²C devices 2021-05-18 14:29:28 +01:00
Richard Hughes
3ba0b29ba3 trivial: Fix critical warning when running fwupd as non-root 2021-05-18 11:06:51 +01:00
Richard Hughes
b94a7b507b trivial: Do not generate fwupdplugin.vapi
We don't want applications to use libfwupdplugin, and we don't want to
support plugins written in Vala either.
2021-05-17 09:27:54 +01:00
Richard Hughes
8792afa894 trivial: Fixup some documentation to use the correct type 2021-05-17 09:27:54 +01:00
Richard Hughes
54d9de9290 Force the device locker to ->close() an aborted ->open()
Fixes https://github.com/fwupd/fwupd/issues/3187
2021-05-12 10:10:57 +01:00
Richard Hughes
dbd57ebc43 trivial: Always include the newline for fu_common_string_append_kv() 2021-05-11 21:01:33 +01:00
Richard Hughes
e9cc87d740 trivial: Add some more missing GObjectIntrospection markup 2021-05-11 16:55:53 +01:00
Richard Hughes
69a643d7e1 trivial: Work around a GObjectIntrospection warning
We broke this rule: https://gi.readthedocs.io/en/latest/writingbindableapis.html?highlight=boxed#don-t-have-properties-and-methods-with-the-same-name
2021-05-11 16:55:53 +01:00
Richard Hughes
38f82b10f8 trivial: Remove warnings from the GObjectIntrospection output 2021-05-11 16:55:53 +01:00
Richard Hughes
88aff562d2 trivial: More GObjectIntrospection fixes 2021-05-11 16:55:53 +01:00
Richard Hughes
8fe6a1dd0c trivial: Make FuSrecFirmwareRecord usable from non-C languages 2021-05-11 13:15:27 +01:00
Richard Hughes
20ef071b3c trivial: Style fixes to lots of gtk-doc 2021-05-10 14:35:10 +01:00
Daniel Campello
a4fbe2a6f4 Switch lock directory from /var/run to /run/lock
This allows for proper locking between executions of fwupdtool in
Chromium OS minijail environment. It is needed after commit
9cf5f8f7ff was introduced.

Change-Id: I37b33c8d1fbe97ec9baddc5f77ea94e2f4ff1fa4
2021-05-05 13:34:49 -06:00
Richard Hughes
ffcaf14021 trivial: Skip the fmap tests when memmem is not available 2021-05-04 09:45:03 +01:00
Richard Hughes
29e04f926d trivial: Skip the efivar tests on Windows 2021-05-04 09:45:03 +01:00
Richard Hughes
7b7eb9e9b5 trivial: Skip the lockdown tests on Windows 2021-05-04 09:45:03 +01:00
Richard Hughes
5e95cae0c4 trivial: Fix CI by including the version symbols 2021-04-30 16:07:10 +01:00
Richard Hughes
c77b4f03a2 Check the versions of libfwupd and libfwupdplugin at startup
This prevents super-hard-to-debug crashes like we saw in #3197 where the user
was mixing PPAs and official versions.
2021-04-30 15:00:04 +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
7b23f95a21 trivial: Fix up some introspection bugs 2021-04-28 16:19:50 +01:00
Richard Hughes
495302ca06 Support binary artifact resources in cabinet archives
Fixes the other half of https://github.com/fwupd/fwupd/issues/3193
2021-04-28 15:52:26 +01:00
Richard Hughes
c6bb21356f Support all hash types when loading cabinet archives
Fixes half of https://github.com/fwupd/fwupd/issues/3193
2021-04-27 15:41:44 +01:00
Richard Hughes
1ac05ef3bd trivial: Codespell fixes 2021-04-26 10:29:39 +01:00
Richard Hughes
63bc42eace Add a composite ID that is used to identify all devices in the same physical package 2021-04-22 16:27:04 +01:00
Richard Hughes
f9e9e087d4 trivial: Do not allow changing the logical or physical IDs after calling ->setup()
If we allowed this then the DeviceID would change, and chaos ensues.
2021-04-22 15:37:24 +01:00
Richard Hughes
248ea1b8a9 Fix a crash when shutting down the daemon
Unloading the GModule means that any GTypes registered by that plugin cannot be
queried.

Other plugins could unintentionally call methods like G_OBJECT_TYPE_NAME()
which makes the daemon explode. There's no need to actually close the module,
and so we're just making life diffult for ourselves for no good reason.

Fixes the other half of https://github.com/fwupd/fwupd/issues/3156
2021-04-20 15:09:58 +01:00
Richard Hughes
46f86a5c1e trivial: Enforce that fu_plugin_cache_add() uses a valid GObject 2021-04-20 15:09:58 +01:00
Richard Hughes
5523ac46e3 trivial: Fix introspection markup for a new symbol 2021-04-20 15:09:58 +01:00
Richard Hughes
d42bd85059 trivial: Do not use the deprecated allow-none introspection argument
It's been deprecated since 2014... oops.

https://blogs.gnome.org/desrt/2014/05/27/allow-none-is-dead-long-live-nullable/
2021-04-19 14:46:42 +01:00
Richard Hughes
64416bcd0a trivial: Mark more functions arguments as 'nullable' 2021-04-19 14:46:42 +01:00
Richard Hughes
6ef551a39e Never allow plugins to add a NULL GUID
Not fixing, but should help with https://github.com/fwupd/fwupd/issues/3156
2021-04-19 14:46:42 +01:00
Richard Hughes
e65d28d817 Add a utility to resign firmware files
This can be used like this:

    fwupdtool firmware-sign firmware.cab rhughes_signed.pem rhughes.key

Test signing certificates can be generated using the example script here:
https://github.com/hughsie/libjcat/blob/master/contrib/build-certs.py although
these certificates should not be used for enterprise use.
2021-04-19 12:59:35 +01:00
Richard Hughes
faa35e430b Show a warning if the device has no GType and the plugin has no default
This also renames a symbol to make it clear that you can call it more than once.

Fixes https://github.com/fwupd/fwupd/issues/3148
2021-04-15 16:52:56 +01:00
Richard Hughes
48f04721de Call g_type_ensure() when using fu_context_add_firmware_gtype()
This simplifies plugins as it means we don't need to remember to ensure the type just to be able to ->build() the firmware file.
2021-04-15 16:52:56 +01:00
Peter Marheine
da9a07ba8f FuUdevDevice: add get_siblings_with_subsystem function
This function returns a list of sibling devices that have a chosen subsystem,
allowing callers to perform a limited walk of the device tree to locate related
devices.
2021-04-15 06:53:06 +01:00
Richard Hughes
be1d77bc7c Add fu_ihex_firmware_set_padding_value() for the analogix plugin 2021-04-12 09:55:44 +01:00
Richard Hughes
45493b06d8 trivial: Fix a small memory leak in the new FuContext code
Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=33155
2021-04-11 19:01:33 +01:00
Richard Hughes
7f6f525f21 Add fu_bytes_get_data_safe() to check for zero sized data
Fixes https://github.com/fwupd/fwupd/issues/3122
2021-04-10 13:20:07 +01:00
Mario Limonciello
9bca3bf53c trivial: correct docstring location for a few python files 2021-04-09 16:02:20 +01:00
Daniel Campello
0b9b7ecc84 fu-engine: only disable coldplug if no HwId is found
This change only disables coldplug instead of the whole plugin if no
HwId is found when FWUPD_PLUGIN_FLAG_NO_HARDWARE is set.
2021-04-08 18:12:16 -06:00
Mario Limonciello
6d1afc3e87 trivial: reformat all python code with black 2021-04-08 10:43:29 -05:00
Richard Hughes
4d76d18d35 Set the system battery state and level on the FuContext shared state
This allows plugins to set the battery power state of the *machine* which means
we can automatically inhibit devices with FWUPD_DEVICE_FLAG_REQUIRE_AC set.

It also allows to set the BatteryThreshold to 25% for Lenovo hardware, and we
can override other vendors with further quirks as required.

Fixes https://github.com/fwupd/fwupd/issues/3084
2021-04-07 08:05:15 +01:00
Mario Limonciello
0f50a3186c Add a new internal flag for whether or not to inherit activation
The activation flag is stored into the history database, but not all
plugins will want to inherit it on coldplug the next time the daemon
is started.

For example the Dell Dock plugin will query this information from the
device and it will prevent getting into a bad state as a result.
Fixes: #3106
2021-04-06 14:09:12 -05:00
Richard Hughes
776a0890fe srec: Make FuIhexFirmware derivable for possible future use
An ABI change, so probably not a good idea to backport.
2021-04-06 14:54:39 +01:00
Richard Hughes
7f7e4437fc ihex: Make FuIhexFirmware derivable for future use
An ABI change, so probably not a good idea to backport.
2021-04-06 14:54:39 +01:00
Richard Hughes
edcca6d1d7 Do not show a GType failure when using fwupdtool
If only one plugin is enabled and there exists a device match for a GType that
has not been registered then the user sees a GType error about not being able
to create a device that wouldn't be created anyway.

By removing the error in the quirk parser we will catch actual errors in
fu_plugin_runner_backend_device_added() which actually does chcek for
FWUPD_PLUGIN_FLAG_DISABLED.

Fixes https://github.com/fwupd/fwupd/issues/3099
2021-04-02 21:52:55 +01:00
Richard Hughes
b333e0045c Split out a shared system context
There is a lot of code in fwupd that just assigns a shared object type to
a FuPlugin, and then for each device on that plugin assigns that same shared
object to each FuDevice.

Rather than proxy several kinds of information stores over two different levels
of abstraction create a 'context' which contains the shared *system* state
between the daemon, the plugins and the daemon.

This will allow us to hold other per-machine state in the future, for instance
the system battery level or AC state.
2021-04-01 21:11:29 +01:00
Richard Hughes
0d4255b589 vli: Remove deprecated quirk prefixes 2021-04-01 18:40:14 +01:00
Richard Hughes
c6569eff67 Remvoe the unused fu_plugin_set_coldplug_delay() 2021-04-01 16:01:06 +01:00
Richard Hughes
4ae7b5e837 Remove the unused fu_plugin_recoldplug() 2021-04-01 16:01:06 +01:00
Richard Hughes
250f30ceb9 trivial: Remove more deprecated API because we can
We bumped soversion, so lets clean up the API.
2021-04-01 13:12:45 +01:00
Richard Hughes
a3b8515e51 trivial: Inhibit when the *device* power is below the threshold 2021-03-31 19:19:46 +01:00
Richard Hughes
74ac5ab86d trivial: Add fu_device_remove_flag() as a proper symbol
This allows us to automatically uninhibit() like we do in fu_device_add_flag().
2021-03-31 19:19:46 +01:00
Richard Hughes
b9ac0bc029 Add fu_device_inhibit() to mark the device as non-updatable
We already have two things managing the UPDATABLE_HIDDEN->UPDATABLE transition,
and we're about to add a third.

Add a 'stackable' inhibit-style API so we do not accidentally mark a device as
updatable when it should remain hidden.
2021-03-31 19:19:46 +01:00
Richard Hughes
62a8b0c288
Add fu_device_set_battery_threshold() (#3086)
This allows a device to set a custom 'check battery level is X%' value from
either the plugin or from a quirk.
2021-03-31 16:43:36 +01:00
Richard Hughes
dd61689073 Add fu_device_add_security_attrs() 2021-03-28 17:54:19 +01:00
Richard Hughes
790cb8fea2 ihex: Dectect address overflow causing the fuzz process to take along time
Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=32302
2021-03-21 20:18:34 +00:00
Richard Hughes
c8423fd685 ihex: Do not allow zero-sized data sections 2021-03-21 20:18:34 +00:00
Richard Hughes
69016bda04 ihex: Do not allow data sections after EOF 2021-03-21 20:18:34 +00:00
Richard Hughes
d4ad7cef71 trivial: Print the ASCII data in FuFirmware->to_string() 2021-03-21 20:18:34 +00:00
Richard Hughes
9c318a5a08 trivial: Fix 32 bit overflow in fu_common_get_memory_size()
Spotted by Coverity, thanks!
2021-03-20 17:32:56 +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
119d260bd2 trivial: Limit alignment to 2GB to fix a fuzzing crash
This meant defining alignment values in FuFirmware.

Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=32131
2021-03-17 11:14:46 +00:00
Richard Hughes
f4d3a365f1 fmap: Use standard FuFirmware properties 2021-03-15 12:07:30 +00:00
Richard Hughes
52441f28a4 Allow objects to deserialize to XML
This makes a lot more sense; we can parse a firmware and export the same XML
we would use in a .builder.xml file. This allows us to two two things:

 * Check we can round trip from XML -> binary -> XML

 * Using a .builder.xml file we can check ->write() is endian safe
2021-03-15 12:07:30 +00:00
Richard Hughes
408b056984 trivial: Use fu_byte_array_append_bytes() in more places 2021-03-15 09:46:02 +00:00
Richard Hughes
1ad1458caf dfu: Allow setting the DFU version
The 'version' shadows the variable of the same name in the FuFirmware subclass.
2021-03-15 09:46:02 +00:00
Richard Hughes
664226a350 spi: Move all the IFD parsing to the new 'spi' plugin
We do not want to export this unfinished API, and it's probably best just to
not compile it by default until it is actually useful.
2021-03-15 09:45:17 +00:00
Richard Hughes
1c0ed3ab1d srec: Detect overflow to avoid adding ~4GB of 0xFF padding
Fixes https://oss-fuzz.com/testcase-detail/5468114109202432
2021-03-14 09:50:39 +00:00
Richard Hughes
752c8de149 trivial: Fix up gtk-doc comment for fu_firmware_set_size() 2021-03-13 16:23:26 +00:00
Richard Hughes
d2cdfcdb95 trivial: Fix up gtk-doc for fu_firmware_parse() 2021-03-13 16:09:35 +00:00
Richard Hughes
d27bfc08fd srec: Fix a fuzzing failure when trying to build zero sized firmware 2021-03-11 15:48:02 +00:00
Richard Hughes
88969d10c4 srec: Actually include the address in the written data 2021-03-11 15:48:02 +00:00
Richard Hughes
74db340d93 trivial: Add fu_byte_array_align_up() for future usage 2021-03-11 15:47:13 +00:00
Richard Hughes
8f63180ed0 trivial: Add fu_firmware_get_size()
The idea here is to return the size of the firmware, including the header,
footer or other encapsulation. It would be expected that this value would
include the alignment if provided.
2021-03-11 10:23:26 +00:00
Richard Hughes
7c0560c37f srec: Add support for writing firmware 2021-03-10 21:39:01 -06:00
Richard Hughes
db38dca4c8 trivial: Only print the FuFirmware version once... 2021-03-10 19:21:39 +00:00
Richard Hughes
58d52ede18 trivial: Add fu_common_align_up() for future usage 2021-03-10 17:06:57 +00:00
Richard Hughes
55853e3f2d trivial: Add fu_firmware_get_alignment()
I need this from two different FuFirmware superclasses, and I think it makes
sense in the base object.
2021-03-10 16:13:39 +00:00
Richard Hughes
e9664e8448 trivial: Add fu_byte_array_append_bytes() helper 2021-03-10 14:01:11 +00:00
Richard Hughes
1981c63d58 Remove FuFirmwareImage and just use FuFirmware instead
This allows us to 'nest' firmware formats, and removes a ton of duplication.

The aim here is to deprecate FuFirmwareImage -- it's almost always acting
as a 'child' FuFirmware instance, and even copies most of the vfuncs to allow
custom types. If I'm struggling to work out what should be a FuFirmware and
what should be a FuFirmwareImage then a plugin author has no hope.

For simple payloads we were adding bytes into an image and then the image into
a firmware. This gets really messy when most plugins are treating the FuFirmware
*as* the binary firmware file.

The GBytes saved in the FuFirmware would be considered the payload with the
aim of not using FuFirmwareImage in the single-image case.
2021-03-09 21:14:12 +00:00
Richard Hughes
2d84386034 Remove unused, unsafe and deprecated functions from libfwupdplugin
Keeping *internal* API and ABI compatibility makes working with an already
complex codebase more mentally demanding than it needs to be.

Remember: plugins should be in-tree and upstream! If your out of tree plugin
stops working then it should be upstream.

The public-facing libfwupd will remain API and ABI stable for obvious reasons.
2021-03-09 15:47:56 +00:00
Richard Hughes
aaf74006da trivial: Fix up the Since tags for FuIfd
This was not included in the 1_5_X branch.
2021-03-09 15:35:29 +00:00
Richard Hughes
f2849d24cc Add missing uint64 read and write helpers 2021-03-05 19:34:54 +00:00
Richard Hughes
a76a0da7aa Add fu_device_set_battery_level()
We want to make it as easy as possible for devices to refuse to update on low
battery, as this will likely be one of the WWCB requirements.

Ideally devices will check the battery level inside the firmware, but by also
providing the battery level to fwupd we can give the user a warning *before*
the update has started and without switching the device into bootloader mode.
2021-03-05 12:27:10 +00:00
Richard Hughes
e19ebe7177 Add an Intel Flash Descriptor parser 2021-03-05 10:51:34 +00:00
Richard Hughes
32ffdb2677 Add helper API to write in a safer way 2021-03-05 09:34:18 +00:00
Richard Hughes
bf3732f994 pixart: Use the bluetooth UUID to set the logical ID
This means you can have more than one device attached to the same controller.
2021-03-03 15:36:42 +00:00
Richard Hughes
2ad99bb402 Relax fu_common_bytes_pad() to return the blob if longer than the pad size
This means the caller does not have to do this each time.
2021-03-03 14:29:29 +00:00
Richard Hughes
c81b755872 Be more strict for custom quirk keys
Rather than trying to guess typos, force each plugin to register the quirk
keys it supports, so we can show a sensible warning if required at startup on
the console.
2021-03-03 08:30:34 +00:00
Richard Hughes
7d132b728c Simplify the quirk file format
The best way of not getting something wrong is to not require it in the first
place...

All plugins now use DeviceInstanceId-style quirk matches and we can just drop
the prefix in all files. We were treating HwId=, Guid= and DeviceInstanceId= in
exactly the same way -- they're just converted to GUIDs when building the silo!
2021-03-03 08:30:34 +00:00
Mario Limonciello
3df7dd3708 libfwupdplugin: don't allow device updates while needing activation 2021-03-03 07:32:35 +00:00
Richard Hughes
6122034a19 Show a warning when parsing invalid quirk files
I just wasted more than two hours of my life over `DeviceID`.
2021-03-02 06:31:55 +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
Ricardo Cañuelo
3ed91d52a4 Support for GATT characteristic signals/notifications
NOTE that currently this is implemented for GATT characteristics only,
but can be extended to other types of objects.

Listening for property changes in a bluez characteristic requires a
long-lived connection or proxy, so this also refactors bluez device
UUIDs into a simple object that keeps the path, the proxy and the signal
id in case a callback is registered for this UUID.

An additional advantage of this is that fwupd no longer creates a
throwaway proxy object for every read and write UUID operation.
2021-02-26 18:19:06 +01:00
Richard Hughes
0b6c67a3e3 trivial: Set the GError when calling ioctl() on an un-opened device
I've not yet worked out the real bug, but it was unexpected to crash the daemon
when open failed, rather than for a critical misuse of the API.
2021-02-25 16:21:56 +00:00
Richard Hughes
14c0f7c80e trivial: Fix the debug output for FuDevice 2021-02-25 15:47:25 +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
253e6e4f17 Add a backend ID to the device
This is typically a Linux sysfs path or USB platform ID and is used in a
different way to the physical ID. The physical ID is only set for some devices
after setup() and depends on the subsystem list, and this would not be defined
for devices that do not match a plugin.

This also fixes an regression where the FuDeviceList fails to match the new
FuUdevDevice device in fu_device_list_get_by_guids_removed() and instead
silently gets 'fixed up' only if FWUPD_DEVICE_FLAG_NO_GUID_MATCHING is not set.

This also allows us to move the various backends device caches to FuBackend as
we now have a suitable ID that is for just the backend to use.
2021-02-24 16:49:42 +00:00
Richard Hughes
53de7e25a4 trivial: Only allow verify-update for plugins that support _CAN_VERIFY
If the user explicitly specifies the device-id then we do not do the front-end
filtering. If the device detaches without being able to attach then the hardware
could be left in the bootloader state.

See https://github.com/fwupd/fwupd/issues/2926#issuecomment-784234180
2021-02-23 14:48:00 +00:00
Ricardo Cañuelo
01e87896f5 Fix GVariant declarations in fu_bluez_device_write
References to opt_variant and val_variant are sunk in a subsequent
variant creation and consumed by g_dbus_proxy_call_sync. They don't need
to be freed in this context.
2021-02-23 15:35:52 +01:00
Richard Hughes
61e4ff7684 trivial: Fix up two gtk-doc typos 2021-02-23 10:21:52 +00:00
Richard Hughes
edac3d7d3f trivial: Fix spelling of BlueZ in various places 2021-02-23 10:21:52 +00:00
Richard Hughes
ed0af24406 trivial: Use fwupd_device_remove_flag() to remove a single flag 2021-02-22 22:48:56 +00:00
Richard Hughes
a76de3279b Add a test BLE plugin for a demo 2021-02-22 16:53:41 +01:00
Ricardo Cañuelo
536fb85e21 Add initial support for Bluez bluetooth devices
Bare skeleton for what will be the Bluez backend and the base bluetooth
device class.
2021-02-22 16:53:41 +01:00
Richard Hughes
ad3cfc0fea Convert MBR types to GPT GUIDs to help find the ESP
Fixes https://github.com/fwupd/fwupd/issues/2916
2021-02-22 13:00:33 +00:00
Richard Hughes
2e1245728f Call the superclass directly from subclassed devices
This allows a device subclass to call the parent method after doing an initial
action, or even deliberately not call the *generic* parent method at all.

It also simplifies the plugins; you no longer have to remember what the plugin
is deriving from and accidentally clobber the wrong superclass method.
2021-02-18 16:18:34 +00:00
Richard Hughes
86c6c2d4a3 Add fu_firmware_set_version_raw()
A few plugins need this now, so move it into the base class.
2021-02-16 15:24:29 +00:00
Ricardo Cañuelo
a92026476b Fix ioctl error checking
fu_udev_device_ioctl() interprets the return value of ioctl() as the
error cause and generates a misleading error message (permission
denied).
Fix it to use errno for error checking and reporting.
2021-02-15 16:39:00 +01:00
Richard Hughes
665c5feaca ihex: Never add more than 1 Intel hex signature
If you can create a 1Mb file with hundreds of thousands of zero-byte signatures
it takes a *long* time to parse the image.
2021-02-14 22:03:57 +00:00
Richard Hughes
ffbb1175d0 trivial: Do not consider all whitespace a valid strsafe string 2021-02-14 22:03:57 +00:00
Richard Hughes
a4e0de462c trivial: Fix AddressSanitizer heap-buffer-overflow 2021-02-14 22:03:57 +00:00
Richard Hughes
60a4b56802 srec: Fix an overflow causing an infinite loop when parsing 2021-02-12 20:51:39 +00:00
Richard Hughes
293ccbf106 fmap: Fix self test failure on PPC64 2021-02-12 10:47:34 +00:00
Richard Hughes
c3ecec575b fmap: Use memmem to find the FMAP signature
Trust glibc to optimize for the binary search, removing a oss-fuzz detected
crash with our bad pointer maths.
2021-02-11 20:27:20 +00:00
Richard Hughes
3ffc5baaad trivial: Also fuzz the CRC checking routines
At the moment these sections are all red in the coverage report.
2021-02-11 20:27:20 +00:00
Richard Hughes
220ec716ca trivial: Include firmware writing when fuzzing 2021-02-11 20:27:20 +00:00
Richard Hughes
54bc512388 Add firmware flags for presence of CRC and VID/PID 2021-02-11 20:27:20 +00:00
Richard Hughes
87a8091bed trivial: Fix a crash using fu_firmware_image_get_chunks()
Add a GError as it can return NULL for invalid circumstances. It's okay to
change the API as this symbol has not yet been in a tarball release.
2021-02-11 13:13:06 +00:00
Richard Hughes
9bb5d279db dfuse: Never add a DfuSe image with no defined chunks 2021-02-11 13:12:20 +00:00
Richard Hughes
7a23330158 dfu: Do not allow DfuSe chunk data to include the DFU footer area
Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=30813
2021-02-11 12:56:05 +00:00
Mario Limonciello
be220a4f56 trivial: fu-common: fix fallback for esp-path if udisks missing
Fixes: #2803
2021-02-10 11:58:37 -06:00
Richard Hughes
525f71f54b Merge the _udev_device() and _usb_device() vfuncs
There are now two 'backends' of device plug/unplug events, and there is about
to become three. Rather than just adding two more vfuncs for every backend type
define common ones that all providers can use.

Also fix up the existing in-tree plugins to use the new vfunc names and filter
on the correct GType.
2021-02-10 12:04:05 +00:00
Richard Hughes
9e9b73f303 Remove fu_plugin_get_usb_context()
It's unused, and only encourages plugins to do the wrong thing.
2021-02-10 12:04:05 +00:00
Richard Hughes
2e73bef923 Be more paranoid when parsing from ASCII buffers 2021-02-09 16:37:25 +00:00
Richard Hughes
6920eb1214 ihex: Fix a buffer-overread spotted by AddressSanitizer 2021-02-09 13:05:32 +00:00
Richard Hughes
abdc82b1c1 dfuse: Fix a buffer-overread spotted by AddressSanitizer 2021-02-09 13:05:13 +00:00
Richard Hughes
c123bee369 trivial: Fix a buffer-overread spotted by AddressSanitizer 2021-02-09 13:05:09 +00:00
Richard Hughes
01a30aa6de Add support for oss-fuzz 2021-02-08 09:17:03 +00:00
Richard Hughes
5294d0c7c0 trivial: Use g_memdup2() on new glib2 versions to avoid a warning 2021-02-05 09:50:02 +00:00
Richard Hughes
9b11af985f Add fu_memdup_safe()
See https://mail.gnome.org/archives/desktop-devel-list/2021-February/msg00000.html
for more details.
2021-02-04 21:01:00 +00:00
Richard Hughes
98972f4a34 libfwupdplugin: Promote DfuFirmware to FuDfuseFirmware
Port the DFU plugin to use the new objects to make it act the same as all the
other plugins.
2021-02-01 19:34:28 +00:00
Richard Hughes
77d333fab5 trivial: Allow building FuChunk objects from a XbNode 2021-01-29 18:39:53 +00:00
Richard Hughes
1d163528ab Add fu_firmware_new_from_gtypes() for future usage
This allows a plugin to define a 'set' of firmwares that it would find
acceptable, for instance either accepting DFU, DfuSe or just a plain binary.
2021-01-29 18:18:18 +00:00
Richard Hughes
9a241be490 trivial: Add fu_chunk_array_mutable_new()
This allows us to check that the plugin is writing into a mutable buffer. Also
fix up the plugins that are currently 'wrong' and use the new function for the
plugins doing the right thing.
2021-01-29 14:22:20 +00:00
Richard Hughes
451db0645b trivial: Use a more standard _to_string() for FuChunk 2021-01-29 14:22:20 +00:00
Richard Hughes
20e82cac46 Allow creating a FuChunk from a GBytes directly
This is a perfect object for when we want to just store a blob of data, address
and/or page.
2021-01-29 14:22:20 +00:00
Richard Hughes
bc8678ef13 trivial: Add three public 'setters' for FuChunk 2021-01-29 14:22:20 +00:00
Richard Hughes
318944f322 trivial: Use a more standard name for array of chunks 2021-01-29 14:22:20 +00:00
Richard Hughes
166c71df38 trivial: Check FuChunk is the correct GObject type 2021-01-29 14:22:20 +00:00
Richard Hughes
a3f8fc30ac Convert FuChunk from a C structure to an object 2021-01-28 17:41:46 +00:00
Richard Hughes
d99f86023f trivial: Add getters to FuChunk
At the moment FuChunks are sometimes mutable, and sometimes immutable, and it's
all a bit too low level for comfort.

Before we can do any kind of optimisation or verification we need plugins to
stop reading directly from the C structure. The aim here is to make FuChunk
optionally mutable without making assumptions about the memory model, and also
to be able to introspect it for the docs.
2021-01-28 16:42:54 +00:00
Richard Hughes
c75466751d trivial: Add fu_common_uri_get_scheme() for future use 2021-01-28 15:05:32 +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
9e2cce9596 trivial: Correctly print PrivateFlags when using --verbose 2021-01-27 10:20:12 +00:00
Richard Hughes
d48e841f77 trivial: Fix up two gtk-doc problems 2021-01-27 09:54:14 +00:00
Richard Hughes
8e7a0dce4a trivial: Do not use deprecated symbols internally
This means shuffling things around a little, but no logic changes.
2021-01-26 14:25:56 +00:00
Richard Hughes
e52e1b49ad trivial: Add fu_common_strjoin_array() to join arrays of strings 2021-01-26 14:25:56 +00:00
Richard Hughes
b54d69467d Run the child setup when calling the parent device
If we're creating the child device using `Children=FuFooDevice|FOO&I2C_01` in
the quirk file then there's not actually anywhere to call FuDevice->setup()
on the child.

The logical place to do it is when we setup the parent, which is a NOP if
already called for the child. We also don't need to convert the child instance
IDs as it's already being handled during the child setup.

Tested-By: Ricky Wu <ricky_wu@realtek.com>
2021-01-25 18:23:28 +08:00
Mario Limonciello
e95c1b3bd5 trivial: fwupdplugin: install deprecated header as well 2021-01-22 14:01:25 -06:00
Mario Limonciello
75835b4a0b Use FWUPD_COMPILATION define to indicate an in tree build
When this is done, include:
* Including the hash
* Including anything that is not ABI stable in plugins yet

Suggested-by: Simon McVittie <smcv@debian.org>
2021-01-22 14:01:25 -06:00
Mario Limonciello
1313f23307 trivial: correct includes for fu-plugin.h
Needed for working "out of tree" compilation.
2021-01-22 14:01:25 -06:00
Richard Hughes
4d9b2d1233 Always return a valid semver from fu_common_version_ensure_semver()
Return NULL if not valid, and handle tilde and dash where required.
2021-01-19 11:56:32 +00:00
Richard Hughes
f6751cd783 Allow using custom data to generate CHIDs
This is really useful when working out HwId quirk values for remote systems.

    fwupdtool export-hwids target.hwids
    vim target.hwids
    fwupdtool hwids target.hwids
2021-01-18 07:56:34 +00:00
Richard Hughes
667a7b41e3 Add GUIDs straight away if ->setup() has already been called
We only convert the instance IDs to GUID after setup() has been called, which
means if we add even more instance IDs to the device in functions like
fu_plugin_device_registered() they never actually get converted to the GUID
form too.
2021-01-15 15:00:22 +00:00
Richard Hughes
68175e9ba8 Use a quarter of the RAM size as the archive maximum
It is impossible to choose a static default that is appropriate for both a tiny
ARM IoT device and a giant Xeon server.

Fixes https://github.com/fwupd/fwupd/issues/2760
2021-01-14 22:36:38 +00:00
Richard Hughes
97ad335e4b Fix OOM when using large ArchiveSizeMax values
Read from the file descriptor in 32kB chunks rather than allocating a huge
buffer upfront.
2021-01-14 22:36:38 +00:00
Richard Hughes
68ab1e44fd trivial: Add fu_plugin_get_devices() for general plugin use 2021-01-14 21:13:38 +00:00
Richard Hughes
faf2afed02 trivial: Rename the device cache store with a better name 2021-01-14 21:13:38 +00:00
Richard Hughes
1a3d3b338e Make GUsb optional for fuzzing 2021-01-14 14:23:12 +00:00
Richard Hughes
5add3a75dd Make libarchive optional for fuzzing 2021-01-13 20:12:37 +00:00
Richard Hughes
dd0159dc00 trivial: Remove excess #include 2021-01-13 20:06:08 +00:00
Richard Hughes
6c48e67d6c trivial: Make name optional in fu_efivar_exists() 2021-01-13 09:14:26 +00:00
Richard Hughes
ffb6f91f95 trivial: Add fu_efivar_get_monitor() to allow inotify of efivars 2021-01-13 09:14:01 +00:00
Richard Hughes
b19e05156e trivial: Allow plugins to call fu_plugin_remove_flag() 2021-01-13 09:13:12 +00:00
Mario Limonciello
797da4fc60 trivial: adjust error for no UEFI capsules
Point people towards firwmare setup instead (Fixes: #1454)
2021-01-12 12:56:05 -06:00
Richard Hughes
7a9d9e3aa3 trivial: Fix a critical warning when updating ColorHug 2021-01-11 09:44:26 +00:00
Richard Hughes
fdb3a83a20 uefi-dbx: Ignore the legacy OVMF dummy GUID for the version
This was changed recently in https://sourceforge.net/p/edk2/code/29270/
2021-01-08 14:54:31 +00:00
Richard Hughes
21f4cb5d95 trivial: Add one more missing <string.h> 2021-01-07 18:15:31 +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
b63cfa90d6 Detect the AMD TSME encryption state for HSI 2021-01-06 16:45:33 +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
647ec9677e trivial: Do not show unprintable text when parsing invalid SREC firmware 2021-01-06 10:08:45 +00:00
Richard Hughes
b28e325339 trivial: Fix a buffer over-read when parsing corrupt SMBIOS data 2021-01-06 10:08:45 +00:00
Mario Limonciello
9a6692eb84 Notify plugins of their own registrations
The Thunderbolt plugin wasn't actually working properly for
`DelayedActivation` because Thunderbolt devices weren't actually registered.

This only affected ChromeOS.
2021-01-06 09:11:00 +00:00
Richard Hughes
5c9e9f17c5 libfwupdplugin: Export FuEfiSignatureList for plugins to use 2021-01-05 16:42:58 +00:00
Richard Hughes
cba9020eae trivial: Fix a buffer over-read when parsing invalid SMBIOS data 2021-01-05 15:59:30 +00:00
Richard Hughes
338cab9e73 libfwupdplugin: Subclass FuFirmware in FuSmbios
This allows us to get fuzzing support for free.
2021-01-05 15:59:30 +00:00
Richard Hughes
8c6bfffe2a trivial: Don't crash in the fuzzer for NULL input
The daemon already checks this, but the fuzzer just blindly flings the buffer
to each parser.
2021-01-05 15:59:30 +00:00
Richard Hughes
4bd5450c03 Fix a critical warning when parsing invalid Intel HEX firmware 2021-01-05 15:59:30 +00:00
Richard Hughes
ebb10a5c4a trivial: Fix a tiny memory leak when using fu_plugin_add_firmware_gtype() 2021-01-05 15:59:30 +00:00
Richard Hughes
364e2685ca Do not show unprintable chars from invalid firmware in the logs 2021-01-05 15:15:07 +00:00
Richard Hughes
ac927583a3 libfwupdplugin: Allow getting images by checksum value 2021-01-05 14:45:31 +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
64e9f6bd92 trivial: Fix up some NULL/FALSE confusion 2021-01-04 16:32:50 +00:00
Richard Hughes
9f71fe3dc9 Make the 'id' for fu_plugin_add_firmware_gtype() optional
We can work out the correct value automatically in all cases but one, and it's
less for the plugin author to get wrong...
2021-01-04 15:27:10 +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