Commit Graph

276 Commits

Author SHA1 Message Date
Richard Hughes
ebae396d0a udev: Do not add devices after a small delay
Now devices can have multiple GUIDs and do not share platform IDs there is
really no point waiting to add the device.

This allows us to remove a whole lot of code for this now-unused functionality.
2018-09-09 16:24:30 +01:00
Mario Limonciello
e3016602f8 Include serial number in daemon device output when trusted
This moves the storing of the serial number into the daemon and
when the calling process is UID 0 includes it in device output
2018-09-06 13:34:28 -05:00
Richard Hughes
02c90d8a03 Remove the unused Emacs indenting headers from all source files
Fixes https://github.com/hughsie/fwupd/issues/636
2018-08-09 12:48:04 +01:00
Richard Hughes
dbd8c76eb8 Run a plugin vfunc before and after all the composite devices are updated
Now we can update multiple devices (in multiple plugins) using one firmware
archive we need a way to cleanup after all the plugins have been run.

Fixes https://github.com/hughsie/fwupd/issues/561
2018-06-18 16:06:15 +01:00
Mario Limonciello
51308e648a Adjust all licensing to LGPL 2.1+ (Closes: #526) 2018-05-29 09:03:13 +01:00
Richard Hughes
e82eef3190 trivial: Move the install error heuristic into common code 2018-05-21 21:23:45 +01:00
Richard Hughes
c02cb83d20 trivial: Split out fu_install_task_compare() for future use 2018-05-21 21:23:45 +01:00
Richard Hughes
1d1f5cf098 trivial: Refactor the requirement tests to use a FuInstallTask 2018-05-21 21:23:45 +01:00
Richard Hughes
5b5f655e0b trivial: Allow the daemon to run without any idle sources
We need this if we want to run plugins without a daemon process.
2018-05-18 10:22:39 +01:00
Richard Hughes
76e0f94c86 Allow the client tools to avoid writing the history database 2018-05-14 18:54:15 +01:00
Richard Hughes
9f86ade6bf Allow plugins to define the order composite firmwares are installed 2018-05-12 20:46:02 +01:00
Richard Hughes
4ad41f027c Allow installing more than one firmware using 'fwupdmgr install'
When using failed to open firmware.cab we pass in a device ID of '*' which
tells the daemon to update anything that matches. The current implementation
will fail in two ways:

* If duplicate hardware is installed (for instance two Unifying receivers) then
  only the first matching device will be updated.

* If the firmware archive contains two different images then we only try and
  upgrade the first device that matches. This means we're unable to update
  composite devices using one firmware file.

To fix both issues, carefully build a list of tasks that can be processed using
the given firmware and installed devices, request authentication using all the
different action IDs, then upgrade all the devices one-at-a-time.

Based on a patch by Mario Limonciello <mario.limonciello@dell.com>, many thanks.
2018-05-10 09:26:07 +01:00
Mario Limonciello
6b9f07cbf7 trivial: fix a null pointer dereference
../src/fu-main.c: In function ‘fu_main_daemon_method_call’:
../src/fu-main.c:667:47: error: null pointer dereference [-Werror=null-dereference]
   polkit_authority_check_authorization (helper->priv->authority, subject,
                                         ~~~~~~^~~~~~
../src/fu-main.c:698:47: error: null pointer dereference [-Werror=null-dereference]
   polkit_authority_check_authorization (helper->priv->authority, subject,
                                         ~~~~~~^~~~~~
2018-04-17 10:10:43 +01:00
Mario Limonciello
a98df55d82 Disable -Wunused-function on clang builds (Closes #467)
GLib creates two static inline functions for paramaters that may
not be used that set off warnings in clang but not gcc.

Ignore these on clang builds everywhere that
G_DEFINE_AUTOPTR_CLEANUP_FUNC is used.
2018-04-17 10:10:43 +01:00
Richard Hughes
747b9eeef2 trivial: Fix a small memory leak if parsing the .xml file fails 2018-04-16 16:47:07 +01:00
Richard Hughes
6b22295cf0 Add a D-Bus method to modify a historical device
This allows us to set specific flags on the device stored in the database.
2018-01-11 10:20:48 +00:00
Richard Hughes
476363ac19 Add a D-Bus method to get the history information 2018-01-11 10:08:58 +00:00
Richard Hughes
c7bbbc246b Allow specifying the maximum archive size in the daemon config 2018-01-03 07:38:27 +00:00
Richard Hughes
f3d46c6b03 trivial: Include the remote name if it failed to be updated 2017-11-28 14:14:39 +00:00
Richard Hughes
b6f79556f1 Use a SHA1 hash for the internal DeviceID
It's actually less scary to see a SHA1 hash than it is to see a path like
/sys/devices/pci0000:00/0000:00:1d.0/usb1/1-1/1-1.2. It's also way easier to
copy and paste into the various fwupdmgr command that require a device ID and
also means we can match a partial prefix much like git allows.

If we also move to a model where plugins can be changed during different stages
of the update (e.g. during detach) then the device might change connection type
and then the sysfs path not only becomes difficult to paste, but incorrect.

Session software doesn't care about the format of the device ID (it is supposed
to be an implementation detail) and so there's no API or ABI break here. A few
plugins also needed to be ported, but nothing too worrying.
2017-11-16 07:18:36 +00:00
Richard Hughes
49fafec020 Set environment variables to allow easy per-plugin debugging
This allows end-users testing a specific plugin to start fwupd with an extra
command line parameter, e.g. `--plugin-verbose=unifying` to output a lot of
debugging information to the console for that specific plugin.

This replaces a lot of ad-hoc environment variables with different naming
conventions.
2017-11-14 14:22:02 +00:00
Richard Hughes
87f8a4a284 Add a waiting-for-auth daemon state
Using IDLE for this isn't right as we're basically blocked on the user.
2017-10-02 14:50:26 +01:00
Richard Hughes
642ec13754 trivial: Remove GetUpdates as it is no longer used 2017-09-28 09:23:52 +01:00
Richard Hughes
e0bd53e439 trivial: Use standard _to_variant() and _from_variant() forms 2017-09-28 09:23:52 +01:00
Richard Hughes
9e1b14067c trivial: Always use a a{sv} type to return value
Mixing sa{sv} and a{sv} made everything very confusing...
2017-09-28 09:23:52 +01:00
Richard Hughes
80893e29fe trivial: Remove FwupdResult from libfwupd 2017-09-28 09:23:52 +01:00
Richard Hughes
ba73c76d69 trivial: Remove the deprecated fwupd_client_update_metadata()
Also, rename fwupd_client_update_metadata_with_id() to it's now-removed counterpart.
2017-09-28 09:23:52 +01:00
Richard Hughes
07f963a52d trivial: Remove the deprecated fwupd_client_get_details()
Also, rename fwupd_client_get_details_local() to it's now-removed counterpart.
2017-09-28 09:23:52 +01:00
Richard Hughes
93b1576bef trivial: Add helpers that can be used for returning local files
This also allows us to drop the use of FwupdResult in the daemon.
2017-09-15 14:12:18 +01:00
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