[seahorse] Avoid binding seahorse to the build-time version of gpg



commit dfabc8de30e87fd7b6dc6d12f34fa29858caed95
Author: Daniel Kahn Gillmor <dkg fifthhorseman net>
Date:   Fri Jun 5 16:01:43 2015 -0400

    Avoid binding seahorse to the build-time version of gpg
    
    As a user of gpgme, seahorse should prefer gpg2 over gpg, since gpgme
    is more fully-functional when it works with gpg2.
    
    Moreover, seahorse should not assume that the version of gpg that it
    was built against is the same version of gpg that it is running
    against.
    
    GPGME has allowed a NULL value for the file_name parameter for
    gpgme_set_engine_info ever since the function appeared.  This will use
    gpgme's default engine selection, which is likely to be better than
    hardcoding the path that seahorse found during compile time.
    
    Moreover, seahorse should not bother trying to build against archaic
    versions of these branches, and certainly shouldn't hardcode numeric
    values that only worked for old versions in the seahorse headers.
    
    This changeset adjusts the configure.ac tests to make sure that the
    build environment has a non-archaic version of gnupg at least.
    
    Signed-off-by: Stef Walter <stefw redhat com>
     * Remove support for GnuPG 1.4.x as discussed at linked bug
    
    https://bugzilla.gnome.org/show_bug.cgi?id=750468

 configure.ac                |   22 +++++++++++++---------
 pgp/seahorse-gpg-op.c       |    3 ---
 pgp/seahorse-gpgme-key-op.h |   41 +++--------------------------------------
 pgp/seahorse-pgp-backend.c  |    2 +-
 4 files changed, 17 insertions(+), 51 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 760ec98..bf34ea9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -9,7 +9,7 @@ GCR_REQUIRED=3.11.91
 GTK_REQ=3.4.0
 GTK_MAX=GTK_VERSION_3_4
 
-GNUPG_ACCEPTED="1.2 1.4 2.0"
+GNUPG_ACCEPTED="2.0.12 2.1.4"
 GPGME_REQUIRED=1.0.0
 LIBSECRET_REQUIRED=0.16
 AVAHI_GLIB_REQUIRED=0.6
@@ -130,7 +130,7 @@ else
                DO_CHECK=$enableval, DO_CHECK=yes)
        
        if test "$DO_CHECK" = "yes"; then
-               AC_PATH_PROGS(GNUPG, [gpg gpg2], no)
+               AC_PATH_PROGS(GNUPG, [gpg2 gpg], no)
                AC_DEFINE_UNQUOTED(GNUPG, "$GNUPG", [Path to gpg executable.])
                ok="no"
                if test "$GNUPG" != "no"; then
@@ -144,12 +144,16 @@ else
                                sed 's/^gpg (GnuPG) \([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`
     
                        for ver in $GNUPG_ACCEPTED; do
-                               if test "$ver" = "$major.$minor"; then
-                                       AC_DEFINE_UNQUOTED(GPG_MAJOR, [$major], [GPG Major Version])
-                                       AC_DEFINE_UNQUOTED(GPG_MINOR, [$minor], [GPG Minor Version])
-                                       AC_DEFINE_UNQUOTED(GPG_MICRO, [$micro], [GPG Micro Version])
-                                       ok="yes"
-                                       break
+                               branch=`echo $ver | sed 's/\.[[0-9]]*$//'`
+                               if test "$branch" = "$major.$minor"; then
+                                       min_micro=`echo $ver | sed 's/^[[0-9]]*\.[[0-9]]*\.//'`
+                                       if test "$min_micro" -le "$micro"; then
+                                               AC_DEFINE_UNQUOTED(GPG_MAJOR, [$major], [GPG Major Version])
+                                               AC_DEFINE_UNQUOTED(GPG_MINOR, [$minor], [GPG Minor Version])
+                                               AC_DEFINE_UNQUOTED(GPG_MICRO, [$micro], [GPG Micro Version])
+                                               ok="yes"
+                                               break
+                                       fi
                                fi
                        done
                fi
@@ -206,7 +210,7 @@ fi
 
 if test "$enable_pgp" = "yes"; then
        if test -z "$have_gpg"; then
-               AC_MSG_ERROR([Appropriate version of GnuPG not found. Please install one of versions: 
$GNUPG_ACCEPTED])
+               AC_MSG_ERROR([Appropriate version of GnuPG not found. Please install one of the following 
versions (or later): $GNUPG_ACCEPTED])
        fi
                        
        if test -z "$have_gpgme"; then
diff --git a/pgp/seahorse-gpg-op.c b/pgp/seahorse-gpg-op.c
index f34d9ec..3c3b9b5 100644
--- a/pgp/seahorse-gpg-op.c
+++ b/pgp/seahorse-gpg-op.c
@@ -111,9 +111,6 @@ seahorse_gpg_op_num_uids (gpgme_ctx_t ctx, const char *pattern, guint *number)
                found += 3;
        }
 
-       if ((GPG_MAJOR == 1) && (GPG_MINOR == 2))
-               *number = *number + 1;
-     
     g_free (output);
     return GPG_OK;
 }
diff --git a/pgp/seahorse-gpgme-key-op.h b/pgp/seahorse-gpgme-key-op.h
index 622c93a..0acbfc0 100644
--- a/pgp/seahorse-gpgme-key-op.h
+++ b/pgp/seahorse-gpgme-key-op.h
@@ -30,43 +30,10 @@
 #include "pgp/seahorse-gpgme-uid.h"
 #include "pgp/seahorse-gpgme-photo.h"
 
-/* 
- * Key type options. 
- * Sadly these are not consistent between versions of GPG.
+/*
+ * Key type options.
+ * We only support GPG version >=2.0.12 or >= 2.1.4
  */
-#if ( GPG_MAJOR == 2 &&   GPG_MINOR == 0 && GPG_MICRO < 12 ) || \
-    ( GPG_MAJOR == 1 && ( GPG_MINOR <  4 || GPG_MICRO < 10 ) )
-
-typedef enum {
-       /* DSA key with ElGamal subkey. The ElGamal length is variable
-        * within #ELGAMAL_MIN and #LENGTH_MAX. The DSA key will have a
-        * length equal to the ElGamal key's up to a limit of #DSA_MAX.
-        * Only used in seahorse_ops_key_generate().
-        */
-       DSA_ELGAMAL = 1,
-       /* DSA key, sign only. Can be a subkey or a primary key.
-        * See #DSA_MIN and #DSA_MAX.
-        */
-       DSA = 2,
-       /* ElGamal subkey, encrypt only. See #ELGAMAL_MIN and #LENGTH_MAX.
-        * Only used in seahorse_ops_key_add_subkey().
-        */
-       ELGAMAL = 4,
-       /* RSA key, sign only. Can be a subkey or a primary key.
-        * See #RSA_MIN and #LENGTH_MAX.
-        */
-       RSA_SIGN = 5,
-       /* RSA subkey, encrypt only. See #RSA_MIN and #LENGTH_MAX.
-        * Only used in seahorse_ops_key_add_subkey().
-        */
-       RSA_ENCRYPT = 6,
-       /* RSA sign-only key with RSA encrypt-only subkey. See #RSA_MIN and
-        * #LENGTH_MAX. Only used in seahorse_ops_key_generate().
-        */
-       RSA_RSA = 11
-} SeahorseKeyEncType;
-
-#else /* GPG version >=1.4.10 or >=2.0.12 */
 
 typedef enum {
        RSA_RSA = 1,
@@ -77,8 +44,6 @@ typedef enum {
        RSA_ENCRYPT = 6
 } SeahorseKeyEncType;
 
-#endif /* GPG version >=1.4.10 or >=2.0.12 */
-
 /* Length ranges for key types */
 typedef enum {
        /* Minimum length for #DSA. */
diff --git a/pgp/seahorse-pgp-backend.c b/pgp/seahorse-pgp-backend.c
index 4b267c3..ce613b8 100644
--- a/pgp/seahorse-pgp-backend.c
+++ b/pgp/seahorse-pgp-backend.c
@@ -311,7 +311,7 @@ seahorse_pgp_backend_initialize (void)
 
        g_return_if_fail (pgp_backend != NULL);
 
-       gpgme_set_engine_info (GPGME_PROTOCOL_OpenPGP, GNUPG, NULL);
+       gpgme_set_engine_info (GPGME_PROTOCOL_OpenPGP, NULL, NULL);
 }
 
 SeahorseGpgmeKeyring *


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]