aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog30
-rw-r--r--src/Makefile.am49
-rw-r--r--src/engine-assuan.c7
-rw-r--r--src/engine-backend.h2
-rw-r--r--src/engine-gpgsm.c176
-rw-r--r--src/posix-io.c2
-rw-r--r--src/priv-io.h6
-rw-r--r--src/util.h10
8 files changed, 97 insertions, 185 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index a0b0581d..c2100f73 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,33 @@
+2009-10-20 Marcus Brinkmann <[email protected]>
+
+ * Makefile.am (assuan_cppflags, assuan_libobjs): Removed.
+ (gpgsm_components): Move engine-assuan.c to ...
+ (assuan_components): ... this new variable.
+ (main_sources): Add this new variable.
+ (AM_CPPFLAGS): Remove $(assuan_cppflags).
+ (AM_CFLAGS): Add @LIBASSUAN_CFLAGS@.
+ (libgpgme_la_DEPENDENCIES, libgpgme_pth_la_DEPENDENCIES)
+ (libgpgme_glib_la_DEPENDENCIES, libgpgme_qt_la_DEPENDENCIES)
+ (libgpgme_pthread_la_DEPENDENCIES): Remove $(assuan_libobjs).
+ (libgpgme_la_LIBADD, libgpgme_pth_la_LIBADD)
+ (libgpgme_glib_la_LIBADD, libgpgme_qt_la_LIBADD))
+ (libgpgme_pthread_la_LIBADD): Replace $(assuan_libobjs) by
+ @LIBASSUAN_LIBS@.
+ * priv-io.h [!HAVE_W32_SYSTEM]: Declare _gpgme_io_recvmsg,
+ _gpgme_io_sendmsg, _gpgme_io_waitpid.
+ * engine-backend.h: Define with [ENABLE_ASSUAN] instead
+ of [ENABLE_GPGSM].
+ * posix-io.c (_gpgme_io_waitpid): Make non-static.
+ * util.h (ENABLE_ASSUAN): Declar _gpgme_assuan_system_hooks,
+ _gpgme_assuan_malloc_hooks, _gpgme_assuan_log_cb.
+ * engine-gpgsm.c: Don't map assuan error codes. Use
+ assuan_release instead of assuan_disconnect.
+ (map_assuan_error): Remove function.
+ (gpgsm_new): Use new assuan context interface.
+ * engine-assuan.c: Use assuan_release instead of
+ assuan_disconnect.
+ (llass_new): Use new assuan context interface.
+
2009-10-07 <[email protected]>
* priv-io.h [W32]: Include windows.h instead of sys/socket.h.
diff --git a/src/Makefile.am b/src/Makefile.am
index 8906ce72..73eeef20 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -60,14 +60,6 @@ else
libgpgme_version_script_cmd =
endif
-if BUILD_ASSUAN
-assuan_cppflags = -I$(top_srcdir)/assuan
-assuan_libobjs = ../assuan/libassuan.la
-else
-assuan_cppflags =
-assuan_libobjs =
-endif
-
if HAVE_DOSISH_SYSTEM
system_components = w32-util.c w32-sema.c
system_components_not_extra = w32-io.c
@@ -77,11 +69,17 @@ system_components_not_extra =
endif
if HAVE_GPGSM
-gpgsm_components = engine-gpgsm.c engine-assuan.c
+gpgsm_components = engine-gpgsm.c
else
gpgsm_components =
endif
+if HAVE_ASSUAN
+assuan_components = assuan-support.c engine-assuan.c
+else
+assuan_components =
+endif
+
if HAVE_GPGCONF
gpgconf_components = engine-gpgconf.c
else
@@ -106,7 +104,8 @@ main_sources = \
import.c export.c genkey.c delete.c edit.c getauditlog.c \
opassuan.c \
engine.h engine-backend.h engine.c engine-gpg.c status-table.h \
- $(gpgsm_components) $(gpgconf_components) gpgconf.c \
+ $(gpgsm_components) $(assuan_components) $(gpgconf_components) \
+ gpgconf.c \
sema.h priv-io.h $(system_components) dirinfo.c \
debug.c debug.h gpgme.c version.c error.c
@@ -136,9 +135,9 @@ endif
# We use a global CFLAGS and CPPFLAGS setting for all library
# versions, because then every object file is only compiled once.
-AM_CPPFLAGS = $(assuan_cppflags) @GPG_ERROR_CFLAGS@ @PTH_CPPFLAGS@ \
+AM_CPPFLAGS = @GPG_ERROR_CFLAGS@ @PTH_CPPFLAGS@ \
@QT4_CORE_CFLAGS@
-AM_CFLAGS = @PTH_CFLAGS@ @GLIB_CFLAGS@ @QT4_CORE_CFLAGS@
+AM_CFLAGS = @LIBASSUAN_CFLAGS@ @PTH_CFLAGS@ @GLIB_CFLAGS@ @QT4_CORE_CFLAGS@
if HAVE_W32_SYSTEM
@@ -185,33 +184,30 @@ endif
libgpgme_la_LDFLAGS = $(gpgme_res_ldflag) $(no_undefined) $(export_symbols) \
$(libgpgme_version_script_cmd) -version-info \
@LIBGPGME_LT_CURRENT@:@LIBGPGME_LT_REVISION@:@LIBGPGME_LT_AGE@
-libgpgme_la_DEPENDENCIES = $(assuan_libobjs) \
- @LTLIBOBJS@ $(srcdir)/libgpgme.vers $(gpgme_deps)
-libgpgme_la_LIBADD = $(assuan_libobjs) @LTLIBOBJS@ \
+libgpgme_la_DEPENDENCIES = @LTLIBOBJS@ $(srcdir)/libgpgme.vers $(gpgme_deps)
+libgpgme_la_LIBADD = @LIBASSUAN_LIBS@ @LTLIBOBJS@ \
@GPG_ERROR_LIBS@ @NETLIBS@
libgpgme_pthread_la_LDFLAGS = $(libgpgme_version_script_cmd) -version-info \
@LIBGPGME_LT_CURRENT@:@LIBGPGME_LT_REVISION@:@LIBGPGME_LT_AGE@
-libgpgme_pthread_la_DEPENDENCIES = $(assuan_libobjs) \
- @LTLIBOBJS@ $(srcdir)/libgpgme.vers
-libgpgme_pthread_la_LIBADD = $(assuan_libobjs) @LTLIBOBJS@ \
+libgpgme_pthread_la_DEPENDENCIES = @LTLIBOBJS@ $(srcdir)/libgpgme.vers
+libgpgme_pthread_la_LIBADD = @LIBASSUAN_LIBS@ @LTLIBOBJS@ \
-lpthread @GPG_ERROR_LIBS@ @NETLIBS@
libgpgme_pth_la_LDFLAGS = @PTH_LDFLAGS@ \
$(libgpgme_version_script_cmd) -version-info \
@LIBGPGME_LT_CURRENT@:@LIBGPGME_LT_REVISION@:@LIBGPGME_LT_AGE@
-libgpgme_pth_la_DEPENDENCIES = $(assuan_libobjs) \
- @LTLIBOBJS@ $(srcdir)/libgpgme.vers
-libgpgme_pth_la_LIBADD = $(assuan_libobjs) @LTLIBOBJS@ \
+libgpgme_pth_la_DEPENDENCIES = @LTLIBOBJS@ $(srcdir)/libgpgme.vers
+libgpgme_pth_la_LIBADD = @LIBASSUAN_LIBS@ @LTLIBOBJS@ \
@PTH_LIBS@ @GPG_ERROR_LIBS@ @NETLIBS@
if BUILD_W32_GLIB
libgpgme_glib_la_LDFLAGS = $(gpgme_res_ldflag) $(no_undefined) \
$(export_symbols) $(libgpgme_version_script_cmd) -version-info \
@LIBGPGME_LT_CURRENT@:@LIBGPGME_LT_REVISION@:@LIBGPGME_LT_AGE@
-libgpgme_glib_la_DEPENDENCIES = $(assuan_libobjs) \
- @LTLIBOBJS@ $(srcdir)/libgpgme.vers $(gpgme_deps)
-libgpgme_glib_la_LIBADD = $(assuan_libobjs) @LTLIBOBJS@ \
+libgpgme_glib_la_DEPENDENCIES = @LTLIBOBJS@ \
+ $(srcdir)/libgpgme.vers $(gpgme_deps)
+libgpgme_glib_la_LIBADD = @LIBASSUAN_LIBS@ @LTLIBOBJS@ \
@GPG_ERROR_LIBS@ @GLIB_LIBS@ @NETLIBS@
endif
@@ -219,9 +215,8 @@ if BUILD_W32_QT
libgpgme_qt_la_LDFLAGS = $(gpgme_res_ldflag) $(no_undefined) \
$(export_symbols) $(libgpgme_version_script_cmd) -version-info \
@LIBGPGME_LT_CURRENT@:@LIBGPGME_LT_REVISION@:@LIBGPGME_LT_AGE@
-libgpgme_qt_la_DEPENDENCIES = $(assuan_libobjs) \
- @LTLIBOBJS@ $(srcdir)/libgpgme.vers $(gpgme_deps)
-libgpgme_qt_la_LIBADD = $(assuan_libobjs) @LTLIBOBJS@ \
+libgpgme_qt_la_DEPENDENCIES = @LTLIBOBJS@ $(srcdir)/libgpgme.vers $(gpgme_deps)
+libgpgme_qt_la_LIBADD = @LIBASSUAN_LIBS@ @LTLIBOBJS@ \
@GPG_ERROR_LIBS@ @QT4_CORE_LIBS@ @NETLIBS@
endif
diff --git a/src/engine-assuan.c b/src/engine-assuan.c
index 08ae388d..74cde99c 100644
--- a/src/engine-assuan.c
+++ b/src/engine-assuan.c
@@ -161,7 +161,7 @@ llass_cancel (void *engine)
if (llass->assuan_ctx)
{
- assuan_disconnect (llass->assuan_ctx);
+ assuan_release (llass->assuan_ctx);
llass->assuan_ctx = NULL;
}
@@ -213,7 +213,10 @@ llass_new (void **engine, const char *file_name, const char *home_dir)
llass->opt.gpg_agent = 1;
}
- err = assuan_socket_connect (&llass->assuan_ctx, file_name, 0);
+ err = assuan_new (&llass->assuan_ctx);
+ if (err)
+ goto leave;
+ err = assuan_socket_connect (llass->assuan_ctx, file_name, 0);
if (err)
goto leave;
diff --git a/src/engine-backend.h b/src/engine-backend.h
index 1fe600d0..0a30f348 100644
--- a/src/engine-backend.h
+++ b/src/engine-backend.h
@@ -129,7 +129,7 @@ extern struct engine_ops _gpgme_engine_ops_gpgsm; /* CMS. */
#ifdef ENABLE_GPGCONF
extern struct engine_ops _gpgme_engine_ops_gpgconf; /* gpg-conf. */
#endif
-#ifdef ENABLE_GPGSM /* If this is enabled we also have assuan support. */
+#ifdef ENABLE_ASSUAN
extern struct engine_ops _gpgme_engine_ops_assuan; /* Low-level Assuan. */
#endif
diff --git a/src/engine-gpgsm.c b/src/engine-gpgsm.c
index 647fd931..1d25190a 100644
--- a/src/engine-gpgsm.c
+++ b/src/engine-gpgsm.c
@@ -171,132 +171,6 @@ close_notify_handler (int fd, void *opaque)
}
-static gpgme_error_t
-map_assuan_error (gpg_error_t err)
-{
- if (!err)
- return 0;
-
- if (err == -1)
- return gpg_error (GPG_ERR_INV_ENGINE);
-
- /* New code will use gpg_error_t values. */
- if (gpg_err_source (err))
- return (gpgme_error_t) err;
-
- /* Legacy code will use old values. */
- switch (err)
- {
- case ASSUAN_No_Error:
- return gpg_error (GPG_ERR_NO_ERROR);
- case ASSUAN_General_Error:
- return gpg_error (GPG_ERR_GENERAL);
- case ASSUAN_Out_Of_Core:
- return gpg_error (GPG_ERR_ENOMEM);
- case ASSUAN_Invalid_Value:
- return gpg_error (GPG_ERR_INV_VALUE);
- case ASSUAN_Timeout:
- return gpg_error (GPG_ERR_ETIMEDOUT);
- case ASSUAN_Read_Error:
- return gpg_error (GPG_ERR_GENERAL);
- case ASSUAN_Write_Error:
- return gpg_error (GPG_ERR_GENERAL);
-
- case ASSUAN_Problem_Starting_Server:
- case ASSUAN_Not_A_Server:
- case ASSUAN_Not_A_Client:
- case ASSUAN_Nested_Commands:
- case ASSUAN_No_Data_Callback:
- case ASSUAN_No_Inquire_Callback:
- case ASSUAN_Connect_Failed:
- case ASSUAN_Accept_Failed:
- case ASSUAN_Invalid_Command:
- case ASSUAN_Unknown_Command:
- case ASSUAN_Syntax_Error:
- case ASSUAN_Parameter_Error:
- case ASSUAN_Parameter_Conflict:
- case ASSUAN_No_Input:
- case ASSUAN_No_Output:
- case ASSUAN_No_Data_Available:
- case ASSUAN_Too_Much_Data:
- case ASSUAN_Inquire_Unknown:
- case ASSUAN_Inquire_Error:
- case ASSUAN_Invalid_Option:
- case ASSUAN_Unexpected_Status:
- case ASSUAN_Unexpected_Data:
- case ASSUAN_Invalid_Status:
- return gpg_error (GPG_ERR_ASSUAN);
-
- case ASSUAN_Invalid_Response:
- return gpg_error (GPG_ERR_INV_RESPONSE);
-
- case ASSUAN_Not_Implemented:
- return gpg_error (GPG_ERR_NOT_IMPLEMENTED);
- case ASSUAN_Line_Too_Long:
- return gpg_error (GPG_ERR_LINE_TOO_LONG);
- case ASSUAN_Line_Not_Terminated:
- return gpg_error (GPG_ERR_INCOMPLETE_LINE);
- case ASSUAN_Canceled:
- return gpg_error (GPG_ERR_CANCELED);
-
- case ASSUAN_Unsupported_Algorithm:
- return gpg_error (GPG_ERR_UNSUPPORTED_ALGORITHM);
- case ASSUAN_Server_Resource_Problem:
- return gpg_error (GPG_ERR_RESOURCE_LIMIT);
- case ASSUAN_Server_IO_Error:
- return gpg_error (GPG_ERR_GENERAL);
- case ASSUAN_Server_Bug:
- return gpg_error (GPG_ERR_BUG);
- case ASSUAN_Invalid_Data:
- return gpg_error (GPG_ERR_INV_DATA);
- case ASSUAN_Invalid_Index:
- return gpg_error (GPG_ERR_INV_INDEX);
- case ASSUAN_Not_Confirmed:
- return gpg_error (GPG_ERR_NOT_CONFIRMED);
- case ASSUAN_Bad_Certificate:
- return gpg_error (GPG_ERR_BAD_CERT);
- case ASSUAN_Bad_Certificate_Chain:
- return gpg_error (GPG_ERR_BAD_CERT_CHAIN);
- case ASSUAN_Missing_Certificate:
- return gpg_error (GPG_ERR_MISSING_CERT);
- case ASSUAN_Bad_Signature:
- return gpg_error (GPG_ERR_BAD_SIGNATURE);
- case ASSUAN_No_Agent:
- return gpg_error (GPG_ERR_NO_AGENT);
- case ASSUAN_Agent_Error:
- return gpg_error (GPG_ERR_AGENT);
- case ASSUAN_No_Public_Key:
- return gpg_error (GPG_ERR_NO_PUBKEY);
- case ASSUAN_No_Secret_Key:
- return gpg_error (GPG_ERR_NO_SECKEY);
- case ASSUAN_Invalid_Name:
- return gpg_error (GPG_ERR_INV_NAME);
-
- case ASSUAN_Cert_Revoked:
- return gpg_error (GPG_ERR_CERT_REVOKED);
- case ASSUAN_No_CRL_For_Cert:
- return gpg_error (GPG_ERR_NO_CRL_KNOWN);
- case ASSUAN_CRL_Too_Old:
- return gpg_error (GPG_ERR_CRL_TOO_OLD);
- case ASSUAN_Not_Trusted:
- return gpg_error (GPG_ERR_NOT_TRUSTED);
-
- case ASSUAN_Card_Error:
- return gpg_error (GPG_ERR_CARD);
- case ASSUAN_Invalid_Card:
- return gpg_error (GPG_ERR_INV_CARD);
- case ASSUAN_No_PKCS15_App:
- return gpg_error (GPG_ERR_NO_PKCS15_APP);
- case ASSUAN_Card_Not_Present:
- return gpg_error (GPG_ERR_CARD_NOT_PRESENT);
- case ASSUAN_Invalid_Id:
- return gpg_error (GPG_ERR_INV_ID);
- default:
- return gpg_error (GPG_ERR_GENERAL);
- }
-}
-
-
/* This is the default inquiry callback. We use it to handle the
Pinentry notifications. */
static gpgme_error_t
@@ -330,7 +204,7 @@ gpgsm_cancel (void *engine)
if (gpgsm->assuan_ctx)
{
- assuan_disconnect (gpgsm->assuan_ctx);
+ assuan_release (gpgsm->assuan_ctx);
gpgsm->assuan_ctx = NULL;
}
@@ -450,13 +324,20 @@ gpgsm_new (void **engine, const char *file_name, const char *home_dir)
argv[argc++] = "--server";
argv[argc++] = NULL;
+ err = assuan_new_ext (&gpgsm->assuan_ctx, GPG_ERR_SOURCE_GPGME,
+ &_gpgme_assuan_malloc_hooks, _gpgme_assuan_log_cb,
+ NULL);
+ if (err)
+ goto leave;
+ assuan_ctx_set_system_hooks (gpgsm->assuan_ctx, &_gpgme_assuan_system_hooks);
+
#if USE_DESCRIPTOR_PASSING
err = assuan_pipe_connect_ext
- (&gpgsm->assuan_ctx, file_name ? file_name : _gpgme_get_gpgsm_path (),
+ (gpgsm->assuan_ctx, file_name ? file_name : _gpgme_get_gpgsm_path (),
argv, NULL, NULL, NULL, 1);
#else
err = assuan_pipe_connect
- (&gpgsm->assuan_ctx, file_name ? file_name : _gpgme_get_gpgsm_path (),
+ (gpgsm->assuan_ctx, file_name ? file_name : _gpgme_get_gpgsm_path (),
argv, child_fds);
/* On Windows, handles are inserted in the spawned process with
@@ -504,10 +385,7 @@ gpgsm_new (void **engine, const char *file_name, const char *home_dir)
NULL, NULL, NULL);
free (optstr);
if (err)
- {
- err = map_assuan_error (err);
- goto leave;
- }
+ goto leave;
}
if (isatty (1))
@@ -531,10 +409,7 @@ gpgsm_new (void **engine, const char *file_name, const char *home_dir)
NULL, NULL, NULL);
free (optstr);
if (err)
- {
- err = map_assuan_error (err);
- goto leave;
- }
+ goto leave;
err = _gpgme_getenv ("TERM", &dft_ttytype);
if (err)
@@ -553,10 +428,7 @@ gpgsm_new (void **engine, const char *file_name, const char *home_dir)
NULL, NULL, NULL, NULL);
free (optstr);
if (err)
- {
- err = map_assuan_error (err);
- goto leave;
- }
+ goto leave;
}
}
}
@@ -662,8 +534,6 @@ gpgsm_set_locale (void *engine, int category, const char *value)
err = assuan_transact (gpgsm->assuan_ctx, optstr, NULL, NULL,
NULL, NULL, NULL, NULL);
free (optstr);
- if (err)
- err = map_assuan_error (err);
}
return err;
@@ -684,13 +554,13 @@ gpgsm_assuan_simple_command (assuan_context_t ctx, char *cmd,
err = assuan_write_line (ctx, cmd);
if (err)
- return map_assuan_error (err);
+ return err;
do
{
err = assuan_read_line (ctx, &line, &linelen);
if (err)
- return map_assuan_error (err);
+ return err;
if (*line == '#' || !linelen)
continue;
@@ -702,7 +572,7 @@ gpgsm_assuan_simple_command (assuan_context_t ctx, char *cmd,
else if (linelen >= 4
&& line[0] == 'E' && line[1] == 'R' && line[2] == 'R'
&& line[3] == ' ')
- err = map_assuan_error (atoi (&line[4]));
+ err = atoi (&line[4]);
else if (linelen >= 2
&& line[0] == 'S' && line[1] == ' ')
{
@@ -891,7 +761,6 @@ parse_status (const char *name)
static gpgme_error_t
status_handler (void *opaque, int fd)
{
- gpg_error_t assuan_err;
gpgme_error_t err = 0;
engine_gpgsm_t gpgsm = opaque;
char *line;
@@ -899,23 +768,22 @@ status_handler (void *opaque, int fd)
do
{
- assuan_err = assuan_read_line (gpgsm->assuan_ctx, &line, &linelen);
- if (assuan_err)
+ err = assuan_read_line (gpgsm->assuan_ctx, &line, &linelen);
+ if (err)
{
/* Try our best to terminate the connection friendly. */
/* assuan_write_line (gpgsm->assuan_ctx, "BYE"); */
- err = map_assuan_error (assuan_err);
TRACE3 (DEBUG_CTX, "gpgme:status_handler", gpgsm,
"fd 0x%x: error from assuan (%d) getting status line : %s",
- fd, assuan_err, gpg_strerror (err));
+ fd, err, gpg_strerror (err));
}
else if (linelen >= 3
&& line[0] == 'E' && line[1] == 'R' && line[2] == 'R'
&& (line[3] == '\0' || line[3] == ' '))
{
if (line[3] == ' ')
- err = map_assuan_error (atoi (&line[4]));
- else
+ err = atoi (&line[4]);
+ if (! err)
err = gpg_error (GPG_ERR_GENERAL);
TRACE2 (DEBUG_CTX, "gpgme:status_handler", gpgsm,
"fd 0x%x: ERR line - mapped to: %s",
@@ -1174,7 +1042,7 @@ start (engine_gpgsm_t gpgsm, const char *command)
err = add_io_cb (gpgsm, &gpgsm->message_cb, _gpgme_data_outbound_handler);
if (!err)
- err = map_assuan_error (assuan_write_line (gpgsm->assuan_ctx, command));
+ err = assuan_write_line (gpgsm->assuan_ctx, command);
if (!err)
gpgsm_io_event (gpgsm, GPGME_EVENT_START, NULL);
diff --git a/src/posix-io.c b/src/posix-io.c
index 869d0701..1b9410ae 100644
--- a/src/posix-io.c
+++ b/src/posix-io.c
@@ -278,7 +278,7 @@ get_max_fds (void)
}
-static int
+int
_gpgme_io_waitpid (int pid, int hang, int *r_status, int *r_signal)
{
int status;
diff --git a/src/priv-io.h b/src/priv-io.h
index 8d216955..4eb2e362 100644
--- a/src/priv-io.h
+++ b/src/priv-io.h
@@ -92,4 +92,10 @@ int _gpgme_io_fd2str (char *buf, int buflen, int fd);
(in engine-gpgsm.c). */
int _gpgme_io_dup (int fd);
+#ifndef HAVE_W32_SYSTEM
+int _gpgme_io_recvmsg (int fd, struct msghdr *msg, int flags);
+int _gpgme_io_sendmsg (int fd, const struct msghdr *msg, int flags);
+int _gpgme_io_waitpid (int pid, int hang, int *r_status, int *r_signal);
+#endif
+
#endif /* IO_H */
diff --git a/src/util.h b/src/util.h
index a221bcca..5c61e542 100644
--- a/src/util.h
+++ b/src/util.h
@@ -124,4 +124,14 @@ const char *_gpgme_get_w32spawn_path (void);
#define GPG_ERR_NOT_OPERATIONAL 176
#endif
+
+#ifdef ENABLE_ASSUAN
+#include <assuan.h>
+/* System hooks for assuan integration. */
+extern struct assuan_system_hooks _gpgme_assuan_system_hooks;
+extern struct assuan_malloc_hooks _gpgme_assuan_malloc_hooks;
+int _gpgme_assuan_log_cb (assuan_context_t ctx, void *hook,
+ unsigned int cat, const char *msg);
+#endif
+
#endif /* UTIL_H */