core: Allow usage of gpgtar also for new enough gpg 2.2

* src/engine-gpg.c (have_usable_gpgtar): New.
(start): Always pass --status-fd to the called process.
(gpg_decrypt, gpg_encrypt, gpg_encrypt_sign, gpg_sign, gpg_verify):
Use have_usable_gpgtar() to check for suitable gpg.
--

The version check in start() is not needed because versions of gpg
that are unsuitable for the usage of gpgtar are rejected already by
the callers.

GnuPG-bug-id: 6342
This commit is contained in:
Ingo Klöcker 2023-02-01 09:27:12 +01:00
parent 5ab9c234d6
commit 7f541547fc
No known key found for this signature in database
GPG Key ID: F5A5D1692277A1E9

View File

@ -389,6 +389,14 @@ gpg_get_req_version (void)
} }
static int
have_usable_gpgtar (engine_gpg_t gpg)
{
return have_gpg_version (gpg, "2.4.1")
|| (have_gpg_version (gpg, "2.2.42") && !have_gpg_version (gpg, "2.3.0"));
}
static void static void
free_argv (char **argv) free_argv (char **argv)
{ {
@ -1669,9 +1677,6 @@ start (engine_gpg_t gpg)
return rc; return rc;
} }
if (!gpg->flags.use_gpgtar || have_gpg_version (gpg, "2.4.1"))
{
/* Do not pass --status-fd to gpgtar for gpg < 2.4.1. */
{ {
char buf[25]; char buf[25];
_gpgme_io_fd2str (buf, sizeof (buf), gpg->status.fd[1]); _gpgme_io_fd2str (buf, sizeof (buf), gpg->status.fd[1]);
@ -1683,7 +1688,6 @@ start (engine_gpg_t gpg)
rc = add_arg_ext (gpg, "--status-fd", 1); rc = add_arg_ext (gpg, "--status-fd", 1);
if (rc) if (rc)
return rc; return rc;
}
if (gpg->lc_ctype) if (gpg->lc_ctype)
{ {
@ -1832,7 +1836,7 @@ gpg_decrypt (void *engine,
gpg->flags.use_gpgtar = !!(flags & GPGME_DECRYPT_ARCHIVE); gpg->flags.use_gpgtar = !!(flags & GPGME_DECRYPT_ARCHIVE);
if (gpg->flags.use_gpgtar && !have_gpg_version (gpg, "2.4.1")) if (gpg->flags.use_gpgtar && !have_usable_gpgtar (gpg))
return gpg_error (GPG_ERR_NOT_SUPPORTED); return gpg_error (GPG_ERR_NOT_SUPPORTED);
if (gpg->flags.use_gpgtar && (flags & GPGME_DECRYPT_UNWRAP)) if (gpg->flags.use_gpgtar && (flags & GPGME_DECRYPT_UNWRAP))
@ -2334,7 +2338,7 @@ gpg_encrypt (void *engine, gpgme_key_t recp[], const char *recpstring,
gpg->flags.use_gpgtar = !!(flags & GPGME_ENCRYPT_ARCHIVE); gpg->flags.use_gpgtar = !!(flags & GPGME_ENCRYPT_ARCHIVE);
if (gpg->flags.use_gpgtar && !have_gpg_version (gpg, "2.4.1")) if (gpg->flags.use_gpgtar && !have_usable_gpgtar (gpg))
return gpg_error (GPG_ERR_NOT_SUPPORTED); return gpg_error (GPG_ERR_NOT_SUPPORTED);
if (gpg->flags.use_gpgtar && (flags & GPGME_ENCRYPT_WRAP)) if (gpg->flags.use_gpgtar && (flags & GPGME_ENCRYPT_WRAP))
@ -2449,7 +2453,7 @@ gpg_encrypt_sign (void *engine, gpgme_key_t recp[],
gpg->flags.use_gpgtar = !!(flags & GPGME_ENCRYPT_ARCHIVE); gpg->flags.use_gpgtar = !!(flags & GPGME_ENCRYPT_ARCHIVE);
if (gpg->flags.use_gpgtar && !have_gpg_version (gpg, "2.4.1")) if (gpg->flags.use_gpgtar && !have_usable_gpgtar (gpg))
return gpg_error (GPG_ERR_NOT_SUPPORTED); return gpg_error (GPG_ERR_NOT_SUPPORTED);
if (recp || recpstring) if (recp || recpstring)
@ -3594,7 +3598,7 @@ gpg_sign (void *engine, gpgme_data_t in, gpgme_data_t out,
gpg->flags.use_gpgtar = !!(flags & GPGME_SIG_MODE_ARCHIVE); gpg->flags.use_gpgtar = !!(flags & GPGME_SIG_MODE_ARCHIVE);
if (gpg->flags.use_gpgtar && !have_gpg_version (gpg, "2.4.1")) if (gpg->flags.use_gpgtar && !have_usable_gpgtar (gpg))
return gpg_error (GPG_ERR_NOT_SUPPORTED); return gpg_error (GPG_ERR_NOT_SUPPORTED);
if (flags & GPGME_SIG_MODE_CLEAR) if (flags & GPGME_SIG_MODE_CLEAR)
@ -3678,7 +3682,7 @@ gpg_verify (void *engine, gpgme_verify_flags_t flags, gpgme_data_t sig,
gpg->flags.use_gpgtar = !!(flags & GPGME_VERIFY_ARCHIVE); gpg->flags.use_gpgtar = !!(flags & GPGME_VERIFY_ARCHIVE);
if (gpg->flags.use_gpgtar && !have_gpg_version (gpg, "2.4.1")) if (gpg->flags.use_gpgtar && !have_usable_gpgtar (gpg))
return gpg_error (GPG_ERR_NOT_SUPPORTED); return gpg_error (GPG_ERR_NOT_SUPPORTED);
err = append_args_from_sender (gpg, ctx); err = append_args_from_sender (gpg, ctx);