[gmime] Don't build S/MIME support if GpgMe not found
- From: Jeffrey Stedfast <fejj src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gmime] Don't build S/MIME support if GpgMe not found
- Date: Sat, 13 Feb 2010 04:12:43 +0000 (UTC)
commit aee80363cbddf78c70d8595d17c3feb74af64395
Author: Jeffrey Stedfast <fejj gnome org>
Date: Fri Feb 12 23:11:40 2010 -0500
Don't build S/MIME support if GpgMe not found
2010-02-12 Jeffrey Stedfast <fejj novell com>
Fixes bug #609700.
* configure.ac: Define ENABLE_SMIME if we find GpgMe.
* gmime/gmime-pkcs7-context.c: #ifdef out the GpgMe logic if we
are building without S/MIME support enabled.
ChangeLog | 9 ++++++
configure.ac | 4 ++-
gmime/gmime-pkcs7-context.c | 60 +++++++++++++++++++++++++++++++++++++++++-
3 files changed, 70 insertions(+), 3 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 19267f2..10333b7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2010-02-12 Jeffrey Stedfast <fejj novell com>
+
+ Fixes bug #609700.
+
+ * configure.ac: Define ENABLE_SMIME if we find GpgMe.
+
+ * gmime/gmime-pkcs7-context.c: #ifdef out the GpgMe logic if we
+ are building without S/MIME support enabled.
+
2010-02-07 Jeffrey Stedfast <fejj novell com>
* README: Bumped version
diff --git a/configure.ac b/configure.ac
index dd436ad..3e96ce0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -469,7 +469,9 @@ dnl ******************************************
dnl *** Checks for GpgME needed for S/MIME ***
dnl ******************************************
AM_PATH_GPGME_PTHREAD(1.1.6, enable_smime="yes (via GpgME)", enable_smime="no")
-
+if test "x$enable_smime" != "xno"; then
+ AC_DEFINE(ENABLE_SMIME, 1, [Define if GMime should enable experimental S/MIME support.])
+fi
dnl ****************************
dnl *** Enable Mono bindings ***
diff --git a/gmime/gmime-pkcs7-context.c b/gmime/gmime-pkcs7-context.c
index 8cb727b..331c0ac 100644
--- a/gmime/gmime-pkcs7-context.c
+++ b/gmime/gmime-pkcs7-context.c
@@ -27,17 +27,21 @@
#include <stdlib.h>
#include <string.h>
-#include <gpgme.h>
-
#include "gmime-pkcs7-context.h"
+#ifdef ENABLE_SMIME
#include "gmime-filter-charset.h"
#include "gmime-stream-filter.h"
#include "gmime-stream-pipe.h"
#include "gmime-stream-mem.h"
#include "gmime-stream-fs.h"
#include "gmime-charset.h"
+#endif /* ENABLE_SMIME */
#include "gmime-error.h"
+#ifdef ENABLE_SMIME
+#include <gpgme.h>
+#endif
+
#ifdef ENABLE_DEBUG
#define d(x) x
#else
@@ -59,7 +63,9 @@
typedef struct _GMimePkcs7ContextPrivate {
gboolean always_trust;
+#ifdef ENABLE_SMIME
gpgme_ctx_t ctx;
+#endif
} Pkcs7Ctx;
static void g_mime_pkcs7_context_class_init (GMimePkcs7ContextClass *klass);
@@ -148,7 +154,9 @@ g_mime_pkcs7_context_init (GMimePkcs7Context *ctx, GMimePkcs7ContextClass *klass
ctx->priv = g_slice_new (Pkcs7Ctx);
ctx->priv->always_trust = FALSE;
+#ifdef ENABLE_SMIME
ctx->priv->ctx = NULL;
+#endif
cipher->sign_protocol = "application/pkcs7-signature";
cipher->encrypt_protocol = "application/pkcs7-mime";
@@ -160,8 +168,10 @@ g_mime_pkcs7_context_finalize (GObject *object)
{
GMimePkcs7Context *ctx = (GMimePkcs7Context *) object;
+#ifdef ENABLE_SMIME
if (ctx->priv->ctx)
gpgme_release (ctx->priv->ctx);
+#endif
g_slice_free (Pkcs7Ctx, ctx->priv);
@@ -227,6 +237,7 @@ pkcs7_hash_name (GMimeCipherContext *ctx, GMimeCipherHash hash)
}
}
+#ifdef ENABLE_SMIME
static gpgme_error_t
pkcs7_passphrase_cb (void *hook, const char *uid_hint, const char *passphrase_info, int prev_was_bad, int fd)
{
@@ -382,11 +393,13 @@ pkcs7_add_signer (Pkcs7Ctx *pkcs7, const char *signer, GError **err)
return TRUE;
}
+#endif /* ENABLE_SMIME */
static int
pkcs7_sign (GMimeCipherContext *context, const char *userid, GMimeCipherHash hash,
GMimeStream *istream, GMimeStream *ostream, GError **err)
{
+#ifdef ENABLE_SMIME
GMimePkcs7Context *ctx = (GMimePkcs7Context *) context;
Pkcs7Ctx *pkcs7 = ctx->priv;
gpgme_sign_result_t result;
@@ -424,8 +437,14 @@ pkcs7_sign (GMimeCipherContext *context, const char *userid, GMimeCipherHash has
result = gpgme_op_sign_result (pkcs7->ctx);
return pkcs7_hash_id (context, gpgme_hash_algo_name (result->signatures->hash_algo));
+#else
+ g_set_error (err, GMIME_ERROR, GMIME_ERROR_NOT_SUPPORTED, _("S/MIME support is not enabled in this build"));
+
+ return -1;
+#endif /* ENABLE_SMIME */
}
+#ifdef ENABLE_SMIME
static GMimeSignerTrust
pkcs7_trust (gpgme_validity_t trust)
{
@@ -561,12 +580,14 @@ pkcs7_get_validity (Pkcs7Ctx *pkcs7, gboolean verify)
return validity;
}
+#endif /* ENABLE_SMIME */
static GMimeSignatureValidity *
pkcs7_verify (GMimeCipherContext *context, GMimeCipherHash hash,
GMimeStream *istream, GMimeStream *sigstream,
GError **err)
{
+#ifdef ENABLE_SMIME
GMimePkcs7Context *ctx = (GMimePkcs7Context *) context;
gpgme_data_t message, signature;
Pkcs7Ctx *pkcs7 = ctx->priv;
@@ -604,8 +625,14 @@ pkcs7_verify (GMimeCipherContext *context, GMimeCipherHash hash,
/* get/return the pkcs7 signature validity */
return pkcs7_get_validity (pkcs7, TRUE);
+#else
+ g_set_error (err, GMIME_ERROR, GMIME_ERROR_NOT_SUPPORTED, _("S/MIME support is not enabled in this build"));
+
+ return NULL;
+#endif /* ENABLE_SMIME */
}
+#ifdef ENABLE_SMIME
static void
key_list_free (gpgme_key_t *keys)
{
@@ -618,12 +645,14 @@ key_list_free (gpgme_key_t *keys)
g_free (keys);
}
+#endif /* ENABLE_SMIME */
static int
pkcs7_encrypt (GMimeCipherContext *context, gboolean sign, const char *userid,
GPtrArray *recipients, GMimeStream *istream, GMimeStream *ostream,
GError **err)
{
+#ifdef ENABLE_SMIME
GMimePkcs7Context *ctx = (GMimePkcs7Context *) context;
Pkcs7Ctx *pkcs7 = ctx->priv;
gpgme_data_t input, output;
@@ -674,6 +703,11 @@ pkcs7_encrypt (GMimeCipherContext *context, gboolean sign, const char *userid,
}
return 0;
+#else
+ g_set_error (err, GMIME_ERROR, GMIME_ERROR_NOT_SUPPORTED, _("S/MIME support is not enabled in this build"));
+
+ return -1;
+#endif /* ENABLE_SMIME */
}
@@ -681,6 +715,7 @@ static GMimeSignatureValidity *
pkcs7_decrypt (GMimeCipherContext *context, GMimeStream *istream,
GMimeStream *ostream, GError **err)
{
+#ifdef ENABLE_SMIME
GMimePkcs7Context *ctx = (GMimePkcs7Context *) context;
Pkcs7Ctx *pkcs7 = ctx->priv;
gpgme_data_t input, output;
@@ -710,11 +745,17 @@ pkcs7_decrypt (GMimeCipherContext *context, GMimeStream *istream,
/* get/return the pkcs7 signature validity */
return pkcs7_get_validity (pkcs7, FALSE);
+#else
+ g_set_error (err, GMIME_ERROR, GMIME_ERROR_NOT_SUPPORTED, _("S/MIME support is not enabled in this build"));
+
+ return NULL;
+#endif /* ENABLE_SMIME */
}
static int
pkcs7_import_keys (GMimeCipherContext *context, GMimeStream *istream, GError **err)
{
+#ifdef ENABLE_SMIME
GMimePkcs7Context *ctx = (GMimePkcs7Context *) context;
Pkcs7Ctx *pkcs7 = ctx->priv;
gpgme_data_t keydata;
@@ -735,11 +776,17 @@ pkcs7_import_keys (GMimeCipherContext *context, GMimeStream *istream, GError **e
gpgme_data_release (keydata);
return 0;
+#else
+ g_set_error (err, GMIME_ERROR, GMIME_ERROR_NOT_SUPPORTED, _("S/MIME support is not enabled in this build"));
+
+ return -1;
+#endif /* ENABLE_SMIME */
}
static int
pkcs7_export_keys (GMimeCipherContext *context, GPtrArray *keys, GMimeStream *ostream, GError **err)
{
+#ifdef ENABLE_SMIME
GMimePkcs7Context *ctx = (GMimePkcs7Context *) context;
Pkcs7Ctx *pkcs7 = ctx->priv;
gpgme_data_t keydata;
@@ -763,6 +810,11 @@ pkcs7_export_keys (GMimeCipherContext *context, GPtrArray *keys, GMimeStream *os
gpgme_data_release (keydata);
return 0;
+#else
+ g_set_error (err, GMIME_ERROR, GMIME_ERROR_NOT_SUPPORTED, _("S/MIME support is not enabled in this build"));
+
+ return -1;
+#endif /* ENABLE_SMIME */
}
@@ -777,6 +829,7 @@ pkcs7_export_keys (GMimeCipherContext *context, GPtrArray *keys, GMimeStream *os
GMimeCipherContext *
g_mime_pkcs7_context_new (GMimePasswordRequestFunc request_passwd)
{
+#ifdef ENABLE_SMIME
GMimeCipherContext *cipher;
GMimePkcs7Context *pkcs7;
gpgme_ctx_t ctx;
@@ -798,6 +851,9 @@ g_mime_pkcs7_context_new (GMimePasswordRequestFunc request_passwd)
cipher->request_passwd = request_passwd;
return cipher;
+#else
+ return NULL;
+#endif /* ENABLE_SMIME */
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]