Unverified Commit 565b6c31 authored by Rolf Eike Beer's avatar Rolf Eike Beer
Browse files

use the configured config file and directory when generating keys in expert mode

BUG:428215
parent 7f164118
......@@ -131,19 +131,7 @@ void GnupgBinary::setBinary(const QString &executable)
<< QLatin1String( "--no-tty" )
<< QLatin1String("--no-greeting");
if (!gpgConfigFile.isEmpty()) {
m_standardArguments << QLatin1String("--options")
<< gpgConfigFile;
// Check if the config file is in the default home directory
// of the binary. If it isn't add --homedir to command line also.
QString gpgdir = GPGProc::getGpgHome(executable);
gpgdir.chop(1); // remove trailing '/' as QFileInfo returns string without it
QFileInfo confFile(gpgConfigFile);
if (confFile.absolutePath() != gpgdir)
m_standardArguments << QLatin1String("--homedir")
<< confFile.absolutePath();
}
m_standardArguments << GPGProc::getGpgHomeArguments(executable);
QStringList debugLevelArguments(QLatin1String("--debug-level"));
debugLevelArguments << QLatin1String("none");
......@@ -407,3 +395,24 @@ QString GPGProc::getGpgHome(const QString &binary)
#endif
return gpgHome;
}
QStringList
GPGProc::getGpgHomeArguments(const QString &binary)
{
const QString gpgConfigFile = KGpgSettings::gpgConfigPath();
if (gpgConfigFile.isEmpty())
return {};
QStringList options{ QLatin1String("--options"), gpgConfigFile };
// Check if the config file is in the default home directory
// of the binary. If it isn't add --homedir to command line also.
QString gpgdir = GPGProc::getGpgHome(binary);
gpgdir.chop(1); // remove trailing '/' as QFileInfo returns string without it
QFileInfo confFile(gpgConfigFile);
if (confFile.absolutePath() != gpgdir)
options << QLatin1String("--homedir") << confFile.absolutePath();
return options;
}
......@@ -141,6 +141,13 @@ public:
*/
static QString getGpgHome(const QString &binary);
/**
* @brief get arguments to set the configuration file and home directory
* @param binary name or path to GnuPG binary
* @return GnuPG argument list
*/
static QStringList getGpgHomeArguments(const QString &binary);
/**
* @brief return a list of the public key algorithms GnuPG announces support for
* @param binary name or path to GnuPG binary
......
......@@ -518,6 +518,8 @@ void KeysManager::slotGenerateKey()
else
gpg_args += QLatin1String(" --gen-key");
gpg_args += GPGProc::getGpgHomeArguments(gpgbin).join(QLatin1Char(' '));
QStringList args;
args << QLatin1String( "-e" )
<< gpg_args;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment