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
free_argv (char **argv)
{
@ -1669,21 +1677,17 @@ start (engine_gpg_t gpg)
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];
_gpgme_io_fd2str (buf, sizeof (buf), gpg->status.fd[1]);
rc = add_arg_with_locp (gpg, buf, &gpg->status.arg_loc, 1);
if (rc)
return rc;
}
{
char buf[25];
_gpgme_io_fd2str (buf, sizeof (buf), gpg->status.fd[1]);
rc = add_arg_with_locp (gpg, buf, &gpg->status.arg_loc, 1);
if (rc)
return rc;
}
rc = add_arg_ext (gpg, "--status-fd", 1);
if (rc)
return rc;
}
rc = add_arg_ext (gpg, "--status-fd", 1);
if (rc)
return rc;
if (gpg->lc_ctype)
{
@ -1832,7 +1836,7 @@ gpg_decrypt (void *engine,
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);
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);
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);
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);
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);
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);
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);
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);
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);
err = append_args_from_sender (gpg, ctx);