Commit Graph

369 Commits

Author SHA1 Message Date
Richard Hughes
43053d2a13 Do not include fullstops in the --help output
Fixes https://github.com/fwupd/fwupd/issues/2487
2020-10-19 00:43:49 +01:00
Richard Hughes
1c62adec69 Get the list of unique branch names for 'switch-branch' 2020-10-15 18:05:29 +01:00
Mario Limonciello
11b71f4978 Offer to compile daemon without polkit support
Based on a patch from Daniel Campello at
https://chromium-review.googlesource.com/c/chromiumos/third_party/fwupd/+/2354521
2020-10-14 07:58:16 -05:00
Richard Hughes
7bcb8d4385 Export FwupdPlugin so we can convey enumerated system errors to the end user
For instance, we can tell the user that UEFI UpdateCapsule is disabled in the
system firmware, or that efivarfs is not mounted. This is much better than
creating "dummy" devices which are really just hacks around the problem because
no better API existed. THe dummy devices cause as many problems as they solve.

Plugins have to set FWUPD_PLUGIN_FLAG_USER_WARNING if a warning should be shown
to the user, and only one warning will be shown of each failure type.

It is expected that GUI clients like gnome-software and gnome-firmware would use
this API to notify the user the localized message for why firmware updates are
not being shown.

Fixes https://github.com/fwupd/fwupd/issues/2456
2020-10-13 15:56:49 +01:00
Richard Hughes
6450d0deb4 Add FwupdInstallFlags of _IGNORE_CHECKSUM, _IGNORE_VID_PID and _IGNORE_POWER
The FWUPD_INSTALL_FLAG_FORCE flag has really unclear semantics, and ignoring a
file CRC, checksum or model ID should only be done when using fwupdtool actually
debugging a plugin or firmware parser.

Use the existing --force flag when we want a "gentle nudge" like reuploading
previously processed reports.
2020-10-07 13:15:09 +01:00
Richard Hughes
5bbf013879 Add a --allow-branch-switch to fwupdmgr
This allows us to turn off the tests like version format differences and
checking for downgrades.
2020-10-07 13:15:09 +01:00
Mario Limonciello
e8946a74d1 fwupdtool/fwupdmgr: make return code different for get-updates with no updates
This allows other tools to depend on it when checking for updates rather than
reading the output.
2020-10-06 13:34:41 -05:00
Richard Hughes
460c4b75fe Add the concept of firmware 'branches'
This allows a device to identify with different streams, for instance a Lenovo
laptop could have a coreboot firmware or a AMI firmware. The GUIDs would be the
same, but switching firmware would only be done rarely and very carefully.

Another example would be switching the Broadcom BCM57xx nework adaptors from the
vendor nonfree firmware with a signed PXE image, to the free software reverse
engineered driver with no PXE support (and thus no signed DXE) at all.

It is expected firmware would have additional metadata something like this:

    ...
    <branch>sdcc</branch>
    <description>
      <p>
        This is an alternate firmware built by the community using only free
        software tools.
      </p>
    </description>
    <requires>
      <id compare="ge" version="1.5.0">org.freedesktop.fwupd</id>
      <client>switch-branch</client>
    </requires>
    ...

Additionally, alternate branch firmware will not be returned for clients not
setting the FWUPD_FEATURE_FLAG_SWITCH_BRANCH before the GetReleases request.
2020-09-30 18:33:00 +01:00
Daniel Campello
f8fb2dc436 Fix get-updates and activate to use GUID in addition to device-id
Also merge fu_engine_get_device and fu_engine_get_device_by_id
2020-09-30 09:38:56 +01:00
Richard Hughes
0f89a0d2f0 Use pkttyagent to request user passwords if running without GUI
This change will allow it to use pkcon over remote-shells (ssh) or
to use it witout a running GUI desktop environment in the background.

Should fix https://github.com/fwupd/fwupd/issues/2429
2020-09-29 19:21:18 +01:00
Daniel Campello
9fbd7fe65d Allow to filter get-updates on device-id
This change allows to get available updates for a given device. This is
similar to what is done for the update and activate commands.
2020-09-28 16:43:42 -05:00
Mario Limonciello
02085a0371 trivial: rework fwupdtool activate
Only use the history database to tell if activation should be run.
Instead query the connected devices to find the ones needing activation.

This should allow non-connected devices to not cause a failure (although
it might be a longer shutdown).

Also sort the devices, so that the order follows the defined order from
the daemon and they activate in the same order they install.
2020-09-14 11:28:55 -05:00
Richard Hughes
5c82b94322 Do not show HSI obsoleted attributes by default
When one result is obsoleted by another, then do not show the old result by
default.

Additionally hide the HSI URLs as this was designed more for GUI clients like
gnome-firmware than CLI tools such as fwupdmgr.
2020-09-14 09:58:46 -05:00
Richard Hughes
5976125e25 trivial: Fix two translator comment typos 2020-08-20 07:54:00 +01:00
Richard Hughes
adabe53e2b trivial: Fix some NULL/FALSE confusion when getting the HSI 2020-08-17 14:48:30 +01:00
Richard Hughes
3120683143 Allow blocking specific firmware releases by checksum
Fixes https://github.com/fwupd/fwupd/issues/2280
2020-08-10 17:14:15 +01:00
Torsten Hilbrich
9b819e634c fu-util: Allow get-updates without download remotes
If a system is configured without any downloadable remotes (e.g. with
a remote pointing to a local directory) the call of

fwupdmgr get-updates

fails by outputting "No remotes enabled." even though the call
"get-remotes" clearly shows the configured remote.

I found the following commit:

commit 991c95697e
Author: Mario Limonciello <mario.limonciello@dell.com>
Date:   Wed Jun 17 15:23:13 2020 -0500

    trivial: fu-util: correct an assertion when no remotes configured

introduced the problem. In the call chain:

fu_util_get_updates
-> fu_util_perhaps_refresh_remotes
-> fu_util_check_oldest_remote

the function fu_util_check_oldest_remote now returns FALSE if no
remote of kind FWUPD_REMOTE_KIND_DOWNLOAD is found.

The function fu_util_perhaps_refresh_remotes then returns FALSE
indicating failure even though without a downloadable remote the
concept of refreshing is not useful.

I think, we should return TRUE in this case, as no refresh is needed
and the operation can continue.

As the failure of fu_util_check_oldest_remote is ignored we also need
to pass NULL as error pointer here.

The use-case of this scenario without downloadable remote is by
distributing firmware updates through software updates where the
vendor directory with the capsule file is provided.
2020-07-22 22:06:55 -05:00
Richard Hughes
f4c55d888e libfwupd: Add fwupd_client_install_release()
This allows us to remove a lot of copy-and-paste code in GNOME Software.
2020-07-09 20:57:00 +01:00
Richard Hughes
d528571971 libfwupd: Add fwupd_client_refresh_remote()
This takes care of downloading the correct files and allows remotes to be
refreshed from other CLI and GUI tools without copying large chunks of code.

This also allows us to download the metadata without writing two temp files
to the users cache directory. Although not security sensitive, it's probably
not a good idea if we can avoid it.
2020-07-09 20:57:00 +01:00
Richard Hughes
9b6d616383 fwupd: Export fwupd_client_download_bytes() into the client library
The logic here is that we can use one central session for all client actions.

Also, set the user agent for the *runtime* version of fwupd -- it's the runtime
version we use when checking capabilities, rather than the built-against
version. This would also explain why there are so many very obsolete versions
of fwupd being recorded on the LVFS...
2020-07-08 19:00:42 +01:00
Mario Limonciello
eb7be16bf0 fu-util/fu-tool: Group devices in get-updates/update calls
Fixes: #1840
2020-07-03 11:58:34 -05:00
Richard Hughes
df89cd566e Allow firmware to require specific features from front-end clients
At the moment we just blindly assume the capabilities of the front-end client
when installing firmware. We can somewhat work around by requiring a new enough
fwupd daemon version, but the client software may be older or just incomplete.

This would allow, for instance, the firmware to specify that it requries the
client to be able to show a detach image. This would not be set by a command
line tool using FwupdClient, but would be set by a GUI client that is capable
of downloading a URL and showing a PNG image.

Clients that do not register features are assumed to be dumb.
2020-06-27 15:43:57 +01:00
Mario Limonciello
a11eab61e1 trivial: fu-util: show a better error for non-responsive daemon
See #2212 for more context.
2020-06-24 08:19:15 -05:00
Mario Limonciello
1b8047be1d trivial: fu-util: correct an assertion when no remotes configured
```
(fwupdmgr:185983): FuMain-CRITICAL **: 15:20:57.044: fu_util_time_to_str: assertion 'tmp != 0' failed
```
2020-06-17 15:49:39 -05:00
Richard Hughes
6d9ae625ed trivial: Move the report success report to common code
This would allow us to use it from fwupdagent in the future.
2020-06-16 15:49:28 +01:00
Richard Hughes
4837ab5a22 trivial: Simplify marking devices as reported 2020-06-16 15:49:28 +01:00
Richard Hughes
589270a7c4 trivial: Simplify some reporting code
This is not a fast path, so make getting the FwupdRemote simpler.
2020-06-16 15:49:28 +01:00
Richard Hughes
9bc9debd98 Allow uploading security attributes to the LVFS
We sign the data with the client cert to allow users with LVFS accounts to
publish 'official' HSI ratings.
2020-05-21 11:48:09 +01:00
Richard Hughes
196c6c69db Add support for the Host Security ID
The HSI specification assigns a simple text ID to the current state of firmware
security. As new vulnerabilities are found, and as protection measures are
updated, new requirements will be added to the required firmware behaviours for
each HSI value.

The HSI specification is currently incomplete and in active development, and
so the --force flag is required in all command line tools. The current ID value
will probably change on a given platform so please do not start using the result
for any kind of compliance requirements.
2020-05-11 22:11:49 +01:00
Mario Limonciello
890963108e Clarify invalid arguments display (Fixes: #2045)
Avoid a wall of text and instead direct people to `--help` output.
Also sync up this section of code between `fu-util.c` and `fu-tool.c`
2020-04-30 14:20:36 -05:00
Richard Hughes
9c09e2c9bc trivial: Fix some recent NULL/FALSE confusion 2020-04-22 10:53:59 +01:00
Mario Limonciello
c6009f59fe trivial: fu-util/fu-tool: check for '-' in arguments
Make sure if something doesn't look like a duck that it's not a duck.
2020-04-21 09:04:50 +01:00
Mario Limonciello
bc3c241f91 trivial: fu-util: fix using a GUID for update command 2020-04-21 09:04:50 +01:00
Richard Hughes
3aaf53c6f0 Allow specifying the device on the command line by GUID
The GUID is the only stable identifier, and allowing using the GUID makes it
much easier to test specific devices.
2020-04-20 18:45:45 +01:00
Mario Limonciello
75b3904c2e trivial: show update message on downgrades too 2020-04-09 16:55:17 +01:00
Richard Hughes
ee562b5164 Ignore indirect devices that replug during the composite firmware update
This fixes the confusing case where installing the CCGX firmware on a dock
would reboot the hub, leading to this output:

Installing on USB-I2C Bridge…                                    ]
Installing on USB2.0 Hub…[************************************** ]
Installing on USB3.1 Hub…[************************************** ]
Installing on USB2.0 Hub…[************************************** ]
Installing on USB3.1 Hub…[************************************** ]
Installing on ThinkPad USB-C Dock Gen2 USB Audio…*************** ]
Installing on USB-I2C Bridge…*********************************** ]
Restarting device…       [***************************************]

With the patch, this is now:

Installing on USB-I2C Bridge…                                    ]
Restarting device…       [***************************************]
2020-04-07 15:04:01 +01:00
Richard Hughes
58f85d26ea trivial: Recognize .jcat files as a signature to fix CLI progress message 2020-04-03 16:29:56 +01:00
Richard Hughes
a1de20665a Load the signature to get the aliased CDN-safe version of the metadata
Switch to downloading the signature first, which we can then load to get the
suffixed build-specific URL of the actual metadata file. You need to have
libjcat 0.1.1 installed and fwupd built against the new version for this to
work.

Fixes https://github.com/fwupd/fwupd/issues/391
2020-04-03 16:27:04 +01:00
Richard Hughes
fe4b3eadaa trivial: Use the same source version string between daemon and client
This fixes the common problem encountered when developing plugins:

    ./src/fwupdmgr get-devices
    Unsupported daemon version 1.4.0, client version is 1.4.0-179-gcf8095d5
2020-03-30 13:58:25 +01:00
Richard Hughes
09a4f7559c Add the optional device-id to the update --help output
Fixes https://github.com/fwupd/fwupd/issues/1870
2020-03-17 13:03:16 +00:00
Mario Limonciello
2a0c066a2f trivial: remove unused variables 2020-03-05 09:40:05 -06:00
Mario Limonciello
dc0608dea4 For the get-details command make sure to always show devices
This was likely an existing bug; but if running `get-details` on a CAB
for a device not in your system it would be filtered by default device
filters.
2020-02-26 08:47:43 -06:00
Richard Hughes
9a68084dbc Always check for PLAIN when doing vercmp() operations
In 1de7cc we checked the version format when checking for update, but there are
many other places that are doing verfmt-insensitive comparisons. For instance,
the predicates in <requires> all fail if the device version format is plain.
his breaks updating some NVMe drives where the `ne` requirements are not
semantic versions.

To avoid trying to catch all the bugs in different places, and in case we have
a future verfmt that should be treated another way, refactor this out in to a
common function and deprecate the old function.
2020-02-20 15:49:27 +00:00
Mario Limonciello
27164b70b6 Discard the reason upgrades aren't available (Fixes: #1678)
Also fixes: #1792
2020-02-20 09:40:52 -06:00
Mario Limonciello
5c7e17276c fu-util: fix a logic error in report uploading introduced in e076d48afb
Fixes: #1770
2020-02-13 10:47:56 -08:00
Richard Hughes
e076d48afb trivial: Fix some invalid error handling in fwupdmgr
If somehow we forget to add a case section, return with an error as the code
suggests, rather than always returning TRUE. Found with Coverity.
2020-02-07 15:16:39 +00:00
Mario Limonciello
d81ea2e3fc Move MOTD population into the daemon
This allows it to be refreshed anytime the daemon updates rather
than once a day by a systemd job.

As part of this change, remove the logging from `fwupdmgr` which
was only used for motd purposes.
2020-01-16 10:33:43 -06:00
Mario Limonciello
eb442ea9a5 fu-util: Discourage metadata refreshes more than once per day
As the motd timer may be activated to run on a system, ensure that
it hasn't actually stepped on the user running an update manually
or another client such as gnome-software refreshing metadtata.

Users can override this behavior with `--force`.
2020-01-16 10:33:43 -06:00
Mario Limonciello
234c864ea4 trivial: fu-util/fu-tool: Unify usage of - and _ in help output (Fixes: #1662) 2020-01-08 20:07:29 -06:00
Mario Limonciello
7e4949c4f8 Clarify error messages when no upgrades available 2019-12-09 10:45:49 -06:00