diff options
author | Anne Jan Brouwer <brouwer@annejan.com> | 2023-08-31 12:46:54 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-31 12:46:54 +0200 |
commit | d591acf19b5c999c6d1dceb7b3e45d13d565d701 (patch) | |
tree | 559da03f5ad2dab9b13c74da66304c178b84dbec /src/pass.cpp | |
parent | bd1f363d72c71324232e11b2029000fb3bd5876a (diff) | |
parent | 1da3f142b53e33af3862112270cdbf2430fa1453 (diff) |
Merge branch 'main' into svuorela/clazy-and-other-minor-fixes
Diffstat (limited to 'src/pass.cpp')
-rw-r--r-- | src/pass.cpp | 64 |
1 files changed, 49 insertions, 15 deletions
diff --git a/src/pass.cpp b/src/pass.cpp index 1e5db45d..efa665dd 100644 --- a/src/pass.cpp +++ b/src/pass.cpp @@ -246,8 +246,29 @@ void Pass::finished(int id, int exitCode, const QString &out, * switching profiles) */ void Pass::updateEnv() { - QStringList store = env.filter("PASSWORD_STORE_DIR="); + // put PASSWORD_STORE_SIGNING_KEY in env + QStringList envSigningKey = env.filter("PASSWORD_STORE_SIGNING_KEY="); + QString currentSigningKey = QtPassSettings::getPassSigningKey(); + if (envSigningKey.isEmpty()) { + if (!currentSigningKey.isEmpty()) { + // dbg()<< "Added + // PASSWORD_STORE_SIGNING_KEY with" + currentSigningKey; + env.append("PASSWORD_STORE_SIGNING_KEY=" + currentSigningKey); + } + } else { + if (currentSigningKey.isEmpty()) { + // dbg() << "Removed + // PASSWORD_STORE_SIGNING_KEY"; + env.removeAll(envSigningKey.first()); + } else { + // dbg()<< "Update + // PASSWORD_STORE_SIGNING_KEY with " + currentSigningKey; + env.replaceInStrings(envSigningKey.first(), + "PASSWORD_STORE_SIGNING_KEY=" + currentSigningKey); + } + } // put PASSWORD_STORE_DIR in env + QStringList store = env.filter("PASSWORD_STORE_DIR="); if (store.isEmpty()) { // dbg()<< "Added // PASSWORD_STORE_DIR"; @@ -262,27 +283,40 @@ void Pass::updateEnv() { } /** - * @brief Pass::getRecipientList return list of gpg-id's to encrypt for - * @param for_file which file (folder) would you like recepients for - * @return recepients gpg-id contents + * @brief Pass::getGpgIdPath return gpgid file path for some file (folder). + * @param for_file which file (folder) would you like the gpgid file path for. + * @return path to the gpgid file. */ -QStringList Pass::getRecipientList(QString for_file) { - QDir gpgIdPath(QFileInfo(for_file.startsWith(QtPassSettings::getPassStore()) - ? for_file - : QtPassSettings::getPassStore() + for_file) - .absoluteDir()); +QString Pass::getGpgIdPath(QString for_file) { + QString passStore = + QDir::fromNativeSeparators(QtPassSettings::getPassStore()); + QDir gpgIdDir( + QFileInfo(QDir::fromNativeSeparators(for_file).startsWith(passStore) + ? for_file + : QtPassSettings::getPassStore() + for_file) + .absoluteDir()); bool found = false; - while (gpgIdPath.exists() && - gpgIdPath.absolutePath().startsWith(QtPassSettings::getPassStore())) { - if (QFile(gpgIdPath.absoluteFilePath(".gpg-id")).exists()) { + while (gpgIdDir.exists() && gpgIdDir.absolutePath().startsWith(passStore)) { + if (QFile(gpgIdDir.absoluteFilePath(".gpg-id")).exists()) { found = true; break; } - if (!gpgIdPath.cdUp()) + if (!gpgIdDir.cdUp()) break; } - QFile gpgId(found ? gpgIdPath.absoluteFilePath(".gpg-id") - : QtPassSettings::getPassStore() + ".gpg-id"); + QString gpgIdPath(found ? gpgIdDir.absoluteFilePath(".gpg-id") + : QtPassSettings::getPassStore() + ".gpg-id"); + + return gpgIdPath; +} + +/** + * @brief Pass::getRecipientList return list of gpg-id's to encrypt for + * @param for_file which file (folder) would you like recepients for + * @return recepients gpg-id contents + */ +QStringList Pass::getRecipientList(QString for_file) { + QFile gpgId(getGpgIdPath(for_file)); if (!gpgId.open(QIODevice::ReadOnly | QIODevice::Text)) return QStringList(); QStringList recipients; |