commit 1a8afc64046be922734681fc89ebfc3087926e1a
parent b6125d891ded37178636978d899ea6d93547503c
Author: Dan Vrátil <me@dvratil.cz>
Date: Tue, 29 Jun 2021 23:28:40 +0200
Merge pull request #13 from razcampagne/master
Don’t use pinentry-mode option when using gpg2 version < 2.1
Diffstat:
1 file changed, 18 insertions(+), 11 deletions(-)
diff --git a/src/gpg.cpp b/src/gpg.cpp
@@ -217,17 +217,24 @@ void Gpg::DecryptTask::run()
const auto gpg = findGpgExecutable();
QProcess process;
process.setProgram(gpg.path);
- process.setArguments({QStringLiteral("--quiet"),
- QStringLiteral("--batch"),
- QStringLiteral("--decrypt"),
- QStringLiteral("--no-tty"),
- QStringLiteral("--command-fd=1"),
- QStringLiteral("--no-encrypt-to"),
- QStringLiteral("--compress-algo=none"),
- QStringLiteral("--passphrase-fd=0"),
- QStringLiteral("--pinentry-mode=loopback"),
- QStringLiteral("-r %1").arg(mKey.id),
- mFile});
+ QStringList arguments{
+ QStringLiteral("--quiet"),
+ QStringLiteral("--batch"),
+ QStringLiteral("--decrypt"),
+ QStringLiteral("--no-tty"),
+ QStringLiteral("--command-fd=1"),
+ QStringLiteral("--no-encrypt-to"),
+ QStringLiteral("--compress-algo=none"),
+ QStringLiteral("--passphrase-fd=0")
+ };
+
+ if (gpg.minor_version >= 1) {
+ arguments << QStringLiteral("--pinentry-mode=loopback");
+ }
+
+ arguments << QStringLiteral ("-r %1").arg (mKey.id) << mFile;
+
+ process.setArguments(arguments);
process.start();
process.waitForStarted();
process.write(mPassphrase.toUtf8());