[Pkg-gnupg-commit] [gnupg2] 56/112: Cleanup initialization of libgcrypt.

Daniel Kahn Gillmor dkg at fifthhorseman.net
Tue Aug 30 17:48:20 UTC 2016


This is an automated email from the git hooks/post-receive script.

dkg pushed a commit to branch master
in repository gnupg2.

commit 49829c29e541546084950b8a153067db371d101a
Author: Ben Kibbey <bjk at luxsci.net>
Date:   Mon Aug 8 18:40:03 2016 -0400

    Cleanup initialization of libgcrypt.
    
    * common/init.c (init_common_subsystems): Initialize libgcrypt.
    * dirmngr/Makefile.am (dirmngr_ldap): Link with libgcrypt.
    
    --
    Most other modules already call gcry_check_version() after
    init_common_subsystems() so may as well move initialization of libgcrypt
    to here. Also fixes a warning in the system log from gpgconf --homedir.
    
    Signed-off-by: Ben Kibbey <bjk at luxsci.net>
---
 agent/gpg-agent.c         | 8 --------
 agent/protect-tool.c      | 7 -------
 common/init.c             | 8 ++++++++
 dirmngr/Makefile.am       | 4 ++--
 dirmngr/dirmngr.c         | 4 ----
 g10/gpg.c                 | 8 --------
 g10/gpgv.c                | 5 -----
 g13/g13-syshelp.c         | 5 -----
 g13/g13.c                 | 5 -----
 kbx/kbxutil.c             | 8 --------
 scd/scdaemon.c            | 8 --------
 sm/gpgsm.c                | 3 ---
 tools/gpg-check-pattern.c | 7 -------
 tools/symcryptrun.c       | 5 -----
 14 files changed, 10 insertions(+), 75 deletions(-)

diff --git a/agent/gpg-agent.c b/agent/gpg-agent.c
index 8d6ecfc..b8a5a3e 100644
--- a/agent/gpg-agent.c
+++ b/agent/gpg-agent.c
@@ -764,14 +764,6 @@ main (int argc, char **argv )
 
   npth_init ();
 
-  /* Check that the libraries are suitable.  Do it here because
-     the option parsing may need services of the library. */
-  if (!gcry_check_version (NEED_LIBGCRYPT_VERSION) )
-    {
-      log_fatal( _("%s is too old (need %s, have %s)\n"), "libgcrypt",
-                 NEED_LIBGCRYPT_VERSION, gcry_check_version (NULL) );
-    }
-
   malloc_hooks.malloc = gcry_malloc;
   malloc_hooks.realloc = gcry_realloc;
   malloc_hooks.free = gcry_free;
diff --git a/agent/protect-tool.c b/agent/protect-tool.c
index c2bf87d..f41cc0b 100644
--- a/agent/protect-tool.c
+++ b/agent/protect-tool.c
@@ -566,16 +566,9 @@ main (int argc, char **argv )
   i18n_init ();
   init_common_subsystems (&argc, &argv);
 
-  if (!gcry_check_version (NEED_LIBGCRYPT_VERSION) )
-    {
-      log_fatal( _("%s is too old (need %s, have %s)\n"), "libgcrypt",
-                 NEED_LIBGCRYPT_VERSION, gcry_check_version (NULL) );
-    }
-
   setup_libgcrypt_logging ();
   gcry_control (GCRYCTL_INIT_SECMEM, 16384, 0);
 
-
   pargs.argc = &argc;
   pargs.argv = &argv;
   pargs.flags=  1;  /* (do not remove the args) */
diff --git a/common/init.c b/common/init.c
index c406ffe..591c854 100644
--- a/common/init.c
+++ b/common/init.c
@@ -47,7 +47,9 @@
 # include <assuan.h> /* For _assuan_w32ce_finish_pipe. */
 #endif
 
+#include <gcrypt.h>
 #include "util.h"
+#include "i18n.h"
 
 /* This object is used to register memory cleanup functions.
    Technically they are not needed but they can avoid frequent
@@ -186,6 +188,12 @@ _init_common_subsystems (gpg_err_source_t errsource, int *argcp, char ***argvp)
   atexit (sleep_on_exit);
 #endif
 
+  if (!gcry_check_version (NEED_LIBGCRYPT_VERSION))
+    {
+      log_fatal (_("%s is too old (need %s, have %s)\n"), "libgcrypt",
+                 NEED_LIBGCRYPT_VERSION, gcry_check_version (NULL));
+    }
+
   /* Initialize the Estream library. */
   gpgrt_init ();
   gpgrt_set_alloc_func (gcry_realloc);
diff --git a/dirmngr/Makefile.am b/dirmngr/Makefile.am
index aaa9050..64bc058 100644
--- a/dirmngr/Makefile.am
+++ b/dirmngr/Makefile.am
@@ -94,8 +94,8 @@ dirmngr_ldap_SOURCES = dirmngr_ldap.c $(ldap_url)
 dirmngr_ldap_CFLAGS = $(GPG_ERROR_CFLAGS) $(LIBGCRYPT_CFLAGS)
 dirmngr_ldap_LDFLAGS =
 dirmngr_ldap_LDADD = $(libcommon) no-libgcrypt.o \
-		     $(GPG_ERROR_LIBS) $(LDAPLIBS) $(LBER_LIBS) $(LIBINTL) \
-		     $(LIBICONV)
+		     $(GPG_ERROR_LIBS) $(LIBGCRYPT_LIBS) $(LDAPLIBS) \
+		     $(LBER_LIBS) $(LIBINTL) $(LIBICONV)
 endif
 
 dirmngr_client_SOURCES = dirmngr-client.c
diff --git a/dirmngr/dirmngr.c b/dirmngr/dirmngr.c
index 7e629db..007fa10 100644
--- a/dirmngr/dirmngr.c
+++ b/dirmngr/dirmngr.c
@@ -755,10 +755,6 @@ main (int argc, char **argv)
 
  /* Check that the libraries are suitable.  Do it here because
     the option parsing may need services of the libraries. */
-
-  if (!gcry_check_version (NEED_LIBGCRYPT_VERSION) )
-    log_fatal (_("%s is too old (need %s, have %s)\n"), "libgcrypt",
-               NEED_LIBGCRYPT_VERSION, gcry_check_version (NULL) );
   if (!ksba_check_version (NEED_KSBA_VERSION) )
     log_fatal( _("%s is too old (need %s, have %s)\n"), "libksba",
                NEED_KSBA_VERSION, ksba_check_version (NULL) );
diff --git a/g10/gpg.c b/g10/gpg.c
index b33b61b..91f3472 100644
--- a/g10/gpg.c
+++ b/g10/gpg.c
@@ -2201,14 +2201,6 @@ main (int argc, char **argv)
     i18n_init();
     init_common_subsystems (&argc, &argv);
 
-    /* Check that the libraries are suitable.  Do it right here because the
-       option parsing may need services of the library.  */
-    if (!gcry_check_version (NEED_LIBGCRYPT_VERSION) )
-      {
-        log_fatal ( _("libgcrypt is too old (need %s, have %s)\n"),
-                    NEED_LIBGCRYPT_VERSION, gcry_check_version (NULL) );
-      }
-
     /* Use our own logging handler for Libcgrypt.  */
     setup_libgcrypt_logging ();
 
diff --git a/g10/gpgv.c b/g10/gpgv.c
index 59edbb9..729fcf8 100644
--- a/g10/gpgv.c
+++ b/g10/gpgv.c
@@ -155,11 +155,6 @@ main( int argc, char **argv )
   i18n_init();
   init_common_subsystems (&argc, &argv);
 
-  if (!gcry_check_version (NEED_LIBGCRYPT_VERSION) )
-    {
-      log_fatal ( _("%s is too old (need %s, have %s)\n"), "libgcrypt",
-                  NEED_LIBGCRYPT_VERSION, gcry_check_version (NULL) );
-    }
   gcry_control (GCRYCTL_DISABLE_SECMEM, 0);
 
   gnupg_init_signals (0, NULL);
diff --git a/g13/g13-syshelp.c b/g13/g13-syshelp.c
index f3c20f5..0bb34da 100644
--- a/g13/g13-syshelp.c
+++ b/g13/g13-syshelp.c
@@ -250,11 +250,6 @@ main ( int argc, char **argv)
   i18n_init ();
   init_common_subsystems (&argc, &argv);
 
-  /* Check that the Libgcrypt is suitable.  */
-  if (!gcry_check_version (NEED_LIBGCRYPT_VERSION) )
-    log_fatal (_("%s is too old (need %s, have %s)\n"), "libgcrypt",
-               NEED_LIBGCRYPT_VERSION, gcry_check_version (NULL) );
-
   /* Take extra care of the random pool.  */
   gcry_control (GCRYCTL_USE_SECURE_RNDPOOL);
 
diff --git a/g13/g13.c b/g13/g13.c
index 0499a18..082edc9 100644
--- a/g13/g13.c
+++ b/g13/g13.c
@@ -372,11 +372,6 @@ main ( int argc, char **argv)
 
   npth_init ();
 
-  /* Check that the Libgcrypt is suitable.  */
-  if (!gcry_check_version (NEED_LIBGCRYPT_VERSION) )
-    log_fatal (_("%s is too old (need %s, have %s)\n"), "libgcrypt",
-               NEED_LIBGCRYPT_VERSION, gcry_check_version (NULL) );
-
   /* Take extra care of the random pool.  */
   gcry_control (GCRYCTL_USE_SECURE_RNDPOOL);
 
diff --git a/kbx/kbxutil.c b/kbx/kbxutil.c
index d55a118..e452b4d 100644
--- a/kbx/kbxutil.c
+++ b/kbx/kbxutil.c
@@ -460,14 +460,6 @@ main( int argc, char **argv )
   i18n_init ();
   init_common_subsystems (&argc, &argv);
 
-  /* Check that the libraries are suitable.  Do it here because
-     the option parsing may need services of the library.  */
-  if (!gcry_check_version (NEED_LIBGCRYPT_VERSION) )
-    {
-      log_fatal (_("%s is too old (need %s, have %s)\n"), "libgcrypt",
-                 NEED_LIBGCRYPT_VERSION, gcry_check_version (NULL) );
-    }
-
   gcry_set_log_handler (my_gcry_logger, NULL);
 
   /*create_dotlock(NULL); register locking cleanup */
diff --git a/scd/scdaemon.c b/scd/scdaemon.c
index 7dbb9c7..263d9bd 100644
--- a/scd/scdaemon.c
+++ b/scd/scdaemon.c
@@ -424,14 +424,6 @@ main (int argc, char **argv )
 
   npth_init ();
 
-  /* Check that the libraries are suitable.  Do it here because
-     the option parsing may need services of the library */
-  if (!gcry_check_version (NEED_LIBGCRYPT_VERSION) )
-    {
-      log_fatal (_("%s is too old (need %s, have %s)\n"), "libgcrypt",
-                 NEED_LIBGCRYPT_VERSION, gcry_check_version (NULL) );
-    }
-
   ksba_set_malloc_hooks (gcry_malloc, gcry_realloc, gcry_free);
 
   malloc_hooks.malloc = gcry_malloc;
diff --git a/sm/gpgsm.c b/sm/gpgsm.c
index b64072e..42b6706 100644
--- a/sm/gpgsm.c
+++ b/sm/gpgsm.c
@@ -938,9 +938,6 @@ main ( int argc, char **argv)
 
   /* Check that the libraries are suitable.  Do it here because the
      option parse may need services of the library */
-  if (!gcry_check_version (NEED_LIBGCRYPT_VERSION) )
-    log_fatal (_("%s is too old (need %s, have %s)\n"), "libgcrypt",
-               NEED_LIBGCRYPT_VERSION, gcry_check_version (NULL) );
   if (!ksba_check_version (NEED_KSBA_VERSION) )
     log_fatal (_("%s is too old (need %s, have %s)\n"), "libksba",
                NEED_KSBA_VERSION, ksba_check_version (NULL) );
diff --git a/tools/gpg-check-pattern.c b/tools/gpg-check-pattern.c
index 37283a1..aa228a7 100644
--- a/tools/gpg-check-pattern.c
+++ b/tools/gpg-check-pattern.c
@@ -171,13 +171,6 @@ main (int argc, char **argv )
   i18n_init ();
   init_common_subsystems (&argc, &argv);
 
-  /* We need Libgcrypt for hashing.  */
-  if (!gcry_check_version (NEED_LIBGCRYPT_VERSION) )
-    {
-      log_fatal ( _("%s is too old (need %s, have %s)\n"), "libgcrypt",
-                  NEED_LIBGCRYPT_VERSION, gcry_check_version (NULL) );
-    }
-
   setup_libgcrypt_logging ();
   gcry_control (GCRYCTL_INIT_SECMEM, 4096, 0);
 
diff --git a/tools/symcryptrun.c b/tools/symcryptrun.c
index 3732b39..5c1f0da 100644
--- a/tools/symcryptrun.c
+++ b/tools/symcryptrun.c
@@ -998,11 +998,6 @@ main (int argc, char **argv)
     log_set_file (logfile);
 
   gcry_control (GCRYCTL_SUSPEND_SECMEM_WARN);
-  if (!gcry_check_version (NEED_LIBGCRYPT_VERSION) )
-    {
-      log_fatal (_("%s is too old (need %s, have %s)\n"), "libgcrypt",
-                 NEED_LIBGCRYPT_VERSION, gcry_check_version (NULL) );
-    }
   setup_libgcrypt_logging ();
   gcry_control (GCRYCTL_INIT_SECMEM, 16384, 0);
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-gnupg/gnupg2.git



More information about the Pkg-gnupg-commit mailing list