Allow downloading files in fwupdtool

The useragent was being set as 'fwupdtool/1.8.11 fwupd/(NULL)' which the LVFS
did not like. As we're using fwupdtool without a daemon proxy just set the
fwupd version manually.

Fixes https://github.com/fwupd/fwupd/issues/5519
This commit is contained in:
Richard Hughes 2023-02-13 20:57:54 +00:00 committed by Mario Limonciello
parent 574b4c1979
commit ab2dffac5f
4 changed files with 16 additions and 1 deletions

View File

@ -321,7 +321,16 @@ fwupd_client_set_host_security_id(FwupdClient *self, const gchar *host_security_
fwupd_client_object_notify(self, "host-security-id");
}
static void
/**
* fwupd_client_set_daemon_version:
* @self: a #FwupdClient
* @daemon_version: A semantic version, e.g. "1.2.3"
*
* Sets the daemon version number.
*
* Since: 1.8.11
**/
void
fwupd_client_set_daemon_version(FwupdClient *self, const gchar *daemon_version)
{
FwupdClientPrivate *priv = GET_PRIVATE(self);
@ -5035,6 +5044,7 @@ fwupd_client_set_user_agent_for_package(FwupdClient *self,
g_return_if_fail(FWUPD_IS_CLIENT(self));
g_return_if_fail(package_name != NULL);
g_return_if_fail(package_version != NULL);
g_return_if_fail(priv->daemon_version != NULL);
/* application name and version */
g_string_append_printf(str, "%s/%s", package_name, package_version);

View File

@ -435,6 +435,8 @@ guint
fwupd_client_get_percentage(FwupdClient *self);
const gchar *
fwupd_client_get_daemon_version(FwupdClient *self);
void
fwupd_client_set_daemon_version(FwupdClient *self, const gchar *daemon_version);
const gchar *
fwupd_client_get_host_bkc(FwupdClient *self);
const gchar *

View File

@ -916,6 +916,7 @@ LIBFWUPD_1.8.11 {
fwupd_client_quit;
fwupd_client_quit_async;
fwupd_client_quit_finish;
fwupd_client_set_daemon_version;
fwupd_client_uninhibit;
fwupd_client_uninhibit_async;
fwupd_client_uninhibit_finish;

View File

@ -22,6 +22,7 @@
#include <unistd.h>
#include "fwupd-bios-setting-private.h"
#include "fwupd-client-private.h"
#include "fwupd-common-private.h"
#include "fwupd-device-private.h"
#include "fwupd-enums-private.h"
@ -3657,6 +3658,7 @@ main(int argc, char *argv[])
/* used for monitoring and downloading */
priv->client = fwupd_client_new();
fwupd_client_set_main_context(priv->client, priv->main_ctx);
fwupd_client_set_daemon_version(priv->client, PACKAGE_VERSION);
fwupd_client_set_user_agent_for_package(priv->client, "fwupdtool", PACKAGE_VERSION);
g_signal_connect(FWUPD_CLIENT(priv->client),
"notify::percentage",