Re: [PATCH] show s/mime keyid for successfully checked signatures
Alejandro Colomar via Mutt-dev <[email protected]> Wed, 1 Jul 2026 16:21:47 +0200
| Newsgroups | gmane.mail.mutt.devel |
|---|---|
| Message-ID | <akUhS5HTuPo9IxlX@devuan> |
--x5gwl6jqqfowdbrc Content-Type: text/plain; protected-headers=v1; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable From: Alejandro Colomar <[email protected]> To: Robert =?utf-8?Q?J=C3=A4schke?= <[email protected]> Cc: [email protected] Subject: Re: [PATCH] show s/mime keyid for successfully checked signatures Message-ID: <akUhS5HTuPo9IxlX@devuan> References: <[email protected]> MIME-Version: 1.0 In-Reply-To: <[email protected]> Hi Robert, On 2026-07-01T15:46:03+0200, Robert J=C3=A4schke via Mutt-dev wrote: > Hello, >=20 > with respect to my post "get id of key used for s/mime signature" on the > mutt-users list, I have written a brief patch to show the key id. To > reduce code duplication, I added a function mutt_align to curs_lib.c, > but I am not sure whether that's the best place to go. I hope my aged C > skills have not introduced too many errors, so feedback is very welcome. >=20 > Best regards, > Robert >=20 >=20 > -- >8 -- > --- > crypt-gpgme.c | 21 +++++++-------------- > curs_lib.c | 12 ++++++++++++ > protos.h | 1 + > 3 files changed, 20 insertions(+), 14 deletions(-) >=20 > diff --git a/crypt-gpgme.c b/crypt-gpgme.c > index ccae5503..e42be23d 100644 > --- a/crypt-gpgme.c > +++ b/crypt-gpgme.c > @@ -1619,9 +1619,8 @@ static void show_one_sig_validity(gpgme_ctx_t ctx, = int 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); > @@ -1634,18 +1633,17 @@ static void print_smime_keyinfo(const char *msg, = gpgme_signature_t sig, > 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); > + mutt_align(msg, _("aka: "), s); > } The braces from above should be removed, since now it becomes a single-line block. > state_puts(uids->uid, s); > state_puts("\n", s); > =20 > aka =3D 1; > } > + > + mutt_align(msg, _("KeyId: "), s); > + state_puts(key->fpr, s); > + state_puts("\n", s); > } > else > { > @@ -1666,12 +1664,7 @@ static void print_smime_keyinfo(const char *msg, g= pgme_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); > + mutt_align(msg, _("created: "), s); > print_time(sig->timestamp, s); > state_puts("\n", s); > } > diff --git a/curs_lib.c b/curs_lib.c > index 5c93cbb0..e6d1f7d5 100644 > --- a/curs_lib.c > +++ b/curs_lib.c > @@ -1654,3 +1654,15 @@ int mutt_strwidth(const char *s) > } > return w; > } > + > +void mutt_align(const char *msg, const char *key, STATE *s) > +{ > + int msgwid =3D mutt_strwidth(msg) - mutt_strwidth(_(key)) + 1; > + int i; > + > + if (msgwid < 0) > + msgwid =3D 0; > + for (i =3D 0; i < msgwid; i++) I suggest declaring 'int i' within the loop while doing the refactor. That's C99, but we already require C99 in mutt(1). for (int i =3D 0; i < msgwid; i++) > + state_puts(" ", s); > + state_puts(key, s); > +} I would suggest doing the refactor in a separate patch, so that the diff of the actual feature is minimal. That would make it easier to review. Have a lovely day! Alex > diff --git a/protos.h b/protos.h > index 4958aa0e..407f4859 100644 > --- a/protos.h > +++ b/protos.h > @@ -407,6 +407,7 @@ int mutt_smtp_send(const ADDRESS *, const ADDRESS *, = const ADDRESS *, > size_t mutt_wstr_trunc(const char *, size_t, size_t, size_t *); > int mutt_charlen(const char *s, int *); > int mutt_strwidth(const char *); > +void mutt_align(const char *msg, const char *key, STATE *s); > int mutt_compose_menu(SEND_CONTEXT *); > int mutt_thread_set_flag(HEADER *, int, int, int); > int mutt_user_is_recipient(HEADER *); > --=20 > 2.47.3 >=20 >=20 --=20 <https://www.alejandro-colomar.es> --x5gwl6jqqfowdbrc Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEES7Jt9u9GbmlWADAi64mZXMKQwqkFAmpFInsACgkQ64mZXMKQ wqnAEg//aEp+893CzLh0+P45Xb0QStunhRnU33a1k2nZI3tmZHgqTePlnkrAblCC TuXCHZhhNfDRnSjkAUy7ii92bteL3U43tFgBnANGILP344uWEsRgJZCYZHbtLsMp oriadhTlOe8QSxWrZ5UwQ/lWxzyAR1BL938SZG9G7VNXp36GYpJV9V++JnuIROHf wJkb9TWDu1youFGhH7e0hlGs/PtwpzYaqq1P7csw6WThK0Noj9HYIwSP4A5b6zsS dRq7Yzo1iVFUzMavWfUshNEeIcVt867I+tL3kCu2oOC2Z/RJqMjDnfJ4JiUl7Z8X VH+tbb1nn62ReQct+Vd8B8+TnDayvfBs7CVb+0Qhj9kAbQVUBPBJK8s6i2N5P4i8 G4tTRC09qRYpfoo9A08NrzfU6z/WvTSEUCqn6QtcVHJrdcsTAv1/w4j4IOpFoNTZ YpvNEYKct3eernfrL6c2R1vX24cWiRiDQEBGCJ6DdQe6bo7q6syKlYP6Xt2XLMlJ v5dlYHtWX2AeLd20lN8uqn3LF5WsWSumVoFjxFrrJLGj1/hjiBH5uTYBWU+DNZfi iwfjyVUMOHU5IU6VhX/kkTlyTF9QAvtV+XVD9cxQgLXdKZYPnUvqKAoCTCKJ166C cSc1HZUstXHmtFSWnR993ATFKvfLa8mBSw6Obufsfb7W/0r4xJ0= =R2y9 -----END PGP SIGNATURE----- --x5gwl6jqqfowdbrc--