mirror of
https://git.proxmox.com/git/fwupd
synced 2025-07-27 19:22:27 +00:00
fu-util/fu-tool: Drop the --force on every run
--force was there because HSI specification was incomplete. However now we have the ability for plugins to report when not enough data was gathered to make a calculation. So change it to instead only run if enough data was gathered.
This commit is contained in:
parent
26349d0f28
commit
ee4d369860
@ -2815,35 +2815,41 @@ fu_util_security(FuUtilPrivate *priv, gchar **values, GError **error)
|
|||||||
g_autoptr(GPtrArray) events_array = NULL;
|
g_autoptr(GPtrArray) events_array = NULL;
|
||||||
g_autofree gchar *str = NULL;
|
g_autofree gchar *str = NULL;
|
||||||
|
|
||||||
/* not ready yet */
|
|
||||||
if ((priv->flags & FWUPD_INSTALL_FLAG_FORCE) == 0) {
|
|
||||||
g_set_error_literal(error,
|
|
||||||
FWUPD_ERROR,
|
|
||||||
FWUPD_ERROR_NOT_SUPPORTED,
|
|
||||||
"The HSI specification is not yet complete. "
|
|
||||||
"To ignore this warning, use --force");
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!fu_util_start_engine(priv,
|
if (!fu_util_start_engine(priv,
|
||||||
FU_ENGINE_LOAD_FLAG_COLDPLUG | FU_ENGINE_LOAD_FLAG_HWINFO |
|
FU_ENGINE_LOAD_FLAG_COLDPLUG | FU_ENGINE_LOAD_FLAG_HWINFO |
|
||||||
FU_ENGINE_LOAD_FLAG_REMOTES,
|
FU_ENGINE_LOAD_FLAG_REMOTES,
|
||||||
error))
|
error))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
g_print("%s \033[1m%s\033[0m\n",
|
|
||||||
/* TRANSLATORS: this is a string like 'HSI:2-U' */
|
|
||||||
_("Host Security ID:"),
|
|
||||||
fu_engine_get_host_security_id(priv->engine));
|
|
||||||
|
|
||||||
/* show or hide different elements */
|
/* show or hide different elements */
|
||||||
if (priv->show_all) {
|
if (priv->show_all) {
|
||||||
flags |= FU_SECURITY_ATTR_TO_STRING_FLAG_SHOW_OBSOLETES;
|
flags |= FU_SECURITY_ATTR_TO_STRING_FLAG_SHOW_OBSOLETES;
|
||||||
flags |= FU_SECURITY_ATTR_TO_STRING_FLAG_SHOW_URLS;
|
flags |= FU_SECURITY_ATTR_TO_STRING_FLAG_SHOW_URLS;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* print the "why" */
|
|
||||||
attrs = fu_engine_get_host_security_attrs(priv->engine);
|
attrs = fu_engine_get_host_security_attrs(priv->engine);
|
||||||
|
items = fu_security_attrs_get_all(attrs);
|
||||||
|
for (guint j = 0; j < items->len; j++) {
|
||||||
|
FwupdSecurityAttr *attr = g_ptr_array_index(items, j);
|
||||||
|
|
||||||
|
if (!fwupd_security_attr_has_flag(attr, FWUPD_SECURITY_ATTR_FLAG_MISSING_DATA))
|
||||||
|
continue;
|
||||||
|
if (priv->flags & FWUPD_INSTALL_FLAG_FORCE)
|
||||||
|
continue;
|
||||||
|
g_set_error_literal(error,
|
||||||
|
FWUPD_ERROR,
|
||||||
|
FWUPD_ERROR_NOT_SUPPORTED,
|
||||||
|
"Not enough data was provided to make an HSI calculation. "
|
||||||
|
"To ignore this warning, use --force.");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_print("%s \033[1m%s\033[0m\n",
|
||||||
|
/* TRANSLATORS: this is a string like 'HSI:2-U' */
|
||||||
|
_("Host Security ID:"),
|
||||||
|
fu_engine_get_host_security_id(priv->engine));
|
||||||
|
|
||||||
|
/* print the "why" */
|
||||||
if (priv->as_json) {
|
if (priv->as_json) {
|
||||||
str = fu_security_attrs_to_json_string(attrs, error);
|
str = fu_security_attrs_to_json_string(attrs, error);
|
||||||
if (str == NULL)
|
if (str == NULL)
|
||||||
@ -2851,7 +2857,7 @@ fu_util_security(FuUtilPrivate *priv, gchar **values, GError **error)
|
|||||||
g_print("%s\n", str);
|
g_print("%s\n", str);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
items = fu_security_attrs_get_all(attrs);
|
|
||||||
str = fu_util_security_attrs_to_string(items, flags);
|
str = fu_util_security_attrs_to_string(items, flags);
|
||||||
g_print("%s\n", str);
|
g_print("%s\n", str);
|
||||||
|
|
||||||
|
@ -3371,21 +3371,26 @@ fu_util_security(FuUtilPrivate *priv, gchar **values, GError **error)
|
|||||||
g_autoptr(GError) error_local = NULL;
|
g_autoptr(GError) error_local = NULL;
|
||||||
g_autofree gchar *str = NULL;
|
g_autofree gchar *str = NULL;
|
||||||
|
|
||||||
/* not ready yet */
|
|
||||||
if ((priv->flags & FWUPD_INSTALL_FLAG_FORCE) == 0) {
|
|
||||||
g_set_error_literal(error,
|
|
||||||
FWUPD_ERROR,
|
|
||||||
FWUPD_ERROR_NOT_SUPPORTED,
|
|
||||||
"The HSI specification is not yet complete. "
|
|
||||||
"To ignore this warning, use --force");
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* the "why" */
|
/* the "why" */
|
||||||
attrs = fwupd_client_get_host_security_attrs(priv->client, priv->cancellable, error);
|
attrs = fwupd_client_get_host_security_attrs(priv->client, priv->cancellable, error);
|
||||||
if (attrs == NULL)
|
if (attrs == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
for (guint j = 0; j < attrs->len; j++) {
|
||||||
|
FwupdSecurityAttr *attr = g_ptr_array_index(attrs, j);
|
||||||
|
|
||||||
|
if (!fwupd_security_attr_has_flag(attr, FWUPD_SECURITY_ATTR_FLAG_MISSING_DATA))
|
||||||
|
continue;
|
||||||
|
if (priv->flags & FWUPD_INSTALL_FLAG_FORCE)
|
||||||
|
continue;
|
||||||
|
g_set_error_literal(error,
|
||||||
|
FWUPD_ERROR,
|
||||||
|
FWUPD_ERROR_NOT_SUPPORTED,
|
||||||
|
"Not enough data was provided to make an HSI calculation. "
|
||||||
|
"To ignore this warning, use --force");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
/* the "when" */
|
/* the "when" */
|
||||||
events = fwupd_client_get_host_security_events(priv->client,
|
events = fwupd_client_get_host_security_events(priv->client,
|
||||||
10,
|
10,
|
||||||
|
Loading…
Reference in New Issue
Block a user