[svn] gpgme - r1278 - in trunk: . assuan gpgme tests/gpgsm

svn author wk cvs at cvs.gnupg.org
Thu Nov 22 17:44:52 CET 2007


Author: wk
Date: 2007-11-22 17:44:37 +0100 (Thu, 22 Nov 2007)
New Revision: 1278

Added:
   trunk/gpgme/getauditlog.c
Modified:
   trunk/AUTHORS
   trunk/NEWS
   trunk/assuan/assuan-buffer.c
   trunk/assuan/mkerrors
   trunk/gpgme/ChangeLog
   trunk/gpgme/Makefile.am
   trunk/gpgme/engine-backend.h
   trunk/gpgme/engine-gpgsm.c
   trunk/gpgme/engine.c
   trunk/gpgme/engine.h
   trunk/gpgme/gpgme.def
   trunk/gpgme/gpgme.h
   trunk/gpgme/libgpgme.vers
   trunk/gpgme/rungpg.c
   trunk/tests/gpgsm/t-verify.c
Log:
New API gpgme_op_getauditlog.


Modified: trunk/AUTHORS
===================================================================
--- trunk/AUTHORS	2007-11-20 10:40:41 UTC (rev 1277)
+++ trunk/AUTHORS	2007-11-22 16:44:37 UTC (rev 1278)
@@ -2,6 +2,7 @@
 Maintainer: Marcus Brinkmann <marcus at g10code.com>
 Bug reports: bug-gpgme at gnupg.org
 Security related bug reports: security at gnupg.org
+License: LGPLv2.1+
 
 
 FSF <gnu at gnu.org>

Modified: trunk/NEWS
===================================================================
--- trunk/NEWS	2007-11-20 10:40:41 UTC (rev 1277)
+++ trunk/NEWS	2007-11-22 16:44:37 UTC (rev 1278)
@@ -6,6 +6,10 @@
  * Interface changes relative to the 1.1.1 release:
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  gpgme_signature_t               EXTENDED: New field chain_model.
+ gpgme_op_getauditlog_start      NEW.
+ gpgme_op_getauditlog            NEW.
+ GPGME_AUDITLOG_HTML             NEW.
+ GPGME_AUDITLOG_WITH_HELP        NEW.
 
 
 Noteworthy changes in version 1.1.5 (2007-07-09)
@@ -1192,7 +1196,7 @@
  * Made the W32 support more robust.
 
 
- Copyright 2001, 2002, 2003, 2004, 2005 g10 Code GmbH
+ Copyright 2001, 2002, 2003, 2004, 2005, 2007 g10 Code GmbH
 
  This file is free software; as a special exception the author gives
  unlimited permission to copy and/or distribute it, with or without

Modified: trunk/assuan/assuan-buffer.c
===================================================================
--- trunk/assuan/assuan-buffer.c	2007-11-20 10:40:41 UTC (rev 1277)
+++ trunk/assuan/assuan-buffer.c	2007-11-22 16:44:37 UTC (rev 1278)
@@ -135,10 +135,10 @@
   if (rc)
     {
       if (ctx->log_fp)
-	fprintf (ctx->log_fp, "%s[%u.%d] DBG: <- [Error: %s]\n",
+	fprintf (ctx->log_fp, "%s[%u.%d] DBG: <- [Error: %s (%d)]\n",
 		 assuan_get_assuan_log_prefix (),
                  (unsigned int)getpid (), ctx->inbound.fd,
-                 strerror (errno));
+                 strerror (errno), errno);
       return _assuan_error (ASSUAN_Read_Error);
     }
   if (!nread)

Modified: trunk/assuan/mkerrors
===================================================================
--- trunk/assuan/mkerrors	2007-11-20 10:40:41 UTC (rev 1277)
+++ trunk/assuan/mkerrors	2007-11-22 16:44:37 UTC (rev 1278)
@@ -16,9 +16,7 @@
 # Lesser General Public License for more details.
 #
 # You should have received a copy of the GNU Lesser General Public
-# License along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA 
-
+# License along with this program; if not, see <http://www.gnu.org/licenses/>.
 cat <<EOF
 /* Generated automatically by mkerrors */
 /* Do not edit!  See mkerrors for copyright notice. */
@@ -58,8 +56,13 @@
   unsigned int n;
 
   if (!err_source)
-    return (oldcode & 0x00ffffff); /* Make sure that the gpg-error
-                                      source part is cleared. */
+    {
+      if (oldcode == -1)
+        return -1;
+      else
+        return (oldcode & 0x00ffffff); /* Make sure that the gpg-error
+                                          source part is cleared. */
+    }
 
   switch (oldcode)
     {
@@ -90,6 +93,12 @@
       switch (errno)
         {
         case 0: n = 16381; /*GPG_ERR_MISSING_ERRNO*/  break;
+        case EAGAIN:
+          if (errno > 0 && errno < 4096)
+            {
+              n = (EAGAIN | (1 << 15)); 
+              break;
+            }
         default: n = 270;  /*GPG_ERR_ASS_READ_ERROR*/ break;
         }
       break;
@@ -98,6 +107,12 @@
       switch (errno)
         {
         case 0: n = 16381; /*GPG_ERR_MISSING_ERRNO*/  break;
+        case EAGAIN:
+          if (errno > 0 && errno < 4096)
+            {
+              n = (EAGAIN | (1 << 15)); 
+              break;
+            }
         default: n = 271;  /*GPG_ERR_ASS_WRITE_ERROR*/ break;
         }
       break;
@@ -111,7 +126,12 @@
                     an error is indeed returned. */
           n = 16381; /*GPG_ERR_MISSING_ERRNO*/
           break;
-        case ENOMEM: n = (1 << 15) | 86; break;
+        case ENOMEM:
+          if (errno > 0 && errno < 4096)
+            {
+              n = (ENOMEM | (1 << 15));
+              break;
+            }
         default:  
           n = 16382; /*GPG_ERR_UNKNOWN_ERRNO*/
           break;

Modified: trunk/gpgme/ChangeLog
===================================================================
--- trunk/gpgme/ChangeLog	2007-11-20 10:40:41 UTC (rev 1277)
+++ trunk/gpgme/ChangeLog	2007-11-22 16:44:37 UTC (rev 1278)
@@ -1,3 +1,15 @@
+2007-11-22  Werner Koch  <wk at g10code.com>
+
+	* gpgme.h (gpgme_op_getauditlog_start, gpgme_op_getauditlog): New.
+	* libgpgme.vers: Ditto.
+	* gpgme.def: Ditto.
+	* getauditlog.c: New.
+	* engine-backend.h (struct engine_ops): Add member GETAUDITLOG.
+	* engine-gpgsm.c (gpgsm_getauditlog): New.
+	(_gpgme_engine_ops_gpgsm): Insert new function.
+	(gpgsm_new): Try to enable audit log support.
+	* rungpg.c (_gpgme_engine_ops_gpg): Insert dummy entry.
+	
 2007-11-20  Werner Koch  <wk at g10code.com>
 
 	* op-support.c (_gpgme_parse_inv_recp): Add new reason code 11.

Modified: trunk/gpgme/Makefile.am
===================================================================
--- trunk/gpgme/Makefile.am	2007-11-20 10:40:41 UTC (rev 1277)
+++ trunk/gpgme/Makefile.am	2007-11-22 16:44:37 UTC (rev 1278)
@@ -98,7 +98,7 @@
 	encrypt.c encrypt-sign.c decrypt.c decrypt-verify.c verify.c	\
 	sign.c passphrase.c progress.c					\
 	key.c keylist.c trust-item.c trustlist.c			\
-	import.c export.c genkey.c delete.c edit.c			\
+	import.c export.c genkey.c delete.c edit.c getauditlog.c        \
 	engine.h engine-backend.h engine.c rungpg.c status-table.h	\
 	$(gpgsm_components) sema.h priv-io.h $(system_components)	\
 	debug.c debug.h gpgme.c version.c error.c

Modified: trunk/gpgme/engine-backend.h
===================================================================
--- trunk/gpgme/engine-backend.h	2007-11-20 10:40:41 UTC (rev 1277)
+++ trunk/gpgme/engine-backend.h	2007-11-22 16:44:37 UTC (rev 1278)
@@ -94,7 +94,9 @@
   gpgme_error_t (*verify) (void *engine, gpgme_data_t sig,
 			   gpgme_data_t signed_text,
 			   gpgme_data_t plaintext);
-  
+  gpgme_error_t  (*getauditlog) (void *engine, gpgme_data_t output,
+                                 unsigned int flags);
+
   void (*set_io_cbs) (void *engine, gpgme_io_cbs_t io_cbs);
   void (*io_event) (void *engine, gpgme_event_io_t type, void *type_data);
 

Modified: trunk/gpgme/engine-gpgsm.c
===================================================================
--- trunk/gpgme/engine-gpgsm.c	2007-11-20 10:40:41 UTC (rev 1277)
+++ trunk/gpgme/engine-gpgsm.c	2007-11-22 16:44:37 UTC (rev 1278)
@@ -515,6 +515,15 @@
 	}
     }
 
+  /* Ask gpgsm to enable the audit log support.  */
+  if (!err)
+    {
+      err = assuan_transact (gpgsm->assuan_ctx, "OPTION enable-audit-log=1",
+                             NULL, NULL, NULL, NULL, NULL, NULL);
+      if (gpg_err_code (err) == GPG_ERR_UNKNOWN_OPTION)
+        err = 0; /* This is an optional feature of gpgsm.  */
+    }
+
 #if !USE_DESCRIPTOR_PASSING
   if (!err
       && (_gpgme_io_set_close_notify (gpgsm->input_cb.fd,
@@ -1704,6 +1713,32 @@
 }
 
 
+/* Send the GETAUDITLOG command.  The result is saved to a gpgme data
+   object.  */
+static gpgme_error_t
+gpgsm_getauditlog (void *engine, gpgme_data_t output, unsigned int flags)
+{
+  engine_gpgsm_t gpgsm = engine;
+  gpgme_error_t err = 0;
+
+  if (!gpgsm || !output)
+    return gpg_error (GPG_ERR_INV_VALUE);
+
+  gpgsm->output_cb.data = output;
+  err = gpgsm_set_fd (gpgsm, OUTPUT_FD, 0);
+  if (err)
+    return err;
+
+  gpgsm_clear_fd (gpgsm, INPUT_FD);
+  gpgsm_clear_fd (gpgsm, MESSAGE_FD);
+
+  err = start (gpgsm, "GETAUDITLOG");
+
+  return err;
+}
+
+
+
 static void
 gpgsm_set_status_handler (void *engine, engine_status_handler_t fnc,
 			  void *fnc_value) 
@@ -1782,6 +1817,7 @@
     gpgsm_sign,
     NULL,		/* trustlist */
     gpgsm_verify,
+    gpgsm_getauditlog,
     gpgsm_set_io_cbs,
     gpgsm_io_event,
     gpgsm_cancel

Modified: trunk/gpgme/engine.c
===================================================================
--- trunk/gpgme/engine.c	2007-11-20 10:40:41 UTC (rev 1277)
+++ trunk/gpgme/engine.c	2007-11-22 16:44:37 UTC (rev 1278)
@@ -710,6 +710,20 @@
 }
 
 
+gpgme_error_t
+_gpgme_engine_op_getauditlog (engine_t engine, gpgme_data_t output,
+                              unsigned int flags)
+{
+  if (!engine)
+    return gpg_error (GPG_ERR_INV_VALUE);
+
+  if (!engine->ops->getauditlog)
+    return gpg_error (GPG_ERR_NOT_IMPLEMENTED);
+
+  return (*engine->ops->getauditlog) (engine->engine, output, flags);
+}
+
+
 void
 _gpgme_engine_set_io_cbs (engine_t engine, gpgme_io_cbs_t io_cbs)
 {

Modified: trunk/gpgme/engine.h
===================================================================
--- trunk/gpgme/engine.h	2007-11-20 10:40:41 UTC (rev 1277)
+++ trunk/gpgme/engine.h	2007-11-22 16:44:37 UTC (rev 1278)
@@ -123,6 +123,10 @@
 				       gpgme_data_t signed_text,
 				       gpgme_data_t plaintext);
 
+gpgme_error_t _gpgme_engine_op_getauditlog (engine_t engine,
+                                            gpgme_data_t output,
+                                            unsigned int flags);
+
 void _gpgme_engine_set_io_cbs (engine_t engine,
 			       gpgme_io_cbs_t io_cbs);
 void _gpgme_engine_io_event (engine_t engine,

Added: trunk/gpgme/getauditlog.c
===================================================================
--- trunk/gpgme/getauditlog.c	2007-11-20 10:40:41 UTC (rev 1277)
+++ trunk/gpgme/getauditlog.c	2007-11-22 16:44:37 UTC (rev 1278)
@@ -0,0 +1,81 @@
+/* getauditlog.c - Retrieve the audit log.
+   Copyright (C) 2007 g10 Code GmbH
+
+   This file is part of GPGME.
+ 
+   GPGME is free software; you can redistribute it and/or modify it
+   under the terms of the GNU Lesser General Public License as
+   published by the Free Software Foundation; either version 2.1 of
+   the License, or (at your option) any later version.
+   
+   GPGME is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+   
+   You should have received a copy of the GNU Lesser General Public
+   License along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "gpgme.h"
+#include "context.h"
+#include "ops.h"
+
+
+static gpgme_error_t
+getauditlog_status_handler (void *priv, gpgme_status_code_t code, char *args)
+{
+  return 0;
+}
+
+
+static gpgme_error_t
+getauditlog_start (gpgme_ctx_t ctx, int synchronous,
+                   gpgme_data_t output, unsigned int flags)
+{
+  gpgme_error_t err;
+
+  if (!output)
+    return gpg_error (GPG_ERR_INV_VALUE);
+
+  err = _gpgme_op_reset (ctx, synchronous);
+  if (err)
+    return err;
+
+  _gpgme_engine_set_status_handler (ctx->engine, 
+                                    getauditlog_status_handler, ctx);
+
+  return _gpgme_engine_op_getauditlog (ctx->engine, output, flags);
+}
+
+
+
+/* Return the auditlog for the current session.  This may be called
+   after a successful or failed operation.  If no audit log is
+   available GPG_ERR_NO_DATA is returned.  This is the asynchronous
+   variant. */
+gpgme_error_t
+gpgme_op_getauditlog_start (gpgme_ctx_t ctx, 
+                            gpgme_data_t output, unsigned int flags)
+{
+  return getauditlog_start (ctx, 0, output, flags);
+}
+
+
+/* Return the auditlog for the current session.  This may be called
+   after a successful or failed operation.  If no audit log is
+   available GPG_ERR_NO_DATA is returned.  This is the synchronous
+   variant. */
+gpgme_error_t
+gpgme_op_getauditlog (gpgme_ctx_t ctx, gpgme_data_t output, unsigned int flags)
+{
+  gpgme_error_t err = getauditlog_start (ctx, 1, output, flags);
+  if (!err)
+    err = _gpgme_wait_one (ctx);
+  return err;
+}
+

Modified: trunk/gpgme/gpgme.def
===================================================================
--- trunk/gpgme/gpgme.def	2007-11-20 10:40:41 UTC (rev 1277)
+++ trunk/gpgme/gpgme.def	2007-11-22 16:44:37 UTC (rev 1278)
@@ -156,5 +156,8 @@
     gpgme_get_giochannel		  @121
     gpgme_get_fdptr			  @122
 
+    gpgme_op_getauditlog_start            @123
+    gpgme_op_getauditlog                  @124
+
 ; END
 

Modified: trunk/gpgme/gpgme.h
===================================================================
--- trunk/gpgme/gpgme.h	2007-11-20 10:40:41 UTC (rev 1277)
+++ trunk/gpgme/gpgme.h	2007-11-22 16:44:37 UTC (rev 1278)
@@ -315,6 +315,11 @@
 typedef unsigned int gpgme_keylist_mode_t;
 
 
+/* Flags for the audit log functions.  */
+#define GPGME_AUDITLOG_HTML      1 
+#define GPGME_AUDITLOG_WITH_HELP 128
+
+
 /* Signature notations.  */
 
 /* The available signature notation flags.  */
@@ -1639,6 +1644,16 @@
      _GPGME_DEPRECATED;
 
 
+/* Return the auditlog for the current session.  This may be called
+   after a successful or failed operation.  If no audit log is
+   available GPG_ERR_NO_DATA is returned.  */
+gpgme_error_t gpgme_op_getauditlog_start (gpgme_ctx_t ctx, gpgme_data_t output,
+                                          unsigned int flags);
+gpgme_error_t gpgme_op_getauditlog (gpgme_ctx_t ctx, gpgme_data_t output, 
+                                    unsigned int flags);
+
+
+
 /* Various functions.  */
 
 /* Check that the library fulfills the version requirement.  */

Modified: trunk/gpgme/libgpgme.vers
===================================================================
--- trunk/gpgme/libgpgme.vers	2007-11-20 10:40:41 UTC (rev 1277)
+++ trunk/gpgme/libgpgme.vers	2007-11-22 16:44:37 UTC (rev 1278)
@@ -36,6 +36,9 @@
     gpgme_sig_notation_get;
 
     gpgme_free;
+
+    gpgme_op_getauditlog_start;
+    gpgme_op_getauditlog;
 };
 
 

Modified: trunk/gpgme/rungpg.c
===================================================================
--- trunk/gpgme/rungpg.c	2007-11-20 10:40:41 UTC (rev 1277)
+++ trunk/gpgme/rungpg.c	2007-11-22 16:44:37 UTC (rev 1278)
@@ -2120,6 +2120,7 @@
     gpg_sign,
     gpg_trustlist,
     gpg_verify,
+    NULL,
     gpg_set_io_cbs,
     gpg_io_event,
     gpg_cancel

Modified: trunk/tests/gpgsm/t-verify.c
===================================================================
--- trunk/tests/gpgsm/t-verify.c	2007-11-20 10:40:41 UTC (rev 1277)
+++ trunk/tests/gpgsm/t-verify.c	2007-11-22 16:44:37 UTC (rev 1278)
@@ -108,6 +108,21 @@
 }
 
 
+static void
+show_auditlog (gpgme_ctx_t ctx)
+{
+  gpgme_error_t err;
+  gpgme_data_t data;
+
+  err = gpgme_data_new (&data);
+  fail_if_err (err);
+  err = gpgme_op_getauditlog (ctx, data, 0);
+  fail_if_err (err);
+  gpgme_data_release (data);
+}
+
+
+
 int 
 main (int argc, char **argv)
 {
@@ -135,6 +150,8 @@
 		"3CF405464F66ED4A7DF45BBDD1E4282E33BDB76E",
 		GPG_ERR_NO_ERROR, GPGME_VALIDITY_FULL);
 
+  show_auditlog (ctx);
+
   /* Checking a manipulated message.  */
   gpgme_data_release (text);
   err = gpgme_data_new_from_mem (&text, test_text1f, strlen (test_text1f), 0);




More information about the Gnupg-commits mailing list