sailfish-safe

Sailfish frontend for safe(1)
git clone git://git.z3bra.org/sailfish-safe.git
Log | Files | Refs | README | LICENSE

commit 5bbbd6260a1bd03e6b251efc890e62dd7c720029
parent b6125d891ded37178636978d899ea6d93547503c
Author: Renaud Casenave-Péré <renaud@casenave-pere.fr>
Date:   Tue, 29 Jun 2021 21:56:30 +0200

Don’t use pinentry-mode option when using gpg2 version < 2.1

Diffstat:
Msrc/gpg.cpp | 29++++++++++++++++++-----------
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());