Commit Graph

371 Commits

Author SHA1 Message Date
NIIBE Yutaka
0d9d0a6b5b cleanup: Fix type mismatch around gpgme_error_t.
* src/data-compat.c (gpgme_error_to_errno): Use gpg_err_code
to get error code from gpgme_error_t.
* src/gpgme.c (gpgme_new): Don't use gpgme_error.
2015-10-16 09:51:42 +09:00
Werner Koch
f0ccce855b
gpgme-tool: Switch to argparse.c for option parsing.
* src/argparse.c, src/argparse.h: New. Taken from current gnupg.
* src/Makefile.am (gpgme_tool_SOURCES): New.
* src/gpgme-tool.c: Remove all argp.h stuff.
(my_strusage): New.
(main): Change to use argparse.
--

As a GnuPG related tool the user should get the same experience in
option parsing as with gpg et al.  Thus we use the same parser.

Signed-off-by: Werner Koch <wk@gnupg.org>
2015-08-31 20:34:00 +02:00
Werner Koch
c4b6b35bfa
Add gpgme_pubkey_algo_string
* src/gpgme.h.in (GPGME_PK_EDDSA): New.
(gpgme_pubkey_algo_string): New.
* src/conversion.c (_gpgme_map_pk_algo): Add new algo.
* src/gpgme.c (gpgme_pubkey_algo_string): New.
(gpgme_pubkey_algo_name): Reformat.

Signed-off-by: Werner Koch <wk@gnupg.org>
2015-08-30 19:04:44 +02:00
Werner Koch
c4f4b5c0a6
Make use of GPGRT macros is available.
* src/gpgme.h.in (_GPGME_INLINE): Define using GPGRT_INLINE if
possible.  Fix problem with -Wundef by adding an extra "defined()".
(_GPGME_GCC_VERSION): Define using GPGRT_ macro if possible.
2015-08-26 09:16:36 +02:00
Werner Koch
3f53d3d5d9
Avoid -Wundef warnings if gpgme.h is used by g++.
* src/gpgme.h.in (_GPGME_INLINE): Move definition into the
extern-C-scope.

Signed-off-by: Werner Koch <wk@gnupg.org>
2015-08-25 21:04:15 +02:00
Daiki Ueno
028a0ef333
Relax ttyname_r error checks
* src/engine-assuan.c (llass_new): Don't treat ttyname_r error as
fatal.
* src/engine-g13.c (g13_new): Likewise.
* src/engine-gpg.c (gpg_new): Likewise.
* src/engine-gpgsm.c (gpgsm_new): Likewise.
* src/engine-uiserver.c (uiserver_new): Likewise.

--
Even though isatty() returns 1, ttyname_r() may fail in many ways, e.g.,
when /dev/pts is not accessible under chroot.  Since all our uses of
ttyname_r() require that the function works, we can treat the failure as
if isatty() fails.

Signed-off-by: Daiki Ueno <ueno@gnu.org>
2015-08-25 19:11:30 +02:00
Werner Koch
97f1f3e883
Cleanup layout of gpgme.h
* src/gpgme.h.in: Reorder prototypes.  Chnage some comments.

Signed-off-by: Werner Koch <wk@gnupg.org>
2015-08-25 18:10:14 +02:00
Werner Koch
8ddc5801ad
Improve error return by checking the FAILURE status.
* src/gpgme.h.in (GPGME_STATUS_FAILURE): New.
* src/status-table.c (FAILURE): New.
* src/op-support.c (_gpgme_parse_failure): New.
* src/passphrase.c (_gpgme_passphrase_status_handler): Forward FAILURE
status line to the status callback.

* src/decrypt.c (op_data_t): Add field failure_code.
(_gpgme_decrypt_status_handler): Parse that code and act upon it on EOF.
* src/encrypt.c (op_data_t): Add field failure_code.
(_gpgme_encrypt_status_handler): Parse that code and act upon it on EOF.
* src/genkey.c (op_data_t): Add field failure_code.
(genkey_status_handler): Parse that code and act upon it on EOF.
* src/passwd.c (op_data_t): Add field failure_code.
(passwd_status_handler): Parse that code and act upon it on EOF.
* src/sign.c (op_data_t): Add field failure_code.
(_gpgme_sign_status_handler): Parse that code and act upon it on EOF.
* src/verify.c (op_data_t): Add field failure_code.
(_gpgme_verify_status_handler): Parse that code and act upon it on EOF.

--

This requires GnuPG 2.1.8 to actually make a difference.

Signed-off-by: Werner Koch <wk@gnupg.org>
2015-08-25 13:23:51 +02:00
Werner Koch
ad46f4f655
Call status_cb for an ERROR status seen in the passphrase handler.
* src/passphrase.c (_gpgme_passphrase_status_handler): Call status_cb.
--

Frankly, we should have a more generic way of feeding the status_cb
handler than our current ad-hoc method.

Signed-off-by: Werner Koch <wk@gnupg.org>
2015-08-24 21:17:21 +02:00
Werner Koch
a7dbab23ea
w32: Look for gpgconf in the new GnuPG 2.1 install dir.
* src/w32-util.c (_gpgme_get_gpgconf_path): Try another location of
gpgconf.exe.

Signed-off-by: Werner Koch <wk@gnupg.org>
2015-08-24 19:59:43 +02:00
Werner Koch
06d6fd8ca0
w32: Expect gpgme-w32spawn.exe only in the gpgme installation dir.
* src/w32-util.c (find_program_at_standard_place): Remove.
(_gpgme_get_gpg_path): Make the search order more explicit.
(_gpgme_get_gpgconf_path): Ditto.
(_gpgme_get_w32spawn_path): Search only in the inst_dir.
--

This tries to avoid possible unclear bug reports by removing the
fallback to the current gpg4win installation directory for the gpgme
helper.  It is expected that users of gpgme installing their own gpgme
version also install the matching helper.

Signed-off-by: Werner Koch <wk@gnupg.org>
2015-08-24 16:34:29 +02:00
Werner Koch
df098d6a43
w32: Print the installation directory in debug mode.
* src/debug.c (debug_init) [W32]: Show libgpgme installation dir.
--

I expect that gpgme will be distributed by applications and thus it
will be helpful to see in the debug log which gpgme is actually used.

Signed-off-by: Werner Koch <wk@gnupg.org>
2015-08-24 15:03:20 +02:00
Werner Koch
2b632bbb78
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 <wk@gnupg.org>
2015-08-24 12:41:24 +02:00
Ben Kibbey
ccbaccbf2e Parse INQUIRE_MAXLEN in the passphrase callback.
* src/passphrase.c (_gpgme_passphrase_status_handler): Parse
GPGME_STATUS_INQUIRE_MAXLEN.
* src/passphrase.c (_gpgme_passphrase_command_handler): Send the
INQUIRE_MAXLEN status message.

--
Fixes passing this status message along when decrypting symmetric data
from gpg.
2015-08-16 12:54:50 -04:00
Ben Kibbey
70b3e5964e Fix gpgme_{get,set}_status_cb to match documentation.
* doc/gpgme.texi: Minor fixes.
* src/gpgme.c (gpgme_get_status_cb): Set return variables to NULL and
check for a valid ctx pointer.
2015-08-15 18:19:27 -04:00
Ben Kibbey
6dd24c3c61 Parse the INQUIRE_MAXLEN status message.
* src/gpgme.h.in: (gpgme_status_code_t): Add INQUIRE_MAXLEN.
* src/status-table.c (status_table_s): Ditto.
* src/genkey.c (genkey_status_handler): Parse INQUIRE_MAXLEN.
* src/decrypt.c (_gpgme_decrypt_status_handler): Ditto.
* src/sign.c (_gpgme_sign_status_handler): Ditto.

This status message informs the client of the maximum length of an
inquired line. It is sent from gpg and forwarded to the client via
gpgme_status_cb_t.
2015-08-15 18:19:27 -04:00
Ben Kibbey
4fadcf06ec Add gpgme_set/get_status_cb().
* src/gpgme.h.in (gpgme_set_status_cb): New.
(gpgme_get_status_cb): New.
(gpgme_status_cb_t): New.
* src/gpgme.c (gpgme_set_status_cb): New.
(gpgme_get_status_cb): New.
* src/context.h (status_cb): New.
(status_cb_value): New.
* src/gpgme.def: Export new symbols.
* src/libgpgme.vers: Ditto.
* doc/gpgme.texi: Document these new functions.

--
This callback function is used to forward status messages from gpg back
to the client.
2015-08-15 18:19:27 -04:00
Ben Kibbey
2b6ae3dadf Make use of user passphrase handler during genkey.
* src/genkey.c (genkey_start): set engine passphrase command handler.

--
This allows for inquiring a new passphrase during key generation rather
than requiring a pinentry. Needs a patch to gnupg to make use of
--command-fd with --gen-key.
2015-08-15 18:17:06 -04:00
Ben Kibbey
e07d38f5f9 Also check the return code in gpg_sign().
* src/engine-gpg.c (gpg_sign): Check return value from start().
2015-08-12 06:46:43 -04:00
Ben Kibbey
8f28e3caf9 Check the return value when starting gpg.
* src/engine-gpg.c (gpg_decrypt, gpg_delete, gpg_passwd): Check return
value of start().
2015-08-10 21:23:02 -04:00
Andre Heinecke
08086dd690
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 <aheinecke@intevation.de>
2015-07-31 15:18:27 +02:00
Werner Koch
c23f889710
Add option --lib-version to gpgme-tool.
* src/gpgme-tool.c (options, parse_options):  Add --lib-version
(CMD_LIBVERSION): New.
(main): Implement.
2015-07-23 11:40:09 +02:00
Werner Koch
ddbd54ef88
Fix regression with gpgsm 2.0 due to "OPTION with-secret".
* src/engine-gpgsm.c (gpgsm_assuan_simple_command): Do not terminate
on a status lines.
--

This bug has been with us since the support for gpgsm: If there is no
status line handler but a status line is received anyway the command
handling loop terminates and thus the command/answer order gets out of
sync.  In the case of the bug report this is triggered by sending an
option which starts the agent and that starting emits a "PROGRESS"
status line.

The solution is not to stop reading after a status line but record a
possible error code and return that only after OK or ERR.

GnuPG-bug-id: 1795
Signed-off-by: Werner Koch <wk@gnupg.org>
2015-06-08 12:34:49 +02:00
Werner Koch
8b9f84828c
Fix compiler warnings about unused value in TRACE macros.
* src/debug.h: Change macros to not have a literal 0 as last
expression of the comma operator.
* src/debug.c (_gpgme_debug_frame_end): Return 0.
(_gpgme_debug): Return 0.
--

Instead of using
   foo(), 0
for the trace macros we let foo() return 0 instead.

Signed-off-by: Werner Koch <wk@gnupg.org>
2015-06-08 11:08:08 +02:00
Matthew Barnes
87d713ff41
Set GPGME_SIGSUM_KEY_REVOKED also for gpg.
* src/verify.c (calc_sig_summary): Handle GPG_ERR_CERT_REVOKED.

--

parse_new_sig() handles a revoked key by setting sig->status to
GPG_ERR_CERT_REVOKED, but then later calc_sig_summary() expects that
code in sig->validity_reason.

Additional comments added by wk.
2015-06-05 14:58:06 +02:00
Werner Koch
0d28a69616
Fix segv for userids with a backslash.
* src/engine-gpg.c (gpg_keylist_preprocess): Increment SRC for a
backslash.
--

This bug is not exploitable because this bug fills up .data with
backslashes and thus causes the segv.

Signed-off-by: Werner Koch <wk@gnupg.org>
2015-06-05 14:25:59 +02:00
Werner Koch
524dacfbb6
w32: Use -static-libgcc to avoid linking to libgcc_s_sjlj-1.dll.
* src/Makefile.am (extra_ltoptions): New.
(libgpgme_la_LDFLAGS): Use it.
(libgpgme_pthread_la_LDFLAGS): Ditto.
(libgpgme_glib_la_LDFLAGS): Ditto.
--

Since gcc 4.8 there is a regression in Mingw64 in that plain C
programs may link to libgcc_s.a which has a dependency on
libgcc_s_sjlj.dll.  This is for example triggered by using long long
arithmetic on a 32 bit Windows (e.g symbol __udivdi3).

Note that we don't use this patch for the Qt version which, as C++
programs, actually requires that DLL,

Signed-off-by: Werner Koch <wk@gnupg.org>
2015-04-13 15:35:06 +02:00
Werner Koch
8cfcdfe556
Fix potential crash in trace macro.
* src/signers.c (gpgme_signers_add): Avoid deref of a NULL KEY in the
trace macro.
* src/engine-spawn.c (engspawn_release): Remove always true condition.
* src/engine-gpg.c (gpg_release): Ditto.

Signed-off-by: Werner Koch <wk@gnupg.org>
2015-03-16 13:40:34 +01:00
Werner Koch
119f27032b
Fix one byte too short malloc.
* src/engine-spawn.c (add_data): Fix malloc
--

Bummer.  Why did I subtracted one from the size?  Did I assume a
dynamically allocated structure with a string field which was not
going to be used?  Very strange.

Not a real problem though because malloc will anyway round up the
allocation to at least the next word size.

Detected by Stack 0.3.
2015-03-16 13:38:10 +01:00
Werner Koch
05258d4275 Return an error for some export key operations.
* src/context.h (OPDATA_EXPORT): New.
* src/export.c (op_data_t): New.
(release_op_data): New.
(parse_error): New.
(export_status_handler): New.
(export_start, export_ext_start): Prepare op_data.
(gpgme_op_export_ext, gpgme_op_export_keys): Return an error from the
status handler.
--

To support an error return also for the async functions we need to
extend the API.  Until we have done that this new features helps at
least in some cases; in particular for --send-keys.
2014-12-08 11:19:16 +01:00
Werner Koch
81ce87111f Update the previous commit
* src/sign.c (gpgme_op_sign_result): Reformat and take care of failed
malloc.
--

Although _gpgme_debug_trace() is current always true, the code should
be run always and not just in trace mode.  Also added error checking
to malloc and strdup.  And while at replace some while by for loop for
easier readability.
2014-11-21 21:12:06 +01:00
Ben Kibbey
5942b0c7e0 Fix returning new signatures when there are none.
* src/sign.c (gpgme_op_sign_result): Test that invalid and valid
signatures add up to gpgme_signers_count().
--

When invalid and valid signatures do not equal gpgme_signers_count() it
means that there was a bad passphrase during signing after the first
signer. This leaves the result.signatures from previous signers intact
which isn't correct since gpg will report:

gpg: number of one-pass packets does not match number of signature
packets
gpg: can't handle this ambiguous signature data

during verify. So when this happens append the valid signatures to the
.invalid_signers list with .reason set to GPG_ERR_GENERAL.
2014-11-21 20:25:43 +01:00
Werner Koch
8031341283 Improve the debug output a bit.
* src/debug.h (TRACE_ERR): Include the line number in the output.
2014-11-06 15:59:06 +01:00
Werner Koch
4027a0a897 build: Implement SYSROOT feature.
* configure.ac: Document SYSROOT.
* m4/gpg-error.m4: Update from libgpg-error master.
* src/gpgme.m4: Implement SYSROOT stuff.
2014-10-02 15:57:50 +02:00
Daniel Kahn Gillmor
b3309f997c Use --no-sk-comments, not --no-sk-comment.
--
The --no-sk-comments flag is (or should be) a no-op in modern versions
of gnupg, but gpgme should still use its full form rather than the
(slightly) abbreviated --no-sk-comment
2014-10-02 15:20:35 +02:00
Werner Koch
4160ef90a1 gpgme-tool: Print fingerprint and keyid with keyservers.
* src/gpgme-tool.c (cmd_keylist): Print keyid.  Print FPR only if
available.
2014-08-12 18:50:14 +02:00
Werner Koch
3450bff52b Handle modern keyserver output which may emit the fingerprint.
* src/engine-gpg.c (read_colon_line): Split preprocessed lines.
(gpg_keylist_preprocess): Limit keyid field and print fingerprint.
2014-08-12 18:47:39 +02:00
Werner Koch
488e44cdb5 gpgme-tool: Install gpgme-tool.
* src/Makefile.am (bin_PROGRAMS): New.  Add gpgme-tools.
(noinst_PROGRAMS): Remove.
2014-08-12 17:51:38 +02:00
Werner Koch
e5ab116072 gpgme-tool: Fix segv for external key listing.
* src/gpgme-tool.c (result_xml_escape): Allow for DATA being NULL.
2014-08-12 17:42:08 +02:00
Werner Koch
2cbd76f791 Fix possible realloc overflow for gpgsm and uiserver engines.
* src/engine-gpgsm.c (status_handler):
* src/engine-uiserver.c (status_handler):
--

After a realloc (realloc is also used for initial alloc) the allocated
size if the buffer is not correctly recorded.  Thus an overflow can be
introduced by receiving data with different line lengths in a specific
order.  This is not easy exploitable because libassuan constructs the
line.  However a crash has been reported and thus it might be possible
to constructs an exploit.

CVE-id: CVE-2014-3564
Reported-by: Tomáš Trnka
2014-07-30 11:04:55 +02:00
Werner Koch
68116fa5f6 w32: Get IOSPAWN flag back in sync with spawn helper.
* src/gpgme-w32spawn.c: Include priv-io.h.
2014-06-26 10:42:56 +02:00
Werner Koch
efaf42205c w32: Add comment about a compiler warning
--
2014-06-26 10:41:46 +02:00
Werner Koch
86260b47c9 Add new reason codes to the INV_RECP status code.
* src/op-support.c (_gpgme_parse_inv_recp): Add codes 13 and 14.
2014-06-10 14:52:06 +02:00
Werner Koch
4dc9af2415 Add new keylist mode GPGME_KEYLIST_MODE_WITH_SECRET.
* src/gpgme.h.in (GPGME_KEYLIST_MODE_WITH_SECRET): New.
* src/engine-gpg.c (gpg_keylist_build_options): Handle new mode.
* src/engine-gpgsm.c (gpgsm_keylist, gpgsm_keylist_ext): Ditto.
* src/keylist.c (parse_sec_field15): Add arg key and take care of
--with-secret output.

* src/gpgme-tool.c (gt_get_keylist_mode, cmd_keylist_mode): Add
"with_secret".  Print card info and and secret flag for subkeys.
--

Note: This mode may only be used with GnuPG >= 2.1.
2014-06-04 09:57:54 +02:00
Werner Koch
de6caeed6d Add 6 new GPGME_STATUS_ codes.
* src/status-table.c: Also add missing DECRYPTION_INFO entry.
2014-05-13 16:08:01 +02:00
Werner Koch
88f15336ec Add field CURVE to the key info.
* src/gpgme.h.in (struct _gpgme_subkey): Add field CURVE.
* src/key.c (gpgme_key_unref): Free CURVE.
* src/keylist.c (keylist_colon_handler): Set CURVE.

* src/gpgme.c (gpgme_release): For failsafe reasons reset engine and
engine info after freeing.
--

The engine hack is useful in case the other release functions
accidently call engine release.
2014-05-08 20:39:15 +02:00
Werner Koch
de4a1ea684 Fix a memory access and a double slash bug.
* src/engine-spawn.c (engspawn_start): Allocate space for list
terminator.
* src/posix-util.c (walk_path): Fix trailing slash detection.
--

Kudos to Valgrind for pointing out these two problems.

The first is a plain allocation bug in a code pattern I have written
thousands of times - this time it went wrong.  The allocation is not
user controlled thus not directly exploitable.

The second is missed to do what it intended to do.  Found due to the
access of malloced but not initialized memory.  Not using calloc
again proved to be helpful to detect logical error.
2014-05-08 20:35:57 +02:00
Werner Koch
d5fb92cdae Map public key algos returned by gpg to gpgme values.
* src/conversion.c (_gpgme_map_pk_algo): New.
* src/decrypt.c (parse_enc_to): Add arg PROTOCOL and map pubkey algo.
(_gpgme_decrypt_status_handler): Map pubkey algo.
* src/keylist.c (keylist_colon_handler): Map pubkey algo.
* src/sign.c (parse_sig_created): Add arg PROTOCOL and map pubkey
algo.
* src/verify.c (parse_new_sig): Ditto.
(parse_valid_sig): Ditto.

* src/gpgme.h.in (GPGME_PK_ECC): New.
(GPGME_MD_SHA224): New.
* src/gpgme.c (gpgme_pubkey_algo_name): Add GPGME_PK_ECC case.
(gpgme_hash_algo_name): Add GPGME_MD_SHA224.
--

This affects only the not yet released ECC code of GnuPG 2.1.
2014-05-08 14:11:58 +02:00
Werner Koch
991cde9e79 Add GPGME_ENCRYPT_NO_COMPRESS flag.
* src/gpgme.h.in (GPGME_ENCRYPT_NO_COMPRESS): New.
* src/engine-gpg.c (gpg_encrypt, gpg_encrypt_sign): Implement it.
* src/gpgme-tool.c (_cmd_sign_encrypt): Add option --no-compress.
2014-05-08 11:31:30 +02:00
Werner Koch
62711e5614 w32: Fix another memleak on error.
* src/w32-io.c (create_reader): free CTX.
--

Found by Hans-Christoph Steiner with cppcheck.
2014-04-16 10:19:54 +02:00
Werner Koch
85a07ca7e3 w32: Fix memleak in an error code paths.
* src/w32-io.c (create_writer): Free CTX in cased of bad FD.
* src/w32-util.c (_gpgme_mkstemp): Free TMPNAME in case of a failed
mkstemp.
--

Found by Hans-Christoph Steiner with cppcheck.
2014-04-15 22:18:04 +02:00
Werner Koch
2bb26185e3 Fix possible zombie processes.
* src/posix-io.c (_gpgme_io_waitpid): Protect waitpid agains EINTR.
(_gpgme_io_dup): Likewise.
(_gpgme_io_connect): Likewise.
--

GnuPG-bug-id: 1630
2014-04-15 12:25:45 +02:00
Werner Koch
d3bd8fff86 Actually implement flags for gpgme_op_spawn.
* src/spawn.c (gpgme_op_spawn_start, gpgme_op_spawn): Pass FLAGS dow
to spawn_start and add FLAGS args along the call path.
* src/engine-spawn.c (engspawn_start): Hack to automagically provide
argv[0].
2014-04-10 14:17:19 +02:00
Werner Koch
4f2d652e60 Add GPGME_PROTOCOL_SPAWN and gpgme_op_spawn.
* src/gpgme.h.in (GPGME_PROTOCOL_SPAWN): New.
(GPGME_SPAWN_DETACHED, GPGME_SPAWN_ALLOW_SET_FG): New.
* src/gpgme.c (gpgme_set_protocol): Add new protocol.
(gpgme_get_protocol_name): Ditto.
* src/spawn.c: New.
* src/libgpgme.vers, src/gpgme.def: Add new public functions.
* src/engine-spawn.c: New.
* src/Makefile.am: Add new files.
* src/engine-backend.h (struct engine_ops): Add OPSPAWN.
* src/engine.c (engine_ops): Add _gpgme_engine_ops_spawn.
(gpgme_get_engine_info): Add Spawn to the list of protocols.
(_gpgme_engine_op_spawn): New.

* src/gpgme-tool.c (gt_protocol_from_name): Add new protocol.
(gt_spawn, cmd_spawn): New.
2014-04-10 13:01:00 +02:00
Werner Koch
77931a9a14 Add gpgme_get_dirinfo.
* src/dirinfo.c (gpgme_get_dirinfo): New.
* tests/t-engine-info.c (main): Print results from that function.
2014-04-10 11:48:20 +02:00
Werner Koch
443f6b76a9 Make use of internal iospawn flags more flexible.
* src/priv-io.h (IOSPAWN_FLAG_DETACHED): New. Renumber the others.
* src/w32-io.c (_gpgme_io_spawn): Use DETACHED_PROCESS process only if
IOSPAWN_FLAG_DETACHED is given.
* src/w32-qt-io.cpp (_gpgme_io_spawn): Ditto.
* src/w32-glib-io.c (_gpgme_io_spawn): Ditto.
* src/assuan-support.c (my_spawn): Pass IOSPAWN_FLAG_DETACHED flags.
* src/dirinfo.c (read_gpgconf_dirs): Ditto.
* src/engine-gpg.c (start): Ditto.
* src/engine-gpgconf.c (gpgconf_read, gpgconf_write): Ditto.
* src/version.c (_gpgme_get_program_version): Ditto.
2014-04-10 11:39:14 +02:00
Werner Koch
617d3be629 Make sure a spawned process has all standard fds connected.
* src/posix-io.c (_gpgme_io_spawn): dup /dev/null also to unsued
stdout.
--

Better be sure that stdout of a spawned process is connected to stdout
so that the process does not run into a write error if it writes to
stdout.  AFAICS we always use a connected stdout; thus this is only
for correctness.
2014-04-10 11:15:40 +02:00
Werner Koch
766355b5d4 Add configure option --enable-fixed-path.
* configure.ac: Add option --enable-fixed-path.
(FIXED_SEARCH_PATH): New ac_define.
* src/posix-util.c (walk_path): Make use of the option.  Remove
current directory from fallback PATH.
--

Note that using this option PATH is entirely ignored by GPGME and only
the given value is used instead to locate the GnuPG binaries.

On Android the use of PATH is not desirable.  Instead the GnuPG tools
are expected in a fixed directory.  By using

  ./configure --enable-fixed-path="/foo/bar"

gpg et al are expected to be installed as /foo/bar/gpg.  With

  ./configure --enable-fixed-path="/foo/bar:/bin"

gpg is expected as /foo/bar/gpg or /bin/gpg.
2014-03-13 14:24:14 +01:00
Werner Koch
dd9c8c5671 Avoid pointer arithmetic on void pointer.
* src/gpgme.c (gpgme_io_writen): Use new var buffer.
--

Reported-by: Albert Chin
2014-03-11 13:58:38 +01:00
Werner Koch
75a6255935 Change implementation return type to match the definition.
* src/gpgme.c (gpgme_get_sub_protocol): Change return type to
gpgme_protocol_t.
--

Yet another enum/int mismatch.

Reported-by: Albert Chin.
2014-03-11 13:54:21 +01:00
Werner Koch
651d9e1c6b Always pass correct name to argv[0]. Ignore GPG_AGENT_INFO for gpg2.
* src/dirinfo.c (WANT_GPG_ONE_MODE): New.
(struct dirinfo): Add field "gpg_one_mode".
(get_gpgconf_item): Set that field and return it if requested.
(_gpgme_in_gpg_one_mode): New.
* src/engine-gpg.c (build_argv): Check GPG_AGENT_INFO only in gpg-1
mode.

* src/dirinfo.c (_gpgme_get_basename): New.
* src/engine-g13.c (g13_new): Take argv[0] from the pgmname.
* src/engine-gpgsm.c (gpgsm_new): Ditto.
* src/engine-gpg.c (build_argv): Ditto. Add arg PGMNAME.
(start): Pass PGMNAME to buildargv.
2014-02-21 11:22:45 +01:00
Werner Koch
f916ab753b Fix type inconsistency between gpgme.h and gpgme.c.
* src/gpgme.c (gpgme_set_pinentry_mode): Fix type of MODE.
--

GnuPG-bug-id: 1617
2014-02-12 20:36:08 +01:00
Werner Koch
ab6e718327 Make gpgconf engine work again - fixes 02ba35c1.
* src/gpgconf.c: Remove ENABLE_GPGCONF and move prototypes to ...
* src/engine-backend.h: ... here.
--

gpgconf is a required part for gpgme.
2014-01-07 17:59:59 +01:00
Werner Koch
121efcc561 Make gpgme_new return a proper error if no engines are installed.
* src/engine.c (gpgme_get_engine_info): Improve error handling.
(_gpgme_engine_info_copy): Ditto.
* src/gpgme.c (gpgme_new): Return error GPG_ERR_NO_ENGINE.
2014-01-07 13:32:08 +01:00
Werner Koch
d63058b852 Print the full PATH in the log if gpg was not found.
* src/posix-util.c (walk_path): Keep a copy of PATH.
2014-01-07 12:44:55 +01:00
Werner Koch
6564e5e78e Add global flags disable-gpgconf, gpgconf-name, and gpg-name.
* src/gpgme.c (gpgme_set_global_flag): Add names "disable-gpgconf",
"gpgconf-name", and "gpg-name".
* src/dirinfo.c (_gpgme_dirinfo_disable_gpgconf): New.
(get_gpgconf_item): Minor debug info change.
* src/posix-util.c (default_gpg_name, default_gpgconf_name): Add vars.
(_gpgme_set_default_gpg_name): New.
(_gpgme_set_default_gpgconf_name): New.
(_gpgme_get_gpg_path, _gpgme_get_gpgconf_path): Use new vars.
(walk_path): Add debug output on failure.
* src/w32-util.c (default_gpg_name, default_gpgconf_name): Add vars.
(replace_slashes): New.
(get_basename): New.
(_gpgme_set_default_gpg_name): New.
(_gpgme_set_default_gpgconf_name): New.
(_gpgme_get_gpg_path, _gpgme_get_gpgconf_path): Use new vars.

* tests/t-engine-info.c (main): Add --verbose and --set-global-flag
options.
--

Note that the Windows part has not been tested.
2014-01-06 17:16:52 +01:00
Werner Koch
02ba35c1b6 Locate engine names only at runtime and prefer GnuPG-2.
* configure.ac (NEED_GPG_VERSION, NEED_GPGSM_VERSION)
(NEED_G13_VERSION, NEED_GPGCONF_VERSION): Remove vars and all related
checks.  Do not check for any engine version.
(HAVE_ASSUAN): Remove AM conditional.
* src/Makefile.am: Remove separate component vars and always build all
engines but uiserver.
* src/dirinfo.c (WANT_GPGCONF_NAME): New.
(struct dirinfo): Add field gpgconf_name.
(_gpgme_get_default_gpgconf_name): Use WANT_GPGCONF_NAME.
(get_gpgconf_item): Set gpgconf name and adjust for _gpgme_get_*_path
now returning a malloced string.
* src/engine.c (engine_ops): Always init all engines except for
uiserver.
* src/posix-util.c (_gpgme_get_gpgsm_path, _gpgme_get_g13_path):
Remove unused functions.
(walk_path): New.
(_gpgme_get_gpg_path, _gpgme_get_gpgconf_path ): Re-implement using
walk_path.
* src/w32-util.c (_gpgme_get_gpgsm_path, _gpgme_get_g13_path): Remove
unused functions.
(_gpgme_get_gpg_path, _gpgme_get_gpgconf_path): Return a malloced
string.
* src/engine-g13.c (g13_get_req_version): Use a hardwired string with
the required version.  This info belongs into this file.
* src/engine-gpg.c (gpg_get_req_version): Ditto.
* src/engine-gpgconf.c (gpgconf_get_req_version): Ditto.
* src/engine-gpgsm.c (gpgsm_get_req_version): Ditto.
* tests/t-engine-info.c: Replace now useless test by an info output.
* tests/gpg/Makefile.am (GPG, GPG_AGENT): Hardwire gpg and gpg-agent.
* tests/gpgsm/Makefile.am (GPGSM): Hardwire gpgsm.

Signed-off-by: Werner Koch <wk@gnupg.org>
2013-12-27 16:08:20 +01:00
Werner Koch
372bd43983 Fix possible segv in the gpgme_op_card_edit.
* src/edit.c (gpgme_op_edit_start, gpgme_op_card_edit_start): Do not
deref a NULL KEY in TRACE_BEG.
2013-08-19 20:40:10 +02:00
Werner Koch
8579091c4f Add function gpgme_data_identify.
* src/gpgme.h.in (gpgme_data_type_t): New.
(gpgme_data_identify): New prototype.
* src/data-identify.c: New.
* src/parsetlv.c, src/parsetlv.h: New.  Take from gpa.
* src/libgpgme.vers, src/gpgme.def: Add gpgme_data_identify.
* src/gpgme-tool.c (status): Add STATUS_IDENTIFY_RESULT.
(gt_identify): New.
(cmd_identify): New.

(hlp_passwd): Move close to cmd_passwd.
--

It is often useful to have a way to identify the data which needs
processing.  This is such a common task that it makes sense to
implement this in gpgme to avoid diverging implementations.
2013-08-09 19:19:26 +02:00
Werner Koch
a4c80126ae Prefer GnuPG-2 engines over GnuPG-1.
* src/util.h: Move some prototypes to ...
* src/sys-util.h: New.
* src/Makefile.am (main_sources): Add sys-util.h.
* configure.ac (AH_VERBATIM): Add DIRSEP_C and DIRSEP_S.
* src/dirinfo.c: Include sys-util.h.
(WANT_GPG_NAME, WANT_GPGSM_NAME, WANT_G13_NAME)
(WANT_UISRV_SOCKET): New.
(dirinfo): Add corresponding fields.
(parse_output): Add arg COMPONENTS and set new fields.
(read_gpgconf_dirs): Add arg components and act upon it.
(get_gpgconf_item): Call read_gpgconf_dirs two times.  Add debug
output.
(_gpgme_get_default_gpg_name): New.
(_gpgme_get_default_gpgsm_name): New.
(_gpgme_get_default_g13_name): New.
(_gpgme_get_default_gpgconf_name): New.
(_gpgme_get_default_uisrv_socket): New.
* src/engine-gpg.c, src/engine-g13.c, src/engine-gpgconf.c
* src/engine-gpgsm.c, src/engine-uiserver.c: Change to use
_gpgme_get_default_ instead of those from sys-util.h.
* src/posix-util.c (_gpgme_get_gpg_path): Include sys-util.h.
(_gpgme_get_uiserver_socket_path): Remove.
* src/w32-util.c (_gpgme_get_gpg_path): Include sys-util.h.
(_gpgme_get_uiserver_socket_path): Remove.
--

The default engines names are now taken from the output of gpgconf.
If gpgconf is not installed gpg 1 is assumed and locate the same was
as gpgconf.
2013-08-02 15:25:23 +02:00
Werner Koch
3881ea4e83 w32: Try to locate gpg in the gpgme installation dir.
* src/w32-util.c (my_hmodule): New.
(wchar_to_utf8): New.
(DllMain): New.
(_gpgme_get_inst_dir): New.
(find_program_in_dir): New.
(find_program_in_inst_dir): Add arg INST_DIR.
(_gpgme_get_gpg_path): Get inst_dir before acquiring the lock.
(_gpgme_get_gpgconf_path): Ditto.
(_gpgme_get_g13_path): Ditto.
(_gpgme_get_w32spawn_path): Ditto.
2013-08-02 12:48:30 +02:00
Werner Koch
f2eeccbdfa Add function gpgme_signers_count.
* src/signers.c (gpgme_signers_count): New.
* src/libgpgme.vers, src/gpgme.def: Add as external symbol.
* src/gpgme.h.in: Add prototype.
2013-06-18 10:27:46 +02:00
Werner Koch
2e8feb6016 Add convenience macro GPGME_PROTOCOL_OPENPGP.
* src/gpgme.h.in (GPGME_PROTOCOL_OPENPGP): New.
2013-05-28 10:55:35 +02:00
Werner Koch
c29dad2315 w32: Fix installing of .def file.
* src/Makefile.am (install-def-file): Create libdir first.
2013-05-23 20:18:04 +02:00
Werner Koch
d4371ed30d Support --no-encrypt-to also with gpgme_op_encrypt_sign.
* src/engine-gpg.c (gpg_encrypt_sign): Support the
GPGME_ENCRYPT_NO_ENCRYPT_TO flag.
2013-05-22 16:32:15 +02:00
Werner Koch
567e6481d7 Allow symmetric encryption with gpgme_op_encrypt_sign.
* src/encrypt-sign.c (encrypt_sym_status_handler): New.
(encrypt_sign_start): Handle recp == NULL case.
* src/engine-gpg.c (gpg_encrypt_sign): Implement symmetric encryption.
* tests/gpg/t-encrypt-sign.c (main): Add a test case for this.
--

Co-authored-by: Kyle L. Huff <g10bts@curetheitch.com>
GnuPG-bug-id: 1440
2013-05-22 16:31:51 +02:00
Werner Koch
0c1de7abd5 gpgme-tool: Allow for symmetric encryption.
* src/gpgme-tool.c (gt_sign_encrypt): Pass NULL for recp if no
recipients are given.
2013-05-22 16:20:14 +02:00
Werner Koch
e99356306d Improve C++ compatibility of previous patch.
* src/gpgme.h.in: Move gpgme_sssize_t and gpgme_off_t typedefs into
the extern "C" scope.
--

Frankly, this does not help very much because g++ still does not
interpret gpgme_data_seek_cb_t as compatible with the C++ ssize_t.  I
am sorry for that API change but C and C++ are too different to always
get both of them under one umbrella.  However, the ABI should now be
identical to older gpgme versions.
2013-05-18 13:49:52 +02:00
Werner Koch
6d0d8e7ba0 Make definition of off_t robust against misbehaving w32 toolchains.
* configure.ac (NEED__FILE_OFFSET_BITS): Change to define gpgme_off_t
and gpgme_ssize_t.
(API__OFF_T, API__SSIZE_T): New ac_subst.
* src/gpgme.h.in: Replace all ssize_t and off_t by ac_subst macros.
* src/assuan-support.c, src/ath-pthread.c, src/ath.c, src/ath.h
* src/data-compat.c, src/data-fd.c, src/data-mem.c, src/data-stream.c
* src/data-user.c, src/data.c, src/data.h, src/engine-gpgsm.c
* src/engine-uiserver.c, src/gpgme-tool.c, src/gpgme.c: Replace off_t
by gpgme_off_t and sszie_t by gpgme_ssize_t.
* src/ath-pthread.c, src/ath.h: Include gpgme.h.
--

For a detailed description, see the gpgme.texi diff.
2013-05-16 17:48:50 +02:00
Werner Koch
9e7df9aa6d w32: Change the way the I/O threads are cleaned up.
* src/w32-io.c (reader_context_s, create_reader)
(writer_context_s, create_writer): Rename STOPPED to CLOSE_EV.
(reader, writer): Remove setting of STOPPED.  Wait for CLOSE_EV and
then release the context.
(destroy_reader, destroy_writer): Do not wait but set the CLOSE_EV.
(kill_reader, kill_writer): Remove.
(_gpgme_io_close): Add code from kill_reader and kill_writer.
--

The old code was prone to deadlocks which were actually exhibited at
Kleopatra startup.  The new code is much more straightforward and
easier to understand.  The reason for the complex old code was
probably due to our former idea to allow re-use of the I/O threads.
However we have long given up on this.
2013-05-11 15:38:08 +02:00
Werner Koch
9f330be821 Fix hang in socket closing.
* src/w32-io.c (destroy_reader): Call shutdown.
(reader): Do not print an error in the shutdown case.
2013-05-08 20:38:50 +02:00
Werner Koch
2118f49701 Improve debug output of the I/O reader and writer.
* src/w32-io.c (reader, writer): Also print file_sock.
2013-05-08 19:10:41 +02:00
Werner Koch
a7e5f1096f Simplify a debug code function.
* src/debug.c (_gpgme_debug): Remove static space string.
2013-05-06 20:22:23 +02:00
Werner Koch
f623a6b94c Allow reading of long gpgconf output lines.
* src/engine-gpgconf.c (gpgconf_read): Rewrite to allow for line
lengths up to 64k.
2013-04-30 18:09:13 +02:00
Werner Koch
5090f6f246 Enable FD passing and thus building of the UI-server.
* configure.ac: Make --enable-fd-passing the default.
* src/engine-uiserver.c (_gpgme_engine_ops_uiserver): Syntax fix.
2013-02-26 17:26:44 +01:00
Werner Koch
cdae524b28 w32: Hacks for building with 32 bit mingw64.
* configure.ac (INSERT__TYPEDEFS_FOR_GPGME_H): Add hacks for 32 bit
mingw64.
* src/util.h [W32]: Include winsock2.h before windows to make mingw64
happy.
* src/w32-util.c (_WIN32_IE): Need to use 5.1 for mingw64.
--

It is not clear to me what mingw64 wants to achieve with their POSIX
hacks. In particular the off64_t stuff looks quite strange given that
Windows has a pretty stable API for close to 2 decades.  Thus I can't
say whether it will really work when build with that toolchain.
2013-02-26 17:10:45 +01:00
Werner Koch
d8b46c919f Change the various version numbers to the new scheme.
* configure.ac: Rename my_foo variables to mym4_foo variables to make
clear that they are processed by m4.
(VERSION_NUMBER): New ac_subst.
(AH_BOTTOM): Add CRIGHTBLURB macro.
(BUILD_REVISION, BUILD_FILEVERSION, BUILD_TIMESTAMP): Change them to
work similar to libgpg-error et al.
* src/versioninfo.rc.in: Remove use of BUILD_NUMBER and get it in line
with gpg-error et al.
* src/version.c (cright_blurb): New.
(gpgme_check_version_internal): Add magic to display the above
information.
* tests/t-version.c (main): Add option --verbose.
2013-02-26 17:10:18 +01:00
Werner Koch
f48f75b1e8 Add macro GPGME_VERSION_NUMBER.
* src/gpgme.h.in (GPGME_VERSION_NUMBER): New.
* configure.ac (my_version_major, my_version_minor)
(my_version_micro): New m4 macros.
(my_version): Build from new m4 macros.
(VERSION_NUMBER): New ac_subst.
2013-02-12 14:02:08 +01:00
Werner Koch
4f38155441 Add public function gpgme_get_pinentry_mode.
* src/gpgme.c (gpgme_get_pinentry_mode): New.
2013-02-12 10:42:54 +01:00
Werner Koch
02a2cf0ccb gpgme_tool: Support GPG's new pinentry-mode.
* src/gpgme-tool.c (log_error): Do not always print the error source.
(gt_set_pinentry_mode): New.
(server_passphrase_cb): New.
(cmd_pinentry_mode): New.
(register_commands): Add cmd_pinentry_mode.
(options): Add option --gpg-binary.
(struct args): Add field gpg-binary.
(parse_options, main): Implement that option.
2013-02-07 21:03:44 +01:00
Werner Koch
61a0d92b67 Add public function gpgme_set_pinentry_mode.
* src/gpgme.c (gpgme_set_pinentry_mode): New.
* src/gpgme.h.in (gpgme_pinentry_t): New.
(gpgme_set_pinentry_mode): New.
* src/context.h (struct gpgme_context): Add field pinentry_mode.
* src/engine-backend.h (struct engine_ops): Add field
set_pinentry_mode.
* src/engine-gpg.c (struct engine_gpg): Add field pinentry_mode.
(build_argv): Implement pinentry_mode.
(gpg_set_pinentry_mode): New.
(_gpgme_engine_ops_gpg): Register gpg_set_pinentry_mode.

--

Note that this new fucntion may only be used with gpg 2.1.
2013-02-07 20:59:16 +01:00
Werner Koch
29eced5068 Add public function gpgme_io_writen.
* src/gpgme.c (gpgme_io_read): New.
--

This is a writen style variant for gpgme_io_write.  It is often easier
to use this one in passphrase and edit callbacks.
2013-02-07 20:51:29 +01:00
Werner Koch
51fd6d8292 Use gpg_error_from_syserror instead of directly accessing errno.
--

Also fixed a couple of minor thing; e.g. save the error before calling
cleanup functions.  Do not save the errno if only free is called
in between.
2013-02-06 17:35:40 +01:00
Werner Koch
1a17acd8e9 Make _gpgme_encode_percent_string work for memory buffers.
* src/conversion.c (D_gpgme_encode_percent_string): Remove stray
semicolon.  Reported by Xi Wang.
--
Obviously this function is not used with a supplied LEN argument != 0.
2012-11-15 11:14:58 +01:00
Werner Koch
12a0c93433 Fix ttyname problem on Android.
* configure.ac: Define macro and conditional HAVE_ANDROID_SYSTEM.
* m4/gnupg-ttyname.m4: Force use of replacement on Android.
* src/ttyname_r.c: Ditto.
--

Android's bionic lib has no working ttyname_r() nor ttyname().  Using
them anyway will print

  FIX ME! implement ttyname_r() bionic/libc/bionic/stubs.c:466

Thus we force the use of our replacement code which simply return
"/dev/tty".
2012-10-24 16:44:34 +02:00
Werner Koch
bd24feaa86 Trace the use of GPG_ERR_INV_ENGINE.
* src/debug.h: Include "gpgme.h"
(_gpgme_trace_gpgme_error): New.
(trace_gpg_error): New macro.  Use it in all files where we return
GPG_ERR_INV_ENGINE; also "include debug.h" as needed.
--

This is a pretty common error code but often it is hard to figure out
the actual cause.  With debug level 4 we now print the file name and
line number where this error code is generated by gpgme.  Along with
the git revision printed in the first log lines, this should give us
an easier way to track down the problems related to this error code.
2012-10-19 11:23:39 +02:00
Werner Koch
14a8fd4eec Avoid warning about initialized but not used variable
* src/engine-gpgsm.c (gpgsm_set_fd): Do not set DIR if not needed.
2012-10-19 11:18:08 +02:00
Werner Koch
e11e7fc558 gpgme-tool: Use membuf functions to build up strings.
* src/gpgme-tool.c (clear_membuf, init_membuf, put_membuf)
(put_membuf_str, get_membuf, peek_membuf): Add membuf functions.
Take from GnuPG master's common/membuf.[ch] and patch for our use.
(result_xml_escape): Rewrite using new functions.
--

First counting, then allocating, and finally copying data is prone to
errors.  We better use the membuf functions which make it much easier.
2012-10-11 17:02:50 +02:00
Werner Koch
aa30b47aa0 gpgme-tool: Change license from LPGLv2+ to GPLv3+
* src/gpgme-tool.c: Change license notice.
--

gpgme-tool.c is a standalone program, thus it makes no sense to keep
it under the LGPL.  We already had the manual under GPLv3+.
2012-10-11 16:54:58 +02:00
W. Trevor King
3f1329e1c9 gpgme-tool: escape special characters in output XML data (<, >, and &).
[[PGP Signed Part:Undecided]]
src/gpgme-tool.c (result_xml_escape_replacement, result_xml_escape):
New.
(result_xml_tag_data): Use result_xml_escape() to escape data.
(result_add_error): Use unescaped < and >.
--

This is a general solution for generating valid XML, but the specific
output that inspired the change was from the KEYLIST command:

  <uid>William Trevor King <wking@tremily.us></uid>

Now the uids are properly escaped:

   <uid>William Trevor King &lt;wking@tremily.us&gt;</uid>

Signed-off-by: W. Trevor King <wking@tremily.us>
2012-10-11 16:22:46 +02:00
W. Trevor King
c28ebca9f2 gpgme-tool: Fix chain_id -> chain-id in KEYLIST XML.
[[PGP Signed Part:Undecided]]
src/gpgme-tool.c (cmd_keylist): Use <chain-id> instead of <chain_id>.
--
All the other tags map struct attribute underscores to hyphens, so
fixing <chain_id> follows the priciple of least surprise.

Signed-off-by: W. Trevor King <wking@tremily.us>
2012-10-11 16:18:24 +02:00
W. Trevor King
3d69b51f7f gpgme-tool: Return more detailed XML from KEYLIST
src/gpgme-tool.c (cmd_keylist): Convert output from a list of
to more detailed XML.
(xml_preamble1, xml_preamble2, xml_end): Make global.
(result_add_protocol, result_add_validity): New functions for
generating XML from GPGME types.
(result_add_string): Treat NULL strings as "".
(result_xml_tag_data): Make 'data' a 'const char' so we can use the
value returned by gpgme_get_protocol_name directly.
--

This is a first pass at returning most of the gpgme_key_t data from the
KEYLIST call.

Signed-off-by: W. Trevor King <wking@tremily.us>
2012-09-28 08:31:51 +02:00
W. Trevor King
dda3702a90 gpgme-tool: Initialize input_fd and output_fd
* src/gpgme-tool.c (gpgme_server): Initialize input_fd and output_fd.

Signed-off-by: W. Trevor King <wking@tremily.us>
2012-09-28 08:25:48 +02:00
Werner Koch
193eb62538 gpgme-tool: Fix handling of file descriptors
* src/gpgme-tool.c (server_reset_fds): Use close/CloseHandle instead
of the assuan close functions.
(_cmd_decrypt_verify, _cmd_sign_encrypt, cmd_verify, cmd_import)
(cmd_export, cmd_genkey, cmd_getauditlog): Use SERVER object instead
of assuan_get_*_fd functions.
--

Although we used our own handlers for INPUT and OUTPUT, we still used
assuan_get_input_fd, assuan_get_output_fd and their close functions.
That clearly can't work because libassuan does not have any values for
them.
2012-09-26 09:37:22 +02:00
Werner Koch
c62b79a1d6 Add gpgme_set_global_flag to help debugging
* src/gpgme.c (gpgme_set_global_flag): New.
* src/gpgme.h.in (gpgme_set_global_flag): New.
* src/gpgme.def, src/libgpgme.vers: Add new public function.
* src/debug.c (envvar_override): New.:
(_gpgme_debug_set_debug_envvar): New.
(debug_init): Take ENVVAR_OVERRIDE in account.
--

On Android envvars can't be used, thus we need another way to enable
GPGME debugging.  The new function allows this and may be used in the
future to implement similar things.
2012-09-25 15:38:26 +02:00
Werner Koch
139e798c87 Remove all trailing whitespace from source files
--
Command used:  sed -i 's,[ \t]*$,,' FILE
2012-09-25 15:29:49 +02:00
Marcus Brinkmann
8384ccbd1a Fix sign error in position calculation for mem_seek.
* data-mem.c (mem_seek): Fix sign error in position calculation.
2012-07-28 22:06:09 +02:00
Marcus Brinkmann
434735f71e Allow null context on gpgme_set_locale.
* gpgme.c (gpgme_set_locale): Allow CTX to be a null pointer.
2012-07-28 01:17:03 +02:00
Werner Koch
e7aeaebb01 Do not include the removed file status-table.h
* src/engine-uiserver.c: Remove status-table.h which is not anymore
built.  Fixes bug#1412.
--

The file was actually removed from the code by 885243e0 but for
unknown reasons the missing file was not reported by "make distcheck".
2012-07-13 14:00:22 +02:00
Werner Koch
9f081da735 Make handling of new conf values more robust (bug#1413).
* src/engine-gpgconf.c (arg_to_data): Allow for NULL as value.string.
--

I was not able to replicate the problem.  However this patch makes the
code more robust and tolerates errors by the user.  IT should fix the
problem at hand.
2012-07-13 10:59:22 +02:00
Werner Koch
9c8608f702 Release 1.3.2.
* configure.ac: Bump LT version to C19/A8/R1.

* configure.ac (GITLOG_TO_CHANGELOG): Define.
* Makefile.am (gen-ChangeLog): Use it.
2012-05-02 11:18:24 +02:00
Werner Koch
295dd3f238 Remove unused pth stuff from gpgme-config.
* src/gpgme-config.in: Remove unused pth stuff.
2012-05-02 10:43:22 +02:00
Werner Koch
d6402b888f Update signature summary for the case of missing X.509 keys.
* src/verify.c (gpgme_op_verify_result): Update summary field.
--

This is actually a hack to solve the problem that GPGME currently does
not emit ERRSIG for a missing public key.
2012-05-02 10:30:09 +02:00
Werner Koch
1a21574b48 Fix timestamp parsing for y2038 hack.
* src/conversion.c (_gpgme_parse_timestamp): Set ENDP before year 2038
check.
2012-04-30 17:46:15 +02:00
Werner Koch
22de98b7a6 Remove trailing white space
--
2012-04-30 17:42:53 +02:00
W. Trevor King
4cb408d33e .gitignore: flesh out rules and add subdirectory-.gitignores. 2012-04-20 16:05:11 +02:00
W. Trevor King
62bbe58280 status-table.c: include string.h for strcmp.
* status-table.c: include string.h to avoid `warning: implicit
declaration of function 'strcmp'`.
2012-04-13 10:02:39 +02:00
W. Trevor King
c318e69d8f gpgme-tool: add help messages for a number of commands.
* src/gpgme-tool.c (hlp_engine, hlp_sub_protocol, hlp_armor, hlp_textmode,
hlp_include_certs, hlp_keylist_mode, hlp_input, hlp_output, hlp_message,
hlp_recipient, hlp_signer, hlp_signers_clear, hlp_decrypt, hlp_decrypt_verify,
hlp_encrypt, hlp_sign_encrypt, hlp_sign, hlp_verify, hlp_import): New strings.
(hlp_protocol): Fix typo.
(register_commands): Add documentation strings.
(doc): Mention Assuan.
2012-04-03 15:20:27 +02:00
Marcus Brinkmann
ff0a640a18 Do not rely on glibc name of syscall.
* src/ath.c (ath_self): Use __NR_gettid, not SYS_gettid.
2012-03-12 16:37:26 +01:00
Marcus Brinkmann
885243e054 Rework status table to be less dynamically generated.
* src/Makefile.am (EXTRA_DIST): Remove mkstatus.
(BUILT_SOURCE, MOSTLYCLEANFILES): Remove.
(main_sources): Remove status-table.h, extra-stati.h.
Add status-table.c.
(status-table.h): Remove rules for built source.
* src/decrypt.c: Don't include extra-stati.h.
* src/engine-gpg.c: Don't include status-table.h.
(status_cmp): Remove function.
(read_status): Use _gpgme_parse_status.
* src/engine-gpgsm.c: Don't include status-table.h.
(status_cmp, parse_status): Remove function.
(gpgsm_assuan_simple_command, status_handler): Use _gpgme_parse_status.
* src/engine-uiserver.c: Don't include status-table.h.
(status_cmp, parse_status): Remove function.
(uiserver_assuan_simple_command, status_handler): Use
_gpgme_parse_status.
* src/gpgme.h.in (gpgme_status_code_t): Add
GPGME_STATUS_DECRYPTION_INFO.
* src/util.h (_gpgme_status_init,_gpgme_parse_status): New declaration.
* src/status-table.c: New file.
* src/extra-stati.h, src/mkstatus: Files removed.
* version.c (do_subsystem_inits): Call _gpgme_status_init.
2012-02-14 13:34:44 +01:00
Marcus Brinkmann
3f03897cbd Link gpgme-tool directly to libassuan, as it uses its interface.
* src/Makefile.am (gpgme_tool_LDADD): Add @LIBASSUAN_LIBS@.
2012-02-08 15:18:11 +01:00
Werner Koch
2f304957f5 Fix Solaris problems with ttyname_r.
* m4/gnupg-ttyname.m4: New.  Based on ttyname_r from gnulib.
* src/ttyname_r.c (_gpgme_ttyname_r): Rename from ttyname_r.
Implement hacks required for Solaris and possible other non-fully
Posix systems.
* src/util.h: Include unistd.h.  Redefine ttyname_r depending on
REPLACE_TTYNAME_R and put it into the gpgme name space.
--

Unfortunately we cant not use the ttyname_r replacement from gnulib
because we want to keep GPGME LGPLv2+.
2012-01-19 18:43:10 +01:00
Werner Koch
574b087e84 For W32 use a build number instead of abbreviated commit id.
We would need to use a shortened commit id so that it fits into an 16
bit Windows variable.  Further it is a random number and not something
increasing.  Thus a build number made up from the day of the year and
the hour is much more useful to describe a build number for a specific
revision.
* configure.ac [W32]: Replace BUILD_REVISION by BUILD_NUMBER.
* src/versioninfo.rc.in: Ditto.
2012-01-19 16:04:19 +01:00
Werner Koch
a4c4ee1aae Generate the ChangeLog from commit logs.
* build-aux/gitlog-to-changelog: New script.  Taken from gnulib.
* build-aux/git-log-fix: New file.
* build-aux/git-log-footer: New file.
* build-aux/git-hook/commit-msg: New script.
* doc/HACKING: New file.
* ChangeLog: New file.
* Makefile.am (EXTRA_DIST): Add new files.
(gen-ChangeLog): New.
(dist-hook): Run gen-ChangeLog.
* autogen.sh: Install commit-msg hook for git.

Rename all ChangeLog files to ChangeLog-2011.
2011-12-02 11:36:37 +01:00
Marcus Brinkmann
3ddf4c3d40 Remove support for libgpgme-pth. 2011-10-25 18:59:26 +02:00
Marcus Brinkmann
b34add3fe4 Check context pointers for null pointer on entry points. 2011-05-26 16:01:26 +02:00
Werner Koch
cdefec02b3 gpgme-config cleanups and --host option
gpgme-config.in: Add option --host.  Change options --cflags and
--libs to collapse duplicate include and lib dirs.  Try to put extra
libs at the end.

Note that gpgme.m4 has not yet been extended.
2011-04-06 20:10:45 +02:00
Werner Koch
7e547d87d2 Insert platform dependent typedefs into gpgme.h
We already modify gpgme.h per playform and thus we can also get rid of
some #ifdefs.  The change does not change anything for current
platforms but should do the right think for W64.

Note that as per MS specs ssize_t is to be defined as LONG_PTR which
translates to a long on 32 bit platforms and to __int64 on 64 bit
Windows platforms.  We already used long in the past.  There seems to
be a problem with some versions of mingw32 which includes a ssize_t
type typedefed to int.  O(n 32 bit W32 platforms int and long are
identically.
2011-04-06 13:45:15 +02:00
Werner Koch
b001a8df68 Merge branch 'master' of git+ssh://playfair.gnupg.org/git/gpgme 2011-02-03 20:51:36 +01:00
Werner Koch
55ad4d80e2 Add support for non-API GnuPG status codes.
As an example stub code for DECRYTPION_INFO has been added.  Note
that the status codes in gpgme.h do only make sense for the edit
interactor interface and thus certain codes don't need to be part of
the public interface.
2011-02-03 20:49:41 +01:00
Marcus Brinkmann
2bdbe88822 Fix socket implementation on Windows.
2011-02-03  Marcus Brinkmann  <marcus@g10code.com>

        * w32-io.c (_gpgme_io_socket): Return fd, not res.
2011-02-03 12:38:28 +01:00
Marcus Brinkmann
129741d2f7 Fix Windows port (spawn and assuan engine).
2011-02-02  Marcus Brinkmann  <mb@g10code.com>

        * configure.ac (NEED_LIBASSUAN_VERSION): Bump to 2.0.2 for system hooks.

src/
2011-02-02  Marcus Brinkmann  <mb@g10code.com>

        * assuan-support.c (my_socket, my_connect): New functions.
        (_gpgme_assuan_system_hooks): Add my_Socket, my_connect.
        * priv-io.h (_gpgme_io_socket): New prototype.
        * w32-io.c (pid_to_handle, handle_to_oid, fd_to_handle): Remove macros.
        (is_socket): Remove function.
        (_gpgme_io_spawn) [HAVE_W32CE_SYSTEM]: Remove some dead code.
        (_gpgme_io_spawn): Translate handles before DuplicateHandle them.
2011-02-02 14:11:18 +01:00
Marcus Brinkmann
de287a7996 Merge commit 'a2b9adafe46c55a2c26dd46163055bbdf3526835' 2011-02-02 13:51:42 +01:00
Marcus Brinkmann
a2b9adafe4 2011-02-02 Marcus Brinkmann <mb@g10code.com>
* w32-util.c (mkstemp): Don't use CreateFile instead of open (the
        function is not used on Windows CE, and the callers were not
        adjusted).
2011-02-02 13:47:53 +01:00
Marcus Brinkmann
1f0f033f55 Fix gpgconf option change if not self-assigning.
2011-01-21  Marcus Brinkmann  <mb@g10code.com>

        * engine-gpgconf.c (_gpgme_conf_opt_change): Fix the case that is
        not self-assignment.
2011-01-21 04:21:30 +01:00
Werner Koch
ce1d166ef7 Allow multiple patterns for KEYLIST. 2010-12-08 09:55:00 +00:00
Marcus Brinkmann
e59b0a98ba 2010-11-23 Marcus Brinkmann <mb@g10code.com>
* w32-io.c (create_reader, create_writer): Use small stack size on
        Windows CE.
2010-11-23 10:47:59 +00:00
Marcus Brinkmann
eff0b7766a 2010-11-23 Marcus Brinkmann <mb@g10code.com>
* gpgme.h.in (gpgme_conf_arg_new): Make VALUE arg const void *.
	* gpgconf.c (_gpgme_conf_arg_new): Likewise.
	(gpgme_conf_arg_new): Likewise.
	* engine-gpgconf.c (_gpgme_conf_arg_new): Likewise.
	(gpgconf_write): Remove debug hack.
2010-11-23 09:46:52 +00:00
Marcus Brinkmann
ed8c52941c 2010-11-19 Marcus Brinkmann <mb@g10code.com>
* engine-gpgconf.c (_gpgme_conf_opt_change): Support
	self-assignment.  Requested by Marc Mutz.
2010-11-19 16:06:43 +00:00
Marcus Brinkmann
f1527436c4 2010-11-17 Marcus Brinkmann <mb@g10code.com>
* vasprintf.c (int_vasprintf) [HAVE_W32CE_SYSTEM]: Just use a
        fixed size buffer, as va_copy is not easy to fake.
2010-11-17 02:11:05 +00:00
Marcus Brinkmann
f8e4d353fa 2010-11-15 Marcus Brinkmann <mb@g10code.com>
* w32-ce.h (strcasecmp, strdup) [_MSC_VER]: Define.
	* genkey.c, passphrase.c: Include util.h.
2010-11-15 15:30:04 +00:00
Marcus Brinkmann
15ef3c9eeb 2010-11-15 Marcus Brinkmann <mb@g10code.com>
* w32-util.c (_gpgme_w32ce_get_debug_envvar): Fix return value.
2010-11-15 15:11:59 +00:00
Werner Koch
eef49ef417 Fixes for the MSC build 2010-11-15 08:40:30 +00:00
Werner Koch
44b2702258 More changes for W32CE with MSC. 2010-11-04 08:16:57 +00:00
Werner Koch
83d88d444e Hopefully last changes for building with MSC. 2010-11-03 10:33:10 +00:00
Werner Koch
21eb91ae3a More include guards.
Provide access for Wince.
Install dummy sehmap.h
2010-11-03 09:56:27 +00:00
Werner Koch
753375ffcf Might now build for CE using MSC. 2010-11-02 20:17:57 +00:00
Werner Koch
987993a38d First take on changes to allow building with MSC for W32CE.
Fixed regression in plain W32 build.
2010-11-02 16:27:46 +00:00
Marcus Brinkmann
b65638692e 2010-10-28 Marcus Brinkmann <marcus.brinkmann@ruhr-uni-bochum.de>
* opassuan.c (gpgme_op_assuan_transact_ext): Fix uninitialized
	value use.  Reported by Marc Mutz.
2010-10-28 14:00:14 +00:00
Werner Koch
de9f0b932e Fix last change 2010-10-07 12:54:17 +00:00