Commit Graph

624 Commits

Author SHA1 Message Date
Richard Hughes
7020f49aa9 trivial: Fix a GObjectIntrospection warning by using the correct prefix 2021-08-28 06:50:50 -05:00
Richard Hughes
d8af914072 trivial: Remove some unused variables 2021-08-28 10:17:56 +01:00
Mario Limonciello
55de39c077 trivial: reformat the whole tree to match new format 2021-08-24 11:18:40 -05:00
Mario Limonciello
d3983674f4 trivial: don't use same variable definition as config.h in code
If config.h is included by a file then which one is used may end up
be confusing.  Be explicit to use the values that are declared by
libraries.
2021-08-24 11:18:40 -05:00
Mario Limonciello
7ae233b7cf Forcefully set checksums found in cabinet files to lowercase
Archives uploaded to LVFS will have checksums written by hexdigest
and be set to lowercase, but hand generated archives this may not
be true.

For maximum compatibility with the most fwupd versions they should
be written in lowercase, but in case they aren't, convert to lowercase.

Reference https://github.com/fwupd/firmware-lenovo-thinkpad/issues/145
2021-08-18 14:18:28 -05:00
Richard Hughes
6f8ab5e70c Restart the daemon if any of the the plugin config files are modified
Fixes https://github.com/fwupd/fwupd/issues/3625
2021-08-11 14:27:47 +01:00
Richard Hughes
486f793df7 Recalculate the device inhibits when the flags property changes
Fixes https://github.com/fwupd/fwupd/issues/3622
2021-08-11 10:54:38 +01:00
Richard Hughes
bc759d0584 Fix cleanup and plugin to have the correct args order
All the other vfuncs have 'plugin, device, flags' but prepare and
cleanup vfuncs being 'plugin, flags, device' order has been triggering
my OCD for the last few years.

We've just broken the symbol names, so it's the right time to fix this.
2021-08-10 09:57:49 +01:00
Mario Limonciello
37e06fff1c trivial: bump 1.6.3->1.7.0 2021-08-09 10:24:54 -05:00
Richard Hughes
09770c60f0 trivial: Fork for 1_6_X 2021-08-09 09:24:03 +01:00
Richard Hughes
f42b44e427 Remove some deprecated API 2021-08-06 19:49:53 +01:00
Richard Hughes
a5a978b3f6 Rename some confusing API
More than one person has asked about 'why call fu_plugin_update() for a
reinstall or downgrade' and I didn't have a very good answer.

The plugin API is not officially stable, and we should fix things to be
less confusing. Use the same verbs as the FuDevice vfuncs instead.
2021-08-06 19:49:53 +01:00
Ricardo Cañuelo
14d21c941c trivial: Allow handling EPROTO in plugins
Signed-off-by: Richard Hughes <richard@hughsie.com>
2021-08-05 15:46:06 +01:00
Richard Hughes
12842fdfce Fall back to the parent if the child does not have a battery level set 2021-08-04 09:29:02 +01:00
Richard Hughes
05c1f2b1f3 trivial: Fix docgen warning that crept in with FwupdRequest 2021-08-03 17:33:21 +01:00
Richard Hughes
8f19ea75d3 Sanitize the device name harder 2021-08-03 15:45:37 +01:00
Richard Hughes
4daaabe451 trivial: Do not log a scary warning for the common case 2021-07-30 18:53:30 +01:00
Richard Hughes
3b919fc38d trivial: Actually use USE_PARENT_FOR_OPEN for close as the docs say
This fixes updating the Synaptics prometheus hardware.
2021-07-30 18:53:30 +01:00
Richard Hughes
d8f9b66e0e trivial: Actually use the right USE_PARENT_FOR_OPEN flag 2021-07-30 18:53:30 +01:00
Richard Hughes
5f7e58b395 Revert "trivial: Ignore the NUL suffix to fix loading new firmware"
This reverts commit a8d73369f7.

“No matter how far you have gone on the wrong road, turn back.”
2021-07-30 13:42:41 +01:00
Richard Hughes
a8d73369f7 trivial: Ignore the NUL suffix to fix loading new firmware
The LVFS is now adding an artificial NUL to the metainfo data to work
around a possible buffer over-read on old fwupd versions. This breaks
new code that reads the XML buffer using xb_builder_source_load_bytes
as GLib then tries to parse the final NUL byte.

As `xmllint` actually ignores the trailing NUL, we should as well.
2021-07-29 20:07:22 +01:00
Richard Hughes
3747e245e5 uefi-capsule: Add support for CapsuleOnDisk
Based on a patch by Ilias Apalodimas <ilias.apalodimas@linaro.org>,
many thanks.

Fixes https://github.com/fwupd/fwupd/issues/2900
2021-07-28 17:11:39 +01:00
Richard Hughes
0efa97229a Automatically clear the update error as required
This is less fragile than patching all the callers.
2021-07-23 13:16:47 +01:00
Richard Hughes
ae48e02ac2 Do not assume the metainfo file is NUL-terminated
This was only true by accident. We'll need another fix for the LVFS to
add the missing NUL to restore compatibility for older clients.

Fixes https://github.com/fwupd/fwupd/issues/3533
2021-07-23 11:58:56 +01:00
Peter Marheine
464425fb5c SMBIOS: try reading from /sys/class/dmi if direct access fails
The raw SMBIOS tables that Linux exposes in /sys/firmware/dmi
are restricted to being readable by root only. If running as
non-root access is still permitted by fields that have been
pre-parsed by the kernel in /sys/class/dmi, most of which are
world-readable. This allows the daemon to load most HWIDs even
if running as a non-root user, as is done on Chromium OS.
2021-07-23 09:46:45 +01:00
Richard Hughes
f2fd6b0717 trivial: Do not save the self test quirk silo to disk
This also speeds up the tests as the amount of pointless i/o is reduced.

Fixes https://github.com/fwupd/fwupd/issues/3522
2021-07-22 12:51:47 +01:00
Richard Hughes
55f6fd435a Add a ->get_results() vfunc that can be used by subclasses of FuDevice 2021-07-22 12:47:54 +01:00
Mario Limonciello
798d1ed3ee trivial: update markdown for pre-commit style 2021-07-18 14:42:47 -05:00
Richard Hughes
15b668c0c6 Open the device proxy in the engine where required
The benefit of using the proxy device is that we can 'use' the proxy
device for device access, but 'report' the progress on the passed
FuDevice instance.

This means the front-end reports the device status correctly when
updating composite devices that us proxies.

The comment always said we should move it to the daemon if another
plugin started doing this, and that is now.
2021-07-17 17:20:01 +01:00
Richard Hughes
942802063e trivial: Remove the unused parent instance from the private struct
I assume at some point we forgot to remove it when converting an object
from FINAL to DERIVABLE and the anti-pattern just got copied around the
codebase...
2021-07-15 16:20:19 +01:00
Richard Hughes
a65f5759ef trivial: Fix a typo of fwupd itself 2021-07-15 09:33:25 +01:00
Richard Hughes
19abf996c7 Allow the daemon to request interactive action from the end user
The "return error and hope the client resubmits the firmware again"
pattern is clunky. There are two plugins doing this now, and about to
be one more.

This adds FwupdRequest which provides a structured way of asking the
user to perform an action, e.g. to replug the device or to press a
special key or button.

This replaces much of the UpdateMessage and UpdateImage API although
it is still used internally. Clients capable of processing the new
DeviceRequest signal should add REQUESTS to their feature flags.

Also, this allows us go back to the old meaning of _NEEDS_BOOTLOADER,
which was "needs rebooting into a bootloader mode" rather than the
slightly weird "user needs to do something and resubmit request".
2021-07-14 17:03:50 +01:00
Ivan Mikhanchuk
5e04fae8f2 Add functions to read from and write to FU_PATH_KIND_FIRMWARE_SEARCH 2021-07-13 21:57:08 +01:00
Mario Limonciello
da895169a7 Add a new path for configuring runtime firmware load path
The kernel allows configuring this, and certain plugins will use this
path to be able to load firmware in the kernel driver through runtime,
but to flash to the device.
2021-07-13 21:57:08 +01:00
Richard Hughes
89064bf410 trivial: Downgrade a warning to avoid a lot of extra code 2021-07-12 19:01:55 +01:00
Richard Hughes
b2ee236060 trivial: Show a critical warning if a device has no context 2021-07-12 19:01:55 +01:00
Richard Hughes
d938ab62e6 trivial: Add fu_device_add_guid_full() to control behaviour 2021-07-12 19:01:55 +01:00
Richard Hughes
53538685fc trivial: Add FU_DEVICE_INSTANCE_FLAG_NO_QUIRKS to avoid quirk matches 2021-07-12 19:01:55 +01:00
Richard Hughes
9c31d1fadd trivial: Set the FuContext on more devices 2021-07-12 19:01:55 +01:00
Richard Hughes
488f2e1f37 Export the EFI and IFD parsers
We'll need to use this from another plugin soon.
2021-07-12 10:33:38 +01:00
Richard Hughes
0cc06f032c Add a flag to open and close with the parent device
This is a common pattern that is used in lots of plugins, so move the
logic into common code.
2021-07-11 16:37:47 +01:00
Richard Hughes
a84b76573a trivial: Set the remove delay on the child automatically 2021-07-10 07:37:59 +01:00
Richard Hughes
3b84bb2135 trivial: Set the backend ID on children if unset
This allows children of devices that derive from FuUdevDevice to be
removed correctly.
2021-07-10 07:37:59 +01:00
Richard Hughes
f89cb3850b Add a device flag to control child removal
At the moment the device list auto-removes children when the parent is
removed. This was originally working around the bug that the child
devices had no backend ID, and thus were not matched like the parent
in fu_engine_backend_device_removed_cb() and removed automatically.

Using the workaround means that the children are potentially removed
before the parent depending on the order of the device list -- which
might be modified by replug events.

I think the old cleanup is probably an anti-pattern, and going forward
composite devices should probably define _NO_AUTO_REMOVE_CHILDREN but
we don't want to change this behaviour for plugins already expecting
the old flow, or for devices with no parent backend IDs.
2021-07-09 19:46:41 +01:00
Richard Hughes
a117b7da12 trivial: Correctly show negative device order numbers 2021-07-09 17:01:45 +01:00
Richard Hughes
48c98a5564 trivial: Don't fail tests on old GLib versions
We were silently depending on 2.61.0 by accident.
2021-07-09 16:18:25 +01:00
Richard Hughes
5343a4a083 Export the build timestamp from plugins 2021-07-08 16:31:07 +01:00
Richard Hughes
5458480356 Add a flag which inhibits children automatically
Fixes https://github.com/fwupd/fwupd/issues/3454
2021-07-07 12:50:27 +01:00
Richard Hughes
ef73701aa1 trivial: Provide FWUPD_PLUGIN_FLAG_AUTH_REQUIRED for future usage 2021-07-06 20:12:17 +01:00
Richard Hughes
121cffe7d8 trivial: Export fwupd_device_has_icon()
This is useful in self tests.
2021-07-06 16:47:50 +01:00
Richard Hughes
dfaae2e837 Move amdgpu safety check into the plugin
There are now multiple plugins using drm_dp_aux_dev interface which
may potentially be combined with an amdgpu. Prevent exercising this
interface with any plugin using DP aux unless a new enough kernel is
installed.
2021-07-04 17:49:36 +01:00
Richard Hughes
974d63851d Allow calculating the CRC-16 with the CCITT polynomial 2021-07-03 13:49:50 +01:00
Richard Hughes
7b209bb2c1 Watch for children added or removed after setup has been completed
Some devices may 'discover' child devices during poll, rather than the
more usual case of adding them as children during setup.
2021-07-02 13:27:10 +01:00
Richard Hughes
7830ed5812 trivial: Fix accidental ABI break when adding ->ready()
If adding an entry into the class function table then the padding has
to be decremented unless the SO version is incremented.

Fixes out-of-tree plugins failing to load with:

   GLib-GObject: Specified class size for type 'FuXxxDevice' is smaller
   than the parent type's 'FuDevice' class size
2021-07-02 11:51:35 +01:00
Richard Hughes
1cee26eba9 Remove the vendor string from the device name where required
This means we don't display something like 'Logitech Logitech Product'
when showing the devices on one line.

This is now required in two plugins so move it to common code. Also
support setting the properties in either order to prevent regressions
when using the device name as part of the instance ID.
2021-06-30 18:43:07 +01:00
Richard Hughes
6288886d35 trivial: Fix up an introspection tag added recently 2021-06-28 19:45:19 +01:00
Richard Hughes
c3b973a91e trivial: Prevent critical warning when the EFI variable has no data
I don't think this can happen in reality, but I hit it when mocking up
an efivar directory using FWUPD_SYSFSFWDIR with a 4 byte file.
2021-06-28 19:42:13 +01:00
Richard Hughes
69bfebc498 trivial: Set the physical ID in FuI2cDevice->probe() 2021-06-28 10:09:52 +01:00
Peter Marheine
6281467a6b Add a fu_udev_device_get_children_with_subsystem function
This works like fu_udev_device_get_siblings_with_subsystem but returns child
devices of self rather than siblings.
2021-06-28 10:09:52 +01:00
Richard Hughes
6ff0ae2bc4 redfish: Split out the SMBIOS table parsing
This makes it more robust against corrupted data, and also adds support
for fuzzing.
2021-06-25 19:55:19 +01:00
Mario Limonciello
d20a95458d libfwupdplugin: add support for firmware-attributes 2021-06-25 08:12:58 -05:00
Richard Hughes
9a2e10c639 trivial: Export the matching fu_udev_device_set_dev() 2021-06-24 14:22:08 +01:00
Richard Hughes
8ae988dda8 Allow writing multiple bytes to the I²C device 2021-06-24 14:22:08 +01:00
Richard Hughes
e2f51539b9 trivial: Add the missing fu_i2c_device_set_bus_number() function 2021-06-24 14:22:08 +01:00
Richard Hughes
f350dd49cf trivial: Fix the internal enum used for the i2c bus number 2021-06-24 14:22:08 +01:00
Richard Hughes
aaa77c6f51 Allow adding and removing custom flags on devices
The CustomFlags feature is a bit of a hack where we just join the flags
and store in the device metadata section as a string. This makes it
inefficient to check if just one flag exists as we have to split the
string to a temporary array each time.

Rather than adding to the hack by splitting, appending (if not exists)
then joining again, store the flags in the plugin privdata directly.

This allows us to support negating custom properties (e.g. ~hint) and
also allows quirks to append custom values without duplicating them on
each GUID match, e.g.

[USB\VID_17EF&PID_307F]
Plugin = customflag1
[USB\VID_17EF&PID_307F&HUB_0002]
Flags = customflag2

...would result in customflag1,customflag2 which is the same as you'd
get from an enumerated device flag doing the same thing.
2021-06-23 07:59:15 +01:00
Richard Hughes
2360aa296a Use an internal device flag rather that using a custom flag
If this is shared between plugins it needs to be specified in a shared
place.
2021-06-21 19:38:00 +01:00
Richard Hughes
fe7b0794b3 Use the parent physical ID to autoset the device parent
Of course, this only works if the parent and child both export a
FuDevice of the same physical kind, e.g. USB.
2021-06-19 16:57:35 +01:00
Richard Hughes
351989ed9e trivial: Reduce the debug verbosity when reading SREC firmware 2021-06-18 14:03:54 +01:00
Richard Hughes
a2682eeed9 Add a device flag to ignore the serial number
On some devices the serial number is junk, or not set. On some Wacom
hardware reading the serial LangID puts the device into Android mode...
2021-06-18 14:03:54 +01:00
Richard Hughes
fc3f95079e colorhug: Move the vendor specific setup out of common code
The now-defunct ColorHug devices are the only ones to support the
abandoned FW/GU descriptor specification.
2021-06-18 14:03:54 +01:00
Richard Hughes
2db68bf835 trivial: Fix setting internal flags from quirk files
This is a typo, non-negated flags shouldn't be removed.
2021-06-17 17:47:06 +01:00
Richard Hughes
9f13d8ed1e vli: Be more specific when matching the MSP430
Add a FuDevice->ready() vfunc that is run after ->setup()
This allows plugins to perform setup actions that require quirk matches
after the instance IDs have been converted. This allows us to also
remove FuVliDevice->setup() as the ordering chain has been broken.

There are two USB-3 hubs internally (with the same VID&PID), and the
MSP430 is only attached to the top-level one.

Fixes https://github.com/fwupd/fwupd/issues/3366
2021-06-17 17:09:48 +01:00
Richard Hughes
bf72d393fd Split up FuUsbDevice into ->open() and ->setup()
Before this change calling FuUsbDevice->open() opened the device, and
also unconditionally added various GUIDs and InstanceIDs which we
normally do in setup.
Then fu_device_setup() would call the FuSubclass->setup() vfunc which
would have no way of either opting out of the FuUsbDevice->setup()-like
behaviour, or controlling if the parent class ->setup is run before or
after the subclass setup.

Split up FuUsbDevice->open() into clear ->open() and ->setup() phases
and add the parent class calls where appropriate.

This means that ->setup() now behaves the same as all the other vfuncs.
2021-06-17 16:21:41 +01:00
Richard Hughes
8eb5825bdb trivial: Show the USB class code when debugging 2021-06-17 14:41:49 +01:00
Crag Wang
5a384a3f02 trivial: fix for expr check introduced in 3a48af58 2021-06-17 09:17:43 +01:00
Mario Limonciello
3a48af58c2 trivial: move kernel version check into common library code
This will be used by more than one plugin in an upcoming commit.
2021-06-16 14:54:17 -05:00
Mario Limonciello
78b78d8edd trivial: update python black style to 21.6b0 2021-06-16 06:41:46 -05:00
Mario Limonciello
800d45549c trivial: fix a codespell mistake 2021-06-16 06:41:46 -05:00
Richard Hughes
8b0031fad3 trivial: Codespell fixes 2021-06-15 21:45:15 +01:00
Sergii Dmytruk
c16602d688 Corrections for fu-efivar-freebsd.c
There were some compilation warnings (one actual error) and possibility
to use incorrect efivar library.

Signed-off-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com>
2021-06-15 17:25:16 +01:00
Richard Hughes
bda57e8c9d modem-manager: Do not convert instance IDs to GUIDs manually
This already happens during setup, there shouldn't be a need to depend
on the private header to accomplish this.
2021-06-15 09:14:39 -05:00
Richard Hughes
e64ebe8a7c trivial: Allow setting device inhibits from quirk files 2021-06-15 14:15:34 +01:00
Richard Hughes
a5a82ba519 trivial: Fix the FuDeviceInternalFlags conversion funcs 2021-06-15 10:18:24 +01:00
Richard Hughes
2dd6462c0c trivial: Export the DFU version constants into libfwupdplugin 2021-06-14 07:15:42 -05:00
Mario Limonciello
73cdf067ed trivial: fixup includes for a variety of plugins 2021-06-14 10:12:45 +01:00
Mario Limonciello
a8cfa9ee86 trivial: fix gir compilation when gusb is turned off 2021-06-14 09:26:22 +01:00
Mario Limonciello
172fd51e93 trivial: don't include gusb in pkg-config unless gusb enabled 2021-06-14 09:25:53 +01:00
Mario Limonciello
7794c03907 trivial: add missing header include for in top level libfwupdplugin 2021-06-14 09:25:12 +01:00
Mario Limonciello
be5de229e0 trivial: set header for fwupdplugin documentation 2021-06-14 09:24:58 +01:00
Richard Hughes
a02c1073f2 trivial: Fix up some of the developer docs
And add some missing content as requried.
2021-06-11 09:39:03 +01:00
Mario Limonciello
1e17457b16 Allow building the documentation with gi-docgen and gtk-doc
Until gi-docgen is declared stable support either of them.
This effectively means that hand builds and CI builds will use
gi-docgen, but distro builds use gtk-doc-tools.
2021-06-09 22:21:53 +01:00
Michał Kopeć
0f75f55c72 Obtain firmware major and minor versions from SMBIOS
Signed-off-by: Michał Kopeć <michal.kopec@3mdeb.com>
2021-06-09 15:45:10 +01:00
Michał Kopeć
d678b755d0 libfwupdplugin: Implement fu-efivar-freebsd.c
Signed-off-by: Richard Hughes <richard@hughsie.com>
2021-06-09 15:22:58 +01:00
Richard Hughes
d1717f19cd Ensure the composite ID is used when setting parent during construction
Shadow FwupdDevice::parent with FuDevice::parent so that we *also* set
the context and composite ID.
This means we can always install all components of the Lenovo docks.
2021-06-08 15:29:43 +01:00
Richard Hughes
694e774c2a uefi-capsule: Make less Linux-specific
Based on patches by Sergii Dmytruk <sergii.dmytruk@3mdeb.com>
2021-06-07 19:54:12 +01:00
Richard Hughes
4c734c797a trivial: Remove some more _WIN32 defines now we have an OS split 2021-06-07 19:54:12 +01:00
Sergii Dmytruk
080129fc43 Handle bsdisks' UDisks2 implementation on FreeBSD
There is no Manager object, so block devices must be discovered
manually.

Additionally, Type field contains FS name rather than its MBR ID in
hex form or a GPT GUID.

Signed-off-by: Richard Hughes <richard@hughsie.com>
2021-06-07 19:54:12 +01:00
Richard Hughes
d783594ea5 Make fu_common_convert_to_gpt_type() FreeBSD compatible
Based on a patch by Sergii Dmytruk <sergii.dmytruk@3mdeb.com>
2021-06-07 19:54:12 +01:00
Sergii Dmytruk
1e5aec4eb1 Correct error msg in fu_common_get_block_devices
Signed-off-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com>
2021-06-07 11:19:30 +01:00