From a5b040cc57c65b3d105666b90c7eb59ee6ff3882 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Mon, 8 Jun 2015 10:43:29 +0200 Subject: Fix test suite for GnuPG 2.1 which uses pubring.kbx. * tests/gpgsm/final.test: New. * tests/gpgsm/initial.test: New. * tests/gpg/start-stop-agent: Move to ../. * tests/gpgsm/Makefile.am (TESTS_ENVIRONMENT): Export top_srcdir. (TESTS): Add intial.test and final.test. (AM_LDFLAGS): Add -no-install. (clean-local): Use start-stop-agent (initial.test): Add dependency. * tests/gpg/Makefile.am (top_srcdir): Export top_srcdir. (AM_LDFLAGS): Add -no-install. (check-local): Depend on pubring-stamp instead of pubring.gpg. (initial.test): Depend on check-local. (./pubring-gpg): Replace by rule for ./pubring-stamp. -- There are also a couple of other changes which should make the tests a bit more robust and the gpg and gpgsm tests more similar. The -no-install avoids creating wrappers for test programs, which make debugging easier. The dependency on check-local guarantees that its rules are run before the first test. This is important because conf files are setup by this rule. Earlier automake versions seem to have run check-local always before the tests but today the order of execution is not defined. Signed-off-by: Werner Koch --- tests/Makefile.am | 2 +- tests/gpg/Makefile.am | 23 +++++++++++++++-------- tests/gpg/final.test | 2 +- tests/gpg/initial.test | 2 +- tests/gpg/start-stop-agent | 45 --------------------------------------------- tests/gpgsm/Makefile.am | 20 +++++++++++++++----- tests/gpgsm/final.test | 5 +++++ tests/gpgsm/initial.test | 4 ++++ tests/start-stop-agent | 45 +++++++++++++++++++++++++++++++++++++++++++++ 9 files changed, 87 insertions(+), 61 deletions(-) delete mode 100755 tests/gpg/start-stop-agent create mode 100755 tests/gpgsm/final.test create mode 100755 tests/gpgsm/initial.test create mode 100755 tests/start-stop-agent (limited to 'tests') diff --git a/tests/Makefile.am b/tests/Makefile.am index 4b465d8e..94eddac5 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -23,7 +23,7 @@ TESTS_ENVIRONMENT = GNUPGHOME=$(abs_builddir) TESTS = t-version t-data t-engine-info -EXTRA_DIST = t-data-1.txt t-data-2.txt ChangeLog-2011 +EXTRA_DIST = start-stop-agent t-data-1.txt t-data-2.txt ChangeLog-2011 AM_CPPFLAGS = -I$(top_builddir)/src @GPG_ERROR_CFLAGS@ LDADD = ../src/libgpgme.la @GPG_ERROR_LIBS@ diff --git a/tests/gpg/Makefile.am b/tests/gpg/Makefile.am index 5f40dfe2..107397b4 100644 --- a/tests/gpg/Makefile.am +++ b/tests/gpg/Makefile.am @@ -22,7 +22,8 @@ GPG = gpg GPG_AGENT = gpg-agent -TESTS_ENVIRONMENT = GNUPGHOME=$(abs_builddir) LC_ALL=C GPG_AGENT_INFO= +TESTS_ENVIRONMENT = GNUPGHOME=$(abs_builddir) LC_ALL=C GPG_AGENT_INFO= \ + top_srcdir=$(top_srcdir) # The keylist tests must come after the import and the edit test. noinst_HEADERS = t-support.h @@ -43,7 +44,7 @@ TESTS = initial.test $(c_tests) final.test CLEANFILES = secring.gpg pubring.gpg pubring.kbx trustdb.gpg dirmngr.conf \ gpg-agent.conf pubring.kbx~ S.gpg-agent gpg.conf pubring.gpg~ \ - random_seed S.gpg-agent .gpg-v21-migrated + random_seed S.gpg-agent .gpg-v21-migrated pubring-stamp private_keys = \ 13CD0F3BDF24BE53FE192D62F18737256FF6E4FD \ @@ -53,11 +54,12 @@ private_keys = \ 7A030357C0F253A5BBCD282FFC4E521B37558F5C -EXTRA_DIST = start-stop-agent initial.test final.test \ +EXTRA_DIST = initial.test final.test \ pubdemo.asc secdemo.asc cipher-1.asc cipher-2.asc \ geheim.txt pubkey-1.asc seckey-1.asc pinentry $(private_keys) AM_CPPFLAGS = -I$(top_builddir)/src @GPG_ERROR_CFLAGS@ +AM_LDFLAGS = -no-install LDADD = ../../src/libgpgme.la t_thread1_LDADD = ../../src/libgpgme-pthread.la -lpthread @@ -65,12 +67,16 @@ t_thread1_LDADD = ../../src/libgpgme-pthread.la -lpthread noinst_PROGRAMS = $(c_tests) t-genkey clean-local: - -$(srcdir)/start-stop-agent --stop + -$(top_srcdir)/tests/start-stop-agent --stop -rm -fR private-keys-v1.d -check-local: ./gpg.conf ./gpg-agent.conf ./pubring.gpg \ +check-local: ./gpg.conf ./gpg-agent.conf ./pubring-stamp \ ./private-keys-v1.d/gpg-sample.stamp +# To guarantee that check-local is run before any tests we +# add this dependency: +initial.test : check-local + export GNUPGHOME := $(abs_builddir) export GPG_AGENT_INFO := @@ -82,11 +88,12 @@ export GPG_AGENT_INFO := done echo x > ./private-keys-v1.d/gpg-sample.stamp -./pubring.gpg: $(srcdir)/pubdemo.asc - -$(GPG) --no-permission-warning \ - --import $(srcdir)/pubdemo.asc +./pubring-stamp: $(srcdir)/pubdemo.asc + $(GPG) --no-permission-warning \ + --import $(srcdir)/pubdemo.asc -$(GPG) --no-permission-warning \ --import $(srcdir)/secdemo.asc + touch ./pubring-stamp ./gpg.conf: # This is required for t-sig-notations. diff --git a/tests/gpg/final.test b/tests/gpg/final.test index 5148a34b..5289396f 100755 --- a/tests/gpg/final.test +++ b/tests/gpg/final.test @@ -1,4 +1,4 @@ #!/bin/sh -${srcdir}/start-stop-agent --stop +${top_srcdir}/tests/start-stop-agent --stop exit 0 diff --git a/tests/gpg/initial.test b/tests/gpg/initial.test index 1981c99d..93c8621a 100755 --- a/tests/gpg/initial.test +++ b/tests/gpg/initial.test @@ -1,4 +1,4 @@ #!/bin/sh -${srcdir}/start-stop-agent --start +${top_srcdir}/tests/start-stop-agent --start exit 0 diff --git a/tests/gpg/start-stop-agent b/tests/gpg/start-stop-agent deleted file mode 100755 index ab47d8d9..00000000 --- a/tests/gpg/start-stop-agent +++ /dev/null @@ -1,45 +0,0 @@ -#!/bin/sh -# Copyright (C) 2013 g10 Code GmbH -# -# This file is free software; as a special exception the author gives -# unlimited permission to copy and/or distribute it, with or without -# modifications, as long as this notice is preserved. This file is -# distributed in the hope that it will be useful, but WITHOUT ANY -# WARRANTY, to the extent permitted by law; without even the implied -# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - -if [ -z "$(command -v gpg-connect-agent)" ]; then - echo "gpg-agent not installed and thus not started" >&2 - exit 0; -fi - -GPG_AGENT_INFO= -export GPG_AGENT_INFO - -token=$(echo "gpgme-$(pwd)" | tr ' ' '_') - -if [ "$1" = "--stop" ]; then - if [ "$(gpg-connect-agent getval\ $token /bye 2>/dev/null | head -1)" \ - != "D set" ]; then - echo "gpg-agent not running" >&2 - exit 0 - fi - echo "stopping gpg-agent " >&2 - gpg-connect-agent KILLAGENT /bye >/dev/null 2>&1 - exit 0 -fi - -if [ "$(gpg-connect-agent getval\ $token /bye 2>/dev/null | head -1)" \ - = "D set" ]; then - echo "gpg-agent already running" >&2 - exit 0 -fi - -echo "starting gpg-agent " >&2 -gpg-connect-agent putval\ $token\ set /bye >/dev/null 2>&1 -if [ "$(gpg-connect-agent getval\ $token /bye 2>/dev/null | head -1)" \ - != "D set" ]; then - echo "error starting gpg-agent" >&2 - exit 1 -fi -exit 0 diff --git a/tests/gpgsm/Makefile.am b/tests/gpgsm/Makefile.am index bf616d32..41645b6c 100644 --- a/tests/gpgsm/Makefile.am +++ b/tests/gpgsm/Makefile.am @@ -21,20 +21,26 @@ GPGSM = gpgsm -TESTS_ENVIRONMENT = GNUPGHOME=$(abs_builddir) GPG_AGENT_INFO= +TESTS_ENVIRONMENT = GNUPGHOME=$(abs_builddir) LC_ALL=C GPG_AGENT_INFO= \ + top_srcdir=$(top_srcdir) noinst_HEADERS = t-support.h -TESTS = t-import t-keylist t-encrypt t-verify t-decrypt t-sign t-export + +c_tests = t-import t-keylist t-encrypt t-verify t-decrypt t-sign t-export + + +TESTS = initial.test $(c_tests) final.test EXTRA_DIST = cert_dfn_pca01.der cert_dfn_pca15.der cert_g10code_test1.der \ - $(key_id) + $(key_id) initial.test final.test AM_CPPFLAGS = -I$(top_builddir)/src @GPG_ERROR_CFLAGS@ +AM_LDFLAGS = -no-install LDADD = ../../src/libgpgme.la # We don't run t-genkey in the test suite, because it takes too long # and needs a working pinentry. -noinst_PROGRAMS = $(TESTS) t-genkey cms-keylist cms-decrypt +noinst_PROGRAMS = $(c_tests) t-genkey cms-keylist cms-decrypt key_id = 32100C27173EF6E9C4E9A25D3D69F86D37A4F939 @@ -42,12 +48,16 @@ CLEANFILES = pubring.kbx pubring.kbx~ gpgsm.conf trustlist.txt \ random_seed S.gpg-agent clean-local: - -gpg-connect-agent KILLAGENT /bye + -$(top_srcdir)/tests/start-stop-agent --stop -rm -fR private-keys-v1.d check-local: ./pubring.kbx ./gpgsm.conf \ ./private-keys-v1.d/$(key_id).key ./trustlist.txt +# To guarantee that check-local is run before any tests we add this +# dependency: +initial.test : check-local + export GNUPGHOME := $(abs_builddir) export GPG_AGENT_INFO := diff --git a/tests/gpgsm/final.test b/tests/gpgsm/final.test new file mode 100755 index 00000000..d0567e3f --- /dev/null +++ b/tests/gpgsm/final.test @@ -0,0 +1,5 @@ +#!/bin/sh + +${top_srcdir}/tests/start-stop-agent --stop + +exit 0 diff --git a/tests/gpgsm/initial.test b/tests/gpgsm/initial.test new file mode 100755 index 00000000..93c8621a --- /dev/null +++ b/tests/gpgsm/initial.test @@ -0,0 +1,4 @@ +#!/bin/sh + +${top_srcdir}/tests/start-stop-agent --start +exit 0 diff --git a/tests/start-stop-agent b/tests/start-stop-agent new file mode 100755 index 00000000..ab47d8d9 --- /dev/null +++ b/tests/start-stop-agent @@ -0,0 +1,45 @@ +#!/bin/sh +# Copyright (C) 2013 g10 Code GmbH +# +# This file is free software; as a special exception the author gives +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. This file is +# distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY, to the extent permitted by law; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +if [ -z "$(command -v gpg-connect-agent)" ]; then + echo "gpg-agent not installed and thus not started" >&2 + exit 0; +fi + +GPG_AGENT_INFO= +export GPG_AGENT_INFO + +token=$(echo "gpgme-$(pwd)" | tr ' ' '_') + +if [ "$1" = "--stop" ]; then + if [ "$(gpg-connect-agent getval\ $token /bye 2>/dev/null | head -1)" \ + != "D set" ]; then + echo "gpg-agent not running" >&2 + exit 0 + fi + echo "stopping gpg-agent " >&2 + gpg-connect-agent KILLAGENT /bye >/dev/null 2>&1 + exit 0 +fi + +if [ "$(gpg-connect-agent getval\ $token /bye 2>/dev/null | head -1)" \ + = "D set" ]; then + echo "gpg-agent already running" >&2 + exit 0 +fi + +echo "starting gpg-agent " >&2 +gpg-connect-agent putval\ $token\ set /bye >/dev/null 2>&1 +if [ "$(gpg-connect-agent getval\ $token /bye 2>/dev/null | head -1)" \ + != "D set" ]; then + echo "error starting gpg-agent" >&2 + exit 1 +fi +exit 0 -- cgit From 7addffc0826e7f36afcc7f66268e9ee2a37e2042 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Mon, 8 Jun 2015 12:30:11 +0200 Subject: tests: Add option --secret to run-keylist. Signed-off-by: Werner Koch --- tests/run-keylist.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/run-keylist.c b/tests/run-keylist.c index c0c72022..07c6fa18 100644 --- a/tests/run-keylist.c +++ b/tests/run-keylist.c @@ -45,6 +45,7 @@ show_usage (int ex) " --verbose run in verbose mode\n" " --openpgp use the OpenPGP protocol (default)\n" " --cms use the CMS protocol\n" + " --secret list only secret keys\n" " --local use GPGME_KEYLIST_MODE_LOCAL\n" " --extern use GPGME_KEYLIST_MODE_EXTERN\n" " --sigs use GPGME_KEYLIST_MODE_SIGS\n" @@ -70,6 +71,7 @@ main (int argc, char **argv) gpgme_key_t keyarray[100]; int keyidx = 0; gpgme_protocol_t protocol = GPGME_PROTOCOL_OpenPGP; + int only_secret = 0; if (argc) { argc--; argv++; } @@ -99,6 +101,11 @@ main (int argc, char **argv) protocol = GPGME_PROTOCOL_CMS; argc--; argv++; } + else if (!strcmp (*argv, "--secret")) + { + only_secret = 1; + argc--; argv++; + } else if (!strcmp (*argv, "--local")) { mode |= GPGME_KEYLIST_MODE_LOCAL; @@ -150,7 +157,7 @@ main (int argc, char **argv) gpgme_set_keylist_mode (ctx, mode); - err = gpgme_op_keylist_start (ctx, argc? argv[0]:NULL, 0); + err = gpgme_op_keylist_start (ctx, argc? argv[0]:NULL, only_secret); fail_if_err (err); while (!(err = gpgme_op_keylist_next (ctx, &key))) -- cgit From 08086dd6901740e155e4361212b4e9cff8a47296 Mon Sep 17 00:00:00 2001 From: Andre Heinecke Date: Thu, 2 Jul 2015 10:19:04 +0200 Subject: Add offline mode support for CMS keylisting * doc/gpgme.texi: Document offline mode. * src/context.h (gpgme_context): Add offline. * src/engine-backend.h (keylist, keylist_ext): Add engine_flags. * src/engine.c, src/engine.h (_gpgme_engine_op_keylist): Ditto. (_gpgme_engine_op_keylist_ext): Ditto. * src/engine.h (GPGME_ENGINE_FLAG_OFFLINE): New. * src/engine-gpg.c (gpg_keylist, gpg_keylist_ext): Ditto. * src/engine-gpgsm.c (gpgsm_keylist): Handle engine_flags. (gpgsm_keylist_ext): Ditto. * src/gpgme.c (gpgme_set_offline, gpgme_get_offline): New. * src/gpgme.def (gpgme_set_offline, gpgme_get_offline): New. * src/gpgme.h.in (gpgme_set_offline, gpgme_get_offline): New. * src/libgpgme.vers (gpgme_set_offline, gpgme_get_offline): New. * src/keylist.c (gpgme_op_keylist_start): Set offline flag. (gpgme_op_keylist_ext_start): Ditto. * tests/run-keylist.c (show_usage, main): Add offline argument. -- The offline engine option was introduced with gpgsm 2.1.6 it is mainly useful for a full keylisting that includes the certificate validation but does not depend on external information that could take an indefinite amount of time to collect. Signed-off-by: Andre Heinecke --- doc/gpgme.texi | 33 +++++++++++++++++++++++++++++++++ src/context.h | 3 +++ src/engine-backend.h | 6 ++++-- src/engine-gpg.c | 4 ++-- src/engine-gpgsm.c | 15 ++++++++++++--- src/engine.c | 10 ++++++---- src/engine.h | 9 +++++++-- src/gpgme.c | 24 ++++++++++++++++++++++++ src/gpgme.def | 3 +++ src/gpgme.h.in | 6 ++++++ src/keylist.c | 13 +++++++++++-- src/libgpgme.vers | 3 +++ tests/run-keylist.c | 9 +++++++++ 13 files changed, 123 insertions(+), 15 deletions(-) (limited to 'tests') diff --git a/doc/gpgme.texi b/doc/gpgme.texi index 45c359d0..ef4936dd 100644 --- a/doc/gpgme.texi +++ b/doc/gpgme.texi @@ -189,6 +189,7 @@ Context Attributes * Crypto Engine:: Configuring the crypto engine. * ASCII Armor:: Requesting @acronym{ASCII} armored output. * Text Mode:: Choosing canonical text mode. +* Offline Mode:: Choosing offline mode. * Included Certificates:: Including a number of certificates. * Key Listing Mode:: Selecting key listing mode. * Passphrase Callback:: Getting the passphrase from the user. @@ -2285,6 +2286,7 @@ started. In fact, these references are accessed through the * Crypto Engine:: Configuring the crypto engine. * ASCII Armor:: Requesting @acronym{ASCII} armored output. * Text Mode:: Choosing canonical text mode. +* Offline Mode:: Choosing offline mode. * Included Certificates:: Including a number of certificates. * Key Listing Mode:: Selecting key listing mode. * Passphrase Callback:: Getting the passphrase from the user. @@ -2413,6 +2415,37 @@ valid pointer. @end deftypefun +@node Offline Mode +@subsection Offline Mode +@cindex context, offline mode +@cindex offline mode + +@deftypefun void gpgme_set_offline (@w{gpgme_ctx_t @var{ctx}}, @w{int @var{yes}}) +The function @code{gpgme_set_offline} specifies if offline mode +should be used. By default, offline mode is not used. + +The offline mode specifies if dirmngr should be used to do additional +validation that might require connections to external services. +(e.g. CRL / OCSP checks). + +Offline mode only affects the keylist mode @code{GPGME_KEYLIST_MODE_VALIDATE} +and is only relevant to the CMS crypto engine. Offline mode +is ignored otherwise. + +This option may be extended in the future to completely disable +the use of dirmngr for any engine. + +Offline mode is disabled if @var{yes} is zero, and enabled +otherwise. +@end deftypefun + +@deftypefun int gpgme_get_offline (@w{gpgme_ctx_t @var{ctx}}) +The function @code{gpgme_get_offline} returns 1 if offline +mode is enabled, and @code{0} if it is not, or if @var{ctx} is not a +valid pointer. +@end deftypefun + + @node Included Certificates @subsection Included Certificates @cindex certificates, included diff --git a/src/context.h b/src/context.h index 745ffa89..8cd86e9c 100644 --- a/src/context.h +++ b/src/context.h @@ -98,6 +98,9 @@ struct gpgme_context /* True if text mode should be used. */ unsigned int use_textmode : 1; + /* True if offline mode should be used. */ + unsigned int offline : 1; + /* Flags for keylist mode. */ gpgme_keylist_mode_t keylist_mode; diff --git a/src/engine-backend.h b/src/engine-backend.h index b3cc412a..4f4519c0 100644 --- a/src/engine-backend.h +++ b/src/engine-backend.h @@ -85,10 +85,12 @@ struct engine_ops gpgme_error_t (*import) (void *engine, gpgme_data_t keydata, gpgme_key_t *keyarray); gpgme_error_t (*keylist) (void *engine, const char *pattern, - int secret_only, gpgme_keylist_mode_t mode); + int secret_only, gpgme_keylist_mode_t mode, + int engine_flags); gpgme_error_t (*keylist_ext) (void *engine, const char *pattern[], int secret_only, int reserved, - gpgme_keylist_mode_t mode); + gpgme_keylist_mode_t mode, + int engine_flags); gpgme_error_t (*sign) (void *engine, gpgme_data_t in, gpgme_data_t out, gpgme_sig_mode_t mode, int use_armor, int use_textmode, int include_certs, diff --git a/src/engine-gpg.c b/src/engine-gpg.c index e14fd8dd..510dfd9d 100644 --- a/src/engine-gpg.c +++ b/src/engine-gpg.c @@ -2279,7 +2279,7 @@ gpg_keylist_build_options (engine_gpg_t gpg, int secret_only, static gpgme_error_t gpg_keylist (void *engine, const char *pattern, int secret_only, - gpgme_keylist_mode_t mode) + gpgme_keylist_mode_t mode, int engine_flags) { engine_gpg_t gpg = engine; gpgme_error_t err; @@ -2298,7 +2298,7 @@ gpg_keylist (void *engine, const char *pattern, int secret_only, static gpgme_error_t gpg_keylist_ext (void *engine, const char *pattern[], int secret_only, - int reserved, gpgme_keylist_mode_t mode) + int reserved, gpgme_keylist_mode_t mode, int engine_flags) { engine_gpg_t gpg = engine; gpgme_error_t err; diff --git a/src/engine-gpgsm.c b/src/engine-gpgsm.c index ac6c5fc6..37711574 100644 --- a/src/engine-gpgsm.c +++ b/src/engine-gpgsm.c @@ -1542,7 +1542,7 @@ gpgsm_import (void *engine, gpgme_data_t keydata, gpgme_key_t *keyarray) static gpgme_error_t gpgsm_keylist (void *engine, const char *pattern, int secret_only, - gpgme_keylist_mode_t mode) + gpgme_keylist_mode_t mode, int engine_flags) { engine_gpgsm_t gpgsm = engine; char *line; @@ -1599,6 +1599,11 @@ gpgsm_keylist (void *engine, const char *pattern, int secret_only, "OPTION with-secret=1": "OPTION with-secret=0" , NULL, NULL); + gpgsm_assuan_simple_command (gpgsm->assuan_ctx, + (engine_flags & GPGME_ENGINE_FLAG_OFFLINE)? + "OPTION offline=1": + "OPTION offline=0" , + NULL, NULL); /* Length is "LISTSECRETKEYS " + p + '\0'. */ @@ -1629,7 +1634,7 @@ gpgsm_keylist (void *engine, const char *pattern, int secret_only, static gpgme_error_t gpgsm_keylist_ext (void *engine, const char *pattern[], int secret_only, - int reserved, gpgme_keylist_mode_t mode) + int reserved, gpgme_keylist_mode_t mode, int engine_flags) { engine_gpgsm_t gpgsm = engine; char *line; @@ -1669,7 +1674,11 @@ gpgsm_keylist_ext (void *engine, const char *pattern[], int secret_only, "OPTION with-secret=1": "OPTION with-secret=0" , NULL, NULL); - + gpgsm_assuan_simple_command (gpgsm->assuan_ctx, + (engine_flags & GPGME_ENGINE_FLAG_OFFLINE)? + "OPTION offline=1": + "OPTION offline=0" , + NULL, NULL); if (pattern && *pattern) { diff --git a/src/engine.c b/src/engine.c index ff015c00..8e84da95 100644 --- a/src/engine.c +++ b/src/engine.c @@ -726,7 +726,8 @@ _gpgme_engine_op_import (engine_t engine, gpgme_data_t keydata, gpgme_error_t _gpgme_engine_op_keylist (engine_t engine, const char *pattern, - int secret_only, gpgme_keylist_mode_t mode) + int secret_only, gpgme_keylist_mode_t mode, + int engine_flags) { if (!engine) return gpg_error (GPG_ERR_INV_VALUE); @@ -734,14 +735,15 @@ _gpgme_engine_op_keylist (engine_t engine, const char *pattern, if (!engine->ops->keylist) return gpg_error (GPG_ERR_NOT_IMPLEMENTED); - return (*engine->ops->keylist) (engine->engine, pattern, secret_only, mode); + return (*engine->ops->keylist) (engine->engine, pattern, secret_only, mode, + engine_flags); } gpgme_error_t _gpgme_engine_op_keylist_ext (engine_t engine, const char *pattern[], int secret_only, int reserved, - gpgme_keylist_mode_t mode) + gpgme_keylist_mode_t mode, int engine_flags) { if (!engine) return gpg_error (GPG_ERR_INV_VALUE); @@ -750,7 +752,7 @@ _gpgme_engine_op_keylist_ext (engine_t engine, const char *pattern[], return gpg_error (GPG_ERR_NOT_IMPLEMENTED); return (*engine->ops->keylist_ext) (engine->engine, pattern, secret_only, - reserved, mode); + reserved, mode, engine_flags); } diff --git a/src/engine.h b/src/engine.h index bbf009d6..56fcc420 100644 --- a/src/engine.h +++ b/src/engine.h @@ -113,12 +113,14 @@ gpgme_error_t _gpgme_engine_op_import (engine_t engine, gpgme_error_t _gpgme_engine_op_keylist (engine_t engine, const char *pattern, int secret_only, - gpgme_keylist_mode_t mode); + gpgme_keylist_mode_t mode, + int engine_flags); gpgme_error_t _gpgme_engine_op_keylist_ext (engine_t engine, const char *pattern[], int secret_only, int reserved, - gpgme_keylist_mode_t mode); + gpgme_keylist_mode_t mode, + int engine_flags); gpgme_error_t _gpgme_engine_op_sign (engine_t engine, gpgme_data_t in, gpgme_data_t out, gpgme_sig_mode_t mode, int use_armor, int use_textmode, @@ -170,5 +172,8 @@ gpgme_error_t _gpgme_engine_op_spawn (engine_t engine, gpgme_data_t dataerr, unsigned int flags); +/* The available engine option flags. */ +#define GPGME_ENGINE_FLAG_OFFLINE 1 + #endif /* ENGINE_H */ diff --git a/src/gpgme.c b/src/gpgme.c index 628cdaee..c24b6200 100644 --- a/src/gpgme.c +++ b/src/gpgme.c @@ -472,6 +472,30 @@ gpgme_get_textmode (gpgme_ctx_t ctx) } +/* Enable offline mode for this context. In offline mode dirmngr + will be disabled. */ +void +gpgme_set_offline (gpgme_ctx_t ctx, int offline) +{ + TRACE2 (DEBUG_CTX, "gpgme_set_offline", ctx, "offline=%i (%s)", + offline, offline ? "yes" : "no"); + + if (!ctx) + return; + + ctx->offline = offline; +} + +/* Return the state of the offline flag. */ +int +gpgme_get_offline (gpgme_ctx_t ctx) +{ + TRACE2 (DEBUG_CTX, "gpgme_get_offline", ctx, "ctx->offline=%i (%s)", + ctx->offline, ctx->offline ? "yes" : "no"); + return ctx->offline; +} + + /* Set the number of certifications to include in an S/MIME message. The default is GPGME_INCLUDE_CERTS_DEFAULT. -1 means all certs, and -2 means all certs except the root cert. */ diff --git a/src/gpgme.def b/src/gpgme.def index dc189484..cf167b4f 100644 --- a/src/gpgme.def +++ b/src/gpgme.def @@ -217,5 +217,8 @@ EXPORTS gpgme_op_spawn_start @163 gpgme_op_spawn @164 + + gpgme_set_offline @165 + gpgme_get_offline @166 ; END diff --git a/src/gpgme.h.in b/src/gpgme.h.in index 15ed8037..099cc8a5 100644 --- a/src/gpgme.h.in +++ b/src/gpgme.h.in @@ -887,6 +887,12 @@ void gpgme_set_textmode (gpgme_ctx_t ctx, int yes); /* Return non-zero if text mode is set in CTX. */ int gpgme_get_textmode (gpgme_ctx_t ctx); +/* If YES is non-zero, enable offline mode in CTX, disable it otherwise. */ +void gpgme_set_offline (gpgme_ctx_t ctx, int yes); + +/* Return non-zero if offline mode is set in CTX. */ +int gpgme_get_offline (gpgme_ctx_t ctx); + /* Use whatever the default of the backend crypto engine is. */ #define GPGME_INCLUDE_CERTS_DEFAULT -256 diff --git a/src/keylist.c b/src/keylist.c index 36ee3eaa..fcf574fc 100644 --- a/src/keylist.c +++ b/src/keylist.c @@ -889,6 +889,7 @@ gpgme_op_keylist_start (gpgme_ctx_t ctx, const char *pattern, int secret_only) gpgme_error_t err; void *hook; op_data_t opd; + int flags = 0; TRACE_BEG2 (DEBUG_CTX, "gpgme_op_keylist_start", ctx, "pattern=%s, secret_only=%i", pattern, secret_only); @@ -913,8 +914,11 @@ gpgme_op_keylist_start (gpgme_ctx_t ctx, const char *pattern, int secret_only) if (err) return TRACE_ERR (err); + if (ctx->offline) + flags |= GPGME_ENGINE_FLAG_OFFLINE; + err = _gpgme_engine_op_keylist (ctx->engine, pattern, secret_only, - ctx->keylist_mode); + ctx->keylist_mode, flags); return TRACE_ERR (err); } @@ -929,6 +933,7 @@ gpgme_op_keylist_ext_start (gpgme_ctx_t ctx, const char *pattern[], gpgme_error_t err; void *hook; op_data_t opd; + int flags = 0; TRACE_BEG2 (DEBUG_CTX, "gpgme_op_keylist_ext_start", ctx, "secret_only=%i, reserved=0x%x", secret_only, reserved); @@ -952,8 +957,12 @@ gpgme_op_keylist_ext_start (gpgme_ctx_t ctx, const char *pattern[], if (err) return TRACE_ERR (err); + if (ctx->offline) + flags |= GPGME_ENGINE_FLAG_OFFLINE; + err = _gpgme_engine_op_keylist_ext (ctx->engine, pattern, secret_only, - reserved, ctx->keylist_mode); + reserved, ctx->keylist_mode, + flags); return TRACE_ERR (err); } diff --git a/src/libgpgme.vers b/src/libgpgme.vers index 39663c1c..fc2920f8 100644 --- a/src/libgpgme.vers +++ b/src/libgpgme.vers @@ -92,6 +92,9 @@ GPGME_1.1 { gpgme_op_spawn_start; gpgme_op_spawn; + + gpgme_set_offline; + gpgme_get_offline; }; diff --git a/tests/run-keylist.c b/tests/run-keylist.c index 07c6fa18..8abdf43d 100644 --- a/tests/run-keylist.c +++ b/tests/run-keylist.c @@ -53,6 +53,7 @@ show_usage (int ex) " --ephemeral use GPGME_KEYLIST_MODE_EPHEMERAL\n" " --validate use GPGME_KEYLIST_MODE_VALIDATE\n" " --import import all keys\n" + " --offline use offline mode\n" , stderr); exit (ex); } @@ -72,6 +73,7 @@ main (int argc, char **argv) int keyidx = 0; gpgme_protocol_t protocol = GPGME_PROTOCOL_OpenPGP; int only_secret = 0; + int offline = 0; if (argc) { argc--; argv++; } @@ -141,6 +143,11 @@ main (int argc, char **argv) import = 1; argc--; argv++; } + else if (!strcmp (*argv, "--offline")) + { + offline = 1; + argc--; argv++; + } else if (!strncmp (*argv, "--", 2)) show_usage (1); @@ -157,6 +164,8 @@ main (int argc, char **argv) gpgme_set_keylist_mode (ctx, mode); + gpgme_set_offline (ctx, offline); + err = gpgme_op_keylist_start (ctx, argc? argv[0]:NULL, only_secret); fail_if_err (err); -- cgit From 2b632bbb78eee2b94c122f66d171a7c80e9c4fb0 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Mon, 24 Aug 2015 12:41:24 +0200 Subject: Add an export secret key feature. * src/gpgme.h.in (GPGME_EXPORT_MODE_SECRET): New. (GPGME_EXPORT_MODE_RAW): New. (GPGME_EXPORT_MODE_PKCS12): New. * src/export.c (export_start, export_ext_start): Allow new flags. * src/engine-gpg.c (export_common): Support secret key export. * src/engine-gpgsm.c (gpgsm_export, gpgsm_export_ext): Ditto. * src/gpgme-tool.c (cmd_export): Add options --secret, --raw, and --pkcs12. * tests/run-export.c (main): Likewise. -- Note that exporting secret X.509 keys requires GnuPG 2.1.8. Signed-off-by: Werner Koch --- doc/gpgme.texi | 15 +++++++++++++++ src/engine-gpg.c | 8 ++++++-- src/engine-gpgsm.c | 33 ++++++++++++++++++++++----------- src/export.c | 35 +++++++++++++++++++++++++++++++++-- src/gpgme-tool.c | 8 +++++++- src/gpgme.h.in | 3 +++ tests/run-export.c | 41 +++++++++++++++++++++++++++++++++++++---- 7 files changed, 123 insertions(+), 20 deletions(-) (limited to 'tests') diff --git a/doc/gpgme.texi b/doc/gpgme.texi index 010b914d..20e1912b 100644 --- a/doc/gpgme.texi +++ b/doc/gpgme.texi @@ -3700,6 +3700,21 @@ keys it removes all signatures except for the latest self-signatures. For X.509 keys it has no effect. +@item GPGME_EXPORT_MODE_SECRET +Instead of exporting the public key, the secret key is exported. This +may not be combined with @code{GPGME_EXPORT_MODE_EXTERN}. For X.509 +the export format is PKCS#8. + +@item GPGME_EXPORT_MODE_RAW +If this flag is used with @code{GPGME_EXPORT_MODE_SECRET} for an X.509 +key the export format will be changed to PKCS#1. This flag may not be +used with OpenPGP. + +@item GPGME_EXPORT_MODE_PKCS12 +If this flag is used with @code{GPGME_EXPORT_MODE_SECRET} for an X.509 +key the export format will be changed to PKCS#12 which also includes +the certificate. This flag may not be used with OpenPGP. + @end table diff --git a/src/engine-gpg.c b/src/engine-gpg.c index d1385926..ffae2fe4 100644 --- a/src/engine-gpg.c +++ b/src/engine-gpg.c @@ -1793,7 +1793,8 @@ export_common (engine_gpg_t gpg, gpgme_export_mode_t mode, gpgme_error_t err = 0; if ((mode & ~(GPGME_EXPORT_MODE_EXTERN - |GPGME_EXPORT_MODE_MINIMAL))) + |GPGME_EXPORT_MODE_MINIMAL + |GPGME_EXPORT_MODE_SECRET))) return gpg_error (GPG_ERR_NOT_SUPPORTED); if ((mode & GPGME_EXPORT_MODE_MINIMAL)) @@ -1807,7 +1808,10 @@ export_common (engine_gpg_t gpg, gpgme_export_mode_t mode, } else { - err = add_arg (gpg, "--export"); + if ((mode & GPGME_EXPORT_MODE_SECRET)) + err = add_arg (gpg, "--export-secret-keys"); + else + err = add_arg (gpg, "--export"); if (!err && use_armor) err = add_arg (gpg, "--armor"); if (!err) diff --git a/src/engine-gpgsm.c b/src/engine-gpgsm.c index 37711574..24d3b2a8 100644 --- a/src/engine-gpgsm.c +++ b/src/engine-gpgsm.c @@ -1289,17 +1289,23 @@ gpgsm_export (void *engine, const char *pattern, gpgme_export_mode_t mode, if (!gpgsm) return gpg_error (GPG_ERR_INV_VALUE); - if (mode) - return gpg_error (GPG_ERR_NOT_SUPPORTED); - if (!pattern) pattern = ""; - cmd = malloc (7 + strlen (pattern) + 1); + cmd = malloc (7 + 9 + 9 + strlen (pattern) + 1); if (!cmd) return gpg_error_from_syserror (); + strcpy (cmd, "EXPORT "); - strcpy (&cmd[7], pattern); + if ((mode & GPGME_EXPORT_MODE_SECRET)) + { + strcat (cmd, "--secret "); + if ((mode & GPGME_EXPORT_MODE_RAW)) + strcat (cmd, "--raw "); + else if ((mode & GPGME_EXPORT_MODE_PKCS12)) + strcat (cmd, "--pkcs12 "); + } + strcat (cmd, pattern); gpgsm->output_cb.data = keydata; err = gpgsm_set_fd (gpgsm, OUTPUT_FD, use_armor ? "--armor" @@ -1323,16 +1329,13 @@ gpgsm_export_ext (void *engine, const char *pattern[], gpgme_export_mode_t mode, engine_gpgsm_t gpgsm = engine; gpgme_error_t err = 0; char *line; - /* Length is "EXPORT " + p + '\0'. */ - int length = 7 + 1; + /* Length is "EXPORT " + "--secret " + "--pkcs12 " + p + '\0'. */ + int length = 7 + 9 + 9 + 1; char *linep; if (!gpgsm) return gpg_error (GPG_ERR_INV_VALUE); - if (mode) - return gpg_error (GPG_ERR_NOT_SUPPORTED); - if (pattern && *pattern) { const char **pat = pattern; @@ -1357,7 +1360,15 @@ gpgsm_export_ext (void *engine, const char *pattern[], gpgme_export_mode_t mode, return gpg_error_from_syserror (); strcpy (line, "EXPORT "); - linep = &line[7]; + if ((mode & GPGME_EXPORT_MODE_SECRET)) + { + strcat (line, "--secret "); + if ((mode & GPGME_EXPORT_MODE_RAW)) + strcat (line, "--raw "); + else if ((mode & GPGME_EXPORT_MODE_PKCS12)) + strcat (line, "--pkcs12 "); + } + linep = &line[strlen (line)]; if (pattern && *pattern) { diff --git a/src/export.c b/src/export.c index 8930aa68..a29fbde8 100644 --- a/src/export.c +++ b/src/export.c @@ -120,9 +120,24 @@ export_start (gpgme_ctx_t ctx, int synchronous, const char *pattern, op_data_t opd; if ((mode & ~(GPGME_EXPORT_MODE_EXTERN - |GPGME_EXPORT_MODE_MINIMAL))) + |GPGME_EXPORT_MODE_MINIMAL + |GPGME_EXPORT_MODE_SECRET + |GPGME_EXPORT_MODE_RAW + |GPGME_EXPORT_MODE_PKCS12))) return gpg_error (GPG_ERR_INV_VALUE); /* Invalid flags in MODE. */ + if ((mode & GPGME_EXPORT_MODE_SECRET)) + { + if ((mode & GPGME_EXPORT_MODE_EXTERN)) + return gpg_error (GPG_ERR_INV_FLAG); /* Combination not allowed. */ + if ((mode & GPGME_EXPORT_MODE_RAW) + && (mode & GPGME_EXPORT_MODE_PKCS12)) + return gpg_error (GPG_ERR_INV_FLAG); /* Combination not allowed. */ + + if (ctx->protocol != GPGME_PROTOCOL_CMS + && (mode & (GPGME_EXPORT_MODE_RAW|GPGME_EXPORT_MODE_PKCS12))) + return gpg_error (GPG_ERR_INV_FLAG); /* Only supported for X.509. */ + } if ((mode & GPGME_EXPORT_MODE_EXTERN)) { @@ -199,9 +214,25 @@ export_ext_start (gpgme_ctx_t ctx, int synchronous, const char *pattern[], op_data_t opd; if ((mode & ~(GPGME_EXPORT_MODE_EXTERN - |GPGME_EXPORT_MODE_MINIMAL))) + |GPGME_EXPORT_MODE_MINIMAL + |GPGME_EXPORT_MODE_SECRET + |GPGME_EXPORT_MODE_RAW + |GPGME_EXPORT_MODE_PKCS12))) return gpg_error (GPG_ERR_INV_VALUE); /* Invalid flags in MODE. */ + if ((mode & GPGME_EXPORT_MODE_SECRET)) + { + if ((mode & GPGME_EXPORT_MODE_EXTERN)) + return gpg_error (GPG_ERR_INV_FLAG); /* Combination not allowed. */ + if ((mode & GPGME_EXPORT_MODE_RAW) + && (mode & GPGME_EXPORT_MODE_PKCS12)) + return gpg_error (GPG_ERR_INV_FLAG); /* Combination not allowed. */ + + if (ctx->protocol != GPGME_PROTOCOL_CMS + && (mode & (GPGME_EXPORT_MODE_RAW|GPGME_EXPORT_MODE_PKCS12))) + return gpg_error (GPG_ERR_INV_FLAG); /* Only supported for X.509. */ + } + if ((mode & GPGME_EXPORT_MODE_EXTERN)) { if (keydata) diff --git a/src/gpgme-tool.c b/src/gpgme-tool.c index 94d11248..e5e57073 100644 --- a/src/gpgme-tool.c +++ b/src/gpgme-tool.c @@ -3054,7 +3054,7 @@ cmd_import (assuan_context_t ctx, char *line) static const char hlp_export[] = - "EXPORT [--extern] [--minimal] []\n" + "EXPORT [--extern] [--minimal] [--secret [--pkcs12] [--raw]] []\n" "\n" "Export the keys described by PATTERN. Write the\n" "the output to the object set by the last OUTPUT command."; @@ -3082,6 +3082,12 @@ cmd_export (assuan_context_t ctx, char *line) mode |= GPGME_EXPORT_MODE_EXTERN; if (has_option (line, "--minimal")) mode |= GPGME_EXPORT_MODE_MINIMAL; + if (has_option (line, "--secret")) + mode |= GPGME_EXPORT_MODE_SECRET; + if (has_option (line, "--raw")) + mode |= GPGME_EXPORT_MODE_RAW; + if (has_option (line, "--pkcs12")) + mode |= GPGME_EXPORT_MODE_PKCS12; line = skip_options (line); diff --git a/src/gpgme.h.in b/src/gpgme.h.in index 8255e637..76055708 100644 --- a/src/gpgme.h.in +++ b/src/gpgme.h.in @@ -392,6 +392,9 @@ gpgme_pinentry_mode_t; /* The available export mode flags. */ #define GPGME_EXPORT_MODE_EXTERN 2 #define GPGME_EXPORT_MODE_MINIMAL 4 +#define GPGME_EXPORT_MODE_SECRET 16 +#define GPGME_EXPORT_MODE_RAW 32 +#define GPGME_EXPORT_MODE_PKCS12 64 typedef unsigned int gpgme_export_mode_t; diff --git a/tests/run-export.c b/tests/run-export.c index 43332087..b133f130 100644 --- a/tests/run-export.c +++ b/tests/run-export.c @@ -43,7 +43,12 @@ show_usage (int ex) fputs ("usage: " PGM " [options] USERIDS\n\n" "Options:\n" " --verbose run in verbose mode\n" + " --openpgp use OpenPGP protocol (default)\n" + " --cms use X.509 protocol\n" " --extern send keys to the keyserver (TAKE CARE!)\n" + " --secret export secret keys instead of public keys\n" + " --raw use PKCS#1 as secret key format\n" + " --pkcs12 use PKCS#12 as secret key format\n" , stderr); exit (ex); } @@ -59,6 +64,7 @@ main (int argc, char **argv) gpgme_key_t keyarray[100]; int keyidx = 0; gpgme_data_t out; + gpgme_protocol_t protocol = GPGME_PROTOCOL_OpenPGP; gpgme_export_mode_t mode = 0; if (argc) @@ -79,9 +85,34 @@ main (int argc, char **argv) verbose = 1; argc--; argv++; } + else if (!strcmp (*argv, "--openpgp")) + { + protocol = GPGME_PROTOCOL_OpenPGP; + argc--; argv++; + } + else if (!strcmp (*argv, "--cms")) + { + protocol = GPGME_PROTOCOL_CMS; + argc--; argv++; + } else if (!strcmp (*argv, "--extern")) { - mode |= GPGME_KEYLIST_MODE_EXTERN; + mode |= GPGME_EXPORT_MODE_EXTERN; + argc--; argv++; + } + else if (!strcmp (*argv, "--secret")) + { + mode |= GPGME_EXPORT_MODE_SECRET; + argc--; argv++; + } + else if (!strcmp (*argv, "--raw")) + { + mode |= GPGME_EXPORT_MODE_RAW; + argc--; argv++; + } + else if (!strcmp (*argv, "--pkcs12")) + { + mode |= GPGME_EXPORT_MODE_PKCS12; argc--; argv++; } else if (!strncmp (*argv, "--", 2)) @@ -92,11 +123,11 @@ main (int argc, char **argv) if (!argc) show_usage (1); - init_gpgme (GPGME_PROTOCOL_OpenPGP); + init_gpgme (protocol); err = gpgme_new (&ctx); fail_if_err (err); - gpgme_set_protocol (ctx, GPGME_PROTOCOL_OpenPGP); + gpgme_set_protocol (ctx, protocol); /* Lookup the keys. */ err = gpgme_op_keylist_ext_start (ctx, (const char**)argv, 0, 0); @@ -131,8 +162,10 @@ main (int argc, char **argv) } /* Now for the actual export. */ - if ((mode & GPGME_KEYLIST_MODE_EXTERN)) + if ((mode & GPGME_EXPORT_MODE_EXTERN)) printf ("sending keys to keyserver\n"); + if ((mode & GPGME_EXPORT_MODE_SECRET)) + printf ("exporting secret keys!\n"); err = gpgme_data_new (&out); fail_if_err (err); -- cgit From 491fcd91b84564232d5d061942baa50b99e166c0 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Tue, 25 Aug 2015 09:05:27 +0200 Subject: tests: Allow using run-sign to test loopback pinentry problems. * tests/run-sign.c: Add options --status and --loopback. --- tests/run-sign.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'tests') diff --git a/tests/run-sign.c b/tests/run-sign.c index e1498ea8..c59c3563 100644 --- a/tests/run-sign.c +++ b/tests/run-sign.c @@ -36,6 +36,14 @@ static int verbose; +static gpg_error_t +status_cb (void *opaque, const char *keyword, const char *value) +{ + (void)opaque; + printf ("status_cb: %s %s\n", keyword, value); + return 0; +} + static void print_result (gpgme_sign_result_t result, gpgme_sig_mode_t type) @@ -67,9 +75,11 @@ show_usage (int ex) fputs ("usage: " PGM " [options] FILE\n\n" "Options:\n" " --verbose run in verbose mode\n" + " --status print status lines from the backend\n" " --openpgp use the OpenPGP protocol (default)\n" " --cms use the CMS protocol\n" " --uiserver use the UI server\n" + " --loopback use a loopback pinentry\n" " --key NAME use key NAME for signing\n" , stderr); exit (ex); @@ -87,6 +97,8 @@ main (int argc, char **argv) gpgme_sig_mode_t sigmode = GPGME_SIG_MODE_NORMAL; gpgme_data_t in, out; gpgme_sign_result_t result; + int print_status = 0; + int use_loopback = 0; if (argc) { argc--; argv++; } @@ -106,6 +118,11 @@ main (int argc, char **argv) verbose = 1; argc--; argv++; } + else if (!strcmp (*argv, "--status")) + { + print_status = 1; + argc--; argv++; + } else if (!strcmp (*argv, "--openpgp")) { protocol = GPGME_PROTOCOL_OpenPGP; @@ -129,6 +146,11 @@ main (int argc, char **argv) key_string = *argv; argc--; argv++; } + else if (!strcmp (*argv, "--loopback")) + { + use_loopback = 1; + argc--; argv++; + } else if (!strncmp (*argv, "--", 2)) show_usage (1); @@ -149,6 +171,10 @@ main (int argc, char **argv) fail_if_err (err); gpgme_set_protocol (ctx, protocol); gpgme_set_armor (ctx, 1); + if (print_status) + gpgme_set_status_cb (ctx, status_cb, NULL); + if (use_loopback) + gpgme_set_pinentry_mode (ctx, GPGME_PINENTRY_MODE_LOOPBACK); if (key_string) { -- cgit From 208f0297466ce68abfc432f4944f81eb8bf47cf8 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Tue, 25 Aug 2015 10:37:02 +0200 Subject: tests: Build test programs in tests/ without wrappers. -- --- tests/Makefile.am | 1 + 1 file changed, 1 insertion(+) (limited to 'tests') diff --git a/tests/Makefile.am b/tests/Makefile.am index 94eddac5..89e52e8d 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -26,6 +26,7 @@ TESTS = t-version t-data t-engine-info EXTRA_DIST = start-stop-agent t-data-1.txt t-data-2.txt ChangeLog-2011 AM_CPPFLAGS = -I$(top_builddir)/src @GPG_ERROR_CFLAGS@ +AM_LDFLAGS = -no-install LDADD = ../src/libgpgme.la @GPG_ERROR_LIBS@ noinst_HEADERS = run-support.h -- cgit From 8c61cbfb8ff2e1056840ecf8511810ed2482eb1f Mon Sep 17 00:00:00 2001 From: Justus Winter Date: Wed, 2 Dec 2015 11:28:07 +0100 Subject: Fix typos found by codespell. -- Signed-off-by: Justus Winter --- src/argparse.c | 2 +- src/funopen.c | 2 +- src/gpgme.h.in | 4 ++-- src/w32-glib-io.c | 2 +- src/w32-io.c | 4 ++-- src/wait-global.c | 4 ++-- src/wait-private.c | 6 +++--- tests/t-data.c | 2 +- 8 files changed, 13 insertions(+), 13 deletions(-) (limited to 'tests') diff --git a/src/argparse.c b/src/argparse.c index 53c20fca..b6abf86b 100644 --- a/src/argparse.c +++ b/src/argparse.c @@ -851,7 +851,7 @@ find_long_option( ARGPARSE_ARGS *arg, /* Would be better if we can do a binary search, but it is not possible to reorder our option table because we would mess up our help strings - What we can do is: Build a nice option - lookup table wehn this function is first invoked */ + lookup table when this function is first invoked */ if( !*keyword ) return -1; for(i=0; opts[i].short_opt; i++ ) diff --git a/src/funopen.c b/src/funopen.c index b71d3aed..b7220202 100644 --- a/src/funopen.c +++ b/src/funopen.c @@ -35,7 +35,7 @@ The functions to provide my either be NULL if not required or similar to the unistd function with the exception of using the - cookie instead of the fiel descripor. + cookie instead of the file descriptor. */ diff --git a/src/gpgme.h.in b/src/gpgme.h.in index e7216cbe..8264bab9 100644 --- a/src/gpgme.h.in +++ b/src/gpgme.h.in @@ -1518,7 +1518,7 @@ typedef enum GPGME_SIGSUM_CRL_MISSING = 0x0100, /* CRL not available. */ GPGME_SIGSUM_CRL_TOO_OLD = 0x0200, /* Available CRL is too old. */ GPGME_SIGSUM_BAD_POLICY = 0x0400, /* A policy was not met. */ - GPGME_SIGSUM_SYS_ERROR = 0x0800 /* A system error occured. */ + GPGME_SIGSUM_SYS_ERROR = 0x0800 /* A system error occurred. */ } gpgme_sigsum_t; @@ -1610,7 +1610,7 @@ struct _gpgme_import_status /* Fingerprint. */ char *fpr; - /* If a problem occured, the reason why the key could not be + /* If a problem occurred, the reason why the key could not be imported. Otherwise GPGME_No_Error. */ gpgme_error_t result; diff --git a/src/w32-glib-io.c b/src/w32-glib-io.c index a5af4e68..66dc9bf7 100644 --- a/src/w32-glib-io.c +++ b/src/w32-glib-io.c @@ -98,7 +98,7 @@ static struct FD is closed. This, together with the fact that dup'ed file descriptors are closed before the file descriptors from which they are dup'ed are closed, ensures that CHAN is always valid, - and shared among all file descriptors refering to the same + and shared among all file descriptors referring to the same underlying object. The logic behind this is that there is only one reason for us to diff --git a/src/w32-io.c b/src/w32-io.c index a6d52388..8e7abd32 100644 --- a/src/w32-io.c +++ b/src/w32-io.c @@ -74,7 +74,7 @@ static struct that dup'ed file descriptors are closed before the file descriptors from which they are dup'ed are closed, ensures that the handle or socket is always valid, and shared among all file - descriptors refering to the same underlying object. + descriptors referring to the same underlying object. The logic behind this is that there is only one reason for us to dup file descriptors anyway: to allow simpler book-keeping of @@ -978,7 +978,7 @@ _gpgme_io_write (int fd, const void *buffer, size_t count) return TRACE_SYSRES (-1); } - /* If no error occured, the number of bytes in the buffer must be + /* If no error occurred, the number of bytes in the buffer must be zero. */ assert (!ctx->nbytes); diff --git a/src/wait-global.c b/src/wait-global.c index f03775e2..28f3921f 100644 --- a/src/wait-global.c +++ b/src/wait-global.c @@ -206,7 +206,7 @@ _gpgme_wait_global_event_cb (void *data, gpgme_event_io_t type, gpgme_error_t err = ctx_active (ctx); if (err) - /* An error occured. Close all fds in this context, and + /* An error occurred. Close all fds in this context, and send the error in a done event. */ _gpgme_cancel_with_err (ctx, err, 0); } @@ -325,7 +325,7 @@ gpgme_wait_ext (gpgme_ctx_t ctx, gpgme_error_t *status, err = _gpgme_run_io_cb (&fdt.fds[i], 0, &local_op_err); if (err || local_op_err) { - /* An error occured. Close all fds in this context, + /* An error occurred. Close all fds in this context, and signal it. */ _gpgme_cancel_with_err (ictx, err, local_op_err); diff --git a/src/wait-private.c b/src/wait-private.c index 9a43110e..12d31805 100644 --- a/src/wait-private.c +++ b/src/wait-private.c @@ -89,7 +89,7 @@ _gpgme_wait_on_condition (gpgme_ctx_t ctx, volatile int *cond, if (nr < 0) { - /* An error occured. Close all fds in this context, and + /* An error occurred. Close all fds in this context, and signal it. */ err = gpg_error_from_syserror (); _gpgme_cancel_with_err (ctx, err, 0); @@ -116,7 +116,7 @@ _gpgme_wait_on_condition (gpgme_ctx_t ctx, volatile int *cond, err = _gpgme_run_io_cb (&ctx->fdt.fds[i], 0, &op_err); if (err) { - /* An error occured. Close all fds in this context, + /* An error occurred. Close all fds in this context, and signal it. */ _gpgme_cancel_with_err (ctx, err, 0); @@ -124,7 +124,7 @@ _gpgme_wait_on_condition (gpgme_ctx_t ctx, volatile int *cond, } else if (op_err) { - /* An operational error occured. Cancel the current + /* An operational error occurred. Cancel the current operation but not the session, and signal it. */ _gpgme_cancel_with_err (ctx, 0, op_err); diff --git a/tests/t-data.c b/tests/t-data.c index 888475fd..465f29ee 100644 --- a/tests/t-data.c +++ b/tests/t-data.c @@ -143,7 +143,7 @@ read_test (round_t round, gpgme_data_t data) read = gpgme_data_read (data, buffer, sizeof (buffer)); if (read > 0) { - fprintf (stderr, "%s:%d: (%i) gpgme_data_read succeded unexpectedly\n", + fprintf (stderr, "%s:%d: (%i) gpgme_data_read succeeded unexpectedly\n", __FILE__, __LINE__, round); exit (1); } -- cgit