Re: [PATCH] show s/mime keyid for successfully checked signatures
Robert Jäschke via Mutt-dev <[email protected]> Fri, 3 Jul 2026 08:16:48 +0200
| Newsgroups | gmane.mail.mutt.devel |
|---|---|
| Message-ID | <[email protected]> |
--M0/1vweFBfIE7ykZ Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Dear Kevin, Am 03.07.2026 schrieb Kevin J. McCarthy: > Please move the helper function back inside crypt-gpgme.c and make it a > static function there. There is no reason to put it in curs_lib.c, as I > mentioned before. Sorry, my branches got messed up and thus my patches. Below you'll find a cleaned-up version. > Otherwise this looks good. Thank you for the work. It was a good experience. Thank you for all the help. -- >8 -- Subject: [PATCH 1/2] refactored alignment of strings into function Reviewed-by: Alejandro Colomar <[email protected]> --- crypt-gpgme.c | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/crypt-gpgme.c b/crypt-gpgme.c index ccae5503..fe91f2b2 100644 --- a/crypt-gpgme.c +++ b/crypt-gpgme.c @@ -1527,6 +1527,16 @@ static int show_sig_summary(unsigned long sum, return severe; } =20 +static void align_to_msg(const char *msg, const char *key, STATE *s) +{ + int msgwid =3D mutt_strwidth(msg) - mutt_strwidth(_(key)) + 1; + + if (msgwid < 0) + msgwid =3D 0; + for (int i =3D 0; i < msgwid; i++) + state_puts(" ", s); + state_puts(key, s); +} =20 static void show_fingerprint(gpgme_key_t key, STATE *state) { @@ -1619,9 +1629,8 @@ static void show_one_sig_validity(gpgme_ctx_t ctx, in= t idx, STATE *s) static void print_smime_keyinfo(const char *msg, gpgme_signature_t sig, gpgme_key_t key, STATE *s) { - int msgwid; gpgme_user_id_t uids =3D NULL; - int i, aka =3D 0; + int aka =3D 0; =20 state_puts(msg, s); state_puts(" ", s); @@ -1633,14 +1642,7 @@ static void print_smime_keyinfo(const char *msg, gpg= me_signature_t sig, if (uids->revoked) continue; if (aka) - { - msgwid =3D mutt_strwidth(msg) - mutt_strwidth(_("aka: ")) + 1; - if (msgwid < 0) - msgwid =3D 0; - for (i =3D 0; i < msgwid; i++) - state_puts(" ", s); - state_puts(_("aka: "), s); - } + align_to_msg(msg, _("aka: "), s); state_puts(uids->uid, s); state_puts("\n", s); =20 @@ -1666,12 +1668,7 @@ static void print_smime_keyinfo(const char *msg, gpg= me_signature_t sig, "Jan 1 1970" is not the created date. */ if (sig->timestamp) { - msgwid =3D mutt_strwidth(msg) - mutt_strwidth(_("created: ")) + 1; - if (msgwid < 0) - msgwid =3D 0; - for (i =3D 0; i < msgwid; i++) - state_puts(" ", s); - state_puts(_("created: "), s); + align_to_msg(msg, _("created: "), s); print_time(sig->timestamp, s); state_puts("\n", s); } --=20 2.47.3 -- >8 -- Subject: [PATCH 2/2] show s/mime keyid for successfully checked signatures --- crypt-gpgme.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/crypt-gpgme.c b/crypt-gpgme.c index fe91f2b2..63dbc99e 100644 --- a/crypt-gpgme.c +++ b/crypt-gpgme.c @@ -1538,12 +1538,11 @@ static void align_to_msg(const char *msg, const cha= r *key, STATE *s) state_puts(key, s); } =20 -static void show_fingerprint(gpgme_key_t key, STATE *state) +static void show_fingerprint(const char *msg, gpgme_key_t key, STATE *stat= e) { const char *s; int i, is_pgp; char *buf, *p; - const char *prefix =3D _("Fingerprint: "); =20 if (!key) return; @@ -1552,9 +1551,9 @@ static void show_fingerprint(gpgme_key_t key, STATE *= state) return; is_pgp =3D (key->protocol =3D=3D GPGME_PROTOCOL_OpenPGP); =20 - buf =3D safe_malloc( strlen(prefix) + strlen(s) * 4 + 2 ); - strcpy(buf, prefix); /* __STRCPY_CHECKED__ */ - p =3D buf + strlen(buf); + align_to_msg(msg, _("Fingerprint: "), state); + buf =3D safe_malloc( strlen(s) * 4 + 2 ); + p =3D buf; if (is_pgp && strlen(s) =3D=3D 40) { /* PGP v4 style formatted. */ for (i=3D0; *s && s[1] && s[2] && s[3] && s[4]; s +=3D 4, i++) @@ -1648,6 +1647,7 @@ static void print_smime_keyinfo(const char *msg, gpgm= e_signature_t sig, =20 aka =3D 1; } + show_fingerprint(msg, key, s); } else { @@ -1765,7 +1765,6 @@ static int show_one_sig_status(gpgme_ctx_t ctx, int i= dx, STATE *s) ultimate). */ print_smime_keyinfo(_("Good signature from:"), sig, key, s); show_one_sig_validity(ctx, idx, s); - show_fingerprint(key,s); if (show_sig_summary(sum, ctx, key, idx, s, sig)) anywarn =3D 1; } --=20 2.47.3 --M0/1vweFBfIE7ykZ Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQGzBAABCgAdFiEELJ15GEuwMYKw/FK7enZp3UrcWhkFAmpHU88ACgkQenZp3Urc WhlawgwArHV5OMHuy+rf24DdIjPnwnzOpDuoS8hk9MtZtZ3Enpv7kJ9VEQ7l9OSS 6NLEhbK9CVsQn2j3MycJi9NcU1XgmMuBONQ8nw/Vd1uSGzj+nDMIFl6HoYlDs5Ml WxhMNKRvMr8FyTRRtWAx5fL5HKyvaqZNtRlXNDeud3bWDgBmOgBIh9gESFDUkXHZ ITo+lFWfM4W3jh/oLaSKw7qDG8dFGFrPy+xznUPhmMcGpNLhMCYXJxu/igGi/+gx z4GxAqpqdHJQ9JCBUObIqvHLc8dNzPO49bagni12hJ5ieojK1nLT5bHNWdebkoYt NSENtLf/kj6t9OqWAfEI+bV6CIlHKUrHzKQ5vcHyIUTTvxbZGIos3lvoIxeihTMS /Nzjwq4r/NB5bcAMeR/4ehqYT/uEP8MxEzq4J4r/3y+Iiwo6NxmUEbmRA+oGaQGM Wxa7F4oAAcTkABH+ZG3VWX6JwEmqGf/K/G3gSGylPS/pk/VlcBovZfG52lm8U+zm 7oLZ7YJ5 =ym4H -----END PGP SIGNATURE----- --M0/1vweFBfIE7ykZ--