mirror of
https://github.com/ostreedev/ostree.git
synced 2024-12-22 17:35:55 +03:00
gpg: Add ostree_gpg_verify_result_describe_variant()
Needed for printing signature details in places where OstreeGpgVerifyResult cannot go.
This commit is contained in:
parent
4a3c2a25b7
commit
83aac088d1
@ -176,6 +176,7 @@ ostree_gpg_verify_result_get
|
|||||||
ostree_gpg_verify_result_get_all
|
ostree_gpg_verify_result_get_all
|
||||||
OstreeGpgSignatureFormatFlags
|
OstreeGpgSignatureFormatFlags
|
||||||
ostree_gpg_verify_result_describe
|
ostree_gpg_verify_result_describe
|
||||||
|
ostree_gpg_verify_result_describe_variant
|
||||||
<SUBSECTION Standard>
|
<SUBSECTION Standard>
|
||||||
OSTREE_GPG_VERIFY_RESULT
|
OSTREE_GPG_VERIFY_RESULT
|
||||||
OSTREE_IS_GPG_VERIFY_RESULT
|
OSTREE_IS_GPG_VERIFY_RESULT
|
||||||
|
@ -480,11 +480,40 @@ ostree_gpg_verify_result_describe (OstreeGpgVerifyResult *result,
|
|||||||
OstreeGpgSignatureFormatFlags flags)
|
OstreeGpgSignatureFormatFlags flags)
|
||||||
{
|
{
|
||||||
g_autoptr(GVariant) variant = NULL;
|
g_autoptr(GVariant) variant = NULL;
|
||||||
|
|
||||||
|
g_return_if_fail (OSTREE_IS_GPG_VERIFY_RESULT (result));
|
||||||
|
|
||||||
|
variant = ostree_gpg_verify_result_get_all (result, signature_index);
|
||||||
|
|
||||||
|
ostree_gpg_verify_result_describe_variant (variant, output_buffer, line_prefix, flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ostree_gpg_verify_result_describe_variant:
|
||||||
|
* @variant: a #GVariant from ostree_gpg_verify_result_get_all()
|
||||||
|
* @output_buffer: a #GString to hold the description
|
||||||
|
* @line_prefix: (allow-none): optional line prefix string
|
||||||
|
* @flags: flags to adjust the description format
|
||||||
|
*
|
||||||
|
* Similar to ostree_gpg_verify_result_describe() but takes a #GVariant of
|
||||||
|
* all attributes for a GPG signature instead of an #OstreeGpgVerifyResult
|
||||||
|
* and signature index.
|
||||||
|
*
|
||||||
|
* The @variant <emphasis>MUST</emphasis> have been created by
|
||||||
|
* ostree_gpg_verify_result_get_all().
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
ostree_gpg_verify_result_describe_variant (GVariant *variant,
|
||||||
|
GString *output_buffer,
|
||||||
|
const gchar *line_prefix,
|
||||||
|
OstreeGpgSignatureFormatFlags flags)
|
||||||
|
{
|
||||||
g_autoptr(GDateTime) date_time_utc = NULL;
|
g_autoptr(GDateTime) date_time_utc = NULL;
|
||||||
g_autoptr(GDateTime) date_time_local = NULL;
|
g_autoptr(GDateTime) date_time_local = NULL;
|
||||||
g_autofree char *formatted_date_time = NULL;
|
g_autofree char *formatted_date_time = NULL;
|
||||||
gint64 timestamp;
|
gint64 timestamp;
|
||||||
gint64 exp_timestamp;
|
gint64 exp_timestamp;
|
||||||
|
const char *type_string;
|
||||||
const char *fingerprint;
|
const char *fingerprint;
|
||||||
const char *pubkey_algo;
|
const char *pubkey_algo;
|
||||||
const char *user_name;
|
const char *user_name;
|
||||||
@ -495,16 +524,18 @@ ostree_gpg_verify_result_describe (OstreeGpgVerifyResult *result,
|
|||||||
gboolean key_missing;
|
gboolean key_missing;
|
||||||
gsize len;
|
gsize len;
|
||||||
|
|
||||||
g_return_if_fail (OSTREE_IS_GPG_VERIFY_RESULT (result));
|
g_return_if_fail (variant != NULL);
|
||||||
g_return_if_fail (output_buffer != NULL);
|
g_return_if_fail (output_buffer != NULL);
|
||||||
|
|
||||||
|
/* Verify the variant's type string. This code is
|
||||||
|
* not prepared to handle just any random GVariant. */
|
||||||
|
type_string = g_variant_get_type_string (variant);
|
||||||
|
g_return_if_fail (strcmp (type_string, "(bbbbbsxxssss)") == 0);
|
||||||
|
|
||||||
/* The default format roughly mimics the verify output generated by
|
/* The default format roughly mimics the verify output generated by
|
||||||
* check_sig_and_print() in gnupg/g10/mainproc.c, though obviously
|
* check_sig_and_print() in gnupg/g10/mainproc.c, though obviously
|
||||||
* greatly simplified. */
|
* greatly simplified. */
|
||||||
|
|
||||||
variant = ostree_gpg_verify_result_get_all (result, signature_index);
|
|
||||||
g_return_if_fail (variant != NULL);
|
|
||||||
|
|
||||||
g_variant_get_child (variant, OSTREE_GPG_SIGNATURE_ATTR_VALID,
|
g_variant_get_child (variant, OSTREE_GPG_SIGNATURE_ATTR_VALID,
|
||||||
"b", &valid);
|
"b", &valid);
|
||||||
g_variant_get_child (variant, OSTREE_GPG_SIGNATURE_ATTR_SIG_EXPIRED,
|
g_variant_get_child (variant, OSTREE_GPG_SIGNATURE_ATTR_SIG_EXPIRED,
|
||||||
|
@ -119,4 +119,9 @@ void ostree_gpg_verify_result_describe (OstreeGpgVerifyResult *result,
|
|||||||
const gchar *line_prefix,
|
const gchar *line_prefix,
|
||||||
OstreeGpgSignatureFormatFlags flags);
|
OstreeGpgSignatureFormatFlags flags);
|
||||||
|
|
||||||
|
void ostree_gpg_verify_result_describe_variant (GVariant *variant,
|
||||||
|
GString *output_buffer,
|
||||||
|
const gchar *line_prefix,
|
||||||
|
OstreeGpgSignatureFormatFlags flags);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
Loading…
Reference in New Issue
Block a user