From: Tomi Ollila Date: Sun, 16 Aug 2015 19:53:36 +0000 (+0300) Subject: Re: [PATCH] cli/lib: remove support for GMime 2.4 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=f820be6c12c8f0f8bc908fb6fdb3d0b0e68b4099;p=notmuch-archives.git Re: [PATCH] cli/lib: remove support for GMime 2.4 --- diff --git a/b9/01f2fb774930405d3daf62bb3ce24914fafdf5 b/b9/01f2fb774930405d3daf62bb3ce24914fafdf5 new file mode 100644 index 000000000..617e819c5 --- /dev/null +++ b/b9/01f2fb774930405d3daf62bb3ce24914fafdf5 @@ -0,0 +1,452 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by arlo.cworth.org (Postfix) with ESMTP id B327C6DE1435 + for ; Sun, 16 Aug 2015 12:54:50 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at cworth.org +X-Spam-Flag: NO +X-Spam-Score: 1.237 +X-Spam-Level: * +X-Spam-Status: No, score=1.237 tagged_above=-999 required=5 tests=[AWL=-0.159, + SPF_NEUTRAL=0.652, URIBL_SBL=0.644, URIBL_SBL_A=0.1] autolearn=disabled +Received: from arlo.cworth.org ([127.0.0.1]) + by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id ER95b4xdUcz4 for ; + Sun, 16 Aug 2015 12:54:48 -0700 (PDT) +Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34]) + by arlo.cworth.org (Postfix) with ESMTP id A37B66DE142C + for ; Sun, 16 Aug 2015 12:54:47 -0700 (PDT) +Received: from guru.guru-group.fi (localhost [IPv6:::1]) + by guru.guru-group.fi (Postfix) with ESMTP id 46E9D1000E6; + Sun, 16 Aug 2015 22:53:36 +0300 (EEST) +From: Tomi Ollila +To: David Bremner , notmuch@notmuchmail.org +Subject: Re: [PATCH] cli/lib: remove support for GMime 2.4 +In-Reply-To: <1439739201-11068-1-git-send-email-david@tethera.net> +References: <1439739201-11068-1-git-send-email-david@tethera.net> +User-Agent: Notmuch/0.20.2+61~g367bd06 (http://notmuchmail.org) Emacs/24.3.1 + (x86_64-unknown-linux-gnu) +X-Face: HhBM'cA~ +MIME-Version: 1.0 +Content-Type: text/plain +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.18 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Sun, 16 Aug 2015 19:54:50 -0000 + +On Sun, Aug 16 2015, David Bremner wrote: + +> It's becoming a maintenance burden to do anything things with the +> crypto glue code twice, once for 2.4 and once for 2.6. I don't have +> any 2.4 version available to test on my development machine anymore, +> so the 2.4 specific code paths are likely not very well tested. +> --- +> +> I started to rebase the SMIME signature verification patches and got +> aggravated at solving the same conflicts twice in every file. +> +> 2.6.7 is from 2012, so that's a bit newer than some of our +> requirements, but I think not so bad. YMMV. + +Perhaps it is time for me to update to gmime 2.6 in this machine. PITA ;/ + +Tomi + +> +> INSTALL | 6 ++-- +> configure | 49 ++++++++++----------------------- +> crypto.c | 25 ----------------- +> mime-node.c | 83 ------------------------------------------------------- +> notmuch-show.c | 87 ---------------------------------------------------------- +> 5 files changed, 17 insertions(+), 233 deletions(-) +> +> diff --git a/INSTALL b/INSTALL +> index eaccd93..b1b9cd5 100644 +> --- a/INSTALL +> +++ b/INSTALL +> @@ -20,7 +20,7 @@ configure stage. +> +> Dependencies +> ------------ +> -Notmuch depends on four libraries: Xapian, GMime 2.4 or 2.6, +> +Notmuch depends on four libraries: Xapian, GMime 2.6, +> Talloc, and zlib which are each described below: +> +> Xapian +> @@ -39,8 +39,8 @@ Talloc, and zlib which are each described below: +> reading mail while notmuch would wait for Xapian when removing +> the "inbox" and "unread" tags from messages in a thread. +> +> - GMime 2.4 or 2.6 +> - ---------------- +> + GMime 2.6 +> + ---------- +> GMime provides decoding of MIME email messages for Notmuch. +> +> Without GMime, Notmuch would not be able to extract and index +> diff --git a/configure b/configure +> index d289880..440d678 100755 +> --- a/configure +> +++ b/configure +> @@ -71,16 +71,6 @@ WITH_BASH=1 +> WITH_RUBY=1 +> WITH_ZSH=1 +> +> -# Compatible GMime versions (with constraints). +> -# If using GMime 2.6, we need to have a version >= 2.6.5 to avoid a +> -# crypto bug. We need 2.6.7 for permissive "From " header handling. +> -GMIME_24_VERSION_CTR='' +> -GMIME_24_VERSION="gmime-2.4 $GMIME_24_VERSION_CTR" +> -GMIME_26_VERSION_CTR='>= 2.6.7' +> -GMIME_26_VERSION="gmime-2.6 $GMIME_26_VERSION_CTR" +> - +> -WITH_GMIME_VERSIONS="$GMIME_26_VERSION;$GMIME_24_VERSION" +> - +> usage () +> { +> cat < @@ -140,10 +130,6 @@ Fine tuning of some installation directories is available: +> --bashcompletiondir=DIR Bash completions files [SYSCONFDIR/bash_completion.d] +> --zshcompletiondir=DIR Zsh completions files [PREFIX/share/zsh/functions/Completion/Unix] +> +> -Some specific library versions can be specified (auto-detected otherwise): +> - +> - --with-gmime-version=VERS Specify GMIME version (2.4 or 2.6) +> - +> Some features can be disabled (--with-feature=no is equivalent to +> --without-feature) : +> +> @@ -231,12 +217,6 @@ for option; do +> fi +> elif [ "${option}" = '--without-zsh-completion' ] ; then +> WITH_ZSH=0 +> - elif [ "${option%%=*}" = '--with-gmime-version' ] ; then +> - if [ "${option#*=}" = '2.4' ]; then +> - WITH_GMIME_VERSIONS=$GMIME_24_VERSION +> - elif [ "${option#*=}" = '2.6' ]; then +> - WITH_GMIME_VERSIONS=$GMIME_26_VERSION +> - fi +> elif [ "${option%%=*}" = '--build' ] ; then +> true +> elif [ "${option%%=*}" = '--host' ] ; then +> @@ -391,20 +371,19 @@ if [ ${have_xapian} = "1" ]; then +> esac +> fi +> +> + +> +# we need to have a version >= 2.6.5 to avoid a crypto bug. We need +> +# 2.6.7 for permissive "From " header handling. +> +GMIME_MINVER=2.6.7 +> + +> printf "Checking for GMime development files... " +> -have_gmime=0 +> -IFS=';' +> -for gmimepc in $WITH_GMIME_VERSIONS; do +> - if pkg-config --exists $gmimepc; then +> - printf "Yes ($gmimepc).\n" +> - have_gmime=1 +> - gmime_cflags=$(pkg-config --cflags $gmimepc) +> - gmime_ldflags=$(pkg-config --libs $gmimepc) +> - break +> - fi +> -done +> -IFS=$DEFAULT_IFS +> -if [ "$have_gmime" = "0" ]; then +> +if pkg-config --exists "gmime-2.6 >= $GMIME_MINVER"; then +> + printf "Yes.\n" +> + have_gmime=1 +> + gmime_cflags=$(pkg-config --cflags gmime-2.6) +> + gmime_ldflags=$(pkg-config --libs gmime-2.6) +> +else +> + have_gmime=0 +> printf "No.\n" +> errors=$((errors + 1)) +> fi +> @@ -640,7 +619,7 @@ EOF +> echo +> fi +> if [ $have_gmime -eq 0 ]; then +> - echo " Either GMime 2.4 library" $GMIME_24_VERSION_CTR "or GMime 2.6 library" $GMIME_26_VERSION_CTR +> + echo " GMime 2.6 library >= $GMIME_MINVER" +> echo " (including development files such as headers)" +> echo " http://spruce.sourceforge.net/gmime/" +> echo +> @@ -1026,7 +1005,7 @@ LINKER_RESOLVES_LIBRARY_DEPENDENCIES = ${linker_resolves_library_dependencies} +> XAPIAN_CXXFLAGS = ${xapian_cxxflags} +> XAPIAN_LDFLAGS = ${xapian_ldflags} +> +> -# Flags needed to compile and link against GMime-2.4 +> +# Flags needed to compile and link against GMime +> GMIME_CFLAGS = ${gmime_cflags} +> GMIME_LDFLAGS = ${gmime_ldflags} +> +> diff --git a/crypto.c b/crypto.c +> index 026640f..a6eb27d 100644 +> --- a/crypto.c +> +++ b/crypto.c +> @@ -20,8 +20,6 @@ +> +> #include "notmuch-client.h" +> +> -#ifdef GMIME_ATLEAST_26 +> - +> /* Create a GPG context (GMime 2.6) */ +> static notmuch_crypto_context_t * +> create_gpg_context (const char *gpgpath) +> @@ -39,29 +37,6 @@ create_gpg_context (const char *gpgpath) +> return gpgctx; +> } +> +> -#else /* GMIME_ATLEAST_26 */ +> - +> -/* Create a GPG context (GMime 2.4) */ +> -static notmuch_crypto_context_t * +> -create_gpg_context (const char* gpgpath) +> -{ +> - GMimeSession *session; +> - notmuch_crypto_context_t *gpgctx; +> - +> - session = g_object_new (g_mime_session_get_type (), NULL); +> - gpgctx = g_mime_gpg_context_new (session, gpgpath ? gpgpath : "gpg"); +> - g_object_unref (session); +> - +> - if (! gpgctx) +> - return NULL; +> - +> - g_mime_gpg_context_set_always_trust ((GMimeGpgContext *) gpgctx, FALSE); +> - +> - return gpgctx; +> -} +> - +> -#endif /* GMIME_ATLEAST_26 */ +> - +> /* for the specified protocol return the context pointer (initializing +> * if needed) */ +> notmuch_crypto_context_t * +> diff --git a/mime-node.c b/mime-node.c +> index fd9e4a4..e96e663 100644 +> --- a/mime-node.c +> +++ b/mime-node.c +> @@ -129,8 +129,6 @@ DONE: +> return status; +> } +> +> -#ifdef GMIME_ATLEAST_26 +> - +> /* Signature list destructor (GMime 2.6) */ +> static int +> _signature_list_free (GMimeSignatureList **proxy) +> @@ -205,87 +203,6 @@ node_decrypt_and_verify (mime_node_t *node, GMimeObject *part, +> g_error_free (err); +> } +> +> -#else /* GMIME_ATLEAST_26 */ +> - +> -/* Signature validity destructor (GMime 2.4) */ +> -static int +> -_signature_validity_free (GMimeSignatureValidity **proxy) +> -{ +> - g_mime_signature_validity_free (*proxy); +> - return 0; +> -} +> - +> -/* Set up signature validity destructor (GMime 2.4) */ +> -static void +> -set_signature_validity_destructor (mime_node_t *node, +> - GMimeSignatureValidity *sig_validity) +> -{ +> - GMimeSignatureValidity **proxy = talloc (node, GMimeSignatureValidity *); +> - if (proxy) { +> - *proxy = sig_validity; +> - talloc_set_destructor (proxy, _signature_validity_free); +> - } +> -} +> - +> -/* Verify a signed mime node (GMime 2.4) */ +> -static void +> -node_verify (mime_node_t *node, GMimeObject *part, +> - notmuch_crypto_context_t *cryptoctx) +> -{ +> - GError *err = NULL; +> - GMimeSignatureValidity *sig_validity; +> - +> - node->verify_attempted = TRUE; +> - sig_validity = g_mime_multipart_signed_verify +> - (GMIME_MULTIPART_SIGNED (part), cryptoctx, &err); +> - node->sig_validity = sig_validity; +> - if (sig_validity) { +> - set_signature_validity_destructor (node, sig_validity); +> - } else { +> - fprintf (stderr, "Failed to verify signed part: %s\n", +> - err ? err->message : "no error explanation given"); +> - } +> - +> - if (err) +> - g_error_free (err); +> -} +> - +> -/* Decrypt and optionally verify an encrypted mime node (GMime 2.4) */ +> -static void +> -node_decrypt_and_verify (mime_node_t *node, GMimeObject *part, +> - notmuch_crypto_context_t *cryptoctx) +> -{ +> - GError *err = NULL; +> - GMimeMultipartEncrypted *encrypteddata = GMIME_MULTIPART_ENCRYPTED (part); +> - +> - node->decrypt_attempted = TRUE; +> - node->decrypted_child = g_mime_multipart_encrypted_decrypt +> - (encrypteddata, cryptoctx, &err); +> - if (! node->decrypted_child) { +> - fprintf (stderr, "Failed to decrypt part: %s\n", +> - err ? err->message : "no error explanation given"); +> - goto DONE; +> - } +> - +> - node->decrypt_success = TRUE; +> - node->verify_attempted = TRUE; +> - +> - /* The GMimeSignatureValidity returned here is a const, unlike the +> - * one returned by g_mime_multipart_signed_verify() in +> - * node_verify() above, so the destructor is not needed. +> - */ +> - node->sig_validity = g_mime_multipart_encrypted_get_signature_validity (encrypteddata); +> - if (! node->sig_validity) +> - fprintf (stderr, "Failed to verify encrypted signed part: %s\n", +> - err ? err->message : "no error explanation given"); +> - +> - DONE: +> - if (err) +> - g_error_free (err); +> -} +> - +> -#endif /* GMIME_ATLEAST_26 */ +> - +> static mime_node_t * +> _mime_node_create (mime_node_t *parent, GMimeObject *part) +> { +> diff --git a/notmuch-show.c b/notmuch-show.c +> index b80933a..21015fd 100644 +> --- a/notmuch-show.c +> +++ b/notmuch-show.c +> @@ -334,8 +334,6 @@ show_text_part_content (GMimeObject *part, GMimeStream *stream_out, +> g_object_unref(stream_filter); +> } +> +> -#ifdef GMIME_ATLEAST_26 +> - +> /* Get signature status string (GMime 2.6) */ +> static const char* +> signature_status_to_string (GMimeSignatureStatus x) +> @@ -427,91 +425,6 @@ format_part_sigstatus_sprinter (sprinter_t *sp, mime_node_t *node) +> sp->end (sp); +> } +> +> -#else /* GMIME_ATLEAST_26 */ +> - +> -/* Get signature status string (GMime 2.4) */ +> -static const char* +> -signer_status_to_string (GMimeSignerStatus x) +> -{ +> - switch (x) { +> - case GMIME_SIGNER_STATUS_NONE: +> - return "none"; +> - case GMIME_SIGNER_STATUS_GOOD: +> - return "good"; +> - case GMIME_SIGNER_STATUS_BAD: +> - return "bad"; +> - case GMIME_SIGNER_STATUS_ERROR: +> - return "error"; +> - } +> - return "unknown"; +> -} +> - +> -/* Signature status sprinter (GMime 2.4) */ +> -static void +> -format_part_sigstatus_sprinter (sprinter_t *sp, mime_node_t *node) +> -{ +> - const GMimeSignatureValidity* validity = node->sig_validity; +> - +> - sp->begin_list (sp); +> - +> - if (!validity) { +> - sp->end (sp); +> - return; +> - } +> - +> - const GMimeSigner *signer = g_mime_signature_validity_get_signers (validity); +> - while (signer) { +> - sp->begin_map (sp); +> - +> - /* status */ +> - sp->map_key (sp, "status"); +> - sp->string (sp, signer_status_to_string (signer->status)); +> - +> - if (signer->status == GMIME_SIGNER_STATUS_GOOD) +> - { +> - if (signer->fingerprint) { +> - sp->map_key (sp, "fingerprint"); +> - sp->string (sp, signer->fingerprint); +> - } +> - /* these dates are seconds since the epoch; should we +> - * provide a more human-readable format string? */ +> - if (signer->created) { +> - sp->map_key (sp, "created"); +> - sp->integer (sp, signer->created); +> - } +> - if (signer->expires) { +> - sp->map_key (sp, "expires"); +> - sp->integer (sp, signer->expires); +> - } +> - /* output user id only if validity is FULL or ULTIMATE. */ +> - /* note that gmime is using the term "trust" here, which +> - * is WRONG. It's actually user id "validity". */ +> - if ((signer->name) && (signer->trust)) { +> - if ((signer->trust == GMIME_SIGNER_TRUST_FULLY) || (signer->trust == GMIME_SIGNER_TRUST_ULTIMATE)) { +> - sp->map_key (sp, "userid"); +> - sp->string (sp, signer->name); +> - } +> - } +> - } else { +> - if (signer->keyid) { +> - sp->map_key (sp, "keyid"); +> - sp->string (sp, signer->keyid); +> - } +> - } +> - if (signer->errors != GMIME_SIGNER_ERROR_NONE) { +> - sp->map_key (sp, "errors"); +> - sp->integer (sp, signer->errors); +> - } +> - +> - sp->end (sp); +> - signer = signer->next; +> - } +> - +> - sp->end (sp); +> -} +> - +> -#endif /* GMIME_ATLEAST_26 */ +> - +> static notmuch_status_t +> format_part_text (const void *ctx, sprinter_t *sp, mime_node_t *node, +> int indent, const notmuch_show_params_t *params) +> -- +> 2.5.0 +> +> _______________________________________________ +> notmuch mailing list +> notmuch@notmuchmail.org +> http://notmuchmail.org/mailman/listinfo/notmuch