[svn] gpgme - r1398 - in trunk: . m4 src
svn author marcus
cvs at cvs.gnupg.org
Tue Oct 20 17:39:16 CEST 2009
Author: marcus
Date: 2009-10-20 17:39:15 +0200 (Tue, 20 Oct 2009)
New Revision: 1398
Added:
trunk/m4/libassuan.m4
Removed:
trunk/assuan/
Modified:
trunk/ChangeLog
trunk/Makefile.am
trunk/configure.ac
trunk/src/ChangeLog
trunk/src/Makefile.am
trunk/src/engine-assuan.c
trunk/src/engine-backend.h
trunk/src/engine-gpgsm.c
trunk/src/posix-io.c
trunk/src/priv-io.h
trunk/src/util.h
Log:
2009-10-20 Marcus Brinkmann <marcus at g10code.de>
* configure.ac: Replace internal libassuan by external libassuan.
* m4/libassuan.m4: New file.
* Makefile.am (assuan): Remove variable.
(SUBDIRS): Remove ${assuan}.
* assuan/: Removed.
src/
2009-10-20 Marcus Brinkmann <marcus at g10code.de>
* 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 at .
(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 at .
* 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.
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2009-10-15 20:54:25 UTC (rev 1397)
+++ trunk/ChangeLog 2009-10-20 15:39:15 UTC (rev 1398)
@@ -1,3 +1,11 @@
+2009-10-20 Marcus Brinkmann <marcus at g10code.de>
+
+ * configure.ac: Replace internal libassuan by external libassuan.
+ * m4/libassuan.m4: New file.
+ * Makefile.am (assuan): Remove variable.
+ (SUBDIRS): Remove ${assuan}.
+ * assuan/: Removed.
+
2009-06-22 Marcus Brinkmann <marcus at g10code.de>
* configure.ac: Add AC_TYPE_UINTPTR_T.
Modified: trunk/src/ChangeLog
===================================================================
--- trunk/src/ChangeLog 2009-10-15 20:54:25 UTC (rev 1397)
+++ trunk/src/ChangeLog 2009-10-20 15:39:15 UTC (rev 1398)
@@ -1,3 +1,33 @@
+2009-10-20 Marcus Brinkmann <marcus at g10code.de>
+
+ * 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 at .
+ (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 at .
+ * 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 <wk at g10code.com>
* priv-io.h [W32]: Include windows.h instead of sys/socket.h.
Modified: trunk/Makefile.am
===================================================================
--- trunk/Makefile.am 2009-10-15 20:54:25 UTC (rev 1397)
+++ trunk/Makefile.am 2009-10-20 15:39:15 UTC (rev 1398)
@@ -26,11 +26,6 @@
EXTRA_DIST = gpgme.spec.in autogen.sh
-if BUILD_ASSUAN
-assuan = assuan
-else
-assuan =
-endif
if BUILD_COMPLUS
complus = complus
@@ -44,7 +39,7 @@
tests =
endif
-SUBDIRS = ${assuan} src ${tests} doc ${complus} lang
+SUBDIRS = src ${tests} doc ${complus} lang
# Fix the version of the spec file and create a file named VERSION
# to be used for patch's Prereq: feature.
Modified: trunk/configure.ac
===================================================================
--- trunk/configure.ac 2009-10-15 20:54:25 UTC (rev 1397)
+++ trunk/configure.ac 2009-10-20 15:39:15 UTC (rev 1398)
@@ -188,8 +188,10 @@
AM_CONDITIONAL(HAVE_PTHREAD, test "$have_pthread" = "yes")
+
# Checks for header files.
AC_CHECK_HEADERS(sys/select.h)
+AC_CHECK_HEADERS([sys/uio.h])
# Type checks.
@@ -219,13 +221,6 @@
fi
fi
-# Network library fun.
-AC_CHECK_FUNC(gethostbyname, , AC_CHECK_LIB(nsl, gethostbyname,
- [NETLIBS="-lnsl $NETLIBS"]))
-AC_CHECK_FUNC(setsockopt, , AC_CHECK_LIB(socket, setsockopt,
- [NETLIBS="-lsocket $NETLIBS"]))
-AC_SUBST(NETLIBS)
-
# Checks for library functions.
AC_FUNC_FSEEKO
@@ -277,8 +272,16 @@
AC_DEFINE(GPG_ERR_SOURCE_DEFAULT, GPG_ERR_SOURCE_GPGME,
[The default error source for GPGME.])
+# And for libassuan.
+NEED_LIBASSUAN_VERSION=1.1.0
+have_libassuan=no
+AM_PATH_LIBASSUAN("$NEED_LIBASSUAN_VERSION",
+ have_libassuan=yes, have_libassuan=no)
+AM_CONDITIONAL(HAVE_ASSUAN, test "$have_libassuan" = "yes")
+if test "$have_libassuan" = "yes"; then
+ AC_DEFINE(ENABLE_ASSUAN,1,[Whether Assuan support is enabled])
+fi
-
# Checks for system services
NEED_GPG_VERSION_DEFAULT=1.3.0
NEED_GPGSM_VERSION_DEFAULT=1.9.6
@@ -510,7 +513,13 @@
run_gpgsm_test=$enableval)
AM_CONDITIONAL(RUN_GPGSM_TESTS, test "$run_gpgsm_test" = "yes")
+# Require libassuan if GPGSM is here.
+require_libassuan=no
+if test "$GPGSM" != "no"; then
+ require_libassuan=yes
+fi
+
NO_OVERRIDE=no
AC_ARG_WITH(gpgconf,
AC_HELP_STRING([--with-gpgconf=PATH],
@@ -614,13 +623,6 @@
fi
-# FIXME: Only build if supported.
-AM_CONDITIONAL(BUILD_ASSUAN, test "$GPGSM" != "no")
-if test "$GPGSM" != "no"; then
- AC_DEFINE(HAVE_ASSUAN_H, 1,
- [Defined if we are building with assuan support.])
-fi
-
# Check for funopen
AC_CHECK_FUNCS(funopen)
if test $ac_cv_func_funopen != yes; then
@@ -636,18 +638,12 @@
fi
fi
-# More assuan replacement functions.
-AC_REPLACE_FUNCS(isascii)
-AC_REPLACE_FUNCS(putc_unlocked)
-AC_REPLACE_FUNCS(memrchr)
+# Replacement functions.
AC_REPLACE_FUNCS(stpcpy)
# Check for unistd.h for setenv replacement function.
AC_CHECK_HEADERS(unistd.h)
AC_REPLACE_FUNCS(setenv)
-# More assuan checks.
-AC_CHECK_HEADERS([sys/uio.h])
-
# Assuan check for descriptor passing.
AC_CHECK_MEMBER(struct cmsghdr.cmsg_len,
[supports_descriptor_passing=yes],
@@ -684,28 +680,7 @@
AM_CONDITIONAL(USE_DESCRIPTOR_PASSING, test "$use_descriptor_passing" = "yes")
-# Assuan check for the getsockopt SO_PEERCRED
-AC_MSG_CHECKING(for SO_PEERCRED)
-AC_CACHE_VAL(assuan_cv_sys_so_peercred,
- [AC_TRY_COMPILE([#include <sys/socket.h>],
- [struct ucred cr;
- int cl = sizeof cr;
- getsockopt (1, SOL_SOCKET, SO_PEERCRED, &cr, &cl);],
- assuan_cv_sys_so_peercred=yes,
- assuan_cv_sys_so_peercred=no)
- ])
-AC_MSG_RESULT($assuan_cv_sys_so_peercred)
-if test $assuan_cv_sys_so_peercred = yes; then
- AC_DEFINE(HAVE_SO_PEERCRED, 1,
- [Defined if SO_PEERCRED is supported (Linux specific)])
-fi
-if test "$have_w32_system" = yes; then
- NETLIBS="-lws2_32 $NETLIBS"
-fi
-
-# End of assuan checks.
-
AM_CONDITIONAL(BUILD_COMPLUS, test "$component_system" = "COM+")
# Generate values for the DLL version info
@@ -753,6 +728,28 @@
sed 's,\.[[^.]]* ,.lo ,g;s,\.[[^.]]*$,.lo,'`
AC_SUBST(LTLIBOBJS)
+# Last check.
+die=no
+if test "$require_libassuan" = "no"; then
+ die=yes
+ AC_MSG_NOTICE([[
+***
+*** You need libassuan to build this program with GPGSM support.
+*** This library is for example available at
+*** ftp://ftp.gnupg.org/pub/gcrypt/alpha/libassuan/
+*** (at least version $NEED_LIBASSUAN_VERSION is required).
+***]])
+fi
+
+if test "$die" = "yes"; then
+ AC_MSG_ERROR([[
+***
+*** Required libraries not found. Please consult the above messages
+*** and install them before running configure again.
+***]])
+fi
+
+
#
# Create config files
@@ -780,6 +777,8 @@
GpgConf path: $GPGCONF
GpgConf version: $GPGCONF_VERSION, min. $NEED_GPGCONF_VERSION
+ Assuan version: $LIBASSUAN_VERSION
+
GPGME Pthread: $have_pthread
GPGME Pth: $have_pth
"
Added: trunk/m4/libassuan.m4
===================================================================
--- trunk/m4/libassuan.m4 (rev 0)
+++ trunk/m4/libassuan.m4 2009-10-20 15:39:15 UTC (rev 1398)
@@ -0,0 +1,79 @@
+dnl Autoconf macros for libassuan
+dnl Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+dnl
+dnl This file is free software; as a special exception the author gives
+dnl unlimited permission to copy and/or distribute it, with or without
+dnl modifications, as long as this notice is preserved.
+dnl
+dnl This file is distributed in the hope that it will be useful, but
+dnl WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
+dnl implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+
+dnl AM_PATH_LIBASSUAN([MINIMUM-VERSION,
+dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]])
+dnl Test for libassuan and define LIBASSUAN_CFLAGS and LIBASSUAN_LIBS
+dnl
+AC_DEFUN([AM_PATH_LIBASSUAN],
+[ AC_ARG_WITH(libassuan-prefix,
+ AC_HELP_STRING([--with-libassuan-prefix=PFX],
+ [prefix where LIBASSUAN is installed (optional)]),
+ libassuan_config_prefix="$withval", libassuan_config_prefix="")
+ if test x$libassuan_config_prefix != x ; then
+ libassuan_config_args="$libassuan_config_args --prefix=$libassuan_config_prefix"
+ if test x${LIBASSUAN_CONFIG+set} != xset ; then
+ LIBASSUAN_CONFIG=$libassuan_config_prefix/bin/libassuan-config
+ fi
+ fi
+
+ AC_PATH_PROG(LIBASSUAN_CONFIG, libassuan-config, no)
+ min_libassuan_version=ifelse([$1], ,0.0.1,$1)
+ AC_MSG_CHECKING(for LIBASSUAN - version >= $min_libassuan_version)
+ ok=no
+ if test "$LIBASSUAN_CONFIG" != "no" ; then
+ req_major=`echo $min_libassuan_version | \
+ sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
+ req_minor=`echo $min_libassuan_version | \
+ sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
+ req_micro=`echo $min_libassuan_version | \
+ sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
+ libassuan_config_version=`$LIBASSUAN_CONFIG $libassuan_config_args --version`
+ major=`echo $libassuan_config_version | \
+ sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
+ minor=`echo $libassuan_config_version | \
+ sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
+ micro=`echo $libassuan_config_version | \
+ sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`
+ if test "$major" -gt "$req_major"; then
+ ok=yes
+ else
+ if test "$major" -eq "$req_major"; then
+ if test "$minor" -gt "$req_minor"; then
+ ok=yes
+ else
+ if test "$minor" -eq "$req_minor"; then
+ if test "$micro" -ge "$req_micro"; then
+ ok=yes
+ fi
+ fi
+ fi
+ fi
+ fi
+ fi
+ if test $ok = yes; then
+ LIBASSUAN_CFLAGS=`$LIBASSUAN_CONFIG $libassuan_config_args --cflags`
+ LIBASSUAN_LIBS=`$LIBASSUAN_CONFIG $libassuan_config_args --libs`
+ LIBASSUAN_VERSION="$LIBASSUAN_CONFIG_VERSION"
+ AC_MSG_RESULT(yes)
+ ifelse([$2], , :, [$2])
+ else
+ LIBASSUAN_CFLAGS=""
+ LIBASSUAN_LIBS=""
+ LIBASSUAN_VERSION=""
+ AC_MSG_RESULT(no)
+ ifelse([$3], , :, [$3])
+ fi
+ AC_SUBST(LIBASSUAN_CFLAGS)
+ AC_SUBST(LIBASSUAN_LIBS)
+ AC_SUBST(LIBASSUAN_VERSION)
+])
Modified: trunk/src/Makefile.am
===================================================================
--- trunk/src/Makefile.am 2009-10-15 20:54:25 UTC (rev 1397)
+++ trunk/src/Makefile.am 2009-10-20 15:39:15 UTC (rev 1398)
@@ -60,14 +60,6 @@
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 @@
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 @@
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 @@
# 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 @@
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 @@
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
Modified: trunk/src/engine-assuan.c
===================================================================
--- trunk/src/engine-assuan.c 2009-10-15 20:54:25 UTC (rev 1397)
+++ trunk/src/engine-assuan.c 2009-10-20 15:39:15 UTC (rev 1398)
@@ -161,7 +161,7 @@
if (llass->assuan_ctx)
{
- assuan_disconnect (llass->assuan_ctx);
+ assuan_release (llass->assuan_ctx);
llass->assuan_ctx = NULL;
}
@@ -213,9 +213,12 @@
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;
if (llass->opt.gpg_agent)
{
Modified: trunk/src/engine-backend.h
===================================================================
--- trunk/src/engine-backend.h 2009-10-15 20:54:25 UTC (rev 1397)
+++ trunk/src/engine-backend.h 2009-10-20 15:39:15 UTC (rev 1398)
@@ -129,7 +129,7 @@
#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
Modified: trunk/src/engine-gpgsm.c
===================================================================
--- trunk/src/engine-gpgsm.c 2009-10-15 20:54:25 UTC (rev 1397)
+++ trunk/src/engine-gpgsm.c 2009-10-20 15:39:15 UTC (rev 1398)
@@ -171,132 +171,6 @@
}
-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 @@
if (gpgsm->assuan_ctx)
{
- assuan_disconnect (gpgsm->assuan_ctx);
+ assuan_release (gpgsm->assuan_ctx);
gpgsm->assuan_ctx = NULL;
}
@@ -450,13 +324,20 @@
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 @@
NULL, NULL, NULL);
free (optstr);
if (err)
- {
- err = map_assuan_error (err);
- goto leave;
- }
+ goto leave;
}
if (isatty (1))
@@ -531,10 +409,7 @@
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 @@
NULL, NULL, NULL, NULL);
free (optstr);
if (err)
- {
- err = map_assuan_error (err);
- goto leave;
- }
+ goto leave;
}
}
}
@@ -662,8 +534,6 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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);
Modified: trunk/src/posix-io.c
===================================================================
--- trunk/src/posix-io.c 2009-10-15 20:54:25 UTC (rev 1397)
+++ trunk/src/posix-io.c 2009-10-20 15:39:15 UTC (rev 1398)
@@ -278,7 +278,7 @@
}
-static int
+int
_gpgme_io_waitpid (int pid, int hang, int *r_status, int *r_signal)
{
int status;
Modified: trunk/src/priv-io.h
===================================================================
--- trunk/src/priv-io.h 2009-10-15 20:54:25 UTC (rev 1397)
+++ trunk/src/priv-io.h 2009-10-20 15:39:15 UTC (rev 1398)
@@ -92,4 +92,10 @@
(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 */
Modified: trunk/src/util.h
===================================================================
--- trunk/src/util.h 2009-10-15 20:54:25 UTC (rev 1397)
+++ trunk/src/util.h 2009-10-20 15:39:15 UTC (rev 1398)
@@ -124,4 +124,14 @@
#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 */
More information about the Gnupg-commits
mailing list