Hi Peter & Jack: Am 29.11.18 03:07 schrieb(en) Peter Bloomfield:
Agree with you and Albrecht that we should make the info less confusing when the signature is deemed invalid.
Attached is a simple patch which hides confusing information if a signature is broken or a public key is unavailable: - “Signature validity” if the signature is bad, the public key is missing, or without signature data at all (unlikely); - “Signed on” if the signature is bad or without signature data at all Furthermore, if the signature is bad, gpg(me) returns not the full fingerprint of the subkey used, but only the end, so the string comparison has to be modified. For me, this fixes both the screen display as well as the printout for broken signatures and missing public keys; I was not able to simulate the (weird) case of missing signature data. Cheers, Albrecht. --- Patch details: - libbalsa/gmime-gpgme-signature.c: hide unavailable data if a signature is bad, the public key missing, or without signature data at all - libbalsa/libbalsa-gpgme-widgets.c: find proper subkey even if only the end of the fingerprint is given - src/balsa-mime-widget-crypto.c: remove useless debug message
diff --git a/libbalsa/gmime-gpgme-signature.c b/libbalsa/gmime-gpgme-signature.c
index 8e2d1ceff..2aec9c647 100644
--- a/libbalsa/gmime-gpgme-signature.c
+++ b/libbalsa/gmime-gpgme-signature.c
@@ -166,8 +166,12 @@ g_mime_gpgme_sigstat_to_gchar(const GMimeGpgmeSigstat *info,
g_return_val_if_fail(date_string != NULL, NULL);
msg = g_string_new(g_mime_gpgme_sigstat_protocol_name(info));
msg = g_string_append(msg, libbalsa_gpgme_sig_stat_to_gchar(info->status));
- g_string_append_printf(msg, _("\nSignature validity: %s"), libbalsa_gpgme_validity_to_gchar(info-> validity));
- append_time_t(msg, _("\nSigned on: %s"), info->sign_time, date_string);
+ if ((info->status != GPG_ERR_BAD_SIGNATURE) && (info->status != GPG_ERR_NO_DATA)) {
+ if (info->status != GPG_ERR_NO_PUBKEY) {
+ g_string_append_printf(msg, _("\nSignature validity: %s"), libbalsa_gpgme_validity_to_gchar(info-> validity));
+ }
+ append_time_t(msg, _("\nSigned on: %s"), info->sign_time, date_string);
+ }
if (info->fingerprint) {
g_string_append_printf(msg, _("\nKey fingerprint: %s"), info->fingerprint);
}
diff --git a/libbalsa/libbalsa-gpgme-widgets.c b/libbalsa/libbalsa-gpgme-widgets.c
index 58747e473..76773e709 100644
--- a/libbalsa/libbalsa-gpgme-widgets.c
+++ b/libbalsa/libbalsa-gpgme-widgets.c
@@ -165,9 +165,11 @@ libbalsa_gpgme_key(gpgme_key_t key,
GtkWidget *subkey_expander;
GtkWidget *subkey_box;
gpgme_subkey_t subkey;
+ size_t fingerprint_len = 0U; /* assignment makes gcc happy */
if (fingerprint != NULL) {
subkey_expander = gtk_expander_new(_("Subkey used"));
+ fingerprint_len = strlen(fingerprint);
} else if (subkey_capa != GPG_SUBKEY_CAP_ALL) {
gchar *capa_str;
gchar *label_str;
@@ -191,7 +193,11 @@ libbalsa_gpgme_key(gpgme_key_t key,
for (subkey = key->subkeys; subkey != NULL; subkey = subkey->next) {
if (fingerprint != NULL) {
- if (strcmp(fingerprint, subkey->fpr) == 0) {
+ size_t offs;
+
+ /* if the signature is invalid, the fingerprint only the end of the subkey's fingerprint */
+ offs = strlen(subkey->fpr) - fingerprint_len;
+ if (strcmp(fingerprint, &subkey->fpr[offs]) == 0) {
gtk_box_pack_end(GTK_BOX(subkey_box), create_subkey_widget(subkey), FALSE, FALSE, 2);
}
} else if ((((subkey_capa & GPG_SUBKEY_CAP_SIGN) != 0U) && (subkey->can_sign != 0)) ||
@@ -284,10 +290,16 @@ libbalsa_gpgme_key_to_gchar(gpgme_key_t key,
/* subkey information */
if (key->subkeys != NULL) {
gpgme_subkey_t subkey;
+ size_t fingerprint_len;
g_string_append_printf(result, "\n%s", _("Subkey used"));
+ fingerprint_len = strlen(fingerprint);
for (subkey = key->subkeys; subkey != NULL; subkey = subkey->next) {
- if (strcmp(fingerprint, subkey->fpr) == 0) {
+ size_t offs;
+
+ /* if the signature is invalid, the fingerprint only the end of the subkey's fingerprint */
+ offs = strlen(subkey->fpr) - fingerprint_len;
+ if (strcmp(fingerprint, &subkey->fpr[offs]) == 0) {
gchar *details_str;
gchar *timebuf;
diff --git a/src/balsa-mime-widget-crypto.c b/src/balsa-mime-widget-crypto.c
index 73a15dd18..4a9463a9f 100644
--- a/src/balsa-mime-widget-crypto.c
+++ b/src/balsa-mime-widget-crypto.c
@@ -342,7 +342,6 @@ show_public_key_data(GtkExpander *expander,
{
LibBalsaMessageBody *body = (LibBalsaMessageBody *) user_data;
- g_message("%s: %p %p %p", __func__, expander, body, body->sig_info);
if (body->sig_info != NULL) {
if (body->sig_info->key == NULL) {
g_mime_gpgme_sigstat_load_key(body->sig_info);
pgps8MXSzF8Qn.pgp
Description: PGP signature
_______________________________________________ balsa-list mailing list [email protected] https://mail.gnome.org/mailman/listinfo/balsa-list
