显示标签为“C”的博文。显示所有博文
显示标签为“C”的博文。显示所有博文

2008年2月17日星期日

mutt 与 gpg 数字签名邮件

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.8 (OpenBSD)

iQEcBAEBAgAGBQJHt89uAAoJEAQBqiBG05f/gjoH/jG6ZABGYnGCWXPhIYQyrQJU
pkHJlBCExxg1kYw9Ig04wfx05secy28mcSQjSEds/TTBqhh0VGC04ZGg0j8N9aBn
NWYtV+gIRDgrqtcUPyQVcTh/3lWwl+/IFVGVnsga+R8pSpnXyxgO4i/eGZXMcG5l
tU3hHp4L7G6u8I1NkB8DtQEc0SVzgWvutaxrktGKTpHhS7izmZRIUsbPdyF16Z3a
DazpAzYYMwaJk4hjNYNyeKm9T3TUfNlG/i9h6vecvQ12iBZ5n+SpOnU2yktgdoxx
3O6ESM5WFmN8Z9AZmZcQ8sWUjEyqV94fSAHYXDwcZArqwkWmWY3NEESlwg7V4d4=
=9iyr
-----END PGP SIGNATURE-----
默认的 mutt 数字签名邮件,在 gmail 中显示为附件 noname,在 live/hotmail
中显示为附件 ATT*.DAT。这个非常不直观/美观,如果能象 Enigmail 等显示为
附件 signature.asc 就好了。下面是我基于
Sertaç Ö. Yıldız <sertac.liste@gmail.com> 的补丁给出的解决方案:

http://marc.info/?l=mutt-users&m=120315252214068&w=3

$OpenBSD$
--- pgp.c.orig Wed Apr 25 04:12:16 2007
+++ pgp.c Sat Feb 16 16:15:36 2008
@@ -35,6 +35,7 @@
#include "pgp.h"
#include "mime.h"
#include "copy.h"
+#include "rfc2047.h" /* for content-description */

#include <sys/wait.h>
#include <string.h>
@@ -1104,9 +1105,13 @@ BODY *pgp_sign_message (BODY *a)
t->type = TYPEAPPLICATION;
t->subtype = safe_strdup ("pgp-signature");
t->filename = safe_strdup (sigfile);
- t->use_disp = 0;
- t->disposition = DISPINLINE;
+ t->use_disp = 1;
+ t->disposition = DISPATTACH;
t->encoding = ENC7BIT;
+ t->d_filename = safe_strdup ("signature.asc");
+ t->description = safe_strdup (_("Digital Signature"));
+ rfc2047_encode_string (&t->description);
+ mutt_set_parameter ("name", "signature.asc", &t->parameter);
t->unlink = 1; /* ok to remove this file after sending. */

return (a);


$OpenBSD$
--- crypt-gpgme.c.orig Fri Jul 27 03:43:39 2007
+++ crypt-gpgme.c Sat Feb 16 16:15:14 2008
@@ -34,6 +34,7 @@
#include "copy.h"
#include "pager.h"
#include "sort.h"
+#include "rfc2047.h" /* for content-description */

#include <sys/wait.h>
#include <string.h>
@@ -893,13 +894,19 @@ static BODY *sign_message (BODY *a, int use_smime)
t->use_disp = 1;
t->disposition = DISPATTACH;
t->d_filename = safe_strdup ("smime.p7s");
+ t->description = safe_strdup (_("Digital Signature"));
+ rfc2047_encode_string (&t->description);
}
else
{
t->subtype = safe_strdup ("pgp-signature");
- t->use_disp = 0;
- t->disposition = DISPINLINE;
+ mutt_set_parameter ("name", "signature.asc", &t->parameter);
+ t->use_disp = 1;
+ t->disposition = DISPATTACH;
t->encoding = ENC7BIT;
+ t->d_filename = safe_strdup ("signature.asc");
+ t->description = safe_strdup (_("Digital Signature"));
+ rfc2047_encode_string (&t->description);
}
t->filename = sigfile;
t->unlink = 1; /* ok to remove this file after sending. */

2007年12月16日星期日

讨厌的兼容性

kfogel 在 r28368 中引入了:

+ _("Invalid length (%" APR_UINT64_T_FMT ") "
+ "when about to read a string"), len);
从而造成 xgettext 错误:

#: ../libsvn_repos/reporter.c:168
msgid "Invalid length (%"
msgstr ""
但是又不能简单的使用“llu”来替换“APR_UINT64_T_FMT”,因为在 64bit 中不支持“llu”。所以只能使用折中方案:
--- subversion/libsvn_repos
/reporter.c (revision 28499)
+++ subversion/libsvn_repos/reporter.c (working copy)
@@ -155,6 +155,7 @@
{
apr_uint64_t len;
char *buf;
+ char *fmt;

SVN_ERR(read_number(&len, temp, pool));

@@ -164,9 +165,10 @@
string, anyone?) but let's be future-proof anyway. */
if (len + 1 < len)
{
+ fmt = apr_psprintf(pool, _("Invalid length (%%%s) when about to read "
+ "a string"), APR_UINT64_T_FMT);
return svn_error_createf(SVN_ERR_REPOS_BAD_REVISION_REPORT, NULL,
- _("Invalid length (%" APR_UINT64_T_FMT ") "
- "when about to read a string"), len);
+ fmt, len);
}

buf = apr_palloc(pool, len + 1);