[svn] GnuPG - r5486 - in trunk: . agent am common dirmngr g10 sm tools

svn author wk cvs at cvs.gnupg.org
Tue Nov 23 19:46:44 CET 2010


Author: wk
Date: 2010-11-23 19:46:41 +0100 (Tue, 23 Nov 2010)
New Revision: 5486

Modified:
   trunk/ChangeLog
   trunk/NEWS
   trunk/agent/ChangeLog
   trunk/agent/Makefile.am
   trunk/am/cmacros.am
   trunk/common/ChangeLog
   trunk/common/asshelp.c
   trunk/dirmngr/ChangeLog
   trunk/dirmngr/Makefile.am
   trunk/g10/ChangeLog
   trunk/g10/Makefile.am
   trunk/g10/decrypt.c
   trunk/g10/options.h
   trunk/g10/plaintext.c
   trunk/sm/ChangeLog
   trunk/sm/Makefile.am
   trunk/tools/ChangeLog
   trunk/tools/Makefile.am
Log:
Change stack size for Wince.
Allow for a longer agent atartup under wince.
Print gpg output via estream.


Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2010-11-17 16:32:11 UTC (rev 5485)
+++ trunk/ChangeLog	2010-11-23 18:46:41 UTC (rev 5486)
@@ -1,3 +1,8 @@
+2010-11-23  Werner Koch  <wk at g10code.com>
+
+	* am/cmacros.am (extra_bin_ldflags): New.  For W32CE set the stack
+	size to 256k.
+
 2010-11-17  Werner Koch  <wk at g10code.com>
 
 	* configure.ac (ENABLE_CARD_SUPPORT): Define. 

Modified: trunk/agent/ChangeLog
===================================================================
--- trunk/agent/ChangeLog	2010-11-17 16:32:11 UTC (rev 5485)
+++ trunk/agent/ChangeLog	2010-11-23 18:46:41 UTC (rev 5486)
@@ -1,3 +1,7 @@
+2010-11-23  Werner Koch  <wk at g10code.com>
+
+	* Makefile.am (gpg_agent_LDFLAGS): Add extra_bin_ldflags.
+
 2010-11-11  Werner Koch  <wk at g10code.com>
 
 	* agent.h (opt): Add field SIGUSR2_ENABLED.

Modified: trunk/common/ChangeLog
===================================================================
--- trunk/common/ChangeLog	2010-11-17 16:32:11 UTC (rev 5485)
+++ trunk/common/ChangeLog	2010-11-23 18:46:41 UTC (rev 5486)
@@ -1,3 +1,10 @@
+2010-11-23  Werner Koch  <wk at g10code.com>
+
+	* asshelp.c (SECS_TO_WAIT_FOR_AGENT, SECS_TO_WAIT_FOR_DIRMNGR):
+	Use these constants.  For W32CE increase them to 30 seconds.
+	(start_new_gpg_agent): Print time to startup agent.
+	(start_new_dirmngr): Ditto.
+
 2010-11-04  Werner Koch  <wk at g10code.com>
 
 	* logging.c (do_logv) [W32]: Don't set a default log stream if the

Modified: trunk/dirmngr/ChangeLog
===================================================================
--- trunk/dirmngr/ChangeLog	2010-11-17 16:32:11 UTC (rev 5485)
+++ trunk/dirmngr/ChangeLog	2010-11-23 18:46:41 UTC (rev 5486)
@@ -1,3 +1,8 @@
+2010-11-23  Werner Koch  <wk at g10code.com>
+
+	* Makefile.am (dirmngr_LDFLAGS): Add extra_bin_ldflags.
+	(dirmngr_client_LDFLAGS): Ditto.
+
 2010-10-21  Werner Koch  <wk at g10code.com>
 
 	* dirmngr.c (main): Changed faked system time warning

Modified: trunk/g10/ChangeLog
===================================================================
--- trunk/g10/ChangeLog	2010-11-17 16:32:11 UTC (rev 5485)
+++ trunk/g10/ChangeLog	2010-11-23 18:46:41 UTC (rev 5486)
@@ -1,3 +1,13 @@
+2010-11-23  Werner Koch  <wk at g10code.com>
+
+	* Makefile.am (gpg2_LDFLAGS, gpgv2_LDFLAGS): Add extra_bin_ldflags.
+
+	* plaintext.c (handle_plaintext): Change to use estream.
+	s/rc/err/.  Replace some xmalloc by xtrymalloc.  Use more
+	gpg_strerror.
+	* options.h (struct): Change type of OUTFP to estream_t.
+	* decrypt.c (decrypt_message_fd): Adjust accordingly.
+
 2010-11-17  Werner Koch  <wk at g10code.com>
 
 	* keyedit.c (find_pk_from_sknode): Remove.

Modified: trunk/sm/ChangeLog
===================================================================
--- trunk/sm/ChangeLog	2010-11-17 16:32:11 UTC (rev 5485)
+++ trunk/sm/ChangeLog	2010-11-23 18:46:41 UTC (rev 5486)
@@ -1,3 +1,7 @@
+2010-11-23  Werner Koch  <wk at g10code.com>
+
+	* Makefile.am (gpgsm_LDADD): Add extra_bin_ldflags.
+
 2010-10-08  Werner Koch  <wk at g10code.com>
 
 	* gpgsm.c: Add option --with-keygrip.

Modified: trunk/tools/ChangeLog
===================================================================
--- trunk/tools/ChangeLog	2010-11-17 16:32:11 UTC (rev 5485)
+++ trunk/tools/ChangeLog	2010-11-23 18:46:41 UTC (rev 5486)
@@ -1,3 +1,7 @@
+2010-11-23  Werner Koch  <wk at g10code.com>
+
+	* Makefile.am (gpgconf_LDFLAGS): Add extra_bin_ldflags.
+
 2010-11-17  Marcus Brinkmann  <mb at g10code.com>
 
 	* gogconf.c: Revert accidental debug output commit.

Modified: trunk/NEWS
===================================================================
--- trunk/NEWS	2010-11-17 16:32:11 UTC (rev 5485)
+++ trunk/NEWS	2010-11-23 18:46:41 UTC (rev 5486)
@@ -4,7 +4,7 @@
  * TMPDIR is now also honored when creating a socket using
    --no-standard-socket and with symcryptrun's temp files.
 
- * Fixed a bug where Scdaemon sends a signal to Gpg-agent running in
+ * Fixed a bug where SCdaemon sends a signal to Gpg-agent running in
    non-daemon mode.
 
 

Modified: trunk/agent/Makefile.am
===================================================================
--- trunk/agent/Makefile.am	2010-11-17 16:32:11 UTC (rev 5485)
+++ trunk/agent/Makefile.am	2010-11-23 18:46:41 UTC (rev 5486)
@@ -75,7 +75,7 @@
 gpg_agent_LDADD = $(commonpth_libs) \
                 $(LIBGCRYPT_LIBS) $(LIBASSUAN_LIBS) $(PTH_LIBS) \
 	        $(GPG_ERROR_LIBS) $(LIBINTL) $(NETLIBS) $(LIBICONV)
-gpg_agent_LDFLAGS = $(gpg_agent_res_ldflags)
+gpg_agent_LDFLAGS = $(extra_bin_ldflags) $(gpg_agent_res_ldflags)
 gpg_agent_DEPENDENCIES = $(gpg_agent_res_deps)
 
 gpg_protect_tool_SOURCES = \

Modified: trunk/am/cmacros.am
===================================================================
--- trunk/am/cmacros.am	2010-11-17 16:32:11 UTC (rev 5485)
+++ trunk/am/cmacros.am	2010-11-23 18:46:41 UTC (rev 5486)
@@ -54,11 +54,15 @@
 
 # Under Windows we use LockFileEx.  WindowsCE provides this only on
 # the WindowsMobile 6 platform and thus we need to use the coredll6
-# import library.
+# import library.  We also want to use a stacksize of 256k instead of
+# the 2MB which is the default with cegcc.  256k is the largest stack
+# we use with pth.
 if HAVE_W32CE_SYSTEM
 extra_sys_libs = -lcoredll6
+extra_bin_ldflags = -Wl,--stack=0x40000 
 else
 extra_sys_libs = 
+extra_bin_ldflags = 
 endif
 
 

Modified: trunk/common/asshelp.c
===================================================================
--- trunk/common/asshelp.c	2010-11-17 16:32:11 UTC (rev 5485)
+++ trunk/common/asshelp.c	2010-11-23 18:46:41 UTC (rev 5486)
@@ -42,6 +42,15 @@
 # define lock_spawn_t dotlock_t
 #endif
 
+/* The time we wait until the agent or the dirmngr are ready for
+   operation after we started them before giving up.  */ 
+#ifdef HAVE_W32CE_SYSTEM
+# define SECS_TO_WAIT_FOR_AGENT 30
+# define SECS_TO_WAIT_FOR_DIRMNGR 30
+#else
+# define SECS_TO_WAIT_FOR_AGENT 5
+# define SECS_TO_WAIT_FOR_DIRMNGR 5
+#endif
 
 /* A bitfield that specifies the assuan categories to log.  This is
    identical to the default log handler of libassuan.  We need to do
@@ -335,6 +344,7 @@
   gpg_error_t err = 0;
   char *infostr, *p;
   assuan_context_t ctx;
+  int did_success_msg = 0;
 
   *r_ctx = NULL;
 
@@ -423,16 +433,19 @@
 
                       if (verbose)
                         log_info (_("waiting %d seconds for the agent "
-                                    "to come up\n"), 5);
-                      for (i=0; i < 5; i++)
+                                    "to come up\n"), SECS_TO_WAIT_FOR_AGENT);
+                      for (i=0; i < SECS_TO_WAIT_FOR_AGENT; i++)
                         {
                           gnupg_sleep (1);
                           err = assuan_socket_connect (ctx, sockname, 0, 0);
                           if (!err)
                             {
-                              if (verbose && !debug)
-                                log_info (_("connection to agent"
-                                            " established\n"));
+                              if (verbose)
+                                {
+                                  log_info (_("connection to agent "
+                                              "established (%ds)\n"), i+1);
+                                  did_success_msg = 1;
+                                }
                               break;
                             }
                         }
@@ -517,7 +530,7 @@
       return gpg_err_make (errsource, GPG_ERR_NO_AGENT);
     }
 
-  if (debug)
+  if (debug && !did_success_msg)
     log_debug (_("connection to agent established\n"));
 
   err = assuan_transact (ctx, "RESET",
@@ -552,6 +565,7 @@
   gpg_error_t err;
   assuan_context_t ctx;
   const char *sockname;
+  int did_success_msg = 0;
       
   *r_ctx = NULL;
 
@@ -612,16 +626,19 @@
               
               if (verbose)
                 log_info (_("waiting %d seconds for the dirmngr to come up\n"),
-                          5);
-              for (i=0; i < 5; i++)
+                          SECS_TO_WAIT_FOR_DIRMNGR);
+              for (i=0; i < SECS_TO_WAIT_FOR_DIRMNGR; i++)
                 {
                   gnupg_sleep (1);
                   err = assuan_socket_connect (ctx, sockname, 0, 0);
                   if (!err)
                     {
-                      if (verbose && !debug)
-                        log_info (_("connection to the dirmngr"
-                                     " established\n"));
+                      if (verbose)
+                        {
+                          log_info (_("connection to the dirmngr"
+                                      " established (%ds)\n"), i+1);
+                          did_success_msg = 1;
+                        }
                       break;
                     }
                 }
@@ -646,7 +663,7 @@
       return gpg_err_make (errsource, GPG_ERR_NO_DIRMNGR);
     }
 
-  if (debug)
+  if (debug && !did_success_msg)
     log_debug (_("connection to the dirmngr established\n"));
 
   *r_ctx = ctx;

Modified: trunk/dirmngr/Makefile.am
===================================================================
--- trunk/dirmngr/Makefile.am	2010-11-17 16:32:11 UTC (rev 5485)
+++ trunk/dirmngr/Makefile.am	2010-11-23 18:46:41 UTC (rev 5486)
@@ -63,8 +63,8 @@
 if !USE_LDAPWRAPPER
 dirmngr_LDADD += $(LDAPLIBS)
 endif
+dirmngr_LDFLAGS = $(extra_bin_ldflags)
 
-
 if USE_LDAPWRAPPER
 dirmngr_ldap_SOURCES = dirmngr_ldap.c $(ldap_url) 
 dirmngr_ldap_CFLAGS = $(GPG_ERROR_CFLAGS)
@@ -76,7 +76,9 @@
 dirmngr_client_SOURCES = dirmngr-client.c
 dirmngr_client_LDADD = $(libcommon) no-libgcrypt.o \
 	                ../gl/libgnu.a $(LIBASSUAN_LIBS) \
-	               $(GPG_ERROR_LIBS) $(LIBINTL) $(LIBICONV)
+	               $(GPG_ERROR_LIBS) $(LIBINTL) \
+                       $(LIBICONV)
+dirmngr_client_LDFLAGS = $(extra_bin_ldflags)
 
 
 no-libgcrypt.c : $(top_srcdir)/tools/no-libgcrypt.c

Modified: trunk/g10/Makefile.am
===================================================================
--- trunk/g10/Makefile.am	2010-11-17 16:32:11 UTC (rev 5485)
+++ trunk/g10/Makefile.am	2010-11-23 18:46:41 UTC (rev 5486)
@@ -123,8 +123,10 @@
          $(LIBINTL) $(CAPLIBS) $(NETLIBS)
 gpg2_LDADD =  $(LDADD) $(LIBGCRYPT_LIBS) $(LIBASSUAN_LIBS) $(GPG_ERROR_LIBS) \
 	     $(LIBICONV) $(extra_sys_libs)
+gpg2_LDFLAGS = $(extra_bin_ldflags)
 gpgv2_LDADD = $(LDADD) $(LIBGCRYPT_LIBS) $(LIBASSUAN_LIBS) $(GPG_ERROR_LIBS) \
 	      $(LIBICONV) $(extra_sys_libs)
+gpgv2_LDFLAGS = $(extra_bin_ldflags)
 
 t_common_ldadd = 
 module_tests = t-rmd160

Modified: trunk/g10/decrypt.c
===================================================================
--- trunk/g10/decrypt.c	2010-11-17 16:32:11 UTC (rev 5485)
+++ trunk/g10/decrypt.c	2010-11-23 18:46:41 UTC (rev 5486)
@@ -135,7 +135,7 @@
 #warning Need to fix this if we want to use g13
   opt.outfp = NULL;
 #else
-  opt.outfp = fdopen (dup (output_fd), "wb");
+  opt.outfp = es_fdopen_nc (output_fd, "wb");
 #endif
   if (!opt.outfp)
     {
@@ -161,7 +161,7 @@
   err = proc_encryption_packets (ctrl, NULL, fp );
 
   iobuf_close (fp);
-  fclose (opt.outfp);
+  es_fclose (opt.outfp);
   opt.outfp = NULL;
   release_armor_context (afx);
   release_progress_context (pfx);

Modified: trunk/g10/options.h
===================================================================
--- trunk/g10/options.h	2010-11-17 16:32:11 UTC (rev 5485)
+++ trunk/g10/options.h	2010-11-23 18:46:41 UTC (rev 5486)
@@ -43,7 +43,7 @@
   unsigned debug;
   int armor;
   char *outfile;
-  FILE *outfp;      /* Hack, sometimes used in place of outfile.  */
+  estream_t outfp;  /* Hack, sometimes used in place of outfile.  */
   off_t max_output;
   int dry_run;
   int list_only;

Modified: trunk/g10/plaintext.c
===================================================================
--- trunk/g10/plaintext.c	2010-11-17 16:32:11 UTC (rev 5485)
+++ trunk/g10/plaintext.c	2010-11-23 18:46:41 UTC (rev 5486)
@@ -49,9 +49,9 @@
 		  int nooutput, int clearsig)
 {
   char *fname = NULL;
-  FILE *fp = NULL;
+  estream_t fp = NULL;
   static off_t count = 0;
-  int rc = 0;
+  int err = 0;
   int c;
   int convert = (pt->mode == 't' || pt->mode == 'u');
 #ifdef __riscos__
@@ -69,7 +69,7 @@
          output will be written to it.  This is to make sure that no
          not-yet-flushed stuff will be written after the plaintext
          status message.  */
-      fflush (stdout);
+      es_fflush (es_stdout);
 
       snprintf (status, sizeof status, 
                 "%X %lu ", (byte) pt->mode, (ulong) pt->timestamp);
@@ -78,7 +78,7 @@
       
       if (!pt->is_partial)
 	{
-	  sprintf (status, "%lu", (ulong) pt->len);
+	  snprintf (status, sizeof status, "%lu", (ulong) pt->len);
 	  write_status_text (STATUS_PLAINTEXT_LENGTH, status);
 	}
     }
@@ -88,11 +88,21 @@
     ;
   else if (opt.outfp)
     {
-      fname = xstrdup ("[FP]");
+      fname = xtrystrdup ("[FP]");
+      if (!fname)
+        {
+          err = gpg_error_from_syserror ();
+          goto leave;
+        }
     }
   else if (opt.outfile)
     {
-      fname = xstrdup (opt.outfile);
+      fname = xtrystrdup (opt.outfile);
+      if (!fname)
+        {
+          err = gpg_error_from_syserror ();
+          goto leave;
+        }
     }
   else if (pt->namelen == 8 && !memcmp (pt->name, "_CONSOLE", 8))
     {
@@ -106,7 +116,7 @@
 	fname = ask_outfile_name (pt->name, pt->namelen);
       if (!fname)
 	{
-	  rc = gpg_error (GPG_ERR_GENERAL);	/* Can't create file. */
+	  err = gpg_error (GPG_ERR_GENERAL);	/* Can't create file. */
 	  goto leave;
 	}
     }
@@ -118,17 +128,13 @@
   else if (opt.outfp)
     {
       fp = opt.outfp;
-#ifdef HAVE_DOSISH_SYSTEM
-      setmode (fileno (fp), O_BINARY);
-#endif
+      es_set_binary (fp);
     }
   else if (iobuf_is_pipe_filename (fname) || !*fname)
     {
       /* No filename or "-" given; write to stdout. */
-      fp = stdout;
-#ifdef HAVE_DOSISH_SYSTEM
-      setmode (fileno (fp), O_BINARY);
-#endif
+      fp = es_stdout;
+      es_set_binary (fp);
     }
   else
     {
@@ -139,7 +145,7 @@
 	    {
 	      xfree (tmp);
               /* FIXME: Below used to be G10ERR_CREATE_FILE */
-	      rc = gpg_error (GPG_ERR_GENERAL);	
+	      err = gpg_error (GPG_ERR_GENERAL);	
 	      goto leave;
 	    }
 	  xfree (fname);
@@ -148,10 +154,10 @@
     }
   
 #ifndef __riscos__
-  if (opt.outfp && is_secured_file (fileno (opt.outfp)))
+  if (opt.outfp && is_secured_file (es_fileno (opt.outfp)))
     {
-      rc = gpg_error (GPG_ERR_EPERM);
-      log_error (_("error creating `%s': %s\n"), fname, gpg_strerror (rc));
+      err = gpg_error (GPG_ERR_EPERM);
+      log_error (_("error creating `%s': %s\n"), fname, gpg_strerror (err));
       goto leave;
     }
   else if (fp || nooutput)
@@ -159,14 +165,14 @@
   else if (is_secured_filename (fname))
     {
       gpg_err_set_errno (EPERM);
-      rc = gpg_error_from_syserror ();
-      log_error (_("error creating `%s': %s\n"), fname, strerror (errno));
+      err = gpg_error_from_syserror ();
+      log_error (_("error creating `%s': %s\n"), fname, gpg_strerror (err));
       goto leave;
     }
-  else if (!(fp = fopen (fname, "wb")))
+  else if (!(fp = es_fopen (fname, "wb")))
     {
-      rc = gpg_error_from_syserror ();
-      log_error (_("error creating `%s': %s\n"), fname, strerror (errno));
+      err = gpg_error_from_syserror ();
+      log_error (_("error creating `%s': %s\n"), fname, gpg_strerror (err));
       goto leave;
     }
 #else /* __riscos__ */
@@ -182,11 +188,15 @@
     ;
   else
     {
+      /* Note: riscos stuff is not expected to wrok anymore.  If we
+         want to port it again to riscos we should do most of the suff
+         in estream.  FIXME: Consider to remove all riscos special
+         cases.  */
       fp = fopen (fname, "wb");
       if (!fp)
 	{
-	  log_error (_("error creating `%s': %s\n"), fname, strerror (errno));
-	  rc = G10ERR_CREATE_FILE;
+	  log_error (_("error creating `%s': %s\n"), fname, gpg_strerror (err));
+	  err = G10ERR_CREATE_FILE;
 	  if (errno == 106)
 	    log_info ("Do output file and input file have the same name?\n");
 	  goto leave;
@@ -210,7 +220,7 @@
       if (clearsig)
 	{
 	  log_error ("clearsig encountered while not expected\n");
-	  rc = G10ERR_UNEXPECTED;
+	  err = gpg_error (GPG_ERR_UNEXPECTED);
 	  goto leave;
 	}
 
@@ -220,7 +230,7 @@
 	    {
 	      if ((c = iobuf_get (pt->buf)) == -1)
 		{
-		  rc = gpg_error_from_syserror ();
+		  err = gpg_error_from_syserror ();
 		  log_error ("problem reading source (%u bytes remaining)\n",
 			     (unsigned) pt->len);
 		  goto leave;
@@ -237,17 +247,17 @@
 		    {
 		      log_error ("error writing to `%s': %s\n",
 				 fname, "exceeded --max-output limit\n");
-		      rc = gpg_error (GPG_ERR_TOO_LARGE);
+		      err = gpg_error (GPG_ERR_TOO_LARGE);
 		      goto leave;
 		    }
-		  else if (putc (c, fp) == EOF)
+		  else if (es_putc (c, fp) == EOF)
 		    {
-		      if (ferror (fp))
-			rc = gpg_error_from_syserror ();
+		      if (es_ferror (fp))
+			err = gpg_error_from_syserror ();
 		      else
-			rc = gpg_error (GPG_ERR_EOF);
+			err = gpg_error (GPG_ERR_EOF);
 		      log_error ("error writing to `%s': %s\n",
-				 fname, strerror (errno));
+				 fname, gpg_strerror (err));
 		      goto leave;
 		    }
 		}
@@ -262,7 +272,7 @@
 	      len = iobuf_read (pt->buf, buffer, len);
 	      if (len == -1)
 		{
-		  rc = gpg_error_from_syserror ();
+		  err = gpg_error_from_syserror ();
 		  log_error ("problem reading source (%u bytes remaining)\n",
 			     (unsigned) pt->len);
 		  xfree (buffer);
@@ -276,15 +286,15 @@
 		    {
 		      log_error ("error writing to `%s': %s\n",
 				 fname, "exceeded --max-output limit\n");
-		      rc = gpg_error (GPG_ERR_TOO_LARGE);
+		      err = gpg_error (GPG_ERR_TOO_LARGE);
 		      xfree (buffer);
 		      goto leave;
 		    }
-		  else if (fwrite (buffer, 1, len, fp) != len)
+		  else if (es_fwrite (buffer, 1, len, fp) != len)
 		    {
-		      rc = gpg_error_from_syserror ();
+		      err = gpg_error_from_syserror ();
 		      log_error ("error writing to `%s': %s\n",
-				 fname, strerror (errno));
+				 fname, gpg_strerror (err));
 		      xfree (buffer);
 		      goto leave;
 		    }
@@ -312,17 +322,17 @@
 		    {
 		      log_error ("Error writing to `%s': %s\n",
 				 fname, "exceeded --max-output limit\n");
-		      rc = gpg_error (GPG_ERR_TOO_LARGE);
+		      err = gpg_error (GPG_ERR_TOO_LARGE);
 		      goto leave;
 		    }
-		  else if (putc (c, fp) == EOF)
+		  else if (es_putc (c, fp) == EOF)
 		    {
-		      if (ferror (fp))
-			rc = gpg_error_from_syserror ();
+		      if (es_ferror (fp))
+			err = gpg_error_from_syserror ();
 		      else
-			rc = gpg_error (GPG_ERR_EOF);
+			err = gpg_error (GPG_ERR_EOF);
 		      log_error ("error writing to `%s': %s\n",
-				 fname, strerror (errno));
+				 fname, gpg_strerror (err));
 		      goto leave;
 		    }
 		}
@@ -330,9 +340,16 @@
 	}
       else
 	{			/* binary mode */
-	  byte *buffer = xmalloc (32768);
+	  byte *buffer;
 	  int eof_seen = 0;
 
+          buffer = xtrymalloc (32768);
+          if (!buffer)
+            {
+              err = gpg_error_from_syserror ();
+              goto leave;
+            }
+
 	  while (!eof_seen)
 	    {
 	      /* Why do we check for len < 32768:
@@ -354,16 +371,15 @@
 		    {
 		      log_error ("error writing to `%s': %s\n",
 				 fname, "exceeded --max-output limit\n");
-		      rc = gpg_error (GPG_ERR_TOO_LARGE);
+		      err = gpg_error (GPG_ERR_TOO_LARGE);
 		      xfree (buffer);
 		      goto leave;
 		    }
-		  else if (fwrite (buffer, 1, len, fp) != len)
+		  else if (es_fwrite (buffer, 1, len, fp) != len)
 		    {
-		      rc = (errno ? gpg_error_from_syserror ()
-			    : gpg_error (GPG_ERR_INTERNAL));
+		      err = gpg_error_from_syserror ();
 		      log_error ("error writing to `%s': %s\n",
-				 fname, strerror (errno));
+				 fname, gpg_strerror (err));
 		      xfree (buffer);
 		      goto leave;
 		    }
@@ -385,15 +401,14 @@
 		{
 		  log_error ("error writing to `%s': %s\n",
 			     fname, "exceeded --max-output limit\n");
-		  rc = gpg_error (GPG_ERR_TOO_LARGE);
+		  err = gpg_error (GPG_ERR_TOO_LARGE);
 		  goto leave;
 		}
-	      else if (putc (c, fp) == EOF)
+	      else if (es_putc (c, fp) == EOF)
 		{
-		  rc = (errno ? gpg_error_from_syserror ()
-			: gpg_error (GPG_ERR_INTERNAL));
+		  err = gpg_error_from_syserror ();
 		  log_error ("error writing to `%s': %s\n",
-			     fname, strerror (errno));
+			     fname, gpg_strerror (err));
 		  goto leave;
 		}
 	    }
@@ -434,11 +449,10 @@
       pt->buf = NULL;
     }
 
-  if (fp && fp != stdout && fp != opt.outfp && fclose (fp))
+  if (fp && fp != es_stdout && fp != opt.outfp && es_fclose (fp))
     {
-      rc = (errno ? gpg_error_from_syserror ()
-	    : gpg_error (GPG_ERR_INTERNAL));
-      log_error ("error closing `%s': %s\n", fname, strerror (errno));
+      err = gpg_error_from_syserror ();
+      log_error ("error closing `%s': %s\n", fname, gpg_strerror (err));
       fp = NULL;
       goto leave;
     }
@@ -448,20 +462,21 @@
   /* Make sure that stdout gets flushed after the plaintext has been
      handled.  This is for extra security as we do a flush anyway
      before checking the signature.  */
-  if (fflush (stdout))
+  if (es_fflush (es_stdout))
     {
       /* We need to check the return code to detect errors like disk
          full for short plaintexts.  See bug#1207.  Checking return
          values is a good idea in any case.  */
-      if (!rc)
-        rc = gpg_error_from_syserror ();
-      log_error ("error flushing `%s': %s\n", "[stdout]", strerror (errno));
+      if (!err)
+        err = gpg_error_from_syserror ();
+      log_error ("error flushing `%s': %s\n", "[stdout]",
+                 gpg_strerror (err));
     }
 
-  if (fp && fp != stdout && fp != opt.outfp)
-    fclose (fp);
+  if (fp && fp != es_stdout && fp != opt.outfp)
+    es_fclose (fp);
   xfree (fname);
-  return rc;
+  return err;
 }
 
 

Modified: trunk/sm/Makefile.am
===================================================================
--- trunk/sm/Makefile.am	2010-11-17 16:32:11 UTC (rev 5485)
+++ trunk/sm/Makefile.am	2010-11-23 18:46:41 UTC (rev 5486)
@@ -59,6 +59,7 @@
               $(LIBGCRYPT_LIBS) $(KSBA_LIBS) $(LIBASSUAN_LIBS) \
               $(GPG_ERROR_LIBS) $(LIBREADLINE) $(LIBINTL) $(ZLIBS) \
 	      $(LIBICONV) $(extra_sys_libs)
+gpgsm_LDFLAGS = $(extra_bin_ldflags)
 
 # Make sure that all libs are build before we use them.  This is
 # important for things like make -j2.

Modified: trunk/tools/Makefile.am
===================================================================
--- trunk/tools/Makefile.am	2010-11-17 16:32:11 UTC (rev 5485)
+++ trunk/tools/Makefile.am	2010-11-23 18:46:41 UTC (rev 5486)
@@ -96,6 +96,7 @@
 gpgconf_LDADD = $(maybe_commonpth_libs) $(opt_libassuan_libs) \
                 $(LIBINTL) $(GPG_ERROR_LIBS) $(PTH_LIBS) $(NETLIBS) \
 	        $(LIBICONV) $(W32SOCKLIBS)
+gpgconf_LDFLAGS = $(extra_bin_ldflags)
 
 gpgparsemail_SOURCES = gpgparsemail.c rfc822parse.c rfc822parse.h
 gpgparsemail_LDADD = 





More information about the Gnupg-commits mailing list