[svn] GnuPG - r5499 - in trunk: . dirmngr tools

svn author wk cvs at cvs.gnupg.org
Tue Dec 14 20:17:59 CET 2010


Author: wk
Date: 2010-12-14 20:17:58 +0100 (Tue, 14 Dec 2010)
New Revision: 5499

Modified:
   trunk/ChangeLog
   trunk/NEWS
   trunk/configure.ac
   trunk/dirmngr/ChangeLog
   trunk/dirmngr/cdb.h
   trunk/dirmngr/cdblib.c
   trunk/dirmngr/crlcache.c
   trunk/tools/ChangeLog
   trunk/tools/gpgconf-comp.c
Log:
Tweaks for gpgconf.
Fixed dirmngr bug 1010.


Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2010-12-14 12:10:28 UTC (rev 5498)
+++ trunk/ChangeLog	2010-12-14 19:17:58 UTC (rev 5499)
@@ -1,3 +1,9 @@
+2010-12-14  Werner Koch  <wk at g10code.com>
+
+	* configure.ac (BUILD_WITH_GPG, BUILD_WITH_GPGSM)
+	(BUILD_WITH_AGENT, BUILD_WITH_SCDAEMON, BUILD_WITH_DIRMNGR)
+	(BUILD_WITH_G13): New defines.
+
 2010-11-23  Werner Koch  <wk at g10code.com>
 
 	* am/cmacros.am (extra_bin_ldflags): New.  For W32CE set the stack

Modified: trunk/dirmngr/ChangeLog
===================================================================
--- trunk/dirmngr/ChangeLog	2010-12-14 12:10:28 UTC (rev 5498)
+++ trunk/dirmngr/ChangeLog	2010-12-14 19:17:58 UTC (rev 5499)
@@ -1,5 +1,12 @@
 2010-12-14  Werner Koch  <wk at g10code.com>
 
+	* cdb.h (struct cdb) [W32]: Add field CDB_MAPPING.
+	* cdblib.c (cdb_init) [W32]: Save mapping handle.
+	(cdb_free) [W32]: Don't leak the mapping handle from cdb_init by
+	using the saved one.
+
+	* crlcache.c (crl_cache_insert): Close unused matching files.
+
 	* dirmngr.c (main) [W32CE]: Change homedir in daemon mode to /gnupg.
 
 2010-12-07  Werner Koch  <wk at g10code.com>

Modified: trunk/tools/ChangeLog
===================================================================
--- trunk/tools/ChangeLog	2010-12-14 12:10:28 UTC (rev 5498)
+++ trunk/tools/ChangeLog	2010-12-14 19:17:58 UTC (rev 5499)
@@ -1,3 +1,9 @@
+2010-12-14  Werner Koch  <wk at g10code.com>
+
+	* gpgconf-comp.c (gc_options_gpg_agent, gc_options_scdaemon)
+	(gc_options_gpg, gc_options_gpgsm, gc_options_dirmngr): Define to
+	NULL if corresponding BUILD_WITH_foo is not defined.
+
 2010-12-02  Werner Koch  <wk at g10code.com>
 
 	* no-libgcrypt.c (gcry_cipher_algo_name): New.

Modified: trunk/NEWS
===================================================================
--- trunk/NEWS	2010-12-14 12:10:28 UTC (rev 5498)
+++ trunk/NEWS	2010-12-14 19:17:58 UTC (rev 5499)
@@ -12,7 +12,9 @@
    these tools are written robust enough to accept this new algorithm
    name as well.
 
+ * Fixed CRL loading under W32 (bug#1010).
 
+
 Noteworthy changes in version 2.1.0beta1 (2010-10-26)
 -----------------------------------------------------
 

Modified: trunk/configure.ac
===================================================================
--- trunk/configure.ac	2010-12-14 12:10:28 UTC (rev 5498)
+++ trunk/configure.ac	2010-12-14 19:17:58 UTC (rev 5499)
@@ -1523,7 +1523,9 @@
   build_doc=no
 fi
 
-
+#
+# Set variables for use by th automake makefile.
+#
 AM_CONDITIONAL(BUILD_GPG,         test "$build_gpg" = "yes")
 AM_CONDITIONAL(BUILD_GPGSM,       test "$build_gpgsm" = "yes")
 AM_CONDITIONAL(BUILD_AGENT,       test "$build_agent" = "yes")
@@ -1538,7 +1540,30 @@
 AM_CONDITIONAL(RUN_GPG_TESTS,
                test x$cross_compiling = xno -a "$build_gpg" = yes )
 
+# 
+# Set some defines for use gpgconf.
+#
+if test "$build_gpg" = yes ; then
+    AC_DEFINE(BUILD_WITH_GPG,1,[Defined if GPG is to be build])
+fi
+if test "$build_gpgsm" = yes ; then
+    AC_DEFINE(BUILD_WITH_GPGSM,1,[Defined if GPGSM is to be build])
+fi
+if test "$build_agent" = yes ; then
+    AC_DEFINE(BUILD_WITH_AGENT,1,[Defined if GPG-AGENT is to be build])
+fi
+if test "$build_scdaemon" = yes ; then
+    AC_DEFINE(BUILD_WITH_SCDAEMON,1,[Defined if SCDAEMON is to be build])
+fi
+if test "$build_dirmngr" = yes ; then
+    AC_DEFINE(BUILD_WITH_DIRMNGR,1,[Defined if SCDAEMON is to be build])
+fi
+if test "$build_g13" = yes ; then
+    AC_DEFINE(BUILD_WITH_G13,1,[Defined if G13 is to be build])
+fi
 
+
+
 #
 # Print errors here so that they are visible all
 # together and the user can acquire them all together.

Modified: trunk/dirmngr/cdb.h
===================================================================
--- trunk/dirmngr/cdb.h	2010-12-14 12:10:28 UTC (rev 5498)
+++ trunk/dirmngr/cdb.h	2010-12-14 19:17:58 UTC (rev 5499)
@@ -20,6 +20,9 @@
 struct cdb {
   int cdb_fd;			/* file descriptor */
   /* private members */
+#ifdef HAVE_W32_SYSTEM
+  void *cdb_mapping;            /* Mapping handle.  */
+#endif
   cdbi_t cdb_fsize;		/* datafile size */
   const unsigned char *cdb_mem; /* mmap'ed file memory */
   cdbi_t cdb_vpos, cdb_vlen;	/* found data */

Modified: trunk/dirmngr/cdblib.c
===================================================================
--- trunk/dirmngr/cdblib.c	2010-12-14 12:10:28 UTC (rev 5498)
+++ trunk/dirmngr/cdblib.c	2010-12-14 19:17:58 UTC (rev 5499)
@@ -135,7 +135,7 @@
   hFile = fd;
 # else
   hFile = (HANDLE) _get_osfhandle(fd);
-#endif
+# endif
   if (hFile == (HANDLE) -1)
     return -1;
   hMapping = CreateFileMapping(hFile, NULL, PAGE_READONLY, 0, 0, NULL);
@@ -144,6 +144,7 @@
   mem = (unsigned char *)MapViewOfFile(hMapping, FILE_MAP_READ, 0, 0, 0);
   if (!mem)
     return -1;
+  cdbp->cdb_mapping = hMapping;
 #else
   mem = (unsigned char*)mmap(NULL, fsize, PROT_READ, MAP_SHARED, fd, 0);
   if (mem == MAP_FAILED)
@@ -180,18 +181,10 @@
 {
   if (cdbp->cdb_mem) {
 #ifdef _WIN32
-    HANDLE hFile, hMapping;
-#endif
-#ifdef _WIN32
-#ifdef __MINGW32CE__
-    hFile = cdbp->cdb_fd;
+    UnmapViewOfFile ((void*) cdbp->cdb_mem);
+    CloseHandle (cdbp->cdb_mapping);
+    cdbp->cdb_mapping = NULL;
 #else
-    hFile = (HANDLE) _get_osfhandle(cdbp->cdb_fd);
-#endif
-    hMapping = CreateFileMapping(hFile, NULL, PAGE_READONLY, 0, 0, NULL);
-    UnmapViewOfFile((void*) cdbp->cdb_mem);
-    CloseHandle(hMapping);
-#else
     munmap((void*)cdbp->cdb_mem, cdbp->cdb_fsize);
 #endif /* _WIN32 */
     cdbp->cdb_mem = NULL;

Modified: trunk/dirmngr/crlcache.c
===================================================================
--- trunk/dirmngr/crlcache.c	2010-12-14 12:10:28 UTC (rev 5498)
+++ trunk/dirmngr/crlcache.c	2010-12-14 19:17:58 UTC (rev 5499)
@@ -178,7 +178,7 @@
 
 
 
-/* The currently loaded cache object.  This isi usually initialized
+/* The currently loaded cache object.  This is usually initialized
    right at startup.  */
 static crl_cache_t current_cache;
 
@@ -393,7 +393,7 @@
     {
       entry2 = entry->next;
       release_one_cache_entry (entry);
-  }
+    }
   cache->entries = NULL;
   xfree (cache);
 }
@@ -1189,6 +1189,7 @@
         cache->entries = enext;
       else
         eprev->next = enext;
+      /* FIXME: Do we leak ENTRY? */
     }
 }
 
@@ -1204,7 +1205,6 @@
 }
 
 
-
 /* Create a new CRL cache. This fucntion is usually called only once.
    never fail. */
 void
@@ -2177,6 +2177,31 @@
   newfname = make_db_file_name (entry->issuer_hash);
   if (opt.verbose)
     log_info (_("creating cache file `%s'\n"), newfname);
+
+  /* Just in case close unused matching files.  Actually we need this
+     only under Windows but saving file descriptors is never bad.  */
+  {
+    int any;
+    do 
+      {
+        any = 0;
+        for (e = cache->entries; e; e = e->next)
+          if (!e->cdb_use_count && e->cdb
+              && !strcmp (e->issuer_hash, entry->issuer_hash))
+            {
+              int fd = cdb_fileno (e->cdb);
+              cdb_free (e->cdb);
+              xfree (e->cdb);
+              e->cdb = NULL;
+              if (close (fd))
+                log_error (_("error closing cache file: %s\n"),
+                           strerror(errno));
+              any = 1;
+              break;
+            }
+      }
+    while (any);
+  }
 #ifdef HAVE_W32_SYSTEM
   gnupg_remove (newfname);
 #endif

Modified: trunk/tools/gpgconf-comp.c
===================================================================
--- trunk/tools/gpgconf-comp.c	2010-12-14 12:10:28 UTC (rev 5498)
+++ trunk/tools/gpgconf-comp.c	2010-12-14 19:17:58 UTC (rev 5499)
@@ -51,7 +51,6 @@
 #include "gc-opt-flags.h"
 #include "gpgconf.h"
 
-
 /* There is a problem with gpg 1.4 under Windows: --gpgconf-list
    returns a plain filename without escaping.  As long as we have not
    fixed that we need to use gpg2.  */
@@ -467,6 +466,9 @@
 #define GC_OPTION_NULL { NULL }
 
 
+#ifndef BUILD_WITH_AGENT
+#define gc_options_gpg_agent NULL
+#else
 /* The options of the GC_COMPONENT_GPG_AGENT component.  */
 static gc_option_t gc_options_gpg_agent[] =
  {
@@ -569,8 +571,12 @@
 
    GC_OPTION_NULL
  };
+#endif /*BUILD_WITH_AGENT*/
 
 
+#ifndef BUILD_WITH_SCDAEMON
+#define gc_options_scdaemon NULL
+#else
 /* The options of the GC_COMPONENT_SCDAEMON component.  */
 static gc_option_t gc_options_scdaemon[] =
  {
@@ -636,8 +642,11 @@
 
    GC_OPTION_NULL
  };
+#endif /*BUILD_WITH_SCDAEMON*/
 
-
+#ifndef BUILD_WITH_GPG
+#define gc_options_gpg NULL
+#else
 /* The options of the GC_COMPONENT_GPG component.  */
 static gc_option_t gc_options_gpg[] =
  {
@@ -710,9 +719,12 @@
 
    GC_OPTION_NULL
  };
+#endif /*BUILD_WITH_GPG*/
 
 
-
+#ifndef BUILD_WITH_GPGSM
+#define gc_options_gpgsm NULL
+#else
 /* The options of the GC_COMPONENT_GPGSM component.  */
 static gc_option_t gc_options_gpgsm[] =
  {
@@ -802,8 +814,12 @@
 
    GC_OPTION_NULL
  };
+#endif /*BUILD_WITH_GPGSM*/
 
 
+#ifndef BUILD_WITH_DIRMNGR
+#define gc_options_dirmngr NULL
+#else
 /* The options of the GC_COMPONENT_DIRMNGR component.  */
 static gc_option_t gc_options_dirmngr[] =
  {
@@ -942,6 +958,7 @@
 
    GC_OPTION_NULL
  };
+#endif /*BUILD_WITH_DIRMNGR*/
 
 
 /* The options of the GC_COMPONENT_PINENTRY component.  */





More information about the Gnupg-commits mailing list