gpgme.git
21 months agoAdd isDeVs to ostream operator
Andre Heinecke [Mon, 10 Jul 2017 15:27:24 +0000 (17:27 +0200)]
Add isDeVs to ostream operator

* lang/cpp/src/decryptionresult.cpp,
lang/cpp/src/verificationresult.cpp: Extend ostream operator
to include isDeVs.

21 months agoFix some shadow warnings
Andre Heinecke [Mon, 10 Jul 2017 15:26:46 +0000 (17:26 +0200)]
Fix some shadow warnings

--
Warnings in headers hurt downstream.

22 months agocpp: Fix CMake config library name for GPGME
Andre Heinecke [Mon, 12 Jun 2017 13:25:33 +0000 (15:25 +0200)]
cpp: Fix CMake config library name for GPGME

* lang/cpp/src/GpgmeppConfig.cmake.in.in: The link library
is of course also dynamic.

--
GnuPG-Bug-Id: T3181

22 months agoAdd flag 'is_de_vs' to decryption results and signatures.
Justus Winter [Tue, 30 May 2017 12:35:57 +0000 (14:35 +0200)]
Add flag 'is_de_vs' to decryption results and signatures.

* NEWS: Update.
* lang/cpp/src/decryptionresult.cpp (DecryptionResult::isDeVs): New
function.
* lang/cpp/src/decryptionresult.h (DecryptionResult::isDeVs): New
prototype.
* lang/cpp/src/verificationresult.cpp (Signature::isDeVs): New
function.
* lang/cpp/src/verificationresult.h (Signature::isDeVs): New
prototype.
* lang/python/src/results.py (DecryptResult): Turn field 'is_de_vs'
into a boolean.
(Signature): Likewise.
* src/decrypt.c (_gpgme_decrypt_status_handler): Handle the new
compliance status line.
* src/verify.c (_gpgme_verify_status_handler): Likewise.
* src/gpgme.h.in (gpgme_status_code_t): Add new status codes for the
new status lines.
* src/keylist.c (parse_pub_field18): Move function to 'util.h'.
(keylist_colon_handler): Adapt callsites.
* src/status-table.c (status_table): Add new status lines.
* src/util.h (PARSE_COMPLIANCE_FLAGS): New macro.  This used to be
'parse_pub_field18', but turned into a macro to make it polymorphic.
--

When decrypting data and verifying signatures, report whether the
operations are in compliance with the criteria for data classified as
VS-NfD.  This information can the be presented to the user.

GnuPG-bug-id: 3059
Signed-off-by: Justus Winter <justus@g10code.com>
22 months agocore: Sort the status table.
Justus Winter [Tue, 30 May 2017 10:09:23 +0000 (12:09 +0200)]
core: Sort the status table.

--
Signed-off-by: Justus Winter <justus@g10code.com>
23 months agopython: Fix build in certain cases.
Justus Winter [Thu, 18 May 2017 09:42:13 +0000 (11:42 +0200)]
python: Fix build in certain cases.

* lang/python/setup.py.in: Prepend the Python build dir to the list of
include directories so that it takes precedence over any other include
directory.
--
Fixes the build in case an older 'gpgme.h' is installed and is picked
up by the compiler when compiling the Python module.

Signed-off-by: Justus Winter <justus@g10code.com>
23 months agotests: Remove remnants of 'check-local'.
Justus Winter [Wed, 10 May 2017 14:31:58 +0000 (16:31 +0200)]
tests: Remove remnants of 'check-local'.

* tests/gpgsm/Makefile.am (check-local): Drop rule and the dependency
on it.
--
Previously, the test environment was created during 'make check'.
Nowadays we create it using 'BUILT_SOURCES' during 'make all'.  Drop
remnant of the previous method.

Signed-off-by: Justus Winter <justus@g10code.com>
23 months agopython: Fix test environment creation.
Justus Winter [Wed, 10 May 2017 14:19:52 +0000 (16:19 +0200)]
python: Fix test environment creation.

* lang/python/tests/Makefile.am (pubring-stamp): Do not depend on the
configuration files, this can trigger superfluous rebuilds.

Signed-off-by: Justus Winter <justus@g10code.com>
23 months agotests: Make sure to kill all previously running daemons.
Justus Winter [Wed, 10 May 2017 13:52:12 +0000 (15:52 +0200)]
tests: Make sure to kill all previously running daemons.

* lang/python/tests/Makefile.am: Kill all previously running daemons
before creating the private key store.
* lang/qt/tests/Makefile.am: Likewise.
* tests/gpg/Makefile.am: Likewise.
* tests/gpgsm/Makefile.am: Likewise.
--

Now that the daemons sockets are no longer created in the GNUPGHOME,
we cannot rely on cleaning the build directory to make sure they are
shut down.  Therefore, we explicitly kill any running daemons when
creating the test environment.

Signed-off-by: Justus Winter <justus@g10code.com>
23 months agotests: Harmonize test suites.
Justus Winter [Wed, 10 May 2017 13:49:54 +0000 (15:49 +0200)]
tests: Harmonize test suites.

* lang/python/tests/Makefile.am: Create test environment as part of
'make all'.
* tests/gpg/Makefile.am: Make sure the private keystore is created
first.
* tests/gpgsm/Makefile.am: Create test environment as part of
'make all'.  Make sure the private keystore is created
first.

Signed-off-by: Justus Winter <justus@g10code.com>
23 months agoqt: Stop agent on clean.
Justus Winter [Wed, 10 May 2017 13:23:56 +0000 (15:23 +0200)]
qt: Stop agent on clean.

* lang/qt/tests/Makefile.am (clean-local): Stop agent.

Signed-off-by: Justus Winter <justus@g10code.com>
23 months agoqt: Add a missing include <functional>
Andre Heinecke [Wed, 10 May 2017 08:24:18 +0000 (10:24 +0200)]
qt: Add a missing include <functional>

* lang/qt/src/qgpgmenewcryptoconfig.cpp: Include functional.

--
This is intended to fix compilation against the c++ stdlib from
Gentoo / GCC 7.

Patch provided by Martin Väth.
GnuPG-Bug-Id: T3151

23 months agoqt: Undeprecate API that I find useful
Andre Heinecke [Wed, 10 May 2017 08:22:23 +0000 (10:22 +0200)]
qt: Undeprecate API that I find useful

* lang/qt/src/decryptjob.h,
lang/qt/src/decryptverifyjob.h,
lang/qt/src/signencryptjob.h,
lang/qt/src/verifydetachedjob.h,
lang/qt/src/verifyopaquejob.h: Undeprecate ByteArray based API.

--
While an IODevice may be more performant the ByteArray API is
a very easy way to get started with QGpgME as it allows you
basically to encrypt / decrypt any QString.

This also fixes a ton of deprecation warnings in KDE where this
API is used all over the place.

23 months agoqt, tests: Don't use internal API
Andre Heinecke [Wed, 10 May 2017 08:18:41 +0000 (10:18 +0200)]
qt, tests: Don't use internal API

* lang/qt/tests/t-encrypt.cpp, lang/qt/tests/t-tofuinfo.cpp:
Only use exported API.

--
With the Job::Context hack we no longer need to use internal API.

23 months agocore: Don't split gpgconf strings on comma
Andre Heinecke [Wed, 5 Apr 2017 16:23:48 +0000 (18:23 +0200)]
core: Don't split gpgconf strings on comma

* src/engine-gpgconf.c (gpgconf_parse_option): Don't split
strings on comma.

--
This only affects values where the main type is string. Values
with the alt_type string but another main type are still split
to keep lists (e.g. groups) working.

23 months agoqt, cpp: Add additional copyright BSI notes
Andre Heinecke [Tue, 25 Apr 2017 11:03:49 +0000 (13:03 +0200)]
qt, cpp: Add additional copyright BSI notes

* lang/cpp/Makefile.am,
lang/cpp/src/Makefile.am,
lang/cpp/src/callbacks.cpp,
lang/cpp/src/callbacks.h,
lang/cpp/src/configuration.cpp,
lang/cpp/src/configuration.h,
lang/cpp/src/context_glib.cpp,
lang/cpp/src/context_p.h,
lang/cpp/src/context_qt.cpp,
lang/cpp/src/context_vanilla.cpp,
lang/cpp/src/data_p.h,
lang/cpp/src/decryptionresult.cpp,
lang/cpp/src/decryptionresult.h,
lang/cpp/src/defaultassuantransaction.cpp,
lang/cpp/src/defaultassuantransaction.h,
lang/cpp/src/editinteractor.cpp,
lang/cpp/src/editinteractor.h,
lang/cpp/src/encryptionresult.cpp,
lang/cpp/src/encryptionresult.h,
lang/cpp/src/engineinfo.cpp,
lang/cpp/src/engineinfo.h,
lang/cpp/src/error.h,
lang/cpp/src/eventloopinteractor.cpp,
lang/cpp/src/eventloopinteractor.h,
lang/cpp/src/exception.cpp,
lang/cpp/src/exception.h,
lang/cpp/src/global.h,
lang/cpp/src/gpgadduserideditinteractor.cpp,
lang/cpp/src/gpgadduserideditinteractor.h,
lang/cpp/src/gpgagentgetinfoassuantransaction.cpp,
lang/cpp/src/gpgagentgetinfoassuantransaction.h,
lang/cpp/src/gpgmefw.h,
lang/cpp/src/gpgsetexpirytimeeditinteractor.cpp,
lang/cpp/src/gpgsetexpirytimeeditinteractor.h,
lang/cpp/src/gpgsetownertrusteditinteractor.cpp,
lang/cpp/src/gpgsetownertrusteditinteractor.h,
lang/cpp/src/gpgsignkeyeditinteractor.cpp,
lang/cpp/src/gpgsignkeyeditinteractor.h,
lang/cpp/src/importresult.cpp,
lang/cpp/src/importresult.h,
lang/cpp/src/interfaces/assuantransaction.h,
lang/cpp/src/interfaces/dataprovider.h,
lang/cpp/src/interfaces/passphraseprovider.h,
lang/cpp/src/interfaces/progressprovider.h,
lang/cpp/src/keygenerationresult.cpp,
lang/cpp/src/keygenerationresult.h,
lang/cpp/src/keylistresult.cpp,
lang/cpp/src/keylistresult.h,
lang/cpp/src/notation.h,
lang/cpp/src/result.h,
lang/cpp/src/result_p.h,
lang/cpp/src/scdgetinfoassuantransaction.cpp,
lang/cpp/src/scdgetinfoassuantransaction.h,
lang/cpp/src/signingresult.cpp,
lang/cpp/src/signingresult.h,
lang/cpp/src/trustitem.cpp,
lang/cpp/src/trustitem.h,
lang/cpp/src/util.h,
lang/cpp/src/verificationresult.cpp,
lang/cpp/src/verificationresult.h,
lang/cpp/src/vfsmountresult.cpp,
lang/qt/Makefile.am,
lang/qt/doc/Makefile.am,
lang/qt/src/Makefile.am,
lang/qt/src/defaultkeygenerationjob.h,
lang/qt/tests/Makefile.am: Add missing copyright.

--
Moving the qt / cpp bindings into GPGME contained global
changes that modified nearly every source file. To reflect
that the copyright year / note should also be updated.

23 months agoChange copyright from Intevation to BSI
Andre Heinecke [Tue, 25 Apr 2017 08:24:11 +0000 (10:24 +0200)]
Change copyright from Intevation to BSI

* lang/cpp/src/gpggencardkeyinteractor.cpp,
lang/cpp/src/gpggencardkeyinteractor.h,
lang/cpp/src/gpgmepp_export.h,
lang/cpp/src/swdbresult.cpp,
lang/cpp/src/swdbresult.h,
lang/cpp/src/tofuinfo.cpp,
lang/cpp/src/tofuinfo.h,
lang/qt/src/abstractimportjob.h,
lang/qt/src/adduseridjob.h,
lang/qt/src/changeexpiryjob.h,
lang/qt/src/changeownertrustjob.h,
lang/qt/src/changepasswdjob.h,
lang/qt/src/cryptoconfig.cpp,
lang/qt/src/cryptoconfig.h,
lang/qt/src/dataprovider.cpp,
lang/qt/src/dataprovider.h,
lang/qt/src/decryptjob.h,
lang/qt/src/decryptverifyjob.h,
lang/qt/src/deletejob.h,
lang/qt/src/dn.cpp,
lang/qt/src/dn.h,
lang/qt/src/downloadjob.h,
lang/qt/src/encryptjob.h,
lang/qt/src/exportjob.h,
lang/qt/src/hierarchicalkeylistjob.h,
lang/qt/src/importfromkeyserverjob.h,
lang/qt/src/importjob.h,
lang/qt/src/job.cpp,
lang/qt/src/job.h,
lang/qt/src/keyformailboxjob.h,
lang/qt/src/keygenerationjob.h,
lang/qt/src/keylistjob.h,
lang/qt/src/listallkeysjob.h,
lang/qt/src/multideletejob.h,
lang/qt/src/protocol.h,
lang/qt/src/protocol_p.h,
lang/qt/src/qgpgme_export.h,
lang/qt/src/qgpgmeadduseridjob.cpp,
lang/qt/src/qgpgmeadduseridjob.h,
lang/qt/src/qgpgmebackend.cpp,
lang/qt/src/qgpgmebackend.h,
lang/qt/src/qgpgmechangeexpiryjob.cpp,
lang/qt/src/qgpgmechangeexpiryjob.h,
lang/qt/src/qgpgmechangeownertrustjob.cpp,
lang/qt/src/qgpgmechangeownertrustjob.h,
lang/qt/src/qgpgmechangepasswdjob.cpp,
lang/qt/src/qgpgmechangepasswdjob.h,
lang/qt/src/qgpgmedecryptjob.cpp,
lang/qt/src/qgpgmedecryptjob.h,
lang/qt/src/qgpgmedecryptverifyjob.cpp,
lang/qt/src/qgpgmedecryptverifyjob.h,
lang/qt/src/qgpgmedeletejob.cpp,
lang/qt/src/qgpgmedeletejob.h,
lang/qt/src/qgpgmedownloadjob.cpp,
lang/qt/src/qgpgmedownloadjob.h,
lang/qt/src/qgpgmeencryptjob.cpp,
lang/qt/src/qgpgmeencryptjob.h,
lang/qt/src/qgpgmeexportjob.cpp,
lang/qt/src/qgpgmeexportjob.h,
lang/qt/src/qgpgmeimportfromkeyserverjob.cpp,
lang/qt/src/qgpgmeimportfromkeyserverjob.h,
lang/qt/src/qgpgmeimportjob.cpp,
lang/qt/src/qgpgmeimportjob.h,
lang/qt/src/qgpgmekeyformailboxjob.cpp,
lang/qt/src/qgpgmekeyformailboxjob.h,
lang/qt/src/qgpgmekeygenerationjob.cpp,
lang/qt/src/qgpgmekeygenerationjob.h,
lang/qt/src/qgpgmekeylistjob.cpp,
lang/qt/src/qgpgmekeylistjob.h,
lang/qt/src/qgpgmelistallkeysjob.cpp,
lang/qt/src/qgpgmelistallkeysjob.h,
lang/qt/src/qgpgmenewcryptoconfig.cpp,
lang/qt/src/qgpgmenewcryptoconfig.h,
lang/qt/src/qgpgmerefreshkeysjob.cpp,
lang/qt/src/qgpgmerefreshkeysjob.h,
lang/qt/src/qgpgmesecretkeyexportjob.cpp,
lang/qt/src/qgpgmesecretkeyexportjob.h,
lang/qt/src/qgpgmesignencryptjob.cpp,
lang/qt/src/qgpgmesignencryptjob.h,
lang/qt/src/qgpgmesignjob.cpp,
lang/qt/src/qgpgmesignjob.h,
lang/qt/src/qgpgmesignkeyjob.cpp,
lang/qt/src/qgpgmesignkeyjob.h,
lang/qt/src/qgpgmetofupolicyjob.cpp,
lang/qt/src/qgpgmetofupolicyjob.h,
lang/qt/src/qgpgmeverifydetachedjob.cpp,
lang/qt/src/qgpgmeverifydetachedjob.h,
lang/qt/src/qgpgmeverifyopaquejob.cpp,
lang/qt/src/qgpgmeverifyopaquejob.h,
lang/qt/src/qgpgmewkspublishjob.cpp,
lang/qt/src/qgpgmewkspublishjob.h,
lang/qt/src/refreshkeysjob.h,
lang/qt/src/signencryptjob.h,
lang/qt/src/signjob.h,
lang/qt/src/signkeyjob.h,
lang/qt/src/specialjob.h,
lang/qt/src/threadedjobmixin.cpp,
lang/qt/src/threadedjobmixin.h,
lang/qt/src/tofupolicyjob.h,
lang/qt/src/verifydetachedjob.h,
lang/qt/src/verifyopaquejob.h,
lang/qt/src/wkspublishjob.h,
lang/qt/tests/run-keyformailboxjob.cpp,
lang/qt/tests/t-config.cpp,
lang/qt/tests/t-encrypt.cpp,
lang/qt/tests/t-keylist.cpp,
lang/qt/tests/t-keylocate.cpp,
lang/qt/tests/t-ownertrust.cpp,
lang/qt/tests/t-support.cpp,
lang/qt/tests/t-support.h,
lang/qt/tests/t-tofuinfo.cpp,
lang/qt/tests/t-various.cpp,
lang/qt/tests/t-verify.cpp,
lang/qt/tests/t-wkspublish.cpp,
tests/gpg/t-encrypt-mixed.c,
tests/gpg/t-thread-keylist-verify.c,
tests/gpg/t-thread-keylist.c,
tests/run-decrypt.c: Change Intevation GmbH copyright to BSI.

--
This should make it more transparent where the BSI is the actual
copyright holder as the code was mostly developed as part of a
development contract.

23 months agodoc: Improve doc on passphrase_cb / pinentry mode
Andre Heinecke [Mon, 24 Apr 2017 14:46:09 +0000 (16:46 +0200)]
doc: Improve doc on passphrase_cb / pinentry mode

* doc/gpgme.texi (Passphrase Callback): Mention pinentry_mode and
restrictions.
(Pinentry Mode): Fix wording and clarify versions that need
loopback mode for passphrase_cb to work.

23 months agotests: Update encrypted sample files.
Justus Winter [Mon, 24 Apr 2017 13:29:07 +0000 (15:29 +0200)]
tests: Update encrypted sample files.

* tests/gpg/cipher-1.asc: Update file.
* tests/gpg/cipher-2.asc: Likewise.
--
Convert the plaintext to UTF-8 and re-create the encrypted file.

Fixes-commit: a11450eb048df79a3f2b00ebef6d7cab07ad5054
Signed-off-by: Justus Winter <justus@g10code.com>
2 years agopython: Skip TOFU test if not supported by GnuPG.
Justus Winter [Tue, 11 Apr 2017 10:07:59 +0000 (12:07 +0200)]
python: Skip TOFU test if not supported by GnuPG.

* lang/python/tests/support.py (have_tofu_support): New function.
* lang/python/tests/t-quick-key-manipulation.py: Skip TOFU test if not
supported by GnuPG.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agopython: use autoconf pre-processor when building via autoconf
Alon Bar-Lev [Tue, 11 Apr 2017 00:56:00 +0000 (03:56 +0300)]
python: use autoconf pre-processor when building via autoconf

* configure.ac: Add AC_PROG_CPP.
* lang/python/Makefile.am: Set CPP environment for setup.py to use.

Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
2 years agopython: fix run-tests missing python_libdir
Alon Bar-Lev [Mon, 10 Apr 2017 22:55:13 +0000 (01:55 +0300)]
python: fix run-tests missing python_libdir

* lang/python/tests/run-tests.py: Set python_libdir if --python-libdir
is set.

Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
2 years agopython: Prune CLEANFILES.
Justus Winter [Mon, 10 Apr 2017 13:24:03 +0000 (15:24 +0200)]
python: Prune CLEANFILES.

--
Fixes-commit: e7d9c0c3d773f826dbd2ed417d04e25c410f3374
Signed-off-by: Justus Winter <justus@g10code.com>
2 years agopython: Fix distcheck.
Justus Winter [Mon, 10 Apr 2017 13:20:34 +0000 (15:20 +0200)]
python: Fix distcheck.

* lang/python/Makefile.am (uninstall-local): Explicitly request the
scheme 'posix_prefix'.  On Python2.7 the default scheme is
'posix_local', breaking distcheck.

Fixes-commit: 25e6444b3f4601c7821beab06bc4520deacb007b
Signed-off-by: Justus Winter <justus@g10code.com>
2 years agopython: Support alternatate libdir for tests
Alon Bar-Lev [Sat, 8 Apr 2017 13:34:33 +0000 (16:34 +0300)]
python: Support alternatate libdir for tests

* lang/python/tests/run-tests.py: Add --python-libdir optional
parameter.

--

This will make the python tests usable for downstream that build python
module outside of autotools build system.

Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
2 years agopython: Read gpg-error.h using the pre-processor
Alon Bar-Lev [Sat, 8 Apr 2017 13:34:32 +0000 (16:34 +0300)]
python: Read gpg-error.h using the pre-processor

* lang/python/setup.py.in: Read gpg-error.h using the pre-processor.

--

The libgpg-error may be installed in multilib configuration in which
there is a wrapper header at /usr/include that includes the actual
header at /usr/include/*. This causes invalid errors.i generation.

Let the pre-processor extract the header content instead reading it
explicitly.

Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
2 years agopython: Remove unneeded stats copy
Alon Bar-Lev [Sat, 8 Apr 2017 13:34:31 +0000 (16:34 +0300)]
python: Remove unneeded stats copy

* lang/python/setup.py.in: errors.i, gpgme.h are generated and always
newer than the original.

Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
2 years agopython: Remove usage of PYTHON_VERSIONS
Alon Bar-Lev [Sat, 8 Apr 2017 13:34:30 +0000 (16:34 +0300)]
python: Remove usage of PYTHON_VERSIONS

* configure.ac: Remove PYTHON_VERSIONS subst.
* lang/python/Makefile.am: Use basename of python as builddir prefix.
* lang/python/tests/run-tests.py: Likewise.

--

Two variables needs be at sync PYTHONS and PYTHON_VERSIONS, these may go
out of sync in some cases, for example in Gentoo where default python is
3.4 we get:

PYTHON='/usr/bin/python2'
PYTHONS='/usr/bin/python /usr/bin/python2'
PYTHON_VERSIONS='2.7 3.4'

We can use the basename of the python interpreter to achieve similar
effect without having to sync indexes between these two variables.

Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
2 years agotests: Do not use check-local magic as dependency
Alon Bar-Lev [Fri, 7 Apr 2017 14:32:18 +0000 (17:32 +0300)]
tests: Do not use check-local magic as dependency

* tests/gpg/Makefile.am: Use BUILT_SOURCES instead of check-local
and initial.test.
* lang/qt/tests/Makefile.am: Ditto.

--

This fixes "make dist" failure when source tree is clean:
  git clean -dxf
  autoreconf -ivf
  ./configure
  make dist

BUILT_SOURCES should be used when file as generated without explicit
dependency. The check-local is all-am dependency, this means that it
will be resolved also in "make dist".

Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
2 years agopython: support .pydistutils.cfg mode
Alon Bar-Lev [Fri, 7 Apr 2017 14:31:47 +0000 (17:31 +0300)]
python: support .pydistutils.cfg mode

* lang/python/setup.py.in: Do not parse arguments.

--

The distutils settings can come from either command-line or
configuration file. Parsing parameters is not working in all cases.

Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
2 years agopython: simplify build, some fixups
Alon Bar-Lev [Wed, 5 Apr 2017 16:47:08 +0000 (19:47 +0300)]
python: simplify build, some fixups

* lang/python/gpg/version.py.in: Rename to lang/python/version.py.in.
configure.ac: Generate version.py.in in lang/python.
* lang/python/MANIFEST.in: Include version.py explicitly.
* lang/python/gpg: Rename to 'src'.
* lang/python/Makefile.am: Do not copy source files, do not use absolute
directories, support lib64 in uninstall, clean also dist directory, use
symlink for gpg src.
* lang/python/setup.py.in: Use builddir, copy sources into builddir,
copy version.py into module.
--

Simplify build to symlink the gpg sources into builddir instead of
copying. This requires handling of version.py as generated file.

In addition apply some cleanups: Drop the absolution pathes, clean the
dist directory as well, support lib64 for sitelib at uninstall.

Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
2 years agopython: Fix vpath builds, fix distcheck.
Justus Winter [Mon, 3 Apr 2017 13:44:14 +0000 (15:44 +0200)]
python: Fix vpath builds, fix distcheck.

* lang/python/gpgme-h-clean.py: Delete file.
* lang/python/MANIFEST.in: Adapt accordingly.
* lang/python/Makefile.am (EXTRA_DIST): Likewise.
(COPY_FILES_GPG): Bring variable back.
(copystamp): Copy files.
(clean-local): Delete copied files.
(install-exec-local): Do not create and install list of installed
files.
(uninstall-local): Instead, create some explicit rules to uninstall
the extension.
* lang/python/setup.py.in: Parse arguments.  Locate files either in
the source directory, or in the build base directory.  Inline the code
from 'gpgme-h-clean.py'.  Copy 'helpers.c', add source directory as
include directory.

Fixes-commit: 801d7d8c5dd530d26ad6c4bcc94d986e6e022da4
Signed-off-by: Justus Winter <justus@g10code.com>
2 years agopython: Generate files into build directory
Alon Bar-Lev [Sat, 1 Apr 2017 23:29:52 +0000 (02:29 +0300)]
python: Generate files into build directory

* lang/python/setup.py.in: Generate files within BuildExtFirstHack
adjust build flags at this point instead of global.
* lang/python/Makefile.am: Remove logic of separate source directory per
python version in favor of build directory.
* lang/python/tests/run-tests.py: Adjust build directory location.
--

Generate files into build directory, leaving the source directory clean.
Use the same source directory for multiple python version build. Result
of 'prepare' target is a standard distutil layout that can be used
easily by downstream to build all python targets in-place.

Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
2 years agoFix typo.
Justus Winter [Wed, 5 Apr 2017 12:48:04 +0000 (14:48 +0200)]
Fix typo.

--
Signed-off-by: Justus Winter <justus@g10code.com>
2 years agoFreeBSD's closefrom(2) does not return errors
Pietro Cerutti [Mon, 3 Apr 2017 08:31:40 +0000 (08:31 +0000)]
FreeBSD's closefrom(2) does not return errors

2 years agoqt: pass fmt to gpgrt_asprintf()
Igor Gnatenko [Wed, 29 Mar 2017 05:20:51 +0000 (07:20 +0200)]
qt: pass fmt to gpgrt_asprintf()

* lang/qt/src/dn.cpp (parse_dn_part): Add fmt argument instead of
using name directly.

GnuPG-Bug-Id: 3023
Signed-off-by: Igor Gnatenko <ignatenkobrain@fedoraproject.org>
Signed-off-by: Andre Heinecke <aheinecke@intevation.de>
2 years agopython: Don't treat skipped tests as error
Andre Heinecke [Thu, 30 Mar 2017 14:22:20 +0000 (16:22 +0200)]
python: Don't treat skipped tests as error

* lang/python/tests/run-tests.py (failed): Don't count skipped tests
for the return code.

2 years agopython: Fix skipping tests if running with GnuPG < 2.1.12.
Justus Winter [Thu, 30 Mar 2017 12:58:29 +0000 (14:58 +0200)]
python: Fix skipping tests if running with GnuPG < 2.1.12.

* final.py: Import 'support.py' for the side-effect of checking the
GnuPG version.
* t-data.py: Likewise.
* t-protocol-assuan.py: Likewise.
* t-wrapper.py: Likewise.
* t-callbacks.py: Avoid warning about 'support' being unused.
* t-edit.py: Likewise.
* t-encrypt-sym.py: Likewise.
* t-file-name.py: Likewise.
* t-idiomatic.py: Likewise.
* t-sig-notation.py: Likewise.
* t-trustlist.py: Likewise.
* t-verify.py: Likewise.
* t-wait.py: Likewise.
* t-keylist-from-data.py: Trim unused imports.

GnuPG-bug-id: 3008
Fixes-commit: 348da58fe0c3656e6177c98fef6b4c4331326c8e
Signed-off-by: Justus Winter <justus@g10code.com>
2 years agoqt: Handle if gpg does not support tofu in test
Andre Heinecke [Thu, 30 Mar 2017 12:36:49 +0000 (14:36 +0200)]
qt: Handle if gpg does not support tofu in test

* lang/qt/src/t-tofuinfo.cpp (TestTofuInfo::testSupported): Treat
it as unsupported if secret keylisting already fails.

--
The likely cause of this is that the agent can't be started
because the trust model is unsupported. Other tests check
that keylisting actually works.

2 years agopython,build: Reinstate prepare target.
Alon Bar-Lev [Tue, 28 Mar 2017 18:55:59 +0000 (21:55 +0300)]
python,build: Reinstate prepare target.

* lang/python/Makefile.am: Fix 'prepare' target.
* lang/python/setup.py.in: Use 'abs_top_builddir' instead of guessing
the path.
--

'prepare' will prepare target at PREPAREDIR.  The automake integration
will also make use of prepare target.  Downstream distributors may
also make use of prepare target.

Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
2 years agotests: Run the threading tests only on UNIX.
Justus Winter [Tue, 28 Mar 2017 14:32:09 +0000 (16:32 +0200)]
tests: Run the threading tests only on UNIX.

* tests/gpg/Makefile.am (tests_unix): Add 't-thread-keylist' and
't-thread-keylist-verify'.
(c_tests): Drop them here.
--

The tests use pthreads and we suspect problems with MinGW's wrappers.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agotests: Make error message more helpful.
Justus Winter [Tue, 28 Mar 2017 14:30:03 +0000 (16:30 +0200)]
tests: Make error message more helpful.

* tests/gpg/t-keylist.c (main): Print number of returned and expected
keys.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agoMerge branch 'gpgme-1.9-branch'
Werner Koch [Tue, 28 Mar 2017 14:49:42 +0000 (16:49 +0200)]
Merge branch 'gpgme-1.9-branch'

--

2 years agoPost release updates gpgme-1.9-branch
Werner Koch [Tue, 28 Mar 2017 14:38:06 +0000 (16:38 +0200)]
Post release updates

--

2 years agoRelease 1.9.0 gpgme-1.9.0
Werner Koch [Tue, 28 Mar 2017 14:21:37 +0000 (16:21 +0200)]
Release 1.9.0

* configure.ac <c>: Bump LT version to C29/A18/R0.
<cpp>: Bump LT version to C10/A4/R0.
<qt>: Bump LT version to C9/A2/R0.
--

Signed-off-by: Werner Koch <wk@gnupg.org>
2 years agoRevert "qt: Disable testEncryptDecryptNowrap"
Andre Heinecke [Tue, 28 Mar 2017 10:34:28 +0000 (12:34 +0200)]
Revert "qt: Disable testEncryptDecryptNowrap"

This reverts commit 57d60b20f16dd5f1bccbbcaa0a6ed75a554a6414.

2 years agocore: Prepare for new key listing data send by gpg.
Werner Koch [Tue, 28 Mar 2017 09:40:44 +0000 (11:40 +0200)]
core: Prepare for new key listing data send by gpg.

* src/gpgme.h.in (gpgme_user_id_t): New fields 'origin' and
'last_update'.
(gpgme_key_t): New fields 'origin' and 'last_update'.
* src/conversion.c (_gpgme_parse_timestamp_ul): New.
* src/keylist.c (keylist_colon_handler): Parse fields 19 and 20.

* tests/run-keylist.c (main): Print new fields.

Signed-off-by: Werner Koch <wk@gnupg.org>
2 years agoqt: Disable testEncryptDecryptNowrap
Andre Heinecke [Mon, 27 Mar 2017 16:08:45 +0000 (18:08 +0200)]
qt: Disable testEncryptDecryptNowrap

* lang/qt/tests/t-encrypt.cpp (EncryptTest::testEncryptDecryptNowrap):
Disable test.

--
This test produces failures under CI/ASAN conditions as the
verify after the unwrap returns an error. As we currently
don't have time to look into this more it's disabled for now.
Similar to the testMixedEncryptDecrypt.

2 years agopython: Skip tests if running with GnuPG < 2.1.12.
Justus Winter [Mon, 27 Mar 2017 09:11:47 +0000 (11:11 +0200)]
python: Skip tests if running with GnuPG < 2.1.12.

* lang/python/tests/support.py (assert_gpg_version): Fix error
message.  Skip all tests when we use GnuPG older than 2.1.12.

GnuPG-bug-id: 3008
Signed-off-by: Justus Winter <justus@g10code.com>
2 years agoMention new cpp changes in the NEWS
Andre Heinecke [Fri, 24 Mar 2017 16:25:26 +0000 (17:25 +0100)]
Mention new cpp changes in the NEWS

--
Somone that calls a function startCombinedDecryptionAndVerification
should be required to always type it without autocompletion.

2 years agocpp: Respect decrypt flags in new functions
Andre Heinecke [Fri, 24 Mar 2017 16:24:04 +0000 (17:24 +0100)]
cpp: Respect decrypt flags in new functions

* lang/cpp/src/context.cpp: Respect directly provided flags
in the new decrypt functions.

--
Overlooked in the initial commit. Also fixed the according
unused variable warnings.

2 years agoqt: Add unittest for decrypt unwrap
Andre Heinecke [Fri, 24 Mar 2017 15:58:58 +0000 (16:58 +0100)]
qt: Add unittest for decrypt unwrap

* lang/qt/tests/t-encrypt.cpp
(EncryptTest::testEncryptDecryptNowrap): New.

2 years agocpp: Use gpgme_op_decrypt_ex and add new flags.
Andre Heinecke [Fri, 24 Mar 2017 15:51:26 +0000 (16:51 +0100)]
cpp: Use gpgme_op_decrypt_ex and add new flags.

* lang/cpp/src/context.cpp: New decrypt and decryptVerify functions
that take flags as arguments. Use new variants in old functions.
(Context::setDecryptionFlags): New helper.
(Context::Private::Private): Initialize new member.
* lang/cpp/src/context_p.h (Context::Private::decryptFlags): New.
* lang/cpp/src/context.h (Context::DecryptFlags): New enum.
(Context::EncryptionFlags): Extend for EncryptWrap.

--
The setDecryptionFlags provides a generic way to set decryption
flags for the whole context. This allows existing code to just
keep using the old functions and modify the decryption behavior
in a central place.

2 years agocore: New flags GPGME_DECRYPT_UNWRAP and GPGME_ENCRYPT_WRAP.
Werner Koch [Fri, 24 Mar 2017 13:36:54 +0000 (14:36 +0100)]
core: New flags GPGME_DECRYPT_UNWRAP and GPGME_ENCRYPT_WRAP.

* src/gpgme.h.in (GPGME_ENCRYPT_WRAP): New const.
(gpgme_decrypt_flags_t): New enum.
(GPGME_DECRYPT_VERIFY): New const
(GPGME_DECRYPT_UNWRAP): New const
(gpgme_op_decrypt_ext_start): New func.
(gpgme_op_decrypt_ext): New func.
* src/decrypt-verify.c (gpgme_op_decrypt_ext_start): New.
(gpgme_op_decrypt_ext): New.
(decrypt_verify_start): Add arg FLAGS.  Replace call to
engine_op_decrypt_verify by the plain decrypt with the flag set.
(gpgme_op_decrypt_verify_start): Pass the flag.
(gpgme_op_decrypt_verify): Pass the flag.
* src/decrypt.c (decrypt_start): Rename to ...
(_gpgme_decrypt_start): this.  Add arg FLAGS.  Pass FLAGS to
engine_op_decrypt.
(gpgme_op_decrypt_start): Adjust for chnage pass 0 for FLAG.
(gpgme_op_decrypt_start): Ditto.
* src/engine.c (_gpgme_engine_op_decrypt_verify): Remove.
(_gpgme_engine_op_decrypt): Add arg FLAGS.
* src/gpgme.def, src/libgpgme.vers: Add new functions.
* src/engine-backend.h (struct engine_ops): Remove member
'decrypt_verify'.  Add FLAGS to 'decrypt'.  Adjust all initialization.
* src/engine-uiserver.c (uiserver_decrypt): Remove.
(uiserver_decrypt_verify): Remove.
(_uiserver_decrypt): Rename to ...
(uiserver_decrypt): this.  Replace arg VERIFY by new arg FLAGS.
* src/engine-gpg.c (gpg_decrypt): Support GPGME_DECRYPT_UNWRAP.
(gpg_encrypt): Support GPGME_ENCRYPT_WRAP.

* tests/run-decrypt.c (main): New option --unwrap.
* tests/run-encrypt.c (main): New option --wrap.
--

Manual testing of that wrap/unwrap feature can be done this way:

 ./run-encrypt --verbose --key Alice /etc/motd > x
 ./run-decrypt --verbose --unwrap x > y
 ./run-encrypt --verbose --key Bob --wrap y > z

1. The message was first encrypted to Alice.
2. Alice decrypts the message receiving a valid OpenPGP message.
3. Alice encrypt that message to Bob

This will also work with encrypted and signed messages; the signature
will be kept intact during re-encryption.  Requires GnuPG 2.1.12.

Signed-off-by: Werner Koch <wk@gnupg.org>
2 years agoqt: Add test for Data::toKeys
Andre Heinecke [Wed, 22 Mar 2017 15:41:04 +0000 (16:41 +0100)]
qt: Add test for Data::toKeys

* lang/qt/tests/t-various.cpp (TestVarious::testKeyFromFile): New.

2 years agocpp: Wrap keylist_from_data
Andre Heinecke [Wed, 22 Mar 2017 15:38:35 +0000 (16:38 +0100)]
cpp: Wrap keylist_from_data

* lang/cpp/data.h, lang/cpp/data.cpp (GpgME::Data::toKeys): New.

--
Doing this in data instead of Context is a bit more idiomatic. But
this could also be added to Context.

2 years agoqt: Initialize library first in tests
Andre Heinecke [Wed, 22 Mar 2017 15:34:29 +0000 (16:34 +0100)]
qt: Initialize library first in tests

* lang/qt/tests/t-support.cpp (QGpgMETest::initTestCase): Initialize
library.

2 years agopython: Improve Python detection.
Justus Winter [Wed, 22 Mar 2017 14:33:06 +0000 (15:33 +0100)]
python: Improve Python detection.

* m4/python.m4 (_AM_PYTHON_INTERPRETER_LIST): Prefer the generic
'pythonX' over 'pythonX.Y'.  This way we select the users preferred
version for both flavors.  Prefer 'python' over 'python3' but not over
'python2' so that the algorithm still finds a 'python2' even if
'python' is a Python3.

Fixes-commit: 5189c08af9468cdeb6f16a6ecd0fee53e1e3aa0e
Signed-off-by: Justus Winter <justus@g10code.com>
2 years agocore: New API gpgme_op_set_uid_flag.
Werner Koch [Tue, 21 Mar 2017 18:02:20 +0000 (19:02 +0100)]
core: New API gpgme_op_set_uid_flag.

* src/gpgme.h.in (gpgme_op_set_uid_flag_start): New.
(gpgme_op_set_uid_flag_start): New.
* src/gpgme.def, src/libgpgme.vers: Add them.
* src/genkey.c (addrevuid_start): Change arg revoke to a flag.
(gpgme_op_revuid_start): Pass GENKEY_EXTRAFLAG_REVOKE for the fomer
revoke parameter.
(gpgme_op_revuid): Ditto.
(set_uid_flag): New.
(gpgme_op_set_uid_flag_start): New.
(gpgme_op_set_uid_flag): New.
* src/engine.h (GENKEY_EXTRAFLAG_SETPRIMARY): new.
* src/engine-gpg.c (gpg_adduid): Implement that flag.

* tests/run-genkey.c (main): New command --set-primary.
--

GnuPG-bug-id: 2931
Signed-off-by: Werner Koch <wk@gnupg.org>
2 years agopython: Wrap 'gpgme_op_keylist_from_data_start'.
Justus Winter [Tue, 21 Mar 2017 11:32:31 +0000 (12:32 +0100)]
python: Wrap 'gpgme_op_keylist_from_data_start'.

* NEWS: Update.
* lang/python/gpg/core.py (Context.keylist): New keyword argument
'source'.  If given, list keys from 'source'.
* lang/python/gpgme.i: Wrap the argument to
'gpgme_op_keylist_from_data_start'.
* lang/python/tests/Makefile.am (py_tests): Add new test.
* lang/python/tests/support.py (EphemeralContext): Do not throw an
error if no agent has been started in the context.
* lang/python/tests/t-keylist-from-data.py: New file.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agocore: Extend gpgme_get_dirinfo to return the gpg-wks-client name.
Werner Koch [Tue, 21 Mar 2017 10:16:16 +0000 (11:16 +0100)]
core: Extend gpgme_get_dirinfo to return the gpg-wks-client name.

* src/dirinfo.c (WANT_GPG_WKS_CLIENT_NAME): New const.
(struct dirinfo): New field 'gpg_wks_client_name'.
(get_gpgconf_item): Build it on demand.
(gpgme_get_dirinfo): New value "gpg-wks-client-name" for WHAT.

Signed-off-by: Werner Koch <wk@gnupg.org>
2 years agocore: New encryption flag GPGME_ENCRYPT_THROW_KEYIDS.
Werner Koch [Tue, 21 Mar 2017 09:39:33 +0000 (10:39 +0100)]
core: New encryption flag GPGME_ENCRYPT_THROW_KEYIDS.

* src/gpgme.h.in (GPGME_ENCRYPT_THROW_KEYIDS): New flag.
* src/engine-gpg.c (gpg_encrypt): Implement flag
(gpg_encrypt_sign): Implement flag.

* tests/run-encrypt.c (main): New option --throw-keyids.
--

It would be nice to also selectively hide recipients (that is gpg
--hidden-recipient) but our API does not ye allow this because it is
based on key objects.  A possible way to implement that would be a API
to set processing flags into a key but this is complicated due to the
reference counting and thus the possibility that a key object is used
by different context.

Signed-off-by: Werner Koch <wk@gnupg.org>
2 years agocore: New public API gpgme_op_keylist_from_data_start.
Andre Heinecke [Tue, 21 Mar 2017 08:38:11 +0000 (09:38 +0100)]
core: New public API gpgme_op_keylist_from_data_start.

* src/gpgme.h.in: New API gpgme_op_keylist_from_data_start.
* src/libgpgme.vers, src/gpgme.def: Add it.
* src/keylist.c (gpgme_op_keylist_from_data_start): New.
* src/engine-backend.h (engine_ops): Add field 'keylist_data'.  Change
all engines to pass NULL for it.
* src/engine.c (_gpgme_engine_op_keylist_data): New.
* src/engine-gpg.c (gpg_keylist_data): New.
(_gpgme_engine_ops_gpg): Register gpg_keylist_data.

* tests/run-keylist.c (main): New option --from-file.
--

Co-authored-by: Werner Koch <wk@gnupg.org>
GnuPG-bug-id: 2819

2 years agocore,cpp: New key flag 'is_de_vs'.
Werner Koch [Mon, 20 Mar 2017 18:56:10 +0000 (19:56 +0100)]
core,cpp: New key flag 'is_de_vs'.

* src/gpgme.h.in (_gpgme_subkey): New flag is_de_vs.
* tests/run-keylist.c (main): Print that flag.
* src/keylist.c (parse_pub_field18): New.
(keylist_colon_handler): Parse compliance flags.
* lang/cpp/src/key.cpp (Key::isDeVs): New.
(Subkey::isDeVs): New.

* lang/cpp/src/key.h (class Key): New method isDeVs.
(class Subkey): New method isDeVs.

Signed-off-by: Werner Koch <wk@gnupg.org>
2 years agotests: Fix distcheck.
Justus Winter [Mon, 20 Mar 2017 16:07:31 +0000 (17:07 +0100)]
tests: Fix distcheck.

* tests/start-stop-agent: Do not create 'gpg-agent.conf' if it does
not exist.

Fixes-commit: 16b202d9999591b71fb8bb49f6db10ef96d4cbe8
Signed-off-by: Justus Winter <justus@g10code.com>
2 years agopython: Fix version check.
Justus Winter [Mon, 20 Mar 2017 15:53:29 +0000 (16:53 +0100)]
python: Fix version check.

* lang/python/tests/support.py (assert_gpg_version): Cope with
non-released versions.

Fixes-commit: e1cf8bab319ba1dea41ba5d711dbb66ffd8e6fd6
Signed-off-by: Justus Winter <justus@g10code.com>
2 years agotests: Use 'gpg-agent --allow-loopback-pinentry' if applicable.
Justus Winter [Mon, 20 Mar 2017 15:36:27 +0000 (16:36 +0100)]
tests: Use 'gpg-agent --allow-loopback-pinentry' if applicable.

* lang/python/tests/Makefile.am (gpg-agent.conf): Do not hard-code the
option.  This breaks gpg-agent from GnuPG 2.0.
* tests/start-stop-agent: Rather, check if the option is supported and
add it to the configuration if it is.

GnuPG-bug-id: 3008
Fixes-commit: bbf19124bbec9eb6298cef2914baae7ac74382fe
Signed-off-by: Justus Winter <justus@g10code.com>
2 years agopython: Skip tests if GnuPG is too old.
Justus Winter [Mon, 20 Mar 2017 15:00:13 +0000 (16:00 +0100)]
python: Skip tests if GnuPG is too old.

* lang/python/tests/support.py (assert_gpg_version): New function.
* lang/python/tests/t-callbacks.py: Use the new function to skip the
test if GnuPG is too old.
* lang/python/tests/t-edit.py: Likewise.
* lang/python/tests/t-encrypt-sym.py: Likewise.
* lang/python/tests/t-quick-key-creation.py: Likewise.
* lang/python/tests/t-quick-key-manipulation.py: Likewise.
* lang/python/tests/t-quick-key-signing.py: Likewise.

GnuPG-bug-id: 3008
Signed-off-by: Justus Winter <justus@g10code.com>
2 years agopython: Remove superfluous initialization.
Justus Winter [Mon, 20 Mar 2017 15:07:07 +0000 (16:07 +0100)]
python: Remove superfluous initialization.

* lang/python/tests/support.py (init_gpgme): Remove.  This is an
remnant from the c tests.  Nowadays, the Python bindings initialize
GPGME automagically.
* lang/python/tests/initial.py: Remove call to 'support.init_gpgme'.
* lang/python/tests/t-callbacks.py: Likewise.
* lang/python/tests/t-decrypt-verify.py: Likewise.
* lang/python/tests/t-decrypt.py: Likewise.
* lang/python/tests/t-edit.py: Likewise.
* lang/python/tests/t-encrypt-large.py: Likewise.
* lang/python/tests/t-encrypt-sign.py: Likewise.
* lang/python/tests/t-encrypt-sym.py: Likewise.
* lang/python/tests/t-encrypt.py: Likewise.
* lang/python/tests/t-export.py: Likewise.
* lang/python/tests/t-file-name.py: Likewise.
* lang/python/tests/t-idiomatic.py: Likewise.
* lang/python/tests/t-import.py: Likewise.
* lang/python/tests/t-keylist.py: Likewise.
* lang/python/tests/t-sig-notation.py: Likewise.
* lang/python/tests/t-sign.py: Likewise.
* lang/python/tests/t-signers.py: Likewise.
* lang/python/tests/t-trustlist.py: Likewise.
* lang/python/tests/t-verify.py: Likewise.
* lang/python/tests/t-wait.py: Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agopython: Make error message more helpful.
Justus Winter [Tue, 14 Mar 2017 10:10:21 +0000 (11:10 +0100)]
python: Make error message more helpful.

* lang/python/tests/run-tests.py: Make the error message shown when we
cannot locate the python module in the build tree more helpful.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agopython: Make tests more robust.
Justus Winter [Tue, 14 Mar 2017 10:08:08 +0000 (11:08 +0100)]
python: Make tests more robust.

* lang/python/tests/support.py (TemporaryDirectory): Always use our
own version even if 'tempfile.TemporaryDirectory' is provided, because
we need to use 'shutil.rmtree(..., ignore_errors=True)' to avoid it
tripping over gpg-agent deleting its own sockets.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agopython: Improve build system integration.
Justus Winter [Tue, 14 Mar 2017 10:22:28 +0000 (11:22 +0100)]
python: Improve build system integration.

* lang/python/Makefile.am: Use 'set -e' when chaining shell commands
together in rules.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agobuild: Improve Python detection.
Justus Winter [Mon, 13 Mar 2017 14:37:15 +0000 (15:37 +0100)]
build: Improve Python detection.

* configure.ac: Do not error out too early if we don't find a matching
Python version.  We handle this case later.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agobuild: Tune M4 macros for our needs.
Justus Winter [Thu, 9 Mar 2017 15:55:18 +0000 (16:55 +0100)]
build: Tune M4 macros for our needs.

* m4/ax_python_devel.m4: Do not emit 'HAVE_PYTHON'.
* m4/python.m4 (_AM_PYTHON_INTERPRETER_LIST): Add newer Python
versions, drop older ones.  Also, sort the list with older versions at
the front, newer and generic versions towards the end.  This makes the
algorithm pick the lowest version that meets the version requirement.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agobuild: Add M4 macros for python.
Justus Winter [Thu, 9 Mar 2017 15:54:35 +0000 (16:54 +0100)]
build: Add M4 macros for python.

* m4/python.m4: New file.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agoqt: Add test for DN parser
Andre Heinecke [Mon, 13 Mar 2017 10:16:41 +0000 (11:16 +0100)]
qt: Add test for DN parser

* qt/tests/t-various.cpp (testDN): New.

--
A simple test for the DN parser that would have caught
the new / free mismatch fixed in 9d5048d4.

2 years agoqt: Use gpgrt_asprintf instead of qstrdup
Andre Heinecke [Mon, 13 Mar 2017 10:14:54 +0000 (11:14 +0100)]
qt: Use gpgrt_asprintf instead of qstrdup

* lang/qt/src/dn.cpp (parse_dn_part): Use gpgrt_asprintf instead
of qstrdup.

--
This fixes a new / free mismatch because qstrdup uses new and
the allocated parts are freed with free. Similar to: a09ed3f2

2 years agocore: Fix status error return for gpgsm.
Werner Koch [Thu, 9 Mar 2017 10:45:00 +0000 (11:45 +0100)]
core: Fix status error return for gpgsm.

* src/engine-gpgsm.c (gpgsm_assuan_simple_command): Make sure CB_ERR
is returned.
* src/import.c (parse_import_res): Do not return an error for the last
field.
(import_status_handler): Actually return the error from
parse_import_res.

Signed-off-by: Werner Koch <wk@gnupg.org>
2 years agopython: Print path of the Python module used during tests.
Justus Winter [Thu, 2 Mar 2017 15:06:29 +0000 (16:06 +0100)]
python: Print path of the Python module used during tests.

* lang/python/tests/initial.py: Print path of the Python module used
during tests.  Useful to detect if by any mistake the wrong module is
picked up.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agocore: Fix minor code style thing.
Werner Koch [Thu, 2 Mar 2017 13:52:52 +0000 (14:52 +0100)]
core: Fix minor code style thing.

* src/engine-gpg.c (gpg_add_algo_usage_expire): Use double parenthesis
for bit tests.

Signed-off-by: Werner Koch <wk@gnupg.org>
2 years agoRevert "core: Fix error types."
Werner Koch [Thu, 2 Mar 2017 13:47:51 +0000 (14:47 +0100)]
Revert "core: Fix error types."

--
This reverts commit 6df6e01ed5a581765d245bf7303cda4497d0eb22.

gpgme_error_t et al are from a time where we had no hard dependency on
libgpg-error.  Now libgpg-error is a required and thus it does not
make sense to have these surrogates.  In fact we should ventually
completely remove them.

Signed-off-by: Werner Koch <wk@gnupg.org>
2 years agocpp: Add subkey keygrip to API
Andre Heinecke [Thu, 2 Mar 2017 08:35:05 +0000 (09:35 +0100)]
cpp: Add subkey keygrip to API

* lang/cpp/src/key.cpp (Subkey::keyGrip): New.
* lang/cpp/src/key.h: Update accordingly.

2 years agocpp: Add interactor to generate keys on smartcard
Andre Heinecke [Wed, 1 Mar 2017 10:17:27 +0000 (11:17 +0100)]
cpp: Add interactor to generate keys on smartcard

* lang/cpp/src/editinteractor.cpp (EditInteractor::needsNoResponse):
Handle new states.
* lang/cpp/src/gpggencardkeyinteractor.cpp,
lang/cpp/src/gpggencardkeyinteractor.h: New.
* lang/cpp/src/Makefile.am: Update accordingly.

2 years agoqt: Allow creation of default keys without name
Andre Heinecke [Wed, 1 Mar 2017 10:14:07 +0000 (11:14 +0100)]
qt: Allow creation of default keys without name

* lang/qt/src/defaultkeygenerationjob.cpp
(DefaultKeyGenerationJob::start): Handle empty name and email.

2 years agodoc: Correct documentation for recp arg of gpgme_op_encrypt_sign_start
Daniel Kahn Gillmor [Sat, 25 Feb 2017 21:08:11 +0000 (16:08 -0500)]
doc: Correct documentation for recp arg of gpgme_op_encrypt_sign_start

* doc/gpgme.texi (gpgme_op_encrypt_sign_start): recp is an array of
gpgme_key_t, not a single element.

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
2 years agopython: Fix test.
Justus Winter [Mon, 20 Feb 2017 09:23:41 +0000 (10:23 +0100)]
python: Fix test.

* lang/python/tests/t-quick-key-manipulation.py: Modify the
configuration file in the ephemeral home directory, not the one used
by all the tests.

Fixes-commit: 15fbac9e72a4d1bff9a3b9e9822f9175b09fbcd5
Signed-off-by: Justus Winter <justus@g10code.com>
2 years agopython: Support manipulating the TOFU policy.
Justus Winter [Fri, 17 Feb 2017 16:07:05 +0000 (17:07 +0100)]
python: Support manipulating the TOFU policy.

* NEWS: Update.
* doc/gpgme.texi: Fix typos.
* lang/python/gpg/constants/__init__.py: Import new files.
* lang/python/gpg/constants/tofu/__init__.py: New file.
* lang/python/gpg/constants/tofu/policy.py: New file.
* lang/python/gpg/core.py (Context.key_tofu_policy): New function.
* lang/python/gpgme.i: Nice reprs for gpgme_tofu_info_t.
* lang/python/setup.py.in: Install new package.
* lang/python/tests/t-quick-key-manipulation.py: Extend test.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agopython: Support quick key signing.
Justus Winter [Fri, 17 Feb 2017 14:44:35 +0000 (15:44 +0100)]
python: Support quick key signing.

* NEWS: Update.
* doc/gpgme.texi (gpgme_op_keysign): Fix the description of the
'expire' argument.
* lang/python/gpg/constants/__init__.py: Import new file.
* lang/python/gpg/constants/keysign.py: New file.
* lang/python/gpg/core.py (Context.key_sign): New function.
* lang/python/tests/Makefile.am (py_tests): Add new test.
* lang/python/tests/t-quick-key-signing.py: New test.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agopython: Fix teardown of ephemeral contexts.
Justus Winter [Fri, 17 Feb 2017 11:18:56 +0000 (12:18 +0100)]
python: Fix teardown of ephemeral contexts.

* lang/python/tests/support.py (EphemeralContext): New function.
* lang/python/tests/t-quick-key-creation.py: Use the new function to
manage ephemeral contexts.
* lang/python/tests/t-quick-key-manipulation.py: Likewise.
* lang/python/tests/t-quick-subkey-creation.py: Likewise.
--

Previously, there was a problem with cleaning up ephemeral home
directories.  shutil.rmtree deleted the agents main socket, gpg-agent
detected that, and deleted the other sockets as well, racing
shutil.rmtree which did not cope will with that.

Fix this by asking the agent nicely to shut down.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agopython: Fix using strings as commands in the assuan protocol.
Justus Winter [Fri, 17 Feb 2017 11:10:34 +0000 (12:10 +0100)]
python: Fix using strings as commands in the assuan protocol.

* lang/python/gpg/core.py (Context.assuan_transact): Fix testing
whether the command is a string on Python2.
* lang/python/tests/t-protocol-assuan.py: Improve the test to detect
this problem.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agopython: Support adding and revoking UIDs.
Justus Winter [Thu, 16 Feb 2017 16:52:49 +0000 (17:52 +0100)]
python: Support adding and revoking UIDs.

* NEWS: Update.
* lang/python/gpg/core.py (Context.key_add_uid): New function.
(Context.key_revoke_uid): Likewise.
* lang/python/tests/Makefile.am (XTESTS): Add new test.
* lang/python/tests/t-quick-key-manipulation.py: New file.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agopython: Support quick subkey creation.
Justus Winter [Thu, 16 Feb 2017 15:38:21 +0000 (16:38 +0100)]
python: Support quick subkey creation.

* NEWS: Update.
* lang/python/gpg/core.py (Context.create_subkey): New function.
* lang/python/tests/Makefile.am (XTESTS): Add new test.
* lang/python/tests/t-quick-subkey-creation.py: New file.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agopython: Support quick key creation.
Justus Winter [Thu, 16 Feb 2017 13:53:11 +0000 (14:53 +0100)]
python: Support quick key creation.

* NEWS: Update.
* lang/python/gpg/constants/__init__.py: Import new file.
* lang/python/gpg/constants/create.py: New file.
* lang/python/gpg/core.py (Context.create_key): New function.
* lang/python/tests/Makefile.am (XTESTS): Add new test.
* lang/python/tests/support.py (TemporaryDirectory): New class.
* lang/python/tests/t-quick-key-creation.py: New file.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agopython: Fix passphrase callback wrapping.
Justus Winter [Thu, 16 Feb 2017 13:49:27 +0000 (14:49 +0100)]
python: Fix passphrase callback wrapping.

* lang/python/helpers.c (pyPassphraseCb): Cope with 'passphrase_info'
being NULL.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agopython: Fix error handling.
Justus Winter [Thu, 16 Feb 2017 13:42:17 +0000 (14:42 +0100)]
python: Fix error handling.

* lang/python/gpgme.i (typemap gpgme_key_t[]): Set an error if a
non-key element is discovered.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agocore: Fix expiration time handling when creating keys.
Justus Winter [Wed, 15 Feb 2017 15:17:13 +0000 (16:17 +0100)]
core: Fix expiration time handling when creating keys.

* NEWS: Update.
* doc/gpgme.texi (gpgme_op_createkey): Clarify the meaning of the
'expire' parameter.
(GPGME_CREATE_NOEXPIRE): Document new flag.
(gpgme_op_createsubkey): Clarify the meaning of the 'expire'
parameter.
* src/engine-gpg.c (gpg_add_algo_usage_expire): Fix handling of the
expiration time.
* src/gpgme.h.in (GPGME_CREATE_NOEXPIRE): New macro.
--

Previously, the documentation stated that the expiration time was an
absolute timestamp.  However, this value was passed using the
'seconds=N' syntax to GnuPG which specifies the expiration time in
seconds relative to the creation time.  Fix the documentation.

Furthermore, the documentation stated that using 0 results in keys
that do not expire.  This was communicated to GnuPG by using the
implicit default.  However, as of GnuPG 2.1.17, the default was
changed to create keys that expire within a reasonable timespan.

Fix this discrepancy by aligning the behavior with recent GnuPG
versions: 0 means use a reasonable default, and introduce a flag that
can be used to create keys that do not expire.  Communicate this
explicitly to GnuPG.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agopython: Fix build system integration.
Justus Winter [Wed, 15 Feb 2017 10:31:27 +0000 (11:31 +0100)]
python: Fix build system integration.

* lang/python/Makefile.am (copystamp): Also copy the setup script, and
link the header files.
(all-local): Use local setup script.
(sdist): Fix Python source distribution creation.
(CLEANFILES): Remove now obsolete files.
(install-exec-local): Use local setup script.
* lang/python/setup.py.in: Adjust relative paths to in-tree files.

Fixes-commit: fe65a26ab584bd70fad45c7c4d44330e30a748a4
Signed-off-by: Justus Winter <justus@g10code.com>
2 years agopython: Update lists of functions returning gpgme_error_t.
Justus Winter [Wed, 15 Feb 2017 10:28:02 +0000 (11:28 +0100)]
python: Update lists of functions returning gpgme_error_t.

* lang/python/gpg/core.py (Context._errorcheck): Add instructions how
to update the list.  Update list.
(Data._errorcheck): Likewise.
(Context.set_engine_info): Simplify.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agocore: Fix error types.
Justus Winter [Wed, 15 Feb 2017 08:45:46 +0000 (09:45 +0100)]
core: Fix error types.

* NEWS: Update.
* src/data.c (gpgme_data_set_flag): Return a 'gpgme_error_t'.
* src/error.c (gpgme_strerror_r): Fix type of first argument.
* src/gpgme.h.in (gpgme_strerror_r): Adapt.
(gpgme_data_set_flag): Likewise.
--
Fix for consistency.  This should not pose problems, because typedef
gpg_error_t gpgme_error_t.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agopython: Wrap utility functions.
Justus Winter [Tue, 14 Feb 2017 15:30:30 +0000 (16:30 +0100)]
python: Wrap utility functions.

* NEWS: Update.
* lang/python/gpg/core.py (pubkey_algo_string): New function.
(pubkey_algo_name): Add docstring.
(hash_algo_name): Likewise.
(get_protocol_name): Likewise.
(addrspec_from_uid): New function.
* lang/python/gpgme.i (gpgme_pubkey_algo_string): Result must be
freed.
(gpgme_addrspec_from_uid): Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>