aboutsummaryrefslogtreecommitdiffstats
path: root/mail/mail-crypto.c
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@helixcode.com>2001-01-02 07:19:54 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2001-01-02 07:19:54 +0800
commit161d88eee643a9aa9c5d6aa52cce7d4e4d894c72 (patch)
tree3d142a0cdf04ed1c3cee0806f24669fad8222ba9 /mail/mail-crypto.c
parentf561a84cdea45210b991faeddf908d7529d1592b (diff)
downloadgsoc2013-evolution-161d88eee643a9aa9c5d6aa52cce7d4e4d894c72.tar
gsoc2013-evolution-161d88eee643a9aa9c5d6aa52cce7d4e4d894c72.tar.gz
gsoc2013-evolution-161d88eee643a9aa9c5d6aa52cce7d4e4d894c72.tar.bz2
gsoc2013-evolution-161d88eee643a9aa9c5d6aa52cce7d4e4d894c72.tar.lz
gsoc2013-evolution-161d88eee643a9aa9c5d6aa52cce7d4e4d894c72.tar.xz
gsoc2013-evolution-161d88eee643a9aa9c5d6aa52cce7d4e4d894c72.tar.zst
gsoc2013-evolution-161d88eee643a9aa9c5d6aa52cce7d4e4d894c72.zip
Implemented.
2000-12-26 Jeffrey Stedfast <fejj@helixcode.com> * mail-crypto.c (mail_crypto_openpgp_verify): Implemented. 2000-12-23 Jeffrey Stedfast <fejj@helixcode.com> * mail-ops.c (mail_do_setup_trash): New function similar to mail_do_setup_folder() except that this creates the Trash VFolder (special-case). 2000-12-21 Jeffrey Stedfast <fejj@helixcode.com> * mail-ops.c (do_send_mail): Don't free info inside the last if-statement, if sent_folder doesn't exist we'll have a memory leak. Instead free it afterward. svn path=/trunk/; revision=7205
Diffstat (limited to 'mail/mail-crypto.c')
-rw-r--r--mail/mail-crypto.c89
1 files changed, 59 insertions, 30 deletions
diff --git a/mail/mail-crypto.c b/mail/mail-crypto.c
index dd2ee1fe45..95042da6b0 100644
--- a/mail/mail-crypto.c
+++ b/mail/mail-crypto.c
@@ -898,6 +898,25 @@ mail_crypto_openpgp_sign (const char *in, int inlen, const char *userid,
return cyphertext;
}
+static char *
+swrite (const char *data, int len)
+{
+ char *template;
+ int fd;
+
+ template = g_strdup ("/tmp/mail-crypto-XXXXXX");
+ fd = mkstemp (template);
+ if (fd == -1) {
+ g_free (template);
+ return NULL;
+ }
+
+ write (fd, data, len);
+ close (fd);
+
+ return template;
+}
+
gboolean
mail_crypto_openpgp_verify (const char *in, int inlen, const char *sigin, int siglen, CamelException *ex)
{
@@ -907,7 +926,7 @@ mail_crypto_openpgp_verify (const char *in, int inlen, const char *sigin, int si
char *path;
int passwd_fds[2];
char passwd_fd[32];
- char *tmp = "/tmp/mail-crypto-XXXXXX";
+ char *sigfile;
int retval, i, clearlen;
gboolean valid = TRUE;
@@ -925,52 +944,56 @@ mail_crypto_openpgp_verify (const char *in, int inlen, const char *sigin, int si
return FALSE;
}
- i = 0;
-#if defined(GPG_PATH)
- path = GPG_PATH;
-
- argv[i++] = "gpg";
-
- argv[i++] = "--verify";
-
if (sigin != NULL && siglen) {
/* We are going to verify a detached signature so save
- the signature to a temp file and write the data to
- verify to stdin */
- int fd;
-
- fd = mkstemp (tmp);
- if (fd == -1) {
+ the signature to a temp file. */
+ sigfile = swrite (sigin, siglen);
+ if (!sigfile) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("Couldn't create temp file: %s"),
g_strerror (errno));
return FALSE;
}
-
- write (fd, sigin, siglen);
- close (fd);
-
- argv[i++] = tmp;
- argv[i++] = "-";
- } else {
- /* We are going to verify using stdin */
- argv[i++] = "-";
}
- argv[i++] = "--verbose";
- argv[i++] = "--yes";
- argv[i++] = "--batch";
+ i = 0;
+#if defined(GPG_PATH)
+ path = GPG_PATH;
- argv[i++] = "--output";
- argv[i++] = "-"; /* output to stdout */
+ argv[i++] = "gpg";
+
+ argv[i++] = "--verify";
+
+ if (sigin != NULL && siglen)
+ argv[i++] = sigfile;
+
+ /* We are going to verify using stdin */
+ argv[i++] = "-";
+
+ /*argv[i++] = "--verbose";
+ argv[i++] = "--yes";
+ argv[i++] = "--batch";*/
#elif defined (PGP5_PATH)
path = PGP5_PATH;
argv[i++] = "pgpv";
+
+ argv[i++] = "-z";
+
+ if (sigin != NULL && siglen)
+ argv[i++] = sigfile;
+
+ argv[i++] = "-f";
+
#else
path = PGP_PATH;
argv[i++] = "pgp";
+
+ if (sigin != NULL && siglen)
+ argv[i++] = sigfile;
+
+ argv[i++] = "-f";
#endif
argv[i++] = NULL;
@@ -982,8 +1005,14 @@ mail_crypto_openpgp_verify (const char *in, int inlen, const char *sigin, int si
&cleartext, &clearlen,
&diagnostics);
+ /* cleanup */
+ if (sigfile) {
+ unlink (sigfile);
+ g_free (sigfile);
+ }
+
/* FIXME: maybe we should always set an exception? */
- if (retval != 0 || clearlen == 0) {
+ if (retval != 0) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
"%s", diagnostics);
valid = FALSE;