summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am35
-rw-r--r--src/Makefile.in114
-rw-r--r--src/argparse.c4
-rw-r--r--src/argparse.h2
-rw-r--r--src/ath-pthread.c188
-rw-r--r--src/ath.c51
-rw-r--r--src/ath.h13
-rw-r--r--src/b64dec.c2
-rw-r--r--src/context.h19
-rw-r--r--src/data-identify.c2
-rw-r--r--src/decrypt-verify.c4
-rw-r--r--src/decrypt.c15
-rw-r--r--src/dirinfo.c2
-rw-r--r--src/engine-assuan.c3
-rw-r--r--src/engine-backend.h15
-rw-r--r--src/engine-g13.c1
-rw-r--r--src/engine-gpg.c73
-rw-r--r--src/engine-gpgconf.c273
-rw-r--r--src/engine-gpgsm.c13
-rw-r--r--src/engine-spawn.c3
-rw-r--r--src/engine-uiserver.c32
-rw-r--r--src/engine.c36
-rw-r--r--src/engine.h18
-rw-r--r--src/export.c2
-rw-r--r--src/genkey.c2
-rw-r--r--src/getauditlog.c2
-rw-r--r--src/gpgconf.c4
-rw-r--r--src/gpgme-config.in8
-rw-r--r--src/gpgme-tool.c2
-rw-r--r--src/gpgme-w32spawn.c2
-rw-r--r--src/gpgme.c168
-rw-r--r--src/gpgme.def7
-rw-r--r--src/gpgme.h.in74
-rw-r--r--src/keylist.c17
-rw-r--r--src/keysign.c2
-rw-r--r--src/libgpgme.vers7
-rw-r--r--src/mbox-util.c2
-rw-r--r--src/mbox-util.h2
-rw-r--r--src/op-support.c2
-rw-r--r--src/opassuan.c2
-rw-r--r--src/parsetlv.c2
-rw-r--r--src/parsetlv.h2
-rw-r--r--src/passwd.c2
-rw-r--r--src/posix-io.c6
-rw-r--r--src/posix-sema.c68
-rw-r--r--src/queryswdb.c121
-rw-r--r--src/sema.h43
-rw-r--r--src/sys-util.h2
-rw-r--r--src/tofupolicy.c2
-rw-r--r--src/ttyname_r.c2
-rw-r--r--src/util.h5
-rw-r--r--src/verify.c3
-rw-r--r--src/version.c1
-rw-r--r--src/w32-ce.c2
-rw-r--r--src/w32-io.c38
-rw-r--r--src/w32-sema.c117
-rw-r--r--src/w32-util.c15
57 files changed, 929 insertions, 725 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index f166f3b..ce6f1d4 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -14,7 +14,7 @@
# 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/>.
+# License along with this program; if not, see <https://www.gnu.org/licenses/>.
## Process this file with automake to produce Makefile.in
@@ -28,20 +28,13 @@ nodist_include_HEADERS = gpgme.h
bin_PROGRAMS = gpgme-tool
-if HAVE_PTHREAD
-ltlib_gpgme_pthread = libgpgme-pthread.la
-else
-ltlib_gpgme_pthread =
-endif
-
if BUILD_W32_GLIB
ltlib_gpgme_glib = libgpgme-glib.la
else
ltlib_gpgme_glib =
endif
-lib_LTLIBRARIES = libgpgme.la $(ltlib_gpgme_glib) $(ltlib_gpgme_qt) \
- $(ltlib_gpgme_pthread)
+lib_LTLIBRARIES = libgpgme.la $(ltlib_gpgme_glib)
if HAVE_LD_VERSION_SCRIPT
libgpgme_version_script_cmd = -Wl,--version-script=$(srcdir)/libgpgme.vers
@@ -50,10 +43,10 @@ libgpgme_version_script_cmd =
endif
if HAVE_DOSISH_SYSTEM
-system_components = w32-util.c w32-sema.c
+system_components = w32-util.c
system_components_not_extra = w32-io.c
else
-system_components = ath.h posix-util.c posix-sema.c posix-io.c
+system_components = ath.h posix-util.c posix-io.c
system_components_not_extra =
endif
@@ -91,17 +84,15 @@ main_sources = \
$(uiserver_components) \
engine-g13.c vfs-mount.c vfs-create.c \
engine-spawn.c \
- gpgconf.c \
+ gpgconf.c queryswdb.c \
sema.h priv-io.h $(system_components) sys-util.h dirinfo.c \
- debug.c debug.h gpgme.c version.c error.c
+ debug.c debug.h gpgme.c version.c error.c \
+ ath.h ath.c
-libgpgme_la_SOURCES = $(main_sources) \
- ath.h ath.c $(system_components_not_extra)
-libgpgme_pthread_la_SOURCES = $(main_sources) \
- ath.h ath-pthread.c $(system_components_not_extra)
+libgpgme_la_SOURCES = $(main_sources) $(system_components_not_extra)
if BUILD_W32_GLIB
-libgpgme_glib_la_SOURCES = $(main_sources) ath.h ath.c w32-glib-io.c
+libgpgme_glib_la_SOURCES = $(main_sources) w32-glib-io.c
endif
# We use a global CFLAGS setting for all library
@@ -163,14 +154,6 @@ libgpgme_la_DEPENDENCIES = @LTLIBOBJS@ $(srcdir)/libgpgme.vers $(gpgme_deps)
libgpgme_la_LIBADD = $(gpgme_res) @LIBASSUAN_LIBS@ @LTLIBOBJS@ \
@GPG_ERROR_LIBS@
-libgpgme_pthread_la_LDFLAGS = \
- $(no_undefined) $(export_symbols) $(extra_ltoptions) \
- $(libgpgme_version_script_cmd) -version-info \
- @LIBGPGME_LT_CURRENT@:@LIBGPGME_LT_REVISION@:@LIBGPGME_LT_AGE@
-libgpgme_pthread_la_DEPENDENCIES = @LTLIBOBJS@ $(srcdir)/libgpgme.vers
-libgpgme_pthread_la_LIBADD = $(gpgme_res) @LIBASSUAN_LIBS@ @LTLIBOBJS@ \
- -lpthread @GPG_ERROR_LIBS@
-
if BUILD_W32_GLIB
libgpgme_glib_la_LDFLAGS = \
$(no_undefined) $(export_symbols) $(extra_ltoptions) \
diff --git a/src/Makefile.in b/src/Makefile.in
index d70de3b..3f0da74 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -30,7 +30,7 @@
# 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/>.
+# License along with this program; if not, see <https://www.gnu.org/licenses/>.
@@ -107,8 +107,8 @@ subdir = src
DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
$(top_srcdir)/build-aux/mkinstalldirs \
$(srcdir)/versioninfo.rc.in $(srcdir)/gpgme.h.in \
- $(srcdir)/gpgme-config.in vasprintf.c funopen.c stpcpy.c \
- setenv.c ttyname_r.c $(top_srcdir)/build-aux/depcomp
+ $(srcdir)/gpgme-config.in stpcpy.c funopen.c ttyname_r.c \
+ vasprintf.c setenv.c $(top_srcdir)/build-aux/depcomp
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_cxx_compile_stdcxx.m4 \
$(top_srcdir)/m4/ax_pkg_swig.m4 \
@@ -172,16 +172,15 @@ am__libgpgme_glib_la_SOURCES_DIST = util.h conversion.c b64dec.c \
engine-backend.h engine.c engine-gpg.c status-table.c \
engine-gpgsm.c engine-assuan.c engine-gpgconf.c \
engine-uiserver.c engine-g13.c vfs-mount.c vfs-create.c \
- engine-spawn.c gpgconf.c sema.h priv-io.h ath.h posix-util.c \
- posix-sema.c posix-io.c w32-ce.h w32-ce.c w32-util.c \
- w32-sema.c sys-util.h dirinfo.c debug.c debug.h gpgme.c \
- version.c error.c ath.c w32-glib-io.c
+ engine-spawn.c gpgconf.c queryswdb.c sema.h priv-io.h ath.h \
+ posix-util.c posix-io.c w32-ce.h w32-ce.c w32-util.c \
+ sys-util.h dirinfo.c debug.c debug.h gpgme.c version.c error.c \
+ ath.c w32-glib-io.c
@HAVE_UISERVER_TRUE@am__objects_1 = engine-uiserver.lo
@HAVE_W32CE_SYSTEM_TRUE@am__objects_2 = w32-ce.lo
-@HAVE_DOSISH_SYSTEM_FALSE@am__objects_3 = posix-util.lo posix-sema.lo \
-@HAVE_DOSISH_SYSTEM_FALSE@ posix-io.lo $(am__objects_2)
-@HAVE_DOSISH_SYSTEM_TRUE@am__objects_3 = w32-util.lo w32-sema.lo \
-@HAVE_DOSISH_SYSTEM_TRUE@ $(am__objects_2)
+@HAVE_DOSISH_SYSTEM_FALSE@am__objects_3 = posix-util.lo posix-io.lo \
+@HAVE_DOSISH_SYSTEM_FALSE@ $(am__objects_2)
+@HAVE_DOSISH_SYSTEM_TRUE@am__objects_3 = w32-util.lo $(am__objects_2)
am__objects_4 = conversion.lo b64dec.lo get-env.lo parsetlv.lo \
mbox-util.lo data.lo data-fd.lo data-stream.lo data-mem.lo \
data-user.lo data-compat.lo data-identify.lo signers.lo \
@@ -194,10 +193,11 @@ am__objects_4 = conversion.lo b64dec.lo get-env.lo parsetlv.lo \
spawn.lo assuan-support.lo engine.lo engine-gpg.lo \
status-table.lo engine-gpgsm.lo engine-assuan.lo \
engine-gpgconf.lo $(am__objects_1) engine-g13.lo vfs-mount.lo \
- vfs-create.lo engine-spawn.lo gpgconf.lo $(am__objects_3) \
- dirinfo.lo debug.lo gpgme.lo version.lo error.lo
+ vfs-create.lo engine-spawn.lo gpgconf.lo queryswdb.lo \
+ $(am__objects_3) dirinfo.lo debug.lo gpgme.lo version.lo \
+ error.lo ath.lo
@BUILD_W32_GLIB_TRUE@am_libgpgme_glib_la_OBJECTS = $(am__objects_4) \
-@BUILD_W32_GLIB_TRUE@ ath.lo w32-glib-io.lo
+@BUILD_W32_GLIB_TRUE@ w32-glib-io.lo
libgpgme_glib_la_OBJECTS = $(am_libgpgme_glib_la_OBJECTS)
AM_V_lt = $(am__v_lt_@AM_V@)
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
@@ -208,32 +208,6 @@ libgpgme_glib_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \
$(AM_CFLAGS) $(CFLAGS) $(libgpgme_glib_la_LDFLAGS) $(LDFLAGS) \
-o $@
@BUILD_W32_GLIB_TRUE@am_libgpgme_glib_la_rpath = -rpath $(libdir)
-am__libgpgme_pthread_la_SOURCES_DIST = util.h conversion.c b64dec.c \
- get-env.c context.h ops.h parsetlv.c parsetlv.h mbox-util.c \
- mbox-util.h data.h data.c data-fd.c data-stream.c data-mem.c \
- data-user.c data-compat.c data-identify.c signers.c \
- sig-notation.c wait.c wait-global.c wait-private.c wait-user.c \
- wait.h op-support.c encrypt.c encrypt-sign.c decrypt.c \
- decrypt-verify.c verify.c sign.c passphrase.c progress.c key.c \
- keylist.c keysign.c trust-item.c trustlist.c tofupolicy.c \
- import.c export.c genkey.c delete.c edit.c getauditlog.c \
- opassuan.c passwd.c spawn.c assuan-support.c engine.h \
- engine-backend.h engine.c engine-gpg.c status-table.c \
- engine-gpgsm.c engine-assuan.c engine-gpgconf.c \
- engine-uiserver.c engine-g13.c vfs-mount.c vfs-create.c \
- engine-spawn.c gpgconf.c sema.h priv-io.h ath.h posix-util.c \
- posix-sema.c posix-io.c w32-ce.h w32-ce.c w32-util.c \
- w32-sema.c sys-util.h dirinfo.c debug.c debug.h gpgme.c \
- version.c error.c ath-pthread.c w32-io.c
-@HAVE_DOSISH_SYSTEM_TRUE@am__objects_5 = w32-io.lo
-am_libgpgme_pthread_la_OBJECTS = $(am__objects_4) ath-pthread.lo \
- $(am__objects_5)
-libgpgme_pthread_la_OBJECTS = $(am_libgpgme_pthread_la_OBJECTS)
-libgpgme_pthread_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \
- $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \
- $(AM_CFLAGS) $(CFLAGS) $(libgpgme_pthread_la_LDFLAGS) \
- $(LDFLAGS) -o $@
-@HAVE_PTHREAD_TRUE@am_libgpgme_pthread_la_rpath = -rpath $(libdir)
am__libgpgme_la_SOURCES_DIST = util.h conversion.c b64dec.c get-env.c \
context.h ops.h parsetlv.c parsetlv.h mbox-util.c mbox-util.h \
data.h data.c data-fd.c data-stream.c data-mem.c data-user.c \
@@ -246,11 +220,12 @@ am__libgpgme_la_SOURCES_DIST = util.h conversion.c b64dec.c get-env.c \
spawn.c assuan-support.c engine.h engine-backend.h engine.c \
engine-gpg.c status-table.c engine-gpgsm.c engine-assuan.c \
engine-gpgconf.c engine-uiserver.c engine-g13.c vfs-mount.c \
- vfs-create.c engine-spawn.c gpgconf.c sema.h priv-io.h ath.h \
- posix-util.c posix-sema.c posix-io.c w32-ce.h w32-ce.c \
- w32-util.c w32-sema.c sys-util.h dirinfo.c debug.c debug.h \
- gpgme.c version.c error.c ath.c w32-io.c
-am_libgpgme_la_OBJECTS = $(am__objects_4) ath.lo $(am__objects_5)
+ vfs-create.c engine-spawn.c gpgconf.c queryswdb.c sema.h \
+ priv-io.h ath.h posix-util.c posix-io.c w32-ce.h w32-ce.c \
+ w32-util.c sys-util.h dirinfo.c debug.c debug.h gpgme.c \
+ version.c error.c ath.c w32-io.c
+@HAVE_DOSISH_SYSTEM_TRUE@am__objects_5 = w32-io.lo
+am_libgpgme_la_OBJECTS = $(am__objects_4) $(am__objects_5)
libgpgme_la_OBJECTS = $(am_libgpgme_la_OBJECTS)
libgpgme_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
@@ -297,10 +272,9 @@ AM_V_CCLD = $(am__v_CCLD_@AM_V@)
am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
am__v_CCLD_0 = @echo " CCLD " $@;
am__v_CCLD_1 =
-SOURCES = $(libgpgme_glib_la_SOURCES) $(libgpgme_pthread_la_SOURCES) \
- $(libgpgme_la_SOURCES) $(gpgme_tool_SOURCES) gpgme-w32spawn.c
+SOURCES = $(libgpgme_glib_la_SOURCES) $(libgpgme_la_SOURCES) \
+ $(gpgme_tool_SOURCES) gpgme-w32spawn.c
DIST_SOURCES = $(am__libgpgme_glib_la_SOURCES_DIST) \
- $(am__libgpgme_pthread_la_SOURCES_DIST) \
$(am__libgpgme_la_SOURCES_DIST) $(gpgme_tool_SOURCES) \
gpgme-w32spawn.c
am__can_run_installinfo = \
@@ -461,6 +435,9 @@ SWIG = @SWIG@
SWIG_LIB = @SWIG_LIB@
SYSROOT = @SYSROOT@
VERSION = @VERSION@
+VERSION_MAJOR = @VERSION_MAJOR@
+VERSION_MICRO = @VERSION_MICRO@
+VERSION_MINOR = @VERSION_MINOR@
VERSION_NUMBER = @VERSION_NUMBER@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
@@ -529,19 +506,14 @@ bin_SCRIPTS = gpgme-config
m4datadir = $(datadir)/aclocal
m4data_DATA = gpgme.m4
nodist_include_HEADERS = gpgme.h
-@HAVE_PTHREAD_FALSE@ltlib_gpgme_pthread =
-@HAVE_PTHREAD_TRUE@ltlib_gpgme_pthread = libgpgme-pthread.la
@BUILD_W32_GLIB_FALSE@ltlib_gpgme_glib =
@BUILD_W32_GLIB_TRUE@ltlib_gpgme_glib = libgpgme-glib.la
-lib_LTLIBRARIES = libgpgme.la $(ltlib_gpgme_glib) $(ltlib_gpgme_qt) \
- $(ltlib_gpgme_pthread)
-
+lib_LTLIBRARIES = libgpgme.la $(ltlib_gpgme_glib)
@HAVE_LD_VERSION_SCRIPT_FALSE@libgpgme_version_script_cmd =
@HAVE_LD_VERSION_SCRIPT_TRUE@libgpgme_version_script_cmd = -Wl,--version-script=$(srcdir)/libgpgme.vers
@HAVE_DOSISH_SYSTEM_FALSE@system_components = ath.h posix-util.c \
-@HAVE_DOSISH_SYSTEM_FALSE@ posix-sema.c posix-io.c \
-@HAVE_DOSISH_SYSTEM_FALSE@ $(am__append_1)
-@HAVE_DOSISH_SYSTEM_TRUE@system_components = w32-util.c w32-sema.c \
+@HAVE_DOSISH_SYSTEM_FALSE@ posix-io.c $(am__append_1)
+@HAVE_DOSISH_SYSTEM_TRUE@system_components = w32-util.c \
@HAVE_DOSISH_SYSTEM_TRUE@ $(am__append_1)
@HAVE_DOSISH_SYSTEM_FALSE@system_components_not_extra =
@HAVE_DOSISH_SYSTEM_TRUE@system_components_not_extra = w32-io.c
@@ -572,17 +544,13 @@ main_sources = \
$(uiserver_components) \
engine-g13.c vfs-mount.c vfs-create.c \
engine-spawn.c \
- gpgconf.c \
+ gpgconf.c queryswdb.c \
sema.h priv-io.h $(system_components) sys-util.h dirinfo.c \
- debug.c debug.h gpgme.c version.c error.c
-
-libgpgme_la_SOURCES = $(main_sources) \
- ath.h ath.c $(system_components_not_extra)
-
-libgpgme_pthread_la_SOURCES = $(main_sources) \
- ath.h ath-pthread.c $(system_components_not_extra)
+ debug.c debug.h gpgme.c version.c error.c \
+ ath.h ath.c
-@BUILD_W32_GLIB_TRUE@libgpgme_glib_la_SOURCES = $(main_sources) ath.h ath.c w32-glib-io.c
+libgpgme_la_SOURCES = $(main_sources) $(system_components_not_extra)
+@BUILD_W32_GLIB_TRUE@libgpgme_glib_la_SOURCES = $(main_sources) w32-glib-io.c
# We use a global CFLAGS setting for all library
# versions, because then every object file is only compiled once.
@@ -610,15 +578,6 @@ libgpgme_la_DEPENDENCIES = @LTLIBOBJS@ $(srcdir)/libgpgme.vers $(gpgme_deps)
libgpgme_la_LIBADD = $(gpgme_res) @LIBASSUAN_LIBS@ @LTLIBOBJS@ \
@GPG_ERROR_LIBS@
-libgpgme_pthread_la_LDFLAGS = \
- $(no_undefined) $(export_symbols) $(extra_ltoptions) \
- $(libgpgme_version_script_cmd) -version-info \
- @LIBGPGME_LT_CURRENT@:@LIBGPGME_LT_REVISION@:@LIBGPGME_LT_AGE@
-
-libgpgme_pthread_la_DEPENDENCIES = @LTLIBOBJS@ $(srcdir)/libgpgme.vers
-libgpgme_pthread_la_LIBADD = $(gpgme_res) @LIBASSUAN_LIBS@ @LTLIBOBJS@ \
- -lpthread @GPG_ERROR_LIBS@
-
@BUILD_W32_GLIB_TRUE@libgpgme_glib_la_LDFLAGS = \
@BUILD_W32_GLIB_TRUE@ $(no_undefined) $(export_symbols) $(extra_ltoptions) \
@BUILD_W32_GLIB_TRUE@ $(libgpgme_version_script_cmd) -version-info \
@@ -709,9 +668,6 @@ clean-libLTLIBRARIES:
libgpgme-glib.la: $(libgpgme_glib_la_OBJECTS) $(libgpgme_glib_la_DEPENDENCIES) $(EXTRA_libgpgme_glib_la_DEPENDENCIES)
$(AM_V_CCLD)$(libgpgme_glib_la_LINK) $(am_libgpgme_glib_la_rpath) $(libgpgme_glib_la_OBJECTS) $(libgpgme_glib_la_LIBADD) $(LIBS)
-libgpgme-pthread.la: $(libgpgme_pthread_la_OBJECTS) $(libgpgme_pthread_la_DEPENDENCIES) $(EXTRA_libgpgme_pthread_la_DEPENDENCIES)
- $(AM_V_CCLD)$(libgpgme_pthread_la_LINK) $(am_libgpgme_pthread_la_rpath) $(libgpgme_pthread_la_OBJECTS) $(libgpgme_pthread_la_LIBADD) $(LIBS)
-
libgpgme.la: $(libgpgme_la_OBJECTS) $(libgpgme_la_DEPENDENCIES) $(EXTRA_libgpgme_la_DEPENDENCIES)
$(AM_V_CCLD)$(libgpgme_la_LINK) -rpath $(libdir) $(libgpgme_la_OBJECTS) $(libgpgme_la_LIBADD) $(LIBS)
install-binPROGRAMS: $(bin_PROGRAMS)
@@ -869,7 +825,6 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/vasprintf.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/argparse.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/assuan-support.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ath-pthread.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ath.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/b64dec.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/conversion.Plo@am__quote@
@@ -916,9 +871,9 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/passphrase.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/passwd.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/posix-io.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/posix-sema.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/posix-util.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/progress.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/queryswdb.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sig-notation.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sign.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/signers.Plo@am__quote@
@@ -934,7 +889,6 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/w32-ce.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/w32-glib-io.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/w32-io.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/w32-sema.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/w32-util.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wait-global.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wait-private.Plo@am__quote@
diff --git a/src/argparse.c b/src/argparse.c
index 003334f..758173f 100644
--- a/src/argparse.c
+++ b/src/argparse.c
@@ -26,7 +26,7 @@
*
* You should have received a copies of the GNU General Public License
* and the GNU Lesser General Public License along with this program;
- * if not, see <http://www.gnu.org/licenses/>.
+ * if not, see <https://www.gnu.org/licenses/>.
*/
/* This file may be used as part of GnuPG or standalone. A GnuPG
@@ -1518,7 +1518,7 @@ ARGPARSE_STR2(ARGPARSE_GPL_VERSION)
"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
"GNU General Public License for more details.\n\n"
"You should have received a copy of the GNU General Public License\n"
-"along with this software. If not, see <http://www.gnu.org/licenses/>.\n";
+"along with this software. If not, see <https://www.gnu.org/licenses/>.\n";
break;
case 40: /* short and long usage */
case 41: p = ""; break;
diff --git a/src/argparse.h b/src/argparse.h
index 10b838f..81e881d 100644
--- a/src/argparse.h
+++ b/src/argparse.h
@@ -25,7 +25,7 @@
*
* You should have received a copies of the GNU General Public License
* and the GNU Lesser General Public License along with this program;
- * if not, see <http://www.gnu.org/licenses/>.
+ * if not, see <https://www.gnu.org/licenses/>.
*/
#ifndef GNUPG_COMMON_ARGPARSE_H
diff --git a/src/ath-pthread.c b/src/ath-pthread.c
deleted file mode 100644
index 47b38ee..0000000
--- a/src/ath-pthread.c
+++ /dev/null
@@ -1,188 +0,0 @@
-/* ath-pthread.c - pthread module for self-adapting thread-safeness library
- Copyright (C) 2002, 2003, 2004 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, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- 02111-1307, USA. */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <stdlib.h>
-#include <errno.h>
-#ifdef HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-#ifdef HAVE_SYS_SELECT_H
-# include <sys/select.h>
-#else
-# ifdef HAVE_SYS_TIME_H
-# include <sys/time.h>
-# endif
-#endif
-#include <sys/types.h>
-#include <sys/wait.h>
-
-#include <pthread.h>
-
-#include "gpgme.h"
-
-#include "ath.h"
-
-
-/* The lock we take while checking for lazy lock initialization. */
-static pthread_mutex_t check_init_lock = PTHREAD_MUTEX_INITIALIZER;
-
-/* Initialize the mutex *PRIV. If JUST_CHECK is true, only do this if
- it is not already initialized. */
-static int
-mutex_pthread_init (ath_mutex_t *priv, int just_check)
-{
- int err = 0;
-
- if (just_check)
- pthread_mutex_lock (&check_init_lock);
- if (!*priv || !just_check)
- {
- pthread_mutex_t *lock = malloc (sizeof (pthread_mutex_t));
- if (!lock)
- err = ENOMEM;
- if (!err)
- {
- err = pthread_mutex_init (lock, NULL);
- if (err)
- free (lock);
- else
- *priv = (ath_mutex_t) lock;
- }
- }
- if (just_check)
- pthread_mutex_unlock (&check_init_lock);
- return err;
-}
-
-
-void
-ath_init (void)
-{
- /* Nothing to do. */
-}
-
-
-uintptr_t
-ath_self (void)
-{
- return (uintptr_t) pthread_self ();
-}
-
-
-int
-ath_mutex_init (ath_mutex_t *lock)
-{
- return mutex_pthread_init (lock, 0);
-}
-
-
-int
-ath_mutex_destroy (ath_mutex_t *lock)
-{
- int err = mutex_pthread_init (lock, 1);
- if (!err)
- {
- err = pthread_mutex_destroy ((pthread_mutex_t *) *lock);
- free (*lock);
- }
- return err;
-}
-
-
-int
-ath_mutex_lock (ath_mutex_t *lock)
-{
- int ret = mutex_pthread_init (lock, 1);
- if (ret)
- return ret;
-
- return pthread_mutex_lock ((pthread_mutex_t *) *lock);
-}
-
-
-int
-ath_mutex_unlock (ath_mutex_t *lock)
-{
- int ret = mutex_pthread_init (lock, 1);
- if (ret)
- return ret;
-
- return pthread_mutex_unlock ((pthread_mutex_t *) *lock);
-}
-
-
-gpgme_ssize_t
-ath_read (int fd, void *buf, size_t nbytes)
-{
- return read (fd, buf, nbytes);
-}
-
-
-gpgme_ssize_t
-ath_write (int fd, const void *buf, size_t nbytes)
-{
- return write (fd, buf, nbytes);
-}
-
-
-gpgme_ssize_t
-ath_select (int nfd, fd_set *rset, fd_set *wset, fd_set *eset,
- struct timeval *timeout)
-{
- return select (nfd, rset, wset, eset, timeout);
-}
-
-
-gpgme_ssize_t
-ath_waitpid (pid_t pid, int *status, int options)
-{
- return waitpid (pid, status, options);
-}
-
-
-int
-ath_accept (int s, struct sockaddr *addr, socklen_t *length_ptr)
-{
- return accept (s, addr, length_ptr);
-}
-
-
-int
-ath_connect (int s, const struct sockaddr *addr, socklen_t length)
-{
- return connect (s, addr, length);
-}
-
-int
-ath_sendmsg (int s, const struct msghdr *msg, int flags)
-{
- return sendmsg (s, msg, flags);
-}
-
-
-int
-ath_recvmsg (int s, struct msghdr *msg, int flags)
-{
- return recvmsg (s, msg, flags);
-}
diff --git a/src/ath.c b/src/ath.c
index ddd8a87..6b4667e 100644
--- a/src/ath.c
+++ b/src/ath.c
@@ -49,11 +49,6 @@
#include "ath.h"
-#define MUTEX_UNLOCKED ((ath_mutex_t) 0)
-#define MUTEX_LOCKED ((ath_mutex_t) 1)
-#define MUTEX_DESTROYED ((ath_mutex_t) 2)
-
-
#ifdef HAVE_W32_SYSTEM
#include <windows.h>
uintptr_t
@@ -80,52 +75,6 @@ ath_self (void)
#endif
-int
-ath_mutex_init (ath_mutex_t *lock)
-{
-#ifndef NDEBUG
- *lock = MUTEX_UNLOCKED;
-#endif
- return 0;
-}
-
-
-int
-ath_mutex_destroy (ath_mutex_t *lock)
-{
-#ifndef NDEBUG
- assert (*lock == MUTEX_UNLOCKED);
-
- *lock = MUTEX_DESTROYED;
-#endif
- return 0;
-}
-
-
-int
-ath_mutex_lock (ath_mutex_t *lock)
-{
-#ifndef NDEBUG
- assert (*lock == MUTEX_UNLOCKED);
-
- *lock = MUTEX_LOCKED;
-#endif
- return 0;
-}
-
-
-int
-ath_mutex_unlock (ath_mutex_t *lock)
-{
-#ifndef NDEBUG
- assert (*lock == MUTEX_LOCKED);
-
- *lock = MUTEX_UNLOCKED;
-#endif
- return 0;
-}
-
-
gpgme_ssize_t
ath_read (int fd, void *buf, size_t nbytes)
{
diff --git a/src/ath.h b/src/ath.h
index 8eb9eb9..a1be9e5 100644
--- a/src/ath.h
+++ b/src/ath.h
@@ -60,10 +60,6 @@
#define _ATH_PREFIX1(x,y) x ## y
#define _ATH_PREFIX2(x,y) _ATH_PREFIX1(x,y)
#define _ATH_PREFIX(x) _ATH_PREFIX2(_ATH_EXT_SYM_PREFIX,x)
-#define ath_mutex_init _ATH_PREFIX(ath_mutex_init)
-#define ath_mutex_destroy _ATH_PREFIX(ath_mutex_destroy)
-#define ath_mutex_lock _ATH_PREFIX(ath_mutex_lock)
-#define ath_mutex_unlock _ATH_PREFIX(ath_mutex_unlock)
#define ath_read _ATH_PREFIX(ath_read)
#define ath_write _ATH_PREFIX(ath_write)
#define ath_select _ATH_PREFIX(ath_select)
@@ -75,17 +71,8 @@
#endif
-typedef void *ath_mutex_t;
-#define ATH_MUTEX_INITIALIZER 0;
-
uintptr_t ath_self (void);
-/* Functions for mutual exclusion. */
-int ath_mutex_init (ath_mutex_t *mutex);
-int ath_mutex_destroy (ath_mutex_t *mutex);
-int ath_mutex_lock (ath_mutex_t *mutex);
-int ath_mutex_unlock (ath_mutex_t *mutex);
-
/* Replacement for the POSIX functions, which can be used to allow
other (user-level) threads to run. */
gpgme_ssize_t ath_read (int fd, void *buf, size_t nbytes);
diff --git a/src/b64dec.c b/src/b64dec.c
index 9a7efca..c824786 100644
--- a/src/b64dec.c
+++ b/src/b64dec.c
@@ -15,7 +15,7 @@
* 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/>.
+ * along with this program; if not, see <https://www.gnu.org/licenses/>.
*/
#include <config.h>
diff --git a/src/context.h b/src/context.h
index 4b12c3b..1a8698c 100644
--- a/src/context.h
+++ b/src/context.h
@@ -15,7 +15,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, see <http://www.gnu.org/licenses/>.
+ License along with this program; if not, see <https://www.gnu.org/licenses/>.
*/
#ifndef CONTEXT_H
@@ -38,7 +38,8 @@ typedef enum
OPDATA_DECRYPT, OPDATA_SIGN, OPDATA_ENCRYPT, OPDATA_PASSPHRASE,
OPDATA_IMPORT, OPDATA_GENKEY, OPDATA_KEYLIST, OPDATA_EDIT,
OPDATA_VERIFY, OPDATA_TRUSTLIST, OPDATA_ASSUAN, OPDATA_VFS_MOUNT,
- OPDATA_PASSWD, OPDATA_EXPORT, OPDATA_KEYSIGN, OPDATA_TOFU_POLICY
+ OPDATA_PASSWD, OPDATA_EXPORT, OPDATA_KEYSIGN, OPDATA_TOFU_POLICY,
+ OPDATA_QUERY_SWDB
} ctx_op_data_id_t;
@@ -110,6 +111,9 @@ struct gpgme_context
* unmodified string, as received form gpg, will be returned. */
unsigned int raw_description : 1;
+ /* True if session keys should be exported upon decryption. */
+ unsigned int export_session_keys : 1;
+
/* Flags for keylist mode. */
gpgme_keylist_mode_t keylist_mode;
@@ -119,16 +123,21 @@ struct gpgme_context
/* Number of certs to be included. */
unsigned int include_certs;
- /* The number of keys in signers. */
+ /* The actual number of keys in SIGNERS, the allocated size of the
+ * array, and the array with the signing keys. */
unsigned int signers_len;
-
- /* Size of the following array. */
unsigned int signers_size;
gpgme_key_t *signers;
/* The signature notations for this context. */
gpgme_sig_notation_t sig_notations;
+ /* The sender's addr-spec or NULL. */
+ char *sender;
+
+ /* The gpg specific override session key or NULL. */
+ char *override_session_key;
+
/* The locale for the pinentry. */
char *lc_ctype;
char *lc_messages;
diff --git a/src/data-identify.c b/src/data-identify.c
index 615a4f3..857d06c 100644
--- a/src/data-identify.c
+++ b/src/data-identify.c
@@ -14,7 +14,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, see <http://www.gnu.org/licenses/>.
+ License along with this program; if not, see <https://www.gnu.org/licenses/>.
*/
#if HAVE_CONFIG_H
diff --git a/src/decrypt-verify.c b/src/decrypt-verify.c
index a334f86..e0aa8ea 100644
--- a/src/decrypt-verify.c
+++ b/src/decrypt-verify.c
@@ -77,7 +77,9 @@ decrypt_verify_start (gpgme_ctx_t ctx, int synchronous,
_gpgme_engine_set_status_handler (ctx->engine,
decrypt_verify_status_handler, ctx);
- return _gpgme_engine_op_decrypt_verify (ctx->engine, cipher, plain);
+ return _gpgme_engine_op_decrypt_verify (ctx->engine, cipher, plain,
+ ctx->export_session_keys,
+ ctx->override_session_key);
}
diff --git a/src/decrypt.c b/src/decrypt.c
index 51e4292..43717c0 100644
--- a/src/decrypt.c
+++ b/src/decrypt.c
@@ -63,6 +63,9 @@ release_op_data (void *hook)
if (opd->result.file_name)
free (opd->result.file_name);
+ if (opd->result.session_key)
+ free (opd->result.session_key);
+
while (recipient)
{
gpgme_recipient_t next = recipient->next;
@@ -277,6 +280,12 @@ _gpgme_decrypt_status_handler (void *priv, gpgme_status_code_t code,
opd->last_recipient_p = &(*opd->last_recipient_p)->next;
break;
+ case GPGME_STATUS_SESSION_KEY:
+ if (opd->result.session_key)
+ free (opd->result.session_key);
+ opd->result.session_key = strdup(args);
+ break;
+
case GPGME_STATUS_NO_SECKEY:
{
gpgme_recipient_t rec = opd->result.recipients;
@@ -351,7 +360,7 @@ _gpgme_op_decrypt_init_result (gpgme_ctx_t ctx)
static gpgme_error_t
decrypt_start (gpgme_ctx_t ctx, int synchronous,
- gpgme_data_t cipher, gpgme_data_t plain)
+ gpgme_data_t cipher, gpgme_data_t plain)
{
gpgme_error_t err;
@@ -381,7 +390,9 @@ decrypt_start (gpgme_ctx_t ctx, int synchronous,
_gpgme_engine_set_status_handler (ctx->engine, decrypt_status_handler, ctx);
- return _gpgme_engine_op_decrypt (ctx->engine, cipher, plain);
+ return _gpgme_engine_op_decrypt (ctx->engine, cipher, plain,
+ ctx->export_session_keys,
+ ctx->override_session_key);
}
diff --git a/src/dirinfo.c b/src/dirinfo.c
index b24a8a0..a0cbc03 100644
--- a/src/dirinfo.c
+++ b/src/dirinfo.c
@@ -14,7 +14,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, see <http://www.gnu.org/licenses/>.
+ * License along with this program; if not, see <https://www.gnu.org/licenses/>.
*/
#if HAVE_CONFIG_H
diff --git a/src/engine-assuan.c b/src/engine-assuan.c
index 65924eb..3e3b89f 100644
--- a/src/engine-assuan.c
+++ b/src/engine-assuan.c
@@ -14,7 +14,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, see <http://www.gnu.org/licenses/>.
+ * License along with this program; if not, see <https://www.gnu.org/licenses/>.
*/
/*
@@ -796,6 +796,7 @@ struct engine_ops _gpgme_engine_ops_assuan =
llass_transact, /* opassuan_transact */
NULL, /* conf_load */
NULL, /* conf_save */
+ NULL, /* query_swdb */
llass_set_io_cbs,
llass_io_event,
llass_cancel,
diff --git a/src/engine-backend.h b/src/engine-backend.h
index ccab0e3..a8457af 100644
--- a/src/engine-backend.h
+++ b/src/engine-backend.h
@@ -14,7 +14,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, see <http://www.gnu.org/licenses/>.
+ License along with this program; if not, see <https://www.gnu.org/licenses/>.
*/
#ifndef ENGINE_BACKEND_H
@@ -62,9 +62,11 @@ struct engine_ops
gpgme_error_t (*set_locale) (void *engine, int category, const char *value);
gpgme_error_t (*set_protocol) (void *engine, gpgme_protocol_t protocol);
gpgme_error_t (*decrypt) (void *engine, gpgme_data_t ciph,
- gpgme_data_t plain);
+ gpgme_data_t plain, int export_session_key,
+ const char *override_session_key);
gpgme_error_t (*decrypt_verify) (void *engine, gpgme_data_t ciph,
- gpgme_data_t plain);
+ gpgme_data_t plain, int export_session_key,
+ const char *override_session_key);
gpgme_error_t (*delete) (void *engine, gpgme_key_t key, int allow_secret);
gpgme_error_t (*edit) (void *engine, int type, gpgme_key_t key,
gpgme_data_t out, gpgme_ctx_t ctx /* FIXME */);
@@ -111,7 +113,8 @@ struct engine_ops
gpgme_ctx_t ctx /* FIXME */);
gpgme_error_t (*trustlist) (void *engine, const char *pattern);
gpgme_error_t (*verify) (void *engine, gpgme_data_t sig,
- gpgme_data_t signed_text, gpgme_data_t plaintext);
+ gpgme_data_t signed_text, gpgme_data_t plaintext,
+ gpgme_ctx_t ctx);
gpgme_error_t (*getauditlog) (void *engine, gpgme_data_t output,
unsigned int flags);
gpgme_error_t (*opassuan_transact) (void *engine,
@@ -126,6 +129,10 @@ struct engine_ops
gpgme_error_t (*conf_load) (void *engine, gpgme_conf_comp_t *conf_p);
gpgme_error_t (*conf_save) (void *engine, gpgme_conf_comp_t conf);
+ gpgme_error_t (*query_swdb) (void *engine,
+ const char *name, const char *iversion,
+ gpgme_query_swdb_result_t result);
+
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);
diff --git a/src/engine-g13.c b/src/engine-g13.c
index d34db82..972c3a8 100644
--- a/src/engine-g13.c
+++ b/src/engine-g13.c
@@ -811,6 +811,7 @@ struct engine_ops _gpgme_engine_ops_g13 =
g13_transact,
NULL, /* conf_load */
NULL, /* conf_save */
+ NULL, /* query_swdb */
g13_set_io_cbs,
g13_io_event,
g13_cancel,
diff --git a/src/engine-gpg.c b/src/engine-gpg.c
index 4415c94..3ddaa07 100644
--- a/src/engine-gpg.c
+++ b/src/engine-gpg.c
@@ -16,7 +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, see <http://www.gnu.org/licenses/>.
+ License along with this program; if not, see <https://www.gnu.org/licenses/>.
*/
#if HAVE_CONFIG_H
@@ -139,6 +139,9 @@ struct engine_gpg
struct gpgme_io_cbs io_cbs;
gpgme_pinentry_mode_t pinentry_mode;
+
+ /* NULL or the data object fed to --override_session_key-fd. */
+ gpgme_data_t override_session_key;
};
typedef struct engine_gpg *engine_gpg_t;
@@ -441,6 +444,8 @@ gpg_release (void *engine)
if (gpg->cmd.keyword)
free (gpg->cmd.keyword);
+ gpgme_data_release (gpg->override_session_key);
+
free (gpg);
}
@@ -1550,13 +1555,45 @@ add_input_size_hint (engine_gpg_t gpg, gpgme_data_t data)
static gpgme_error_t
-gpg_decrypt (void *engine, gpgme_data_t ciph, gpgme_data_t plain)
+gpg_decrypt (void *engine, gpgme_data_t ciph, gpgme_data_t plain,
+ int export_session_key, const char *override_session_key)
{
engine_gpg_t gpg = engine;
gpgme_error_t err;
err = add_arg (gpg, "--decrypt");
+ if (!err && export_session_key)
+ err = add_arg (gpg, "--show-session-key");
+
+ if (!err && override_session_key && *override_session_key)
+ {
+ if (have_gpg_version (gpg, "2.1.16"))
+ {
+ gpgme_data_release (gpg->override_session_key);
+ TRACE2 (DEBUG_ENGINE, "override", gpg, "seskey='%s' len=%zu\n",
+ override_session_key,
+ strlen (override_session_key));
+
+ err = gpgme_data_new_from_mem (&gpg->override_session_key,
+ override_session_key,
+ strlen (override_session_key), 1);
+ if (!err)
+ {
+ err = add_arg (gpg, "--override-session-key-fd");
+ if (!err)
+ err = add_data (gpg, gpg->override_session_key, -2, 0);
+ }
+ }
+ else
+ {
+ /* Using that option may leak the session key via ps(1). */
+ err = add_arg (gpg, "--override-session-key");
+ if (!err)
+ err = add_arg (gpg, override_session_key);
+ }
+ }
+
/* Tell the gpg object about the data. */
if (!err)
err = add_arg (gpg, "--output");
@@ -1646,6 +1683,23 @@ append_args_from_signers (engine_gpg_t gpg, gpgme_ctx_t ctx /* FIXME */)
static gpgme_error_t
+append_args_from_sender (engine_gpg_t gpg, gpgme_ctx_t ctx)
+{
+ gpgme_error_t err;
+
+ if (ctx->sender && have_gpg_version (gpg, "2.1.15"))
+ {
+ err = add_arg (gpg, "--sender");
+ if (!err)
+ err = add_arg (gpg, ctx->sender);
+ }
+ else
+ err = 0;
+ return err;
+}
+
+
+static gpgme_error_t
append_args_from_sig_notations (engine_gpg_t gpg, gpgme_ctx_t ctx /* FIXME */)
{
gpgme_error_t err = 0;
@@ -1893,6 +1947,9 @@ gpg_encrypt_sign (void *engine, gpgme_key_t recp[],
err = append_args_from_signers (gpg, ctx);
if (!err)
+ err = append_args_from_sender (gpg, ctx);
+
+ if (!err)
err = append_args_from_sig_notations (gpg, ctx);
/* Tell the gpg object about the data. */
@@ -2794,6 +2851,8 @@ gpg_sign (void *engine, gpgme_data_t in, gpgme_data_t out,
if (!err)
err = append_args_from_signers (gpg, ctx);
if (!err)
+ err = append_args_from_sender (gpg, ctx);
+ if (!err)
err = append_args_from_sig_notations (gpg, ctx);
if (gpgme_data_get_file_name (in))
@@ -2845,12 +2904,15 @@ gpg_trustlist (void *engine, const char *pattern)
static gpgme_error_t
gpg_verify (void *engine, gpgme_data_t sig, gpgme_data_t signed_text,
- gpgme_data_t plaintext)
+ gpgme_data_t plaintext, gpgme_ctx_t ctx)
{
engine_gpg_t gpg = engine;
- gpgme_error_t err = 0;
+ gpgme_error_t err;
- if (plaintext)
+ err = append_args_from_sender (gpg, ctx);
+ if (err)
+ ;
+ else if (plaintext)
{
/* Normal or cleartext signature. */
err = add_arg (gpg, "--output");
@@ -2944,6 +3006,7 @@ struct engine_ops _gpgme_engine_ops_gpg =
NULL, /* opassuan_transact */
NULL, /* conf_load */
NULL, /* conf_save */
+ NULL, /* query_swdb */
gpg_set_io_cbs,
gpg_io_event,
gpg_cancel,
diff --git a/src/engine-gpgconf.c b/src/engine-gpgconf.c
index 90f32c7..2ea8673 100644
--- a/src/engine-gpgconf.c
+++ b/src/engine-gpgconf.c
@@ -16,7 +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, see <http://www.gnu.org/licenses/>.
+ License along with this program; if not, see <https://www.gnu.org/licenses/>.
*/
#if HAVE_CONFIG_H
@@ -47,16 +47,26 @@
#include "engine-backend.h"
+
struct engine_gpgconf
{
char *file_name;
char *home_dir;
+ char *version;
};
typedef struct engine_gpgconf *engine_gpgconf_t;
+/* Return true if the engine's version is at least VERSION. */
+static int
+have_gpgconf_version (engine_gpgconf_t gpgconf, const char *version)
+{
+ return _gpgme_compare_versions (gpgconf->version, version);
+}
+
+
static char *
gpgconf_get_version (const char *file_name)
{
@@ -84,6 +94,8 @@ gpgconf_release (void *engine)
free (gpgconf->file_name);
if (gpgconf->home_dir)
free (gpgconf->home_dir);
+ if (gpgconf->version)
+ free (gpgconf->version);
free (gpgconf);
}
@@ -96,8 +108,6 @@ gpgconf_new (void **engine, const char *file_name, const char *home_dir,
gpgme_error_t err = 0;
engine_gpgconf_t gpgconf;
- (void)version; /* Not yet used. */
-
gpgconf = calloc (1, sizeof *gpgconf);
if (!gpgconf)
return gpg_error_from_syserror ();
@@ -114,6 +124,13 @@ gpgconf_new (void **engine, const char *file_name, const char *home_dir,
err = gpg_error_from_syserror ();
}
+ if (!err && version)
+ {
+ gpgconf->version = strdup (version);
+ if (!gpgconf->version)
+ err = gpg_error_from_syserror ();
+ }
+
if (err)
gpgconf_release (gpgconf);
else
@@ -209,7 +226,8 @@ gpgconf_read (void *engine, const char *arg1, char *arg2,
char *linebuf;
size_t linebufsize;
int linelen;
- char *argv[4] = { NULL /* file_name */, NULL, NULL, NULL };
+ char *argv[6];
+ int argc = 0;
int rp[2];
struct spawn_fd_item_s cfd[] = { {-1, 1 /* STDOUT_FILENO */, -1, 0},
{-1, -1} };
@@ -217,14 +235,19 @@ gpgconf_read (void *engine, const char *arg1, char *arg2,
int nread;
char *mark = NULL;
- argv[1] = (char*)arg1;
- argv[2] = arg2;
-
+ /* _gpgme_engine_new guarantees that this is not NULL. */
+ argv[argc++] = gpgconf->file_name;
- /* FIXME: Deal with engine->home_dir. */
+ if (gpgconf->home_dir && have_gpgconf_version (gpgconf, "2.1.13"))
+ {
+ argv[argc++] = (char*)"--homedir";
+ argv[argc++] = gpgconf->home_dir;
+ }
- /* _gpgme_engine_new guarantees that this is not NULL. */
- argv[0] = gpgconf->file_name;
+ argv[argc++] = (char*)arg1;
+ argv[argc++] = arg2;
+ argv[argc] = NULL;
+ assert (argc < DIM (argv));
if (_gpgme_io_pipe (rp, 1) < 0)
return gpg_error_from_syserror ();
@@ -685,16 +708,26 @@ gpgconf_write (void *engine, const char *arg1, char *arg2, gpgme_data_t conf)
#define BUFLEN 1024
char buf[BUFLEN];
int buflen = 0;
- char *argv[] = { NULL /* file_name */, (char*)arg1, arg2, 0 };
+ char *argv[6];
+ int argc = 0;
int rp[2];
struct spawn_fd_item_s cfd[] = { {-1, 0 /* STDIN_FILENO */}, {-1, -1} };
int status;
int nwrite;
- /* FIXME: Deal with engine->home_dir. */
-
/* _gpgme_engine_new guarantees that this is not NULL. */
- argv[0] = gpgconf->file_name;
+ argv[argc++] = gpgconf->file_name;
+
+ if (gpgconf->home_dir && have_gpgconf_version (gpgconf, "2.1.13"))
+ {
+ argv[argc++] = (char*)"--homedir";
+ argv[argc++] = gpgconf->home_dir;
+ }
+
+ argv[argc++] = (char*)arg1;
+ argv[argc++] = arg2;
+ argv[argc] = NULL;
+ assert (argc < DIM (argv));
if (_gpgme_io_pipe (rp, 0) < 0)
return gpg_error_from_syserror ();
@@ -909,6 +942,217 @@ gpgconf_conf_save (void *engine, gpgme_conf_comp_t comp)
}
+/* Parse a line received from gpgconf --query-swdb. This function may
+ * modify LINE. The result is stored at RESUL. */
+static gpg_error_t
+parse_swdb_line (char *line, gpgme_query_swdb_result_t result)
+{
+ char *field[9];
+ int fields = 0;
+ gpg_err_code_t ec;
+
+ while (line && fields < DIM (field))
+ {
+ field[fields++] = line;
+ line = strchr (line, ':');
+ if (line)
+ *line++ = 0;
+ }
+ /* We require that all fields exists - gpgme emits all these fields
+ * even on error. They might be empty, though. */
+ if (fields < 9)
+ return gpg_error (GPG_ERR_INV_ENGINE);
+
+ free (result->name);
+ result->name = strdup (field[0]);
+ if (!result->name)
+ return gpg_error_from_syserror ();
+
+ free (result->iversion);
+ result->iversion = strdup (field[1]);
+ if (!result->iversion)
+ return gpg_error_from_syserror ();
+
+ result->urgent = (strtol (field[3], NULL, 10) > 0);
+
+ ec = gpg_err_code (strtoul (field[4], NULL, 10));
+
+ result->created = _gpgme_parse_timestamp (field[5], NULL);
+ result->retrieved= _gpgme_parse_timestamp (field[6], NULL);
+
+ free (result->version);
+ result->version = strdup (field[7]);
+ if (!result->version)
+ return gpg_error_from_syserror ();
+
+ result->reldate = _gpgme_parse_timestamp (field[8], NULL);
+
+ /* Set other flags. */
+ result->warning = !!ec;
+ result->update = 0;
+ result->noinfo = 0;
+ result->unknown = 0;
+ result->tooold = 0;
+ result->error = 0;
+
+ switch (*field[2])
+ {
+ case '-': result->warning = 1; break;
+ case '?': result->unknown = result->warning = 1; break;
+ case 'u': result->update = 1; break;
+ case 'c': break;
+ case 'n': break;
+ default:
+ result->warning = 1;
+ if (!ec)
+ ec = GPG_ERR_INV_ENGINE;
+ break;
+ }
+
+ if (ec == GPG_ERR_TOO_OLD)
+ result->tooold = 1;
+ else if (ec == GPG_ERR_ENOENT)
+ result->noinfo = 1;
+ else if (ec)
+ result->error = 1;
+
+
+ return 0;
+}
+
+
+static gpgme_error_t
+gpgconf_query_swdb (void *engine,
+ const char *name, const char *iversion,
+ gpgme_query_swdb_result_t result)
+{
+ struct engine_gpgconf *gpgconf = engine;
+ gpgme_error_t err = 0;
+ char *linebuf;
+ size_t linebufsize;
+ int linelen;
+ char *argv[7];
+ int argc = 0;
+ int rp[2];
+ struct spawn_fd_item_s cfd[] = { {-1, 1 /* STDOUT_FILENO */, -1, 0},
+ {-1, -1} };
+ int status;
+ int nread;
+ char *mark = NULL;
+
+ if (!have_gpgconf_version (gpgconf, "2.1.16"))
+ return gpg_error (GPG_ERR_ENGINE_TOO_OLD);
+
+ /* _gpgme_engine_new guarantees that this is not NULL. */
+ argv[argc++] = gpgconf->file_name;
+
+ if (gpgconf->home_dir)
+ {
+ argv[argc++] = (char*)"--homedir";
+ argv[argc++] = gpgconf->home_dir;
+ }
+
+ argv[argc++] = (char*)"--query-swdb";
+ argv[argc++] = (char*)name;
+ argv[argc++] = (char*)iversion;
+ argv[argc] = NULL;
+ assert (argc < DIM (argv));
+
+ if (_gpgme_io_pipe (rp, 1) < 0)
+ return gpg_error_from_syserror ();
+
+ cfd[0].fd = rp[1];
+
+ status = _gpgme_io_spawn (gpgconf->file_name, argv,
+ IOSPAWN_FLAG_DETACHED, cfd, NULL, NULL, NULL);
+ if (status < 0)
+ {
+ _gpgme_io_close (rp[0]);
+ _gpgme_io_close (rp[1]);
+ return gpg_error_from_syserror ();
+ }
+
+ linebufsize = 2048; /* Same as used by gpgconf. */
+ linebuf = malloc (linebufsize);
+ if (!linebuf)
+ {
+ err = gpg_error_from_syserror ();
+ goto leave;
+ }
+ linelen = 0;
+
+ while ((nread = _gpgme_io_read (rp[0], linebuf + linelen,
+ linebufsize - linelen - 1)))
+ {
+ char *line;
+ const char *lastmark = NULL;
+ size_t nused;
+
+ if (nread < 0)
+ {
+ err = gpg_error_from_syserror ();
+ goto leave;
+ }
+
+ linelen += nread;
+ linebuf[linelen] = '\0';
+
+ for (line=linebuf; (mark = strchr (line, '\n')); line = mark+1 )
+ {
+ lastmark = mark;
+ if (mark > line && mark[-1] == '\r')
+ mark[-1] = '\0';
+ else
+ mark[0] = '\0';
+
+ /* Got a full line. Due to the CR removal code (which
+ occurs only on Windows) we might be one-off and thus
+ would see empty lines. */
+ if (*line)
+ {
+ err = parse_swdb_line (line, result);
+ goto leave; /* Ready. */
+ }
+ else /* empty line. */
+ err = 0;
+ }
+
+ nused = lastmark? (lastmark + 1 - linebuf) : 0;
+ memmove (linebuf, linebuf + nused, linelen - nused);
+ linelen -= nused;
+
+ if (!(linelen < linebufsize - 1))
+ {
+ char *newlinebuf;
+
+ if (linelen < 8 * 1024 - 1)
+ linebufsize = 8 * 1024;
+ else if (linelen < 64 * 1024 - 1)
+ linebufsize = 64 * 1024;
+ else
+ {
+ /* We reached our limit - give up. */
+ err = gpg_error (GPG_ERR_LINE_TOO_LONG);
+ goto leave;
+ }
+
+ newlinebuf = realloc (linebuf, linebufsize);
+ if (!newlinebuf)
+ {
+ err = gpg_error_from_syserror ();
+ goto leave;
+ }
+ linebuf = newlinebuf;
+ }
+ }
+
+ leave:
+ free (linebuf);
+ _gpgme_io_close (rp[0]);
+ return err;
+}
+
+
static void
gpgconf_set_io_cbs (void *engine, gpgme_io_cbs_t io_cbs)
{
@@ -966,6 +1210,7 @@ struct engine_ops _gpgme_engine_ops_gpgconf =
NULL, /* opassuan_transact */
gpgconf_conf_load,
gpgconf_conf_save,
+ gpgconf_query_swdb,
gpgconf_set_io_cbs,
NULL, /* io_event */
NULL, /* cancel */
diff --git a/src/engine-gpgsm.c b/src/engine-gpgsm.c
index e7e2a20..d1be049 100644
--- a/src/engine-gpgsm.c
+++ b/src/engine-gpgsm.c
@@ -1120,11 +1120,17 @@ gpgsm_reset (void *engine)
static gpgme_error_t
-gpgsm_decrypt (void *engine, gpgme_data_t ciph, gpgme_data_t plain)
+gpgsm_decrypt (void *engine, gpgme_data_t ciph, gpgme_data_t plain,
+ int export_session_key, const char *override_session_key)
{
engine_gpgsm_t gpgsm = engine;
gpgme_error_t err;
+ /* gpgsm is not capable of exporting session keys right now, so we
+ * will ignore this if requested. */
+ (void)export_session_key;
+ (void)override_session_key;
+
if (!gpgsm)
return gpg_error (GPG_ERR_INV_VALUE);
@@ -1901,11 +1907,13 @@ gpgsm_sign (void *engine, gpgme_data_t in, gpgme_data_t out,
static gpgme_error_t
gpgsm_verify (void *engine, gpgme_data_t sig, gpgme_data_t signed_text,
- gpgme_data_t plaintext)
+ gpgme_data_t plaintext, gpgme_ctx_t ctx)
{
engine_gpgsm_t gpgsm = engine;
gpgme_error_t err;
+ (void)ctx;
+
if (!gpgsm)
return gpg_error (GPG_ERR_INV_VALUE);
@@ -2099,6 +2107,7 @@ struct engine_ops _gpgme_engine_ops_gpgsm =
NULL, /* opassuan_transact */
NULL, /* conf_load */
NULL, /* conf_save */
+ NULL, /* query_swdb */
gpgsm_set_io_cbs,
gpgsm_io_event,
gpgsm_cancel,
diff --git a/src/engine-spawn.c b/src/engine-spawn.c
index df90cb2..1cd4421 100644
--- a/src/engine-spawn.c
+++ b/src/engine-spawn.c
@@ -14,7 +14,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, see <http://www.gnu.org/licenses/>.
+ License along with this program; if not, see <https://www.gnu.org/licenses/>.
*/
#if HAVE_CONFIG_H
@@ -469,6 +469,7 @@ struct engine_ops _gpgme_engine_ops_spawn =
NULL, /* opassuan_transact */
NULL, /* conf_load */
NULL, /* conf_save */
+ NULL, /* query_swdb */
engspawn_set_io_cbs,
engspawn_io_event, /* io_event */
engspawn_cancel, /* cancel */
diff --git a/src/engine-uiserver.c b/src/engine-uiserver.c
index 63e77de..ee7b1d2 100644
--- a/src/engine-uiserver.c
+++ b/src/engine-uiserver.c
@@ -960,13 +960,17 @@ uiserver_reset (void *engine)
static gpgme_error_t
_uiserver_decrypt (void *engine, int verify,
- gpgme_data_t ciph, gpgme_data_t plain)
+ gpgme_data_t ciph, gpgme_data_t plain,
+ int export_session_key, const char *override_session_key)
{
engine_uiserver_t uiserver = engine;
gpgme_error_t err;
const char *protocol;
char *cmd;
+ (void)override_session_key; /* Fixme: We need to see now to add this
+ * to the UI server protocol */
+
if (!uiserver)
return gpg_error (GPG_ERR_INV_VALUE);
if (uiserver->protocol == GPGME_PROTOCOL_DEFAULT)
@@ -978,8 +982,9 @@ _uiserver_decrypt (void *engine, int verify,
else
return gpgme_error (GPG_ERR_UNSUPPORTED_PROTOCOL);
- if (asprintf (&cmd, "DECRYPT%s%s", protocol,
- verify ? "" : " --no-verify") < 0)
+ if (asprintf (&cmd, "DECRYPT%s%s%s", protocol,
+ verify ? "" : " --no-verify",
+ export_session_key ? " --export-session-key" : "") < 0)
return gpg_error_from_syserror ();
uiserver->input_cb.data = ciph;
@@ -1006,16 +1011,21 @@ _uiserver_decrypt (void *engine, int verify,
static gpgme_error_t
-uiserver_decrypt (void *engine, gpgme_data_t ciph, gpgme_data_t plain)
+uiserver_decrypt (void *engine, gpgme_data_t ciph, gpgme_data_t plain,
+ int export_session_key, const char *override_session_key)
{
- return _uiserver_decrypt (engine, 0, ciph, plain);
+ return _uiserver_decrypt (engine, 0, ciph, plain,
+ export_session_key, override_session_key);
}
static gpgme_error_t
-uiserver_decrypt_verify (void *engine, gpgme_data_t ciph, gpgme_data_t plain)
+uiserver_decrypt_verify (void *engine, gpgme_data_t ciph, gpgme_data_t plain,
+ int export_session_key,
+ const char *override_session_key)
{
- return _uiserver_decrypt (engine, 1, ciph, plain);
+ return _uiserver_decrypt (engine, 1, ciph, plain,
+ export_session_key, override_session_key);
}
@@ -1243,13 +1253,16 @@ uiserver_sign (void *engine, gpgme_data_t in, gpgme_data_t out,
/* FIXME: Missing a way to specify --silent. */
static gpgme_error_t
uiserver_verify (void *engine, gpgme_data_t sig, gpgme_data_t signed_text,
- gpgme_data_t plaintext)
+ gpgme_data_t plaintext, gpgme_ctx_t ctx)
{
engine_uiserver_t uiserver = engine;
gpgme_error_t err;
const char *protocol;
char *cmd;
+ (void)ctx; /* FIXME: We should to add a --sender option to the
+ * UISever protocol. */
+
if (!uiserver)
return gpg_error (GPG_ERR_INV_VALUE);
if (uiserver->protocol == GPGME_PROTOCOL_DEFAULT)
@@ -1390,11 +1403,12 @@ struct engine_ops _gpgme_engine_ops_uiserver =
NULL, /* opassuan_transact */
NULL, /* conf_load */
NULL, /* conf_save */
+ NULL, /* query_swdb */
uiserver_set_io_cbs,
uiserver_io_event,
uiserver_cancel,
NULL, /* cancel_op */
NULL, /* passwd */
- NULL, /* set_pinentry_mode */
+ NULL, /* set_pinentry_mode */
NULL /* opspawn */
};
diff --git a/src/engine.c b/src/engine.c
index a1173a0..75d9ff7 100644
--- a/src/engine.c
+++ b/src/engine.c
@@ -15,7 +15,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, see <http://www.gnu.org/licenses/>.
+ License along with this program; if not, see <https://www.gnu.org/licenses/>.
*/
#ifdef HAVE_CONFIG_H
@@ -653,7 +653,8 @@ _gpgme_engine_set_protocol (engine_t engine, gpgme_protocol_t protocol)
gpgme_error_t
_gpgme_engine_op_decrypt (engine_t engine, gpgme_data_t ciph,
- gpgme_data_t plain)
+ gpgme_data_t plain, int export_session_key,
+ const char *override_session_key)
{
if (!engine)
return gpg_error (GPG_ERR_INV_VALUE);
@@ -661,13 +662,15 @@ _gpgme_engine_op_decrypt (engine_t engine, gpgme_data_t ciph,
if (!engine->ops->decrypt)
return gpg_error (GPG_ERR_NOT_IMPLEMENTED);
- return (*engine->ops->decrypt) (engine->engine, ciph, plain);
+ return (*engine->ops->decrypt) (engine->engine, ciph, plain,
+ export_session_key, override_session_key);
}
gpgme_error_t
_gpgme_engine_op_decrypt_verify (engine_t engine, gpgme_data_t ciph,
- gpgme_data_t plain)
+ gpgme_data_t plain, int export_session_key,
+ const char *override_session_key)
{
if (!engine)
return gpg_error (GPG_ERR_INV_VALUE);
@@ -675,7 +678,9 @@ _gpgme_engine_op_decrypt_verify (engine_t engine, gpgme_data_t ciph,
if (!engine->ops->decrypt_verify)
return gpg_error (GPG_ERR_NOT_IMPLEMENTED);
- return (*engine->ops->decrypt_verify) (engine->engine, ciph, plain);
+ return (*engine->ops->decrypt_verify) (engine->engine, ciph, plain,
+ export_session_key,
+ override_session_key);
}
@@ -902,7 +907,8 @@ _gpgme_engine_op_trustlist (engine_t engine, const char *pattern)
gpgme_error_t
_gpgme_engine_op_verify (engine_t engine, gpgme_data_t sig,
- gpgme_data_t signed_text, gpgme_data_t plaintext)
+ gpgme_data_t signed_text, gpgme_data_t plaintext,
+ gpgme_ctx_t ctx)
{
if (!engine)
return gpg_error (GPG_ERR_INV_VALUE);
@@ -910,7 +916,8 @@ _gpgme_engine_op_verify (engine_t engine, gpgme_data_t sig,
if (!engine->ops->verify)
return gpg_error (GPG_ERR_NOT_IMPLEMENTED);
- return (*engine->ops->verify) (engine->engine, sig, signed_text, plaintext);
+ return (*engine->ops->verify) (engine->engine, sig, signed_text, plaintext,
+ ctx);
}
@@ -978,6 +985,21 @@ _gpgme_engine_op_conf_save (engine_t engine, gpgme_conf_comp_t conf)
}
+gpgme_error_t
+_gpgme_engine_op_query_swdb (engine_t engine,
+ const char *name, const char *iversion,
+ gpgme_query_swdb_result_t result)
+{
+ if (!engine)
+ return gpg_error (GPG_ERR_INV_VALUE);
+
+ if (!engine->ops->query_swdb)
+ return gpg_error (GPG_ERR_NOT_IMPLEMENTED);
+
+ return (*engine->ops->query_swdb) (engine->engine, name, iversion, result);
+}
+
+
void
_gpgme_engine_set_io_cbs (engine_t engine, gpgme_io_cbs_t io_cbs)
{
diff --git a/src/engine.h b/src/engine.h
index 4ce2bed..29d2f25 100644
--- a/src/engine.h
+++ b/src/engine.h
@@ -83,10 +83,15 @@ _gpgme_engine_set_colon_line_handler (engine_t engine,
engine_colon_line_handler_t fnc,
void *fnc_value);
gpgme_error_t _gpgme_engine_op_decrypt (engine_t engine, gpgme_data_t ciph,
- gpgme_data_t plain);
+ gpgme_data_t plain,
+ int export_session_key,
+ const char *override_session_key);
gpgme_error_t _gpgme_engine_op_decrypt_verify (engine_t engine,
gpgme_data_t ciph,
- gpgme_data_t plain);
+ gpgme_data_t plain,
+ int export_session_key,
+ const char *override_session_key
+ );
gpgme_error_t _gpgme_engine_op_delete (engine_t engine, gpgme_key_t key,
int allow_secret);
gpgme_error_t _gpgme_engine_op_edit (engine_t engine, int type,
@@ -152,7 +157,8 @@ gpgme_error_t _gpgme_engine_op_trustlist (engine_t engine,
const char *pattern);
gpgme_error_t _gpgme_engine_op_verify (engine_t engine, gpgme_data_t sig,
gpgme_data_t signed_text,
- gpgme_data_t plaintext);
+ gpgme_data_t plaintext,
+ gpgme_ctx_t ctx);
gpgme_error_t _gpgme_engine_op_getauditlog (engine_t engine,
gpgme_data_t output,
@@ -172,6 +178,12 @@ gpgme_error_t _gpgme_engine_op_conf_load (engine_t engine,
gpgme_error_t _gpgme_engine_op_conf_save (engine_t engine,
gpgme_conf_comp_t conf);
+gpgme_error_t _gpgme_engine_op_query_swdb (engine_t engine,
+ const char *name,
+ const char *iversion,
+ gpgme_query_swdb_result_t result);
+
+
void _gpgme_engine_set_io_cbs (engine_t engine,
gpgme_io_cbs_t io_cbs);
void _gpgme_engine_io_event (engine_t engine,
diff --git a/src/export.c b/src/export.c
index 41a9eba..cd94050 100644
--- a/src/export.c
+++ b/src/export.c
@@ -15,7 +15,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, see <http://www.gnu.org/licenses/>.
+ License along with this program; if not, see <https://www.gnu.org/licenses/>.
*/
#if HAVE_CONFIG_H
diff --git a/src/genkey.c b/src/genkey.c
index 9dcf0be..ea3f1ea 100644
--- a/src/genkey.c
+++ b/src/genkey.c
@@ -15,7 +15,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, see <http://www.gnu.org/licenses/>.
+ * License along with this program; if not, see <https://www.gnu.org/licenses/>.
*/
#if HAVE_CONFIG_H
diff --git a/src/getauditlog.c b/src/getauditlog.c
index e2ba25e..dbaf260 100644
--- a/src/getauditlog.c
+++ b/src/getauditlog.c
@@ -15,7 +15,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, see <http://www.gnu.org/licenses/>.
+ License along with this program; if not, see <https://www.gnu.org/licenses/>.
*/
#if HAVE_CONFIG_H
diff --git a/src/gpgconf.c b/src/gpgconf.c
index 6591452..b1b84a6 100644
--- a/src/gpgconf.c
+++ b/src/gpgconf.c
@@ -65,7 +65,7 @@ gpgme_conf_release (gpgme_conf_comp_t conf)
}
-/* Public function to release load a configuration list. No
+/* Public function to load a configuration list. No
asynchronous interface for now. */
gpgme_error_t
gpgme_op_conf_load (gpgme_ctx_t ctx, gpgme_conf_comp_t *conf_p)
@@ -108,5 +108,3 @@ gpgme_op_conf_save (gpgme_ctx_t ctx, gpgme_conf_comp_t comp)
ctx->protocol = proto;
return err;
}
-
-
diff --git a/src/gpgme-config.in b/src/gpgme-config.in
index 0d9fda2..a4d152e 100644
--- a/src/gpgme-config.in
+++ b/src/gpgme-config.in
@@ -32,7 +32,9 @@ gpg_error_libs="@GPG_ERROR_LIBS@"
# Configure thread packages.
thread_modules=""
-@HAVE_PTHREAD_TRUE@thread_modules="$thread_modules pthread"
+# For compatibility we keep proving the
+# thread modules variable.
+thread_modules="$thread_modules pthread"
libs_pthread="-lpthread"
cflags_pthread=""
@@ -50,7 +52,6 @@ usage()
cat <<EOF
Usage: gpgme-config [OPTIONS]
Options:
- --thread={${thread_modules}}]
--prefix
--exec-prefix
--version
@@ -139,7 +140,8 @@ while test $# -gt 0; do
result=
tmp_x=
case "$thread_module" in
- pthread) tmp_l="-lgpgme-pthread"; tmp_x="$libs_pthread" ;;
+ # deprecated
+ pthread) tmp_l="-lgpgme" ;;
*)
if test "x$with_glib" = "xyes" ; then
tmp_l="-lgpgme-glib"
diff --git a/src/gpgme-tool.c b/src/gpgme-tool.c
index fb158f1..3e2dc78 100644
--- a/src/gpgme-tool.c
+++ b/src/gpgme-tool.c
@@ -15,7 +15,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, see <http://www.gnu.org/licenses/>.
+ License along with this program; if not, see <https://www.gnu.org/licenses/>.
*/
#if HAVE_CONFIG_H
diff --git a/src/gpgme-w32spawn.c b/src/gpgme-w32spawn.c
index b510ba3..003b9b0 100644
--- a/src/gpgme-w32spawn.c
+++ b/src/gpgme-w32spawn.c
@@ -14,7 +14,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, see <http://www.gnu.org/licenses/>.
+ License along with this program; if not, see <https://www.gnu.org/licenses/>.
*/
diff --git a/src/gpgme.c b/src/gpgme.c
index d59f808..cf767c7 100644
--- a/src/gpgme.c
+++ b/src/gpgme.c
@@ -16,7 +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, see <http://www.gnu.org/licenses/>.
+ License along with this program; if not, see <https://www.gnu.org/licenses/>.
*/
#if HAVE_CONFIG_H
@@ -38,6 +38,7 @@
#include "debug.h"
#include "priv-io.h"
#include "sys-util.h"
+#include "mbox-util.h"
/* The default locale. */
@@ -84,39 +85,6 @@ gpgme_set_global_flag (const char *name, const char *value)
}
-/* Set the flag NAME for CTX to VALUE. The supported flags are:
- *
- * - full-status :: With a value of "1" the status callback set by
- * gpgme_set_status_cb returns all status lines
- * except for PROGRESS lines. With the default of
- * "0" the status callback is only called in certain
- * situations.
- */
-gpgme_error_t
-gpgme_set_ctx_flag (gpgme_ctx_t ctx, const char *name, const char *value)
-{
- int abool;
-
- if (!ctx || !name || !value)
- return gpg_error (GPG_ERR_INV_VALUE);
-
- abool = *value? !!atoi (value) : 0;
-
- if (!strcmp (name, "full-status"))
- {
- ctx->full_status = abool;
- }
- else if (!strcmp (name, "raw-description"))
- {
- ctx->raw_description = abool;
- }
- else
- return gpg_error (GPG_ERR_UNKNOWN_NAME);
-
- return 0;
-}
-
-
/* Create a new context as an environment for GPGME crypto
operations. */
@@ -275,12 +243,11 @@ gpgme_release (gpgme_ctx_t ctx)
_gpgme_release_result (ctx);
_gpgme_signers_clear (ctx);
_gpgme_sig_notation_clear (ctx);
- if (ctx->signers)
- free (ctx->signers);
- if (ctx->lc_ctype)
- free (ctx->lc_ctype);
- if (ctx->lc_messages)
- free (ctx->lc_messages);
+ free (ctx->sender);
+ free (ctx->signers);
+ free (ctx->lc_ctype);
+ free (ctx->lc_messages);
+ free (ctx->override_session_key);
_gpgme_engine_info_release (ctx->engine_info);
ctx->engine_info = NULL;
DESTROY_LOCK (ctx->lock);
@@ -459,6 +426,42 @@ gpgme_get_protocol_name (gpgme_protocol_t protocol)
}
}
+
+/* Store the sender's address in the context. ADDRESS is addr-spec of
+ * mailbox but my also be a complete mailbox, in which case this
+ * function extracts the addr-spec from it. Returns 0 on success or
+ * an error code if no valid addr-spec could be extracted from
+ * ADDRESS. */
+gpgme_error_t
+gpgme_set_sender (gpgme_ctx_t ctx, const char *address)
+{
+ char *p = NULL;
+
+ TRACE_BEG1 (DEBUG_CTX, "gpgme_set_sender", ctx, "sender='%s'",
+ address?address:"(null)");
+
+ if (!ctx || (address && !(p = _gpgme_mailbox_from_userid (address))))
+ return TRACE_ERR (gpg_error (GPG_ERR_INV_VALUE));
+
+ free (ctx->sender);
+ ctx->sender = p;
+ return TRACE_ERR (0);
+}
+
+
+/* Return the sender's address (addr-spec part) from the context or
+ * NULL if none was set. The returned value is valid as long as the
+ * CTX is valid and gpgme_set_sender has not been used. */
+const char *
+gpgme_get_sender (gpgme_ctx_t ctx)
+{
+ TRACE1 (DEBUG_CTX, "gpgme_get_sender", ctx, "sender='%s'",
+ ctx?ctx->sender:"");
+
+ return ctx->sender;
+}
+
+
/* Enable or disable the use of an ascii armor for all output. */
void
gpgme_set_armor (gpgme_ctx_t ctx, int use_armor)
@@ -469,7 +472,7 @@ gpgme_set_armor (gpgme_ctx_t ctx, int use_armor)
if (!ctx)
return;
- ctx->use_armor = use_armor;
+ ctx->use_armor = !!use_armor;
}
@@ -483,6 +486,85 @@ gpgme_get_armor (gpgme_ctx_t ctx)
}
+/* Set the flag NAME for CTX to VALUE. The supported flags are:
+ *
+ * - full-status :: With a value of "1" the status callback set by
+ * gpgme_set_status_cb returns all status lines
+ * except for PROGRESS lines. With the default of
+ * "0" the status callback is only called in certain
+ * situations.
+ */
+gpgme_error_t
+gpgme_set_ctx_flag (gpgme_ctx_t ctx, const char *name, const char *value)
+{
+ gpgme_error_t err = 0;
+ int abool;
+
+ TRACE2 (DEBUG_CTX, "gpgme_set_ctx_flag", ctx,
+ "name='%s' value='%s'",
+ name? name:"(null)", value?value:"(null)");
+
+ abool = (value && *value)? !!atoi (value) : 0;
+
+ if (!ctx || !name || !value)
+ err = gpg_error (GPG_ERR_INV_VALUE);
+ else if (!strcmp (name, "full-status"))
+ {
+ ctx->full_status = abool;
+ }
+ else if (!strcmp (name, "raw-description"))
+ {
+ ctx->raw_description = abool;
+ }
+ else if (!strcmp (name, "export-session-key"))
+ {
+ ctx->export_session_keys = abool;
+ }
+ else if (!strcmp (name, "override-session-key"))
+ {
+ free (ctx->override_session_key);
+ ctx->override_session_key = strdup (value);
+ if (!ctx->override_session_key)
+ err = gpg_error_from_syserror ();
+ }
+ else
+ err = gpg_error (GPG_ERR_UNKNOWN_NAME);
+
+ return err;
+}
+
+
+/* Get the context flag named NAME. See gpgme_set_ctx_flag for a list
+ * of valid names. If the NAME is unknown NULL is returned. For a
+ * boolean flag an empty string is returned for False and the string
+ * "1" for True; thus either atoi or a simple string test can be
+ * used. */
+const char *
+gpgme_get_ctx_flag (gpgme_ctx_t ctx, const char *name)
+{
+ if (!ctx || !name)
+ return NULL;
+ else if (!strcmp (name, "full-status"))
+ {
+ return ctx->full_status? "1":"";
+ }
+ else if (!strcmp (name, "raw-description"))
+ {
+ return ctx->raw_description? "1":"";
+ }
+ else if (!strcmp (name, "export-session-key"))
+ {
+ return ctx->export_session_keys? "1":"";
+ }
+ else if (!strcmp (name, "override-session-key"))
+ {
+ return ctx->override_session_key? ctx->override_session_key : "";
+ }
+ else
+ return NULL;
+}
+
+
/* Enable or disable the use of the special textmode. Textmode is for
example used for the RFC2015 signatures; note that the updated RFC
3156 mandates that the MUA does some preparations so that textmode
@@ -496,7 +578,7 @@ gpgme_set_textmode (gpgme_ctx_t ctx, int use_textmode)
if (!ctx)
return;
- ctx->use_textmode = use_textmode;
+ ctx->use_textmode = !!use_textmode;
}
/* Return the state of the textmode flag. */
@@ -520,7 +602,7 @@ gpgme_set_offline (gpgme_ctx_t ctx, int offline)
if (!ctx)
return;
- ctx->offline = offline;
+ ctx->offline = !!offline;
}
/* Return the state of the offline flag. */
diff --git a/src/gpgme.def b/src/gpgme.def
index c94c960..0d3ce74 100644
--- a/src/gpgme.def
+++ b/src/gpgme.def
@@ -246,5 +246,12 @@ EXPORTS
gpgme_addrspec_from_uid @186
+ gpgme_set_sender @187
+ gpgme_get_sender @188
+
+ gpgme_op_query_swdb @189
+ gpgme_op_query_swdb_result @190
+
+ gpgme_get_ctx_flag @191
; END
diff --git a/src/gpgme.h.in b/src/gpgme.h.in
index 5c914ae..7cfe8f6 100644
--- a/src/gpgme.h.in
+++ b/src/gpgme.h.in
@@ -999,6 +999,9 @@ void gpgme_release (gpgme_ctx_t ctx);
gpgme_error_t gpgme_set_ctx_flag (gpgme_ctx_t ctx,
const char *name, const char *value);
+/* Get the value of the flag NAME from CTX. */
+const char *gpgme_get_ctx_flag (gpgme_ctx_t ctx, const char *name);
+
/* Set the protocol to be used by CTX to PROTO. */
gpgme_error_t gpgme_set_protocol (gpgme_ctx_t ctx, gpgme_protocol_t proto);
@@ -1161,6 +1164,12 @@ gpgme_error_t gpgme_sig_notation_add (gpgme_ctx_t ctx, const char *name,
/* Get the sig notations for this context. */
gpgme_sig_notation_t gpgme_sig_notation_get (gpgme_ctx_t ctx);
+/* Store a sender address in the context. */
+gpgme_error_t gpgme_set_sender (gpgme_ctx_t ctx, const char *address);
+
+/* Get the sender address from the context. */
+const char *gpgme_get_sender (gpgme_ctx_t ctx);
+
/*
@@ -1521,6 +1530,10 @@ struct _gpgme_op_decrypt_result
/* The original file name of the plaintext message, if
available. */
char *file_name;
+
+ /* A textual representation of the session key used to decrypt the
+ * message, if available */
+ char *session_key;
};
typedef struct _gpgme_op_decrypt_result *gpgme_decrypt_result_t;
@@ -2412,6 +2425,67 @@ gpgme_error_t gpgme_op_conf_load (gpgme_ctx_t ctx, gpgme_conf_comp_t *conf_p);
gpgme_error_t gpgme_op_conf_save (gpgme_ctx_t ctx, gpgme_conf_comp_t comp);
+/* Information about software versions. */
+typedef struct _gpgme_op_query_swdb_result
+{
+ /* RFU */
+ struct _gpgme_op_query_swdb_result *next;
+
+ /* The name of the package (e.g. "gpgme", "gnupg") */
+ char *name;
+
+ /* The version number of the installed version. */
+ char *iversion;
+
+ /* The time the online info was created. */
+ unsigned long created;
+
+ /* The time the online info was retrieved. */
+ unsigned long retrieved;
+
+ /* This bit is set if an error occured or some of the information
+ * in this structure may not be set. */
+ unsigned int warning : 1;
+
+ /* An update is available. */
+ unsigned int update : 1;
+
+ /* The update is important. */
+ unsigned int urgent : 1;
+
+ /* No information at all available. */
+ unsigned int noinfo : 1;
+
+ /* The package name is not known. */
+ unsigned int unknown : 1;
+
+ /* The information here is too old. */
+ unsigned int tooold : 1;
+
+ /* Other error. */
+ unsigned int error : 1;
+
+ unsigned int _reserved : 25;
+
+ /* The version number of the latest released version. */
+ char *version;
+
+ /* The release date of that version. */
+ unsigned long reldate;
+
+} *gpgme_query_swdb_result_t;
+
+
+/* Run the gpgconf --query-swdb command. */
+gpgme_error_t gpgme_op_query_swdb (gpgme_ctx_t ctx,
+ const char *name, const char *iversion,
+ unsigned int reserved);
+
+/* Return the result from the last query_swdb operation. */
+gpgme_query_swdb_result_t gpgme_op_query_swdb_result (gpgme_ctx_t ctx);
+
+
+
/*
* Various functions.
diff --git a/src/keylist.c b/src/keylist.c
index 8a0c5a3..2ce0846 100644
--- a/src/keylist.c
+++ b/src/keylist.c
@@ -16,7 +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, see <http://www.gnu.org/licenses/>.
+ License along with this program; if not, see <https://www.gnu.org/licenses/>.
*/
#if HAVE_CONFIG_H
@@ -54,6 +54,9 @@ typedef struct
{
struct _gpgme_op_keylist_result result;
+ /* The error code from ERROR keydb_search. */
+ gpgme_error_t keydb_search_err;
+
gpgme_key_t tmp_key;
/* This points to the last uid in tmp_key. */
@@ -135,10 +138,17 @@ keylist_status_handler (void *priv, gpgme_status_code_t code, char *args)
opd->result.truncated = 1;
break;
+ case GPGME_STATUS_ERROR:
+ err = _gpgme_parse_failure (args);
+ if (!opd->keydb_search_err && !strcmp (args, "keydb_search"))
+ opd->keydb_search_err = err;
+ err = 0;
+ break;
+
default:
break;
}
- return 0;
+ return err;
}
@@ -1138,7 +1148,8 @@ gpgme_op_keylist_next (gpgme_ctx_t ctx, gpgme_key_t *r_key)
return TRACE_ERR (err);
if (!opd->key_cond)
- return TRACE_ERR (gpg_error (GPG_ERR_EOF));
+ return TRACE_ERR (opd->keydb_search_err? opd->keydb_search_err
+ /**/ : gpg_error (GPG_ERR_EOF));
opd->key_cond = 0;
assert (opd->key_queue);
diff --git a/src/keysign.c b/src/keysign.c
index 7d08c11..c2fcabb 100644
--- a/src/keysign.c
+++ b/src/keysign.c
@@ -14,7 +14,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, see <http://www.gnu.org/licenses/>.
+ * License along with this program; if not, see <https://www.gnu.org/licenses/>.
*/
#if HAVE_CONFIG_H
diff --git a/src/libgpgme.vers b/src/libgpgme.vers
index d3962db..a55cd10 100644
--- a/src/libgpgme.vers
+++ b/src/libgpgme.vers
@@ -101,6 +101,7 @@ GPGME_1.1 {
gpgme_pubkey_algo_string;
gpgme_set_ctx_flag;
+ gpgme_get_ctx_flag;
gpgme_data_set_flag;
gpgme_op_createkey_start;
@@ -119,6 +120,12 @@ GPGME_1.1 {
gpgme_op_interact;
gpgme_addrspec_from_uid;
+
+ gpgme_set_sender;
+ gpgme_get_sender;
+
+ gpgme_op_query_swdb;
+ gpgme_op_query_swdb_result;
};
diff --git a/src/mbox-util.c b/src/mbox-util.c
index 81e929b..0dafc2a 100644
--- a/src/mbox-util.c
+++ b/src/mbox-util.c
@@ -15,7 +15,7 @@
* 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/>.
+ * along with this program; if not, see <https://www.gnu.org/licenses/>.
*/
/* NB: This code has been taken from GnuPG. Please keep it in sync
diff --git a/src/mbox-util.h b/src/mbox-util.h
index c5747b6..8be1343 100644
--- a/src/mbox-util.h
+++ b/src/mbox-util.h
@@ -14,7 +14,7 @@
* 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/>.
+ * along with this program; if not, see <https://www.gnu.org/licenses/>.
*/
#ifndef GNUPG_COMMON_MBOX_UTIL_H
#define GNUPG_COMMON_MBOX_UTIL_H
diff --git a/src/op-support.c b/src/op-support.c
index 9f10cd3..d9217ec 100644
--- a/src/op-support.c
+++ b/src/op-support.c
@@ -14,7 +14,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, see <http://www.gnu.org/licenses/>.
+ License along with this program; if not, see <https://www.gnu.org/licenses/>.
*/
#if HAVE_CONFIG_H
diff --git a/src/opassuan.c b/src/opassuan.c
index e58240c..2bbaacd 100644
--- a/src/opassuan.c
+++ b/src/opassuan.c
@@ -14,7 +14,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, see <http://www.gnu.org/licenses/>.
+ License along with this program; if not, see <https://www.gnu.org/licenses/>.
*/
#if HAVE_CONFIG_H
diff --git a/src/parsetlv.c b/src/parsetlv.c
index 70c9518..b311a73 100644
--- a/src/parsetlv.c
+++ b/src/parsetlv.c
@@ -12,7 +12,7 @@
* 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/>.
+ * along with this program; if not, see <https://www.gnu.org/licenses/>.
*/
#ifdef HAVE_CONFIG_H
diff --git a/src/parsetlv.h b/src/parsetlv.h
index 153073c..bea03d4 100644
--- a/src/parsetlv.h
+++ b/src/parsetlv.h
@@ -12,7 +12,7 @@
* 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/>.
+ * along with this program; if not, see <https://www.gnu.org/licenses/>.
*/
#ifndef PARSETLV_H
diff --git a/src/passwd.c b/src/passwd.c
index c34f357..5bd67a5 100644
--- a/src/passwd.c
+++ b/src/passwd.c
@@ -14,7 +14,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, see <http://www.gnu.org/licenses/>.
+ License along with this program; if not, see <https://www.gnu.org/licenses/>.
*/
#if HAVE_CONFIG_H
diff --git a/src/posix-io.c b/src/posix-io.c
index c0b2f4f..5296f5f 100644
--- a/src/posix-io.c
+++ b/src/posix-io.c
@@ -15,7 +15,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, see <http://www.gnu.org/licenses/>.
+ License along with this program; if not, see <https://www.gnu.org/licenses/>.
*/
#ifdef HAVE_CONFIG_H
@@ -607,7 +607,7 @@ _gpgme_io_select (struct io_select_fd_s *fds, size_t nfds, int nonblock)
if (fds[i].fd >= FD_SETSIZE)
{
TRACE_END (dbg_help, " -BAD- ]");
- gpg_err_set_errno (EBADF);
+ gpg_err_set_errno (EMFILE);
return TRACE_SYSRES (-1);
}
assert (!FD_ISSET (fds[i].fd, &readfds));
@@ -622,7 +622,7 @@ _gpgme_io_select (struct io_select_fd_s *fds, size_t nfds, int nonblock)
if (fds[i].fd >= FD_SETSIZE)
{
TRACE_END (dbg_help, " -BAD- ]");
- gpg_err_set_errno (EBADF);
+ gpg_err_set_errno (EMFILE);
return TRACE_SYSRES (-1);
}
assert (!FD_ISSET (fds[i].fd, &writefds));
diff --git a/src/posix-sema.c b/src/posix-sema.c
deleted file mode 100644
index d04ce61..0000000
--- a/src/posix-sema.c
+++ /dev/null
@@ -1,68 +0,0 @@
-/* posix-sema.c
- Copyright (C) 2001 Werner Koch (dd9jn)
- Copyright (C) 2001, 2002, 2004, 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, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- 02111-1307, USA. */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <assert.h>
-#include <errno.h>
-#include <signal.h>
-#include <fcntl.h>
-#ifdef HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-#ifdef HAVE_SYS_TIME_H
-# include <sys/time.h>
-#endif
-#ifdef HAVE_SYS_TYPES_H
-# include <sys/types.h>
-#endif
-
-#include "util.h"
-#include "sema.h"
-#include "ath.h"
-
-void
-_gpgme_sema_subsystem_init ()
-{
-}
-
-void
-_gpgme_sema_cs_enter (struct critsect_s *s)
-{
- _gpgme_ath_mutex_lock (&s->priv);
-}
-
-void
-_gpgme_sema_cs_leave (struct critsect_s *s)
-{
- _gpgme_ath_mutex_unlock (&s->priv);
-}
-
-void
-_gpgme_sema_cs_destroy (struct critsect_s *s)
-{
- _gpgme_ath_mutex_destroy (&s->priv);
- s->priv = NULL;
-}
diff --git a/src/queryswdb.c b/src/queryswdb.c
new file mode 100644
index 0000000..698a419
--- /dev/null
+++ b/src/queryswdb.c
@@ -0,0 +1,121 @@
+/* queryswdb.c - Access to the SWDB file
+ * Copyright (C) 2016 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 <https://www.gnu.org/licenses/>.
+ */
+
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdlib.h>
+#include <assert.h>
+
+#include "gpgme.h"
+#include "debug.h"
+#include "context.h"
+#include "ops.h"
+
+
+typedef struct
+{
+ struct _gpgme_op_query_swdb_result result;
+
+} *op_data_t;
+
+
+
+static void
+release_op_data (void *hook)
+{
+ op_data_t opd = (op_data_t) hook;
+ gpgme_query_swdb_result_t result = &opd->result;
+
+ assert (!result->next);
+ free (result->name);
+ free (result->iversion);
+ free (result->version);
+}
+
+
+gpgme_query_swdb_result_t
+gpgme_op_query_swdb_result (gpgme_ctx_t ctx)
+{
+ void *hook;
+ op_data_t opd;
+ gpgme_error_t err;
+
+ TRACE_BEG (DEBUG_CTX, "gpgme_op_query_swdb_result", ctx);
+
+ err = _gpgme_op_data_lookup (ctx, OPDATA_QUERY_SWDB, &hook, -1, NULL);
+ opd = hook;
+
+ if (err || !opd)
+ {
+ TRACE_SUC0 ("result=(null)");
+ return NULL;
+ }
+
+ TRACE_SUC1 ("result=%p", &opd->result);
+ return &opd->result;
+}
+
+
+
+/* Query the swdb for software package NAME and check against the
+ * installed version given by IVERSION. If IVERSION is NULL a check
+ * is only done if GPGME can figure out the version by itself
+ * (e.g. for "gpgme" or "gnupg"). RESERVED should be 0.
+ *
+ * Note that we only implemented the synchronous variant of this
+ * function but the API is prepared for an asynchronous variant.
+ */
+gpgme_error_t
+gpgme_op_query_swdb (gpgme_ctx_t ctx, const char *name, const char *iversion,
+ unsigned int reserved)
+{
+ gpgme_error_t err;
+ void *hook;
+ op_data_t opd;
+
+ TRACE_BEG2 (DEBUG_CTX, "gpgme_op_query_swdb", ctx,
+ "name=%s, iversion=%a", name, iversion);
+
+ if (!ctx || reserved)
+ return TRACE_ERR (gpg_error (GPG_ERR_INV_VALUE));
+
+ if (ctx->protocol != GPGME_PROTOCOL_GPGCONF)
+ return TRACE_ERR (gpg_error (GPG_ERR_UNSUPPORTED_PROTOCOL));
+
+ if (!name)
+ name = "gpgme";
+
+ if (!iversion && !strcmp (name, "gpgme"))
+ iversion = VERSION;
+
+ err = _gpgme_op_reset (ctx, 1);
+ if (err)
+ return err;
+
+ err = _gpgme_op_data_lookup (ctx, OPDATA_QUERY_SWDB, &hook,
+ sizeof (*opd), release_op_data);
+ opd = hook;
+ if (err)
+ return TRACE_ERR (err);
+
+ err = _gpgme_engine_op_query_swdb (ctx->engine, name, iversion,
+ &opd->result);
+ return TRACE_ERR (err);
+}
diff --git a/src/sema.h b/src/sema.h
index 4b7c0af..5b0d53d 100644
--- a/src/sema.h
+++ b/src/sema.h
@@ -22,46 +22,23 @@
#ifndef SEMA_H
#define SEMA_H
-struct critsect_s
-{
- const char *name;
- void *priv;
-};
+#include <gpg-error.h>
#define DEFINE_GLOBAL_LOCK(name) \
- struct critsect_s name = { #name, NULL }
+ gpgrt_lock_t name = GPGRT_LOCK_INITIALIZER
+
#define DEFINE_STATIC_LOCK(name) \
- static struct critsect_s name = { #name, NULL }
+ static gpgrt_lock_t name = GPGRT_LOCK_INITIALIZER
-#define DECLARE_LOCK(name) \
- struct critsect_s name
-#define INIT_LOCK(a) \
- do \
- { \
- (a).name = #a; \
- (a).priv = NULL; \
- } \
- while (0)
-#define DESTROY_LOCK(name) _gpgme_sema_cs_destroy (&(name))
+#define INIT_LOCK(name) \
+ name = (gpgrt_lock_t) GPGRT_LOCK_INITIALIZER
+#define DECLARE_LOCK(name) gpgrt_lock_t name
-#define LOCK(name) \
- do \
- { \
- _gpgme_sema_cs_enter (&(name)); \
- } \
- while (0)
+#define DESTROY_LOCK(name) gpgrt_lock_destroy(&name)
-#define UNLOCK(name) \
- do \
- { \
- _gpgme_sema_cs_leave (&(name)); \
- } \
- while (0)
+#define LOCK(name) gpgrt_lock_lock(&name)
-void _gpgme_sema_subsystem_init (void);
-void _gpgme_sema_cs_enter (struct critsect_s *s);
-void _gpgme_sema_cs_leave (struct critsect_s *s);
-void _gpgme_sema_cs_destroy (struct critsect_s *s);
+#define UNLOCK(name) gpgrt_lock_unlock(&name)
#endif /* SEMA_H */
diff --git a/src/sys-util.h b/src/sys-util.h
index 541c557..094399c 100644
--- a/src/sys-util.h
+++ b/src/sys-util.h
@@ -14,7 +14,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, see <http://www.gnu.org/licenses/>.
+ * License along with this program; if not, see <https://www.gnu.org/licenses/>.
*/
#ifndef SYS_UTIL_H
diff --git a/src/tofupolicy.c b/src/tofupolicy.c
index 799779e..460e3ba 100644
--- a/src/tofupolicy.c
+++ b/src/tofupolicy.c
@@ -14,7 +14,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, see <http://www.gnu.org/licenses/>.
+ * License along with this program; if not, see <https://www.gnu.org/licenses/>.
*/
#if HAVE_CONFIG_H
diff --git a/src/ttyname_r.c b/src/ttyname_r.c
index eed28bd..7aed79e 100644
--- a/src/ttyname_r.c
+++ b/src/ttyname_r.c
@@ -14,7 +14,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, see <http://www.gnu.org/licenses/>.
+ License along with this program; if not, see <https://www.gnu.org/licenses/>.
*/
#if HAVE_CONFIG_H
diff --git a/src/util.h b/src/util.h
index 1474b41..a1be6e7 100644
--- a/src/util.h
+++ b/src/util.h
@@ -49,6 +49,11 @@
# define GPG_ERR_FALSE 256
#endif
+#if GPG_ERROR_VERSION_NUMBER < 0x011900 /* 1.25 */
+# define GPG_ERR_ENGINE_TOO_OLD 300
+# define GPG_ERR_TOO_OLD 308
+#endif
+
#ifndef GPGRT_ATTR_SENTINEL
# define GPGRT_ATTR_SENTINEL(a) /* */
#endif
diff --git a/src/verify.c b/src/verify.c
index eb1cc10..faa8deb 100644
--- a/src/verify.c
+++ b/src/verify.c
@@ -1104,7 +1104,8 @@ verify_start (gpgme_ctx_t ctx, int synchronous, gpgme_data_t sig,
if (!sig)
return gpg_error (GPG_ERR_NO_DATA);
- return _gpgme_engine_op_verify (ctx->engine, sig, signed_text, plaintext);
+ return _gpgme_engine_op_verify (ctx->engine, sig, signed_text, plaintext,
+ ctx);
}
diff --git a/src/version.c b/src/version.c
index 8bc898f..99698fa 100644
--- a/src/version.c
+++ b/src/version.c
@@ -74,7 +74,6 @@ do_subsystem_inits (void)
}
#endif
- _gpgme_sema_subsystem_init ();
_gpgme_debug_subsystem_init ();
_gpgme_io_subsystem_init ();
_gpgme_status_init ();
diff --git a/src/w32-ce.c b/src/w32-ce.c
index e42f053..e326bfe 100644
--- a/src/w32-ce.c
+++ b/src/w32-ce.c
@@ -15,7 +15,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, see <http://www.gnu.org/licenses/>.
+ License along with this program; if not, see <https://www.gnu.org/licenses/>.
*/
#ifdef HAVE_CONFIG_H
diff --git a/src/w32-io.c b/src/w32-io.c
index 3a69541..0d1c810 100644
--- a/src/w32-io.c
+++ b/src/w32-io.c
@@ -84,6 +84,7 @@ static struct
duplicates works just fine. */
int dup_from;
} fd_table[MAX_SLAFD];
+DEFINE_STATIC_LOCK (fd_table_lock);
/* Returns the FD or -1 on resource limit. */
@@ -92,6 +93,8 @@ new_fd (void)
{
int idx;
+ LOCK (fd_table_lock);
+
for (idx = 0; idx < MAX_SLAFD; idx++)
if (! fd_table[idx].used)
break;
@@ -99,14 +102,18 @@ new_fd (void)
if (idx == MAX_SLAFD)
{
gpg_err_set_errno (EIO);
- return -1;
+ idx = -1;
+ }
+ else
+ {
+ fd_table[idx].used = 1;
+ fd_table[idx].handle = INVALID_HANDLE_VALUE;
+ fd_table[idx].socket = INVALID_SOCKET;
+ fd_table[idx].rvid = 0;
+ fd_table[idx].dup_from = -1;
}
- fd_table[idx].used = 1;
- fd_table[idx].handle = INVALID_HANDLE_VALUE;
- fd_table[idx].socket = INVALID_SOCKET;
- fd_table[idx].rvid = 0;
- fd_table[idx].dup_from = -1;
+ UNLOCK (fd_table_lock);
return idx;
}
@@ -115,14 +122,21 @@ new_fd (void)
void
release_fd (int fd)
{
- if (fd < 0 || fd >= MAX_SLAFD || !fd_table[fd].used)
+ if (fd < 0 || fd >= MAX_SLAFD)
return;
- fd_table[fd].used = 0;
- fd_table[fd].handle = INVALID_HANDLE_VALUE;
- fd_table[fd].socket = INVALID_SOCKET;
- fd_table[fd].rvid = 0;
- fd_table[fd].dup_from = -1;
+ LOCK (fd_table_lock);
+
+ if (fd_table[fd].used)
+ {
+ fd_table[fd].used = 0;
+ fd_table[fd].handle = INVALID_HANDLE_VALUE;
+ fd_table[fd].socket = INVALID_SOCKET;
+ fd_table[fd].rvid = 0;
+ fd_table[fd].dup_from = -1;
+ }
+
+ UNLOCK (fd_table_lock);
}
diff --git a/src/w32-sema.c b/src/w32-sema.c
deleted file mode 100644
index 648a6bb..0000000
--- a/src/w32-sema.c
+++ /dev/null
@@ -1,117 +0,0 @@
-/* w32-sema.c
- Copyright (C) 2001 Werner Koch (dd9jn)
- Copyright (C) 2001, 2002, 2004, 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, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- 02111-1307, USA. */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <assert.h>
-#include <errno.h>
-#include <fcntl.h>
-#ifdef HAVE_SYS_TIME_H
-# include <sys/time.h>
-#endif
-#ifdef HAVE_SYS_TYPES_H
-# include <sys/types.h>
-#endif
-#include <io.h>
-
-#include "util.h"
-#include "sema.h"
-#include "debug.h"
-
-static void
-sema_fatal (const char *text)
-{
- fprintf (stderr, "sema.c: %s\n", text);
- abort ();
-}
-
-
-static void
-critsect_init (struct critsect_s *s)
-{
- CRITICAL_SECTION *mp;
- static CRITICAL_SECTION init_lock;
- static int initialized;
-
- if (!initialized) {
- /* The very first time we call this function, we assume that
- only one thread is running, so that we can bootstrap the
- semaphore code. */
- InitializeCriticalSection (&init_lock);
- initialized = 1;
- }
- if (!s)
- return; /* we just want to initialize ourself */
-
- /* first test whether it is really not initialized */
- EnterCriticalSection (&init_lock);
- if ( s->priv ) {
- LeaveCriticalSection (&init_lock);
- return;
- }
- /* now init it */
- mp = malloc ( sizeof *mp );
- if (!mp) {
- LeaveCriticalSection (&init_lock);
- sema_fatal ("out of core while creating critical section lock");
- }
- InitializeCriticalSection (mp);
- s->priv = mp;
- LeaveCriticalSection (&init_lock);
-}
-
-void
-_gpgme_sema_subsystem_init ()
-{
- /* fixme: we should check that there is only one thread running */
- critsect_init (NULL);
-}
-
-
-void
-_gpgme_sema_cs_enter ( struct critsect_s *s )
-{
- if (!s->priv)
- critsect_init (s);
- EnterCriticalSection ( (CRITICAL_SECTION*)s->priv );
-}
-
-void
-_gpgme_sema_cs_leave (struct critsect_s *s)
-{
- if (!s->priv)
- critsect_init (s);
- LeaveCriticalSection ((CRITICAL_SECTION*)s->priv);
-}
-
-void
-_gpgme_sema_cs_destroy ( struct critsect_s *s )
-{
- if (s && s->priv) {
- DeleteCriticalSection ((CRITICAL_SECTION*)s->priv);
- free (s->priv);
- s->priv = NULL;
- }
-}
diff --git a/src/w32-util.c b/src/w32-util.c
index 21de6dc..ad36c9a 100644
--- a/src/w32-util.c
+++ b/src/w32-util.c
@@ -16,7 +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, see <http://www.gnu.org/licenses/>.
+ * License along with this program; if not, see <https://www.gnu.org/licenses/>.
**/
#ifdef HAVE_CONFIG_H
@@ -415,8 +415,17 @@ find_program_at_standard_place (const char *name)
We First try the generic place and then fallback to the x86
(i.e. 32 bit) place. This will prefer a 64 bit of the program
over a 32 bit version on 64 bit Windows if installed. */
- if (SHGetSpecialFolderPathA (NULL, path, CSIDL_PROGRAM_FILES, 0)
- || SHGetSpecialFolderPathA (NULL, path, CSIDL_PROGRAM_FILESX86, 0))
+ if (SHGetSpecialFolderPathA (NULL, path, CSIDL_PROGRAM_FILES, 0))
+ {
+ result = _gpgme_strconcat (path, "\\", name, NULL);
+ if (result && access (result, F_OK))
+ {
+ free (result);
+ result = NULL;
+ }
+ }
+ if (!result
+ && SHGetSpecialFolderPathA (NULL, path, CSIDL_PROGRAM_FILESX86, 0))
{
result = _gpgme_strconcat (path, "\\", name, NULL);
if (result && access (result, F_OK))