Commit Graph

247 Commits

Author SHA1 Message Date
Richard Hughes
cc3de2efa4 Do not store the newest release as part of the FuDevice object 2017-09-15 14:12:18 +01:00
Richard Hughes
a96413a368 Add a method to return a list of upgrades for a specific device 2017-09-15 14:12:18 +01:00
Richard Hughes
97284b1ad8 Move the downgrade calculation to the daemon 2017-09-15 14:12:18 +01:00
Richard Hughes
68982c6624 Make FuDevice derive from FwupdDevice rather than FwupdResult
We're aiming for a model where devices can have multiple releases and we can
nuke FwupdResult completely.
2017-09-15 14:12:18 +01:00
Richard Hughes
a6bd5580d3 Add ModifyRemote as an easy way to enable and disable remotes like the LVFS
For example:

    $ fwupdmgr modify-remote lvfs-testing Enabled true
2017-09-07 23:02:58 +01:00
Richard Hughes
943d2c9bb5 trivial: Split out some common functionality from fu-engine.c 2017-06-21 09:04:39 +01:00
Richard Hughes
9945edbe74 Split up the daemon into the loader and an engine object
The idea here is that we move a lot of the 'meat' out of fu-main into the
engine. This also lets us simplify a lot of things and ensures the user
authentication is simple and easy to audit.
2017-06-19 13:50:38 +01:00
Richard Hughes
5475427ca9 Remove the UpdateMetadata D-Bus method as the fallback is done client-side 2017-06-19 09:58:11 +01:00
Richard Hughes
1f162e2f16 Implement the GetDetails->GetDetailsLocal fallback client side
This allows us to get rid of some more complex daemon code.
2017-06-19 09:56:43 +01:00
Richard Hughes
cda1cdf606 Also watch the metadata cache filename for changes
If something changes the cache behind our back (e.g. deleting or updating the
file) we need to reload the list of remotes so that the age is correctly shown.
2017-06-16 21:49:37 +01:00
Richard Hughes
83fb8d95f4 Do not fall back to the default release when verifying
This is never going to be valid. What we want is to try and get a new AsApp and
AsRelease from the system store, not the verification store.
2017-06-16 17:13:05 +01:00
Richard Hughes
0a87f6fb03 Store the metadata files rather than merging to one store
Now we have multiple remotes that can be enabled or changed at runtime we need
to do several things better:

* Only load components from remotes that are enabled

* Only load a component if a higher priority remote has not already added it

Rather than just appending all recieved metadata into one big XML file, save
the original metadata .xml.gz files in /var/lib/fwupd/remotes.d and only load
them in the correct priority order if the remote is known and enabled.

Remove the old /var/cache/app-info/xmls/fwupd.xml file, also noting it wasn't
really a cache file at all but actually something quite important.
2017-06-16 16:43:13 +01:00
Richard Hughes
5935ebda5a Check the remote exists and is enabled when using UpdateMetadataWithId 2017-06-16 15:40:31 +01:00
Richard Hughes
4c36970445 Move the remotes parsing from the client to the server
This allows us to load the metadata stores in a more sensible way in the future.
2017-06-16 15:31:40 +01:00
Richard Hughes
980ef147eb Move the config file parsing out to a new object
This will allow us to move the remote parsing here soon.
2017-06-16 12:46:40 +01:00
Richard Hughes
81f96797f6 trivial: Do not remove all apps in the store when loading metadata 2017-06-16 12:40:49 +01:00
Richard Hughes
8a8425f7be Do not store the verify store in the cachedir
The list of verification hashes is certainly not a cache, it's important data
that needs to be kept for a long time somewhere important.

Move it from /var/cache/app-info/xmls to /var/lib/fwupd and delete the old file
as it may have now-incorrect contents.
2017-06-16 12:40:44 +01:00
Richard Hughes
4619f9f5c1 trivial: Use the 'message' level for normal events 2017-06-14 13:55:30 +01:00
Richard Hughes
b38a4fdfd6 Fix a crash when refreshing metadata
When processing the file handles it seems g_variant_get() actually wants to
write the fd integer. This bug does not happen every time, and seems to vanish
every time under valgrind.

Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1460429
2017-06-13 15:24:06 +01:00
Richard Hughes
fd381cc96e Add the ability to restrict the firmware installation to specific vendor IDs
This allows us to fix https://github.com/hughsie/lvfs-website/issues/4
2017-06-12 20:22:25 +01:00
Richard Hughes
3d2fc1e353 Ensure that firmware provides are legal GUIDs
If they are raw device strings, e.g. 'USB\VID_046D&PID_AAAC' just fix them
in-place.
2017-06-08 14:26:40 +01:00
Richard Hughes
68cc00c7e9 Allow multiple checksums on devices and releases
Although we supported other hashes than SHA1 (which is now moderately unsafe)
we had to switch the metadata provider and daemon on some kind of flag day to
using SHA256. Since that's somewhat impractical, just allow multiple checksums
to be set on objects and just try to match whatever is given in preference
order.

This also means we can easily transition to other hash types in the future.

The removed API was never present in a tarball release, so not an API break.
2017-06-06 20:06:53 +01:00
Richard Hughes
985ac07ab7 Only decompress the firmware after the signature check
This is moderately more secure, in the event that g_zlib_decompressor_new() has
an exploitable overflow. Spotted by Sebastian Krahmer, many thanks.
2017-06-06 20:02:54 +01:00
Richard Hughes
fe461b618e trivial: Use SHA256 for the store origin
If we're using this for caching it seems a good idea to use a secure cache function.
2017-06-06 14:18:17 +01:00
Richard Hughes
6e48871bce trivial: Respect the checksum kind when calling VerifyUpdate 2017-06-05 17:48:13 +01:00
Richard Hughes
e4a100cfee Add a GetReleases() D-Bus call to return all releases for a device
This allows us to downgrade firmware in the future.
2017-06-05 17:42:57 +01:00
Richard Hughes
1642b3b95a Deprecate the old FwupdResult API
It will be removed next time we bump soname.
2017-06-05 17:41:11 +01:00
Richard Hughes
01c13d1634 trivial: Use a helper to get the sysconfig dir
This makes testing using a prefix much easier.
2017-06-05 09:10:17 +01:00
Richard Hughes
b8f8db2082 Add support for Microsoft HardwareIDs
This commit provides a new "hwids" subcommand for fwupdmgr that shows the
hardware GUIDs on the local system. It also provides API that plugins can use
to self-disable when a specific HWID does not match.

The GUIDs used in this implementation match that of ComputerHardwareIds.exe
2017-06-04 19:46:36 +01:00
Richard Hughes
f29a6eeb2c trivial: Modernize the daemon private data cleanup 2017-06-02 20:14:14 +01:00
Richard Hughes
90bcd058f0 Return the remote ID when getting updates about hardware 2017-06-02 13:19:08 +01:00
Richard Hughes
d4bdfd6883 Do not copy the origin from the new metadata file
If the system has multiple remotes enabled then simply setting the origin to
the 'last-updated' source is confusing.
2017-06-02 13:19:08 +01:00
Richard Hughes
1b50d960f2 Send the daemon the remote ID when sending updated firmware metadata
This allows us to 'tag' the components with the correct remote ID value, which
then means we can tell where the firmware information has come from when saving
a composite store. It also allows us use the correct username and password in
the future when downloading the firmware blob itself.

Keep the old D-Bus method around to preserve API for existing clients.
2017-06-02 13:19:05 +01:00
Richard Hughes
f5f400fe52 trivial: Do not fail to startup if an invalid AppStream file is installed 2017-05-15 10:52:49 +01:00
Richard Hughes
c7f61b62db trivial: Fall back to the system config file
This makes trying the daemon locally much easier.
2017-04-26 10:18:42 +01:00
Richard Hughes
05ede65e24 Add a config option to allow runtime disabling plugins by name
See https://github.com/hughsie/fwupd/issues/110
2017-04-16 09:11:39 +01:00
Richard Hughes
d1ced695ca Set the source origin when saving metadata
If this is not done the origin from the last file that was read (which might be
from Fedora, for instance) will be used. This isn't hugely important but can
give misleading and confusing unique-id's in gnome-software.
2017-04-15 12:27:26 +01:00
Richard Hughes
d6db6b4d8a trivial: Change the name of a generated file
The meson build system does not let you choose the output name of the resource.
2017-04-12 15:03:11 +01:00
Richard Hughes
4af05398af trivial: Define the plugindir in one central place 2017-04-12 14:18:15 +01:00
Richard Hughes
e643fb283f Create directories in /var/cache as required
These can be nuked at any time by users, so don't rely on the package manager
or installer to create these for us.
2017-04-12 14:09:06 +01:00
Richard Hughes
8738a9f8e4 trivial: Do not use deprecated appstream-glib API 2017-02-27 10:11:29 +00:00
Richard Hughes
afe00a91e7 trivial: Prevent a critical warning when using --timed-exit 2017-02-21 09:36:49 +00:00
Richard Hughes
f0a799eabf Only register the D-Bus service when all devices have been added
Poll each plugin, and only register the service when all the delayed coldplug
devices have been added to the device list. This prevents returning an error
when calling "fwupdmgr get-devices" for the very first time.

Resolves: https://github.com/hughsie/fwupd/issues/82
2017-01-18 08:10:32 +00:00
Richard Hughes
b21e324c23 trivial: Always call update_cleanup() even when the update action fails
In this case we can't return any failure to cleanup and just log the warning
on the console.
2017-01-11 08:29:17 +00:00
Richard Hughes
b082903c5f Add fu_plugin_set_coldplug_delay() to allow hardware to initialize if required 2017-01-10 09:27:08 +00:00
Richard Hughes
f360583f3c trivial: Reschedule a recoldplug after a small delay
This also ensures that we only re-coldplug once if multiple plugins request
the action in the same 1500ms window.
2017-01-08 10:51:57 +00:00
Richard Hughes
f028ba25ac trivial: Do not allow recoldplugging whilst in coldplug itself 2017-01-08 10:45:12 +00:00
Richard Hughes
362d6d7d7d Allow plugins to request that all plugins re-coldplug
This allows a plugin to signal the daemon that something has happened and that
all plugins should wake up connected devices, re-add them all and then put the
devices back to powersave mode. Any duplicate devices will be ignored.
2017-01-07 21:42:17 +00:00
Richard Hughes
46487c944a Add the ability to run a prepare->exec->cleanup on coldplug
The idea here is that plugins can 'wake up' hardware in prepare, and put it
back into powersaving mode when doing cleanup.
2017-01-07 21:26:36 +00:00
Richard Hughes
4852ff8521 Fix the appstream-glib version guards
Resolves: https://github.com/hughsie/fwupd/issues/78
2017-01-04 20:38:29 +00:00
Richard Hughes
7ceb318a27 Add fwupd_result_get_device_version_bootloader()
This functionality is required so that AppStream metadata can check the fwupd
version, the firmware version, bootloader version or a combination of all three.
2016-12-23 11:21:22 +00:00
Richard Hughes
404cc51be3 Allow the metadata to match a version of fwupd and the existing fw version
This allows us to have new markup specified in the MetaInfo or AppStream XML:

  <requires>
    <id compare="ge" version="0.8.1">org.freedesktop.fwupd</id>
    <firmware compare="ge" version="0.1.2"/>
  </requires>

This means that only updates that match these versions will be shown.
2016-12-21 16:16:18 +00:00
Richard Hughes
2d744f5571 trivial: Fix critical warning when policykit rules are not installed 2016-12-20 09:07:37 +00:00
Richard Hughes
29c220db9f Add VerifyUpdate to update the device checksums server-side 2016-12-15 17:09:37 +00:00
Richard Hughes
74d95ab988 trivial: Find the release when verifying and there is no version 2016-12-15 12:55:21 +00:00
Richard Hughes
4232185bec trivial: Remove some false-positive messages when using clang 2016-12-13 16:01:52 +00:00
Richard Hughes
59a9344c1e Move the UPower functionality to a plugin 2016-12-12 16:28:16 +00:00
Richard Hughes
e8fb74a341 Return the pending UEFI update when not on AC power
The user will not be notified about firmware security updates all the time they
are on battery power. It's better to handle this in the client prompting the
user to connect the AC power source.
2016-12-12 16:17:38 +00:00
Richard Hughes
7b8b202786 Add a set of vfuncs that are run before and after a device update 2016-12-12 16:15:03 +00:00
Richard Hughes
31bfba3d1b trivial: Fix an error path when getting firmware results 2016-12-12 15:14:12 +00:00
Richard Hughes
cff38bcb3a Convert the providers to plugins to simplify code and for future features
This is a large commit that removes all the providers and turns them into
plugins. I think having both providers _and_ plugins was super confusing.

Plugins are loaded at runtime so you could in theory develop a new plugin
without putting it in the fwupd source tree, although there are no installed
headers or PC files as I'm not sure it's a good idea at this stage.

This commit moves all the per-provider docs, tests, notes, debug dumps and test
data to plugin-specific directories -- these also allows the plugin author to
"own" more of the source tree so we don't enforce fu- prefixes and the style
guide everywhere.

This allows us to run the same action on all the plugins in the future, so we
could have a prepare(FuPlugin, FuDevice) and cleanup(FuPlugin, FuDevice) run
on *all* plugins, so doing an update using one plugin would allow us to work
around hardware quirks in other plugins.

If I've broken your out-of-tree provider it's trivial to port to the new API
with sed and a fixed up build file. If you need help please let me know.
2016-12-12 12:31:23 +00:00
Richard Hughes
bc93e4ab6e Make all providers and plugins share a GUsbContext
This means we don't have more that one thread just watching for the USB
hotplug events. To achieve this split up the coldplug into setup and coldplug
phases and run the enumerate just once in the daemon.
2016-12-08 19:51:55 +00:00
Richard Hughes
7419e9624a trivial: Use the correct index value when getting the local file descriptor
I assume GLib in F25 is more strict about invalid values.
2016-11-22 19:48:06 +00:00
Philip Withnall
bc339aa657 Fix redeclaration of polkit autocleanup functions
ifdef cannot be used to determine if a C symbol is defined, as it’s
evaluated by the preprocessor, before symbols are parsed. Instead, try
to detect whether polkit.h is suitably recent enough to define its own
auto-cleanup functions.

Signed-off-by: Richard Hughes <richard@hughsie.com>
2016-11-22 16:13:33 +00:00
Richard Hughes
fec2480330 trivial: Fix a critical warning on shutdown 2016-11-04 09:30:14 +00:00
Mario Limonciello
54a5a21757 Show a different error when checking for updates while on battery power (#68) 2016-10-19 14:29:53 -05:00
Mario Limonciello
3ef952fcea Verify devices support updating in mode they are called.
Providers that have both online and offline update methods don't
do verification that the device actually supports that mode.

This caused problems for Dell TPM devices where if you called
$ fwupdmgr install tpm.cab

It would attempt to use the online stub added in 1d97c8b5.
This would of course fall over requiring you to call with
$ fwupdmgr install tpm.cab --allow-offline

This fix will guarantee that the current install fallback
logic takes into account both device and provider support
for online/offline.
2016-09-20 12:34:42 -05:00
Richard Hughes
27aad5ac1f Add a fallback for older appstream-glib releases
Fixes: https://github.com/hughsie/fwupd/issues/62
2016-08-29 16:12:26 +01:00
Richard Hughes
4ced466f95 trivial: Fix two more compile warnings 2016-08-26 17:33:10 +01:00
Richard Hughes
2db526d178 Save the unique ID in the pending database
Also, generate something sensible if we're reading the status of an old task.
2016-08-25 15:07:25 +01:00
Richard Hughes
fdf46169f3 Ignore devices that do not add at least one GUID 2016-08-25 13:05:18 +01:00
Richard Hughes
644562e291 Use the correct define prefix for FwupdDeviceFlags
Also, add the compat flags so we don't break API.
2016-08-22 10:30:24 +01:00
Richard Hughes
5c066adf29 Use the SHA1 hash of the local file data as the component origin
This means we have a different cache-id for locally modified .cab files.
This allows us to update the text in the metadata without reloading the client.
2016-08-18 18:38:33 +01:00
Richard Hughes
fa782a3915 Add fwupd_result_get_unique_id()
This allows us to have a unique string that identifies the component and can be
used as a cache key.
2016-08-18 18:36:11 +01:00
Richard Hughes
060af614a5 trivial: Ensure the daemon always returns to IDLE 2016-08-17 17:46:15 +01:00
Richard Hughes
14d176499d Handle the 8Bitdo bootloader in a better way 2016-08-17 17:46:15 +01:00
Richard Hughes
876c007b1a Allow providers to export percentage completion 2016-08-17 17:46:15 +01:00
Richard Hughes
ae87438781 trivial: Don't show the current release in the fwupdmgr get-updates output 2016-08-17 17:46:15 +01:00
Richard Hughes
01b9a838b4 Show the vendor flashing instructions when installing 2016-08-16 17:59:32 +01:00
Richard Hughes
4fd38c8f1b trivial: Only show the device error when no devices are due to be updated
Showing a 'no attached hardware matched' then a large list of GUIDs isn't
super helpful.
2016-08-16 17:57:49 +01:00
Richard Hughes
0bda054f63 trivial: Show a warning when a requested plugin is not loaded 2016-08-11 15:35:30 +01:00
Richard Hughes
33a518a615 Add another compile warning and fix up any build failures 2016-07-27 16:57:36 +01:00
Richard Hughes
f192bf025a trivial: Switch to compiling with C99 by default
We're already using non-MSVC features like g_autoptr().
2016-07-22 08:41:59 +01:00
Richard Hughes
9a52c5ed2c Allow blacklisting devices by their GUID
Fixes: https://github.com/hughsie/fwupd/issues/10#issuecomment-233207616
2016-07-18 09:17:02 +01:00
Mario Limonciello
958ead697b Add Dell TPM and TB15/WD15 support via new Dell provider.
This provider will provide support for items that can be flashed
as capsules but aren't present in the ESRT table.

The MST hub and TBT NVM are not yet updatable, but GUIDs are
created to represent them when they are.
2016-07-13 12:30:25 -05:00
Richard Hughes
c8646aff32 Show a more detailed error when installing firmware on the wildcard
Based on a patch by Mario Limonciello, many thanks.
2016-07-04 13:06:17 +01:00
Richard Hughes
bd40528575 Don't make failures critical while checking versions or locked state
Based on a patch by Mario Limonciello, many thanks.
2016-07-04 13:00:54 +01:00
Richard Hughes
3ab17e63dd trivial: Refactor the update helper
No logic changes.
2016-07-04 12:37:22 +01:00
Richard Hughes
346ea88135 trivial: Move a conditional out of the way 2016-07-04 12:31:06 +01:00
Richard Hughes
ce38d94d5e trivial: Get rid of useless internal-only gtk-doc markup 2016-06-29 11:25:25 +01:00
Richard Hughes
a4a2c18ac8 Use the correct firmware blob when installing a composite device update 2016-06-29 11:08:29 +01:00
Richard Hughes
fe5cc9021c Add support for installing against multiple devices from a CAB file
Based on a set of patches from Mario Limonciello <mario_limonciello@dell.com>,
many thanks.
2016-06-29 11:08:29 +01:00
Richard Hughes
db468eef67 trivial: Explicitly tag downgrades in the helper 2016-06-29 10:11:53 +01:00
Richard Hughes
4921bd9770 Ensure the update ID is set when getting local firmware details 2016-06-27 11:17:43 +01:00
Mario Limonciello
8eaadd09d8 In get-details output, display the blob filename
This makes it easier to debug issues with CAB files with multiple
payloads
2016-06-22 15:01:09 -05:00
Mario Limonciello
c2cbd1ab6f trivial: s,cd_,fu_, in a few places in fu-main 2016-06-22 14:59:42 -05:00
Richard Hughes
7289a6b5f0 Add a GetDetailsLocal() method to eventually replace GetDetails()
This allows us to return multiple results from one file, for instance where the
firmware.cab file contains multiple metainfo.xml files.

This allows us to show all the entries in the firmware file, rather than
searching for the installed device that matches and falling back to just the
first listed item.
2016-05-29 09:57:24 +01:00
Richard Hughes
8ac07dcd1c trivial: Modularize the GetDetails call 2016-05-29 09:27:56 +01:00
Richard Hughes
c1a08c75d8 Support returning multiple GUIDs from GetDetails 2016-05-25 09:47:40 +01:00
Mario Limonciello
ff94ccde59 Enforce allowing providers to take away flash abilities
The flags for ALLOW_OFFLINE and ALLOW_ONLINE aren't currently used to
block a provider from flashing a file by hand.
2016-05-18 00:38:08 -05:00