aboutsummaryrefslogtreecommitdiffstats
path: root/src/engine-spawn.c (unfollow)
Commit message (Collapse)AuthorFilesLines
2025-02-26Add API gpgme_op_random_bytes.Werner Koch1-0/+1
* src/genrandom.c: New. * src/Makefile.am: Add new file. * src/engine-backend.h (struct engine_ops): Add func ptr getdirect. Adjust all engine_ops. * src/engine-gpg.c (gpg_getdirect): New. (_gpgme_engine_ops_gpg): Connect new handler. * src/gpgme.h.in (gpgme_random_mode_t): New. (GPGME_RANDOM_MODE_NORMAL): New. (GPGME_RANDOM_MODE_ZBASE32): New. (gpgme_op_random_bytes): New public function * src/libgpgme.vers: Add function. * src/gpgme.def: Add function. * tests/run-genrandom.c: New. * tests/Makefile.am: Add new file. -- This is a first take on this the mode parameter allows to extend the function if ever needed. Due to the gpg calling and fd setup overhead this function is not yet very fast but its purpose is to get "approved" random bytes. We might eventually extend it to keep a small internal cache of random numbers and get for example 128 random bytes directly from gpg and deliver only the few required. GnuPG-bug-id: 6694
2024-08-06core: New function gpgme_op_setownertrustIngo Klöcker1-0/+1
* src/Makefile.am (main_sources): Add new file. * src/context.h (ctx_op_data_id_t): Add OPDATA_SETOWNERTRUST. * src/engine.c, src/engine.h (_gpgme_engine_op_setownertrust): New. * src/engine-backend.h (engine_ops): Add 'setownertrust' and adjust all engine initializers. * src/engine-gpg.c (gpg_setownertrust): New. (_gpgme_engine_ops_gpg): Set setownertrust to gpg_setownertrust. * src/gpgme.h.in (gpgme_op_setownertrust_start, gpgme_op_setownertrust): New. * src/gpgme.def, src/libgpgme.vers: Add new functions. * src/setownertrust.c: New. * doc/gpgme.texi: Document new functions. * tests/Makefile.am (noinst_PROGRAMS): Add new test program. * tests/run-setownertrust.c: New. * tests/gpg/Makefile.am (c_tests): Add new file. (LDADD): Add @GPG_ERROR_LIBS@. * tests/gpg/t-setownertrust.c: New. * tests/gpg/t-support.h (have_gpg_version): New. -- This extends GPGME to support the --quick-set-ownertrust command added by GnuPG 2.4.6. This allows changing the owner trust of keys and enabling/disabling keys without using the editinteractor interface. GnuPG-bug-id: 7239
2020-10-29core: New function gpgme_op_revsig.Ingo Klöcker1-0/+1
* src/gpgme.h.in (gpgme_op_revsig_start, gpgme_op_revsig): New. (GPGME_REVSIG_LFSEP): New. * src/context.h (ctx_op_data_id_t): Add OPDATA_REVSIG. * src/revsig.c: New. * src/Makefile.am (main_sources): Add revsig. * src/libgpgme.vers, src/gpgme.def: Add gpgme_op_revsig and gpgme_op_revsig_start. * src/engine.h, src/engine.c: (_gpgme_engine_op_revsig): New. * src/engine-backend.h (engine_ops): Add 'revsig' and adjust all engine initializers. * src/engine-gpg.c (gpg_revsig): New. (_gpgme_engine_ops_gpg): Set revsig to gpg_revsig. * doc/gpgme.texi: Document new functions. * tests/run-keysign.c: Add option --revoke. -- This extends GPGME to support the --quick-revoke-sig command added by GnuPG 2.2.24. This allows revoking key signatures. GnuPG-bug-id: 5094
2020-08-04core: New function gpgme_op_setexpire.Ingo Klöcker1-0/+1
* src/gpgme.h.in (gpgme_op_setexpire_start, gpgme_op_setexpire): New. * src/libgpgme.vers, src/gpgme.def: Add new functions. * src/genkey.c (setexpire): New. (gpgme_op_setexpire_start, gpgme_op_setexpire): New. * src/engine.h, src/engine.c: (_gpgme_engine_op_setexpire): New. * src/engine-backend.h (engine_ops): Add 'setexpire' and adjust all engine initializers. * src/engine-gpg.c (gpg_setexpire): New. (_gpgme_engine_ops_gpg): Set setexpire to gpg_setexpire. * doc/gpgme.texi: Document new functions. * tests/run-genkey.c: Add option --setexpire. -- This extends GPGME to support the --quick-set-expire command added by GnuPG 2.1.22. This allows changing subkeys expiry date without going through the editinteractor interface. Co-authored-by: Andre Heinecke <[email protected]> GnuPG-bug-id: 4999
2020-07-15core: Deprecate the non-working trustlist functions.Werner Koch1-1/+0
* src/gpgme.h.in: Clarify that the trustlist function should not be used. * src/engine.c (_gpgme_engine_op_trustlist): Always return an error. * src/engine-backend.h (struct engine_ops): Remove trustlist member. * src/engine-gpg.c (gpg_trustlist): Remove. (struct engine_ops): Remove that member. Also in all other engines. * tests/gpg/t-trustlist.c: Remove. * lang/python/tests/t-trustlist.py: Remove. -- This never worked in reality because the required feature has been removed from GnuPG version 1.3.2 soon after introduction of this feature in gpgme - 17 years ago. It was anyway marked as experimental. We keep the API and ABI, though. GnuPG-bug-id: 4834 Signed-off-by: Werner Koch <[email protected]>
2018-11-16core: Simplify the trace maros by using variadics.Werner Koch1-1/+1
* src/debug.h (TRACE_BEG, TRACE_LOG, TRACE_SUC): Use variadic macros and remove the TRACE_BEG1 et al. Change all users to always pass a format string. (TRACE): Ditto. * src/debug.c (_gpgme_debugf): New. * configure.ac <GCC>: Add -Wno-format-zero-length. -- This makes it easier for use to enable format checks. The zero-length format is required to allow for an empty format due to the comman problematic of __VA_ARGS__. Signed-off-by: Werner Koch <[email protected]>
2018-11-16Add SPDX identifiers to most source filesWerner Koch1-17/+18
-- Signed-off-by: Werner Koch <[email protected]>
2018-03-23core: New gpgme_set_ctx_flag "request-origin".Werner Koch1-0/+1
* src/context.h (gpgme_context): Add 'request_origin'. * src/gpgme.c (gpgme_release): Free that field. (gpgme_set_ctx_flag, gpgme_get_ctx_flag): Add "request-origin". * src/engine-backend.h (engine_ops): Add 'set_engine_ops' func ptr and adjust all users. * src/engine.c (_gpgme_engine_set_engine_flags): New. * src/op-support.c (_gpgme_op_reset): Call that func. * src/engine-gpg.c (struct engine_gpg): Add 'request_origin'. (gpg_set_engine_flags): New. (_gpgme_engine_ops_gpg): Hook it. (build_argv): Use command line option --request-origin. * src/engine-gpgsm.c (struct engine_gpgsm): Add 'request_origin'. (gpgsm_set_engine_flags): New. (_gpgme_engine_ops_gpgsm): Hook it. (start): Send OPTION "request-origin". * src/engine-assuan.c (struct engine_llass): Add 'request_origin'. (gpgsm_set_engine_flags): New. (_gpgme_engine_ops_assuan): Hook it. (start): Send OPTION "pretend-request-origin". Signed-off-by: Werner Koch <[email protected]>
2018-02-09core, w32: Enable spawning GUI applicationsAndre Heinecke1-1/+2
* src/engine-spawn.c (engspawn_start): Translate spawn flag to IOSPAWN flag. * src/gpgme-w32spawn.c (my_spawn): Handle the new flag. * src/gpgme.h.in (GPGME_SPAWN_SHOW_WINDOW): New. * src/priv-io.h (IOSPAWN_FLAG_SHOW_WINDOW): New. -- Used by GpgOL
2017-08-15gpgconf: Add access to --list-dirs for non-default engine.Marcus Brinkmann1-0/+1
* src/engine-assuan.c (_gpgme_engine_ops_assuan): Add conf_dir. * src/engine-g13.c (_gpgme_engine_ops_g13): Likewise. * src/engine-gpg.c (_gpgme_engine_ops_gpg): Likewise. * src/engine-gpgsm.c (_gpgme_engine_ops_gpgsm): Likewise. * src/engine-spawn.c (_gpgme_engine_ops_spawn): Likewise. * src/engine-uiserver.c (_gpgme_engine_ops_uiserver): Likewise. * src/engine-backend.h (struct engine_ops): Likewise. * src/engine-gpgconf.c (gpgconf_config_dir_cb, gpgconf_conf_dir): New functions. (struct engine_ops): Add gpgconf_conf_dir. * src/engine.c (_gpgme_engine_op_conf_dir): New function. * src/engine.h (_gpgme_engine_op_conf_dir): New prototype. * src/gpgconf.c (gpgme_op_conf_dir): New function. * src/gpgme.def (gpgme_op_conf_save): New symbol. * src/gpgme.h.in (gpgme_op_conf_dir): New prototype. * src/libgpgme.vers (gpgme_op_conf_dir): New symbol. * tests/gpg/t-gpgconf.c (main): Test gpgme_op_conf_dir. Signed-off-by: Marcus Brinkmann <[email protected]> GnuPG-bug-id: 3018
2017-03-24core: New flags GPGME_DECRYPT_UNWRAP and GPGME_ENCRYPT_WRAP.Werner Koch1-1/+0
* 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 <[email protected]>
2017-03-21core: New public API gpgme_op_keylist_from_data_start.Andre Heinecke1-0/+1
* 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 <[email protected]> GnuPG-bug-id: 2819
2016-11-16doc: Replace http: by https: in core source files.Werner Koch1-1/+1
-- Signed-off-by: Werner Koch <[email protected]>
2016-11-03core: Add gpgme_op_query_swdb and helper.Werner Koch1-0/+1
* src/gpgme.h.in (gpgme_query_swdb_result_t): New. (gpgme_op_query_swdb): New. (gpgme_op_query_swdb_result): New. * src/libgpgme.vers, src/gpgme.def: Add the two new functions. * src/queryswdb.c: New. * src/Makefile.am (main_sources): Add new file. * src/context.h (OPDATA_QUERY_SWDB): New. * src/engine-backend.h (struct engine_ops): Add field 'query_swdb'. Adjust all initializer. * src/engine.c (_gpgme_engine_op_query_swdb): New. * src/engine-gpgconf.c (parse_swdb_line): New. (gpgconf_query_swdb): New. (_gpgme_engine_ops_gpgconf): Register that function. * src/util.h (GPG_ERR_TOO_OLD): Define for older libgpg-error. (GPG_ERR_ENGINE_TOO_OLD): Ditto. * tests/run-swdb.c: New. * tests/Makefile.am (noinst_PROGRAMS): Add new debug tool. Signed-off-by: Werner Koch <[email protected]>
2016-09-14core: New function gpgme_op_tofu_policyWerner Koch1-0/+1
* src/gpgme.h.in (gpgme_op_tofu_policy_start): New function. (gpgme_op_tofu_policy): New function. * src/libgpgme.vers, src/gpgme.def: Add new functions. * src/tofupolicy.c: New. * src/Makefile.am (main_sources): Add that file. * src/context.h (ctx_op_data_id_t): Add OPDATA_TOFU_POLICY. * src/engine.c (_gpgme_engine_op_tofu_policy): New. * src/engine-backend.h (engine_ops): Add funcptr 'tofu_policy'. Adjust all engine initializations. * src/engine-gpg.c (gpg_tofu_policy): New. (_gpgme_engine_ops_gpg): Register this function. * tests/run-tofu.c: New. * tests/Makefile.am (noinst_PROGRAMS): Add it. Signed-off-by: Werner Koch <[email protected]>
2016-09-14core: New function gpgme_op_keysign.Werner Koch1-0/+1
* src/gpgme.h.in (gpgme_op_keysign_start, gpgme_op_keysign): New. (GPGME_KEYSIGN_LOCAL): New. (GPGME_KEYSIGN_LFSEP): New. (GPGME_KEYSIGN_NOEXPIRE): New. * src/context.h (ctx_op_data_id_t): Add OPDATA_KEYSIGN. * src/keysign.c: New. * src/Makefile.am (main_sources): Add keysig. * src/libgpgme.vers, src/gpgme.def: Add gpgme_op_keysign_start. * src/engine.c (_gpgme_engine_op_keysign): New. * src/engine-backend.h (engine_ops): Add 'keysign' and adjust all engine initializers. * src/engine-gpg.c (_add_arg): Add args PREFIX and ARGLEN and change callers to set them. (add_arg_pfx): New. (add_arg_len): New. (gpg_keysign): New. (_gpgme_engine_ops_gpg): Set keysign to gpg_keysign. * tests/run-keysign.c: New. * tests/Makefile.am (noinst_PROGRAMS): Add run-keysign. Signed-off-by: Werner Koch <[email protected]>
2016-08-16core: Simplify setting of dummy versions.Werner Koch1-2/+2
* src/engine.c (_gpgme_engine_info_release): Do not assert but free FILE_NAME. (gpgme_get_engine_info): Provide default for VERSION and REQ_VERSION. Use calloc instead of malloc. (_gpgme_set_engine_info): Ditto. * src/engine-assuan.c (llass_get_version): Return NULL. (llass_get_req_version): Ditto. * src/engine-spawn.c (engspawn_get_version): Ditto. (engspawn_get_req_version): Ditto. * src/engine-uiserver.c (uiserver_get_version): Ditto. (uiserver_get_req_version): Ditto. Signed-off-by: Werner Koch <[email protected]>
2016-07-28src: Fix dummy engine versions.Justus Winter1-2/+2
Previously, 'gpgme_engine_check_version' failed for these protocols because the version parser failed to parse the dummy versions. * src/engine-assuan.c (llass_get_version): Use a version triple that the parser can understand. (llass_get_req_version): Likewise. * src/engine-spawn.c (engspawn_get_version): Likewise. (engspawn_get_req_version): Likewise. * src/engine-uiserver.c (uiserver_get_version): Likewise. (uiserver_get_req_version): Likewise. Signed-off-by: Justus Winter <[email protected]>
2016-07-13core: Pass the engine's version string to the engine's new function.Werner Koch1-1/+3
* src/engine-backend.h (engine_ops): Add arg 'version' to NEW. * src/engine-assuan.c (llass_new): Add dummy arg 'version'. * src/engine-g13.c (g13_new): Ditto. * src/engine-gpgconf.c (gpgconf_new): Ditto. * src/engine-gpgsm.c (gpgsm_new): Ditto. * src/engine-spawn.c (engspawn_new): Ditto. * src/engine-uiserver.c (uiserver_new): Ditto. * src/engine.c (_gpgme_engine_new): Pass version string to the new function. * src/engine-gpg.c (struct engine_gpg): Add field 'version'. (gpg_new): Add arg 'version'. (gpg_release): Free VERSION. Signed-off-by: Werner Koch <[email protected]>
2016-05-19api: Add new function gpgme_set_ctx_flag.Werner Koch1-0/+1
* src/gpgme.h.in (gpgme_set_ctx_flag): New prototype. * src/gpgme.c (gpgme_set_ctx_flag): New. * src/gpgme.def, src/libgpgme.vers: Add new function. * src/context.h (struct gpgme_context): Add FULL_STATUS. * src/decrypt.c (_gpgme_decrypt_status_handler): Do not call the status callback if FULL_STATUS is set. * src/genkey.c (genkey_status_handler): Ditto. * src/passphrase.c (_gpgme_passphrase_status_handler): Ditto. * src/sign.c (_gpgme_sign_status_handler): Ditto. * src/engine-backend.h (struct engine_ops): Add SET_STATUS_CB and add adjust all definitions of that variable. * src/engine.c (_gpgme_engine_set_status_cb): New. * src/op-support.c (_gpgme_op_reset): Call this function. * src/engine-gpg.c (struct engine_gpg): Add fields MON_CB and MON_CB_VALUE. (gpg_set_status_cb): New. (_gpgme_engine_ops_gpg): Register that function. (read_status): Call the monitor callback. * src/engine-gpgsm.c (struct engine_gpgsm): Add fields MON_CB and MON_CB_VALUE. (_gpgme_engine_ops_gpgsm): Register that function. (gpgsm_assuan_simple_command): Change first arg to be an engine context and adjust call callers. Call the monitor callback. * src/engine-uiserver.c (struct engine_uiserver): Add fields MON_CB and MON_CB_VALUE. (_gpgme_engine_ops_uiserver): Register that function. (uiserver_assuan_simple_command): Change first arg to be an engine context and adjust call callers. Call the monitor callback. * tests/run-verify.c (status_cb): New. (print_result): Print algo names. (main): Add option --status. -- This new feature is mainly intended for bug tracking. Having access to the raw status lines might also be useful for applications, though. Signed-off-by: Werner Koch <[email protected]>
2015-03-16Fix potential crash in trace macro.Werner Koch1-2/+1
* 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 <[email protected]>
2015-03-16Fix one byte too short malloc.Werner Koch1-1/+1
* 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.
2014-05-08Fix a memory access and a double slash bug.Werner Koch1-1/+1
* 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-04-10Actually implement flags for gpgme_op_spawn.Werner Koch1-0/+8
* 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-10Add GPGME_PROTOCOL_SPAWN and gpgme_op_spawn.Werner Koch1-0/+467
* 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.