aboutsummaryrefslogtreecommitdiffstats
path: root/src/engine-gpgsm.c
diff options
context:
space:
mode:
authorIngo Klöcker <[email protected]>2023-08-14 10:23:07 +0000
committerIngo Klöcker <[email protected]>2023-08-14 10:24:00 +0000
commitbc98f01c8599f612dd1035b08f827b0657d94984 (patch)
treede93673216394605c2ab53357af468fba10efb23 /src/engine-gpgsm.c
parentcore: Store engine's version string in gpgsm engine (diff)
downloadgpgme-bc98f01c8599f612dd1035b08f827b0657d94984.tar.gz
gpgme-bc98f01c8599f612dd1035b08f827b0657d94984.zip
core: Use offline mode for all operations of gpgsm engine
* src/engine-backend.h (keylist, keylist_ext): Remove engine_flags. * src/engine-gpg.c (gpg_keylist, gpg_keylist_ext): Ditto. * src/engine.c, src/engine.h (_gpgme_engine_op_keylist): Ditto. (_gpgme_engine_op_keylist_ext): Ditto. * src/engine.h (GPGME_ENGINE_FLAG_OFFLINE): Remove. * src/engine-gpgsm.c (struct engine_gpgsm): New field flags with offline flag. (have_gpgsm_version): New. (gpg_set_engine_flags): Set the offline flag. (start): Send OPTION "offline". (gpgsm_keylist, gpgsm_keylist_ext): Remove engine_flags. Remove sending of OPTION "offline". * src/keylist.c (gpgme_op_keylist_start, gpgme_op_keylist_ext_start): Remove setting of offline flag. -- GnuPG-bug-id: 6648
Diffstat (limited to 'src/engine-gpgsm.c')
-rw-r--r--src/engine-gpgsm.c34
1 files changed, 21 insertions, 13 deletions
diff --git a/src/engine-gpgsm.c b/src/engine-gpgsm.c
index cfbef315..8a8beb87 100644
--- a/src/engine-gpgsm.c
+++ b/src/engine-gpgsm.c
@@ -114,6 +114,10 @@ struct engine_gpgsm
/* Memory data containing diagnostics (--logger-fd) of gpgsm */
gpgme_data_t diagnostics;
+
+ struct {
+ unsigned int offline : 1;
+ } flags;
};
typedef struct engine_gpgsm *engine_gpgsm_t;
@@ -123,6 +127,13 @@ static void gpgsm_io_event (void *engine,
gpgme_event_io_t type, void *type_data);
+/* Return true if the engine's version is at least VERSION. */
+static int
+have_gpgsm_version (engine_gpgsm_t gpgsm, const char *version)
+{
+ return _gpgme_compare_versions (gpgsm->version, version);
+}
+
static char *
gpgsm_get_version (const char *file_name)
@@ -613,6 +624,8 @@ gpgsm_set_engine_flags (void *engine, const gpgme_ctx_t ctx)
}
else
*gpgsm->request_origin = 0;
+
+ gpgsm->flags.offline = (ctx->offline && have_gpgsm_version (gpgsm, "2.1.6"));
}
@@ -1175,6 +1188,12 @@ start (engine_gpgsm_t gpgsm, const char *command)
return err;
}
+ gpgsm_assuan_simple_command (gpgsm,
+ gpgsm->flags.offline ?
+ "OPTION offline=1":
+ "OPTION offline=0" ,
+ NULL, NULL);
+
/* We need to know the fd used by assuan for reads. We do this by
using the assumption that the first returned fd from
assuan_get_active_fds() is always this one. */
@@ -1872,7 +1891,7 @@ gpgsm_import (void *engine, gpgme_data_t keydata, gpgme_key_t *keyarray,
static gpgme_error_t
gpgsm_keylist (void *engine, const char *pattern, int secret_only,
- gpgme_keylist_mode_t mode, int engine_flags)
+ gpgme_keylist_mode_t mode)
{
engine_gpgsm_t gpgsm = engine;
char *line;
@@ -1928,12 +1947,6 @@ gpgsm_keylist (void *engine, const char *pattern, int secret_only,
"OPTION with-secret=1":
"OPTION with-secret=0" ,
NULL, NULL);
- gpgsm_assuan_simple_command (gpgsm,
- (engine_flags & GPGME_ENGINE_FLAG_OFFLINE)?
- "OPTION offline=1":
- "OPTION offline=0" ,
- NULL, NULL);
-
/* Length is "LISTSECRETKEYS " + p + '\0'. */
line = malloc (15 + strlen (pattern) + 1);
@@ -1963,7 +1976,7 @@ gpgsm_keylist (void *engine, const char *pattern, int secret_only,
static gpgme_error_t
gpgsm_keylist_ext (void *engine, const char *pattern[], int secret_only,
- int reserved, gpgme_keylist_mode_t mode, int engine_flags)
+ int reserved, gpgme_keylist_mode_t mode)
{
engine_gpgsm_t gpgsm = engine;
char *line;
@@ -2003,11 +2016,6 @@ gpgsm_keylist_ext (void *engine, const char *pattern[], int secret_only,
"OPTION with-secret=1":
"OPTION with-secret=0" ,
NULL, NULL);
- gpgsm_assuan_simple_command (gpgsm,
- (engine_flags & GPGME_ENGINE_FLAG_OFFLINE)?
- "OPTION offline=1":
- "OPTION offline=0" ,
- NULL, NULL);
if (pattern && *pattern)
{