QtPass 2.0.0
Developer documentation
Loading...
Searching...
No Matches
pass.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2016 Anne Jan Brouwer
2// SPDX-License-Identifier: GPL-3.0-or-later
9#ifndef SRC_PASS_H_
10#define SRC_PASS_H_
11
12#include "appsettings.h"
13#include "enums.h"
14#include "executor.h"
15#include "gpgidgeneration.h"
16#include "userinfo.h"
17
18#include <QProcess>
19#include <QProcessEnvironment>
20#include <QQueue>
21#include <QSet>
22#include <QString>
23#include <QStringList>
24
25class GpgIdSigner;
26#include <QHash>
27#include <cassert>
28#include <map>
29#include <optional>
30
44 QString program;
49 QStringList arguments;
50};
51
77class Pass : public QObject {
78 Q_OBJECT
79
81 bool wrapperRunning{false};
87 QProcessEnvironment env;
88
89protected:
95 virtual auto fullKeyListing(QString *listing) -> int;
102 auto refuseKeyLinesHeldTwice(const QStringList &lines) -> bool;
108 static auto enabledKeyLines(const QList<UserInfo> &users) -> QStringList;
115 static auto withoutStatusLines(const QString &err) -> QString;
124 [[nodiscard]] auto storeEnvironment() const -> QProcessEnvironment {
125 return withCurrentGitPin(env);
126 }
127
136 [[nodiscard]] auto withCurrentGitPin(QProcessEnvironment base) const
137 -> QProcessEnvironment;
138
150
155
156public:
158 struct SkippedWalk {
160 std::optional<QString> skipped;
162 QString recordError;
163 };
164
165 using SkippedWalks = QHash<QString, SkippedWalk>;
168 using LinkedWalks = QHash<QString, std::optional<QString>>;
169
173 Pass();
178 void init(const AppSettings &settings);
184 static bool gpgSupportsEd25519(const QString &gpgExecutable = {});
190 static QString getDefaultKeyTemplate(const QString &gpgExecutable = {});
191
192 ~Pass() override = default;
193
194 // Git operations
198 virtual void GitInit() = 0;
202 virtual void GitPull() = 0;
213 virtual void GitPull_b(int timeoutMs) = 0;
214
216 static constexpr int kBlockingPullMs = 30000;
220 virtual void GitPush() = 0;
221
222 // Password operations
227 virtual void Show(QString file) = 0;
234 virtual void Insert(QString file, QString value, bool force) = 0;
245 [[nodiscard]] auto insertsPending() const -> int { return m_insertsPending; }
250 struct EditReaders {
253 QStringList names;
257 bool notSavedHere = false;
263 auto operator==(const EditReaders &other) const -> bool {
264 return names == other.names && notSavedHere == other.notSavedHere;
265 }
266 };
267
282 virtual auto readersAnEditWouldAdd(const QString &file) -> EditReaders {
283 Q_UNUSED(file)
284 return {};
285 }
286
296 virtual auto entriesInitWouldWiden(const QString &dir,
297 const QList<UserInfo> &users)
298 -> QStringList {
299 Q_UNUSED(dir)
300 Q_UNUSED(users)
301 return {};
302 }
303
312 virtual auto entriesMoveWouldWiden(const QString &src, const QString &dest)
313 -> QStringList {
314 Q_UNUSED(src)
315 Q_UNUSED(dest)
316 return {};
317 }
318
324 auto entryReaders(const QString &path) -> QStringList;
336 [[nodiscard]] auto reportedInsert() const -> QString {
337 return m_reportedInsert;
338 }
339
344 virtual void Remove(QString file, bool isDir) = 0;
351 virtual void Move(const QString srcDir, const QString dest,
352 const bool force) = 0;
359 virtual void Copy(const QString srcDir, const QString dest,
360 const bool force) = 0;
366 virtual void Init(QString path, const QList<UserInfo> &users) = 0;
377 virtual void Grep(QString pattern, bool caseInsensitive) = 0;
378
384 virtual void CancelGrep() {}
385
392 virtual auto generatePassword(unsigned int length, const QString &charset)
393 -> QString;
394
395 // GPG operations
400 void GenerateGPGKeys(QString batch);
407 auto listKeys(QStringList keystrings, bool secret = false) -> QList<UserInfo>;
421 virtual auto encryptionReaches(const QStringList &recipients)
422 -> std::optional<QStringList>;
431 [[nodiscard]] virtual auto recipientArgument(const QString &line) const
432 -> QString;
445 static auto exactRecipientArg(const QString &line) -> QString;
459 auto keyLinesHeldTwice(const QStringList &lines)
460 -> std::optional<QHash<QString, QStringList>>;
470 auto exportPublicKeys(const QString &gpg, const QStringList &keys,
471 QString *out, QString *err) -> int;
479 static auto keyLinesHeldTwiceIn(const QStringList &lines,
480 const QString &listing)
481 -> QHash<QString, QStringList>;
489 static auto describeKeyLinesHeldTwice(
490 const std::optional<QHash<QString, QStringList>> &held) -> QString;
497 auto listKeys(const QString &keystring = "", bool secret = false)
498 -> QList<UserInfo>;
502 void updateEnv();
503
511 static constexpr qint64 kMaxPlaintextBytes = 64LL * 1024 * 1024;
512
518 [[nodiscard]] static auto pullTimedOut(int timeoutMs) -> QString;
519
524 static auto maxOutputArgs() -> QStringList;
525
526 // Static helpers
532 static auto resolveGpgconfCommand(const QString &gpgPath)
540 static auto getGpgIdPath(const QString &for_file, const QString &passStore)
541 -> QString;
568 static auto skippedGpgId(const QString &forFile, const QString &passStore,
569 QString *recordError = nullptr,
570 SkippedWalks *walks = nullptr)
571 -> std::optional<QString>;
588 static auto linkedGpgId(const QString &forFile, const QString &passStore,
589 LinkedWalks *walks = nullptr)
590 -> std::optional<QString>;
597 static auto getRecipientList(const QString &for_file,
598 const QString &passStore) -> QStringList;
599
606 enum class State {
608 Unsigned,
610 Verified,
616 VerifiedRollback,
622 Rejected,
623 };
624
627 QStringList recipients;
629 QString warning;
630 };
631
650 auto recipientsForEditing(const QString &dir, const QString &passStore)
672 auto initIfUnchanged(const QString &path, const QList<UserInfo> &users,
673 const QString &dir, const QString &passStore,
674 const RecipientsForEditing &read) -> bool;
682 static auto parseRecipients(const QByteArray &contents,
683 const QString &sourceName) -> QStringList;
698 static auto passReadsDifferently(const QByteArray &contents) -> QString;
705 static auto loggableArgs(const QStringList &args) -> QStringList;
706
711 [[nodiscard]] auto isIdle() const -> bool { return exec.isIdle(); }
717 auto stopRunning() -> bool { return exec.stopRunning(); }
722 [[nodiscard]] auto runningSerial() const -> quint64 {
723 return exec.runningSerial();
724 }
725
729 [[nodiscard]] auto runningProcess() const -> Enums::PROCESS {
730 const int id = exec.runningId();
731 return id >= 0 && id < Enums::PROCESS_COUNT
732 ? static_cast<Enums::PROCESS>(id)
734 }
735
740 [[nodiscard]] auto isPushing() const -> bool {
742 }
743
757 [[nodiscard]] auto autoPushHeld() const -> bool;
758
765 void GitPushAutomatic();
766
767protected:
772 [[nodiscard]] auto pushIsAutomatic() const -> bool;
773
780 void holdAutoPush(const QString &scope);
781
789 void releaseAutoPush(const QString &folder);
790
802 auto refuseSkippedGpgId(const QString &file, bool signing,
803 const QString &except = QString(),
804 SkippedWalks *walks = nullptr) -> bool;
805
818 auto verifySignedList(const GpgIdSigner &signer, const QString &gpgIdFile,
819 QByteArray *contents, QString *why) const -> bool;
820
828 [[nodiscard]] virtual auto insertWritten(const QString &err) const -> bool {
829 Q_UNUSED(err);
830 return false;
831 }
832
841 void queueShow(const QString &file) { m_pendingShows.enqueue(file); }
853 void queueInsert(const QString &entry = QString()) {
855 m_insertedEntries.enqueue(entry);
856 }
857
858 enum class LinkScope {
860 EntryAndParents,
865 ParentsOnly,
866 };
867
868 enum class PathSpelling {
874 Configured,
879 PlacedByCaller,
880 };
881
899 auto refuseLinkedPath(const QString &path,
902 -> bool;
917 auto refuseFolderOutsideStore(const QString &folder,
918 QString *relative = nullptr) -> bool;
919
932 virtual auto storeGit(const QStringList &args, QString *out) -> bool {
933 Q_UNUSED(args);
934 Q_UNUSED(out);
935 return false;
936 }
937
954 auto refuseUnfinishedGitOperation() -> bool;
955
968 auto unfinishedGitOperationReason() -> QString;
969
983 auto refusePendingPull() -> bool;
984
994 auto refuseChangedList() -> bool;
995
1007 auto refuseBusyForExpectedList() -> bool;
1008
1017 void executeWrapper(PROCESS id, const QString &app, const QStringList &args,
1018 bool readStdout = true, bool readStderr = true);
1025 auto generateRandomPassword(const QString &charset, unsigned int length)
1026 -> QString;
1032 auto boundedRandom(quint32 bound) -> quint32;
1039 void setEnvVar(const QString &name, const QString &value);
1040
1053 void pinStoreGitAttributes();
1054
1064 void executeWrapper(PROCESS id, const QString &app, const QStringList &args,
1065 QString input, bool readStdout, bool readStderr);
1074 virtual void beforeExecute(PROCESS id);
1075
1076protected slots:
1084 virtual void finished(int id, int exitCode, const QString &out,
1085 const QString &err);
1086
1087private:
1097 static auto gpgIdVerdictIn(const QString &dir) -> std::optional<SkippedWalk>;
1103 static auto heldScopes() -> QSet<QString> &;
1110 [[nodiscard]] auto scopePath(const QString &path) const -> QString;
1112 bool m_pushIsAutomatic = false;
1127
1128 std::optional<ExpectedList> m_expectedList;
1133 QQueue<QString> m_pendingShows;
1137 QQueue<QString> m_insertedEntries;
1152 void handleProcessError(PROCESS pid, int exitCode, const QString &out,
1153 const QString &err);
1162 auto formatInsertError(const QString &friendly, const QString &err)
1163 -> QString;
1175 void emitProcessFinishedSignal(PROCESS pid, const QString &out,
1176 const QString &err);
1186 void refuseAsNotPartOfStore(const QString &why);
1187
1188signals:
1196 void idle();
1215 void statusMsg(const QString &msg, int timeout);
1229 void critical(const QString &title, const QString &message);
1230
1259 void processErrorExit(int exitCode, const QString &err);
1260
1272 void finishedAnyWithPid(const QString &out, const QString &err,
1273 Enums::PROCESS pid);
1280 void finishedGitInit(const QString &out, const QString &err);
1286 void finishedGitPull(const QString &out, const QString &err);
1292 void finishedGitPush(const QString &out, const QString &err);
1307 void finishedShow(const QString &out, const QString &file,
1308 bool lossless = true);
1321 void finishedInsert(const QString &out, const QString &err);
1327 void finishedRemove(const QString &out, const QString &err);
1334 void finishedInit(const QString &out, const QString &err);
1340 void finishedMove(const QString &out, const QString &err);
1346 void finishedCopy(const QString &out, const QString &err);
1355 void finishedGenerateGPGKeys(const QString &out, const QString &err);
1362 void generateGPGKeysFailed(const QString &err);
1375 void insertFailed(const QString &err, bool written);
1384 void finishedGrep(const QList<QPair<QString, QStringList>> &results);
1385};
1386
1402QString gpgErrorMessage(const QString &err);
1403
1404#endif // SRC_PASS_H_
AppSettings, the value object holding every flat QtPass setting.
Runs non-interactive external commands in FIFO order using a single QProcess.
Definition executor.h:32
auto stopRunning() -> bool
Stop the command that is running, if any: terminate it (its whole process group on Unix),...
Definition executor.cpp:739
auto isIdle() const -> bool
Whether no command is running and nothing is queued.
Definition executor.h:620
auto runningSerial() const -> quint64
Which run is going: a number no other run of this executor had.
Definition executor.h:605
auto hasQueued(int id) const -> bool
Whether a command with process id id is queued or running.
Definition executor.h:659
auto runningId() const -> int
The id of the command that is running.
Definition executor.h:613
The detached signature on a store's .gpg-id: whether the configured signing key is usable,...
Definition gpgidsigner.h:29
auto storeEnvironment() const -> QProcessEnvironment
The environment QtPass runs the store's processes in.
Definition pass.h:124
auto exportPublicKeys(const QString &gpg, const QStringList &keys, QString *out, QString *err) -> int
gpg --armor --export of keys, in the store's environment: the keyring keyLinesHeldTwice() reads.
Definition pass.cpp:558
void startingExecuteWrapper()
Emitted each time a queued process is about to start, and by the refusals that go on to emit processE...
bool wrapperRunning
Unused; kept from the time Pass tracked the running wrapper.
Definition pass.h:81
virtual void beforeExecute(PROCESS id)
Hook invoked just before a wrapped command is dispatched.
Definition pass.cpp:169
void GenerateGPGKeys(QString batch)
Generate GPG keys using batch script.
Definition pass.cpp:420
static auto skippedGpgId(const QString &forFile, const QString &passStore, QString *recordError=nullptr, SkippedWalks *walks=nullptr) -> std::optional< QString >
The folder list getGpgIdPath() passed over on its way up to the one it returns, if it passed one over...
Definition pass.cpp:1609
virtual void CancelGrep()
Stop a running Grep(): the walk ends at the next entry and the gpg decrypting one is terminated....
Definition pass.h:384
static QString getDefaultKeyTemplate(const QString &gpgExecutable={})
Get default key template for new GPG keys.
Definition pass.cpp:317
void finishedAnyWithPid(const QString &out, const QString &err, Enums::PROCESS pid)
A process of any kind finished successfully and its output cannot contain a secret.
void finishedInsert(const QString &out, const QString &err)
An Insert() succeeded: the entry is in the store and, with Git in use, committed.
void pinStoreGitAttributes()
Pin byte-for-byte Git attributes for the store's encrypted files.
Definition pass.cpp:1100
virtual auto recipientArgument(const QString &line) const -> QString
The -r argument for one recipient line, as this backend's encryption hands it to gpg: the probe (encr...
Definition pass.cpp:703
auto isPushing() const -> bool
Whether a Git push of this backend is queued or running.
Definition pass.h:740
AppSettings m_settings
Application settings snapshot injected at init() time.
Definition pass.h:145
static auto passReadsDifferently(const QByteArray &contents) -> QString
Why pass would read a .gpg-id differently from parseRecipients(), if it would.
Definition pass.cpp:1869
static auto getGpgIdPath(const QString &for_file, const QString &passStore) -> QString
Get .gpg-id file path for a password file.
Definition pass.cpp:1511
void handleProcessError(PROCESS pid, int exitCode, const QString &out, const QString &err)
Report a process that exited non-zero; called by finished().
Definition pass.cpp:896
auto reportedInsert() const -> QString
The entry whose insert is reporting now: set while finishedInsert() or insertFailed() goes out,...
Definition pass.h:336
virtual auto encryptionReaches(const QStringList &recipients) -> std::optional< QStringList >
The keys a gpg encryption to recipients reaches: a throwaway encryption outside the store,...
Definition pass.cpp:707
auto scopePath(const QString &path) const -> QString
path as an absolute, cleaned path, relative ones taken from the current store.
Definition pass.cpp:1287
virtual void GitInit()=0
Initialize Git repository in password store.
auto refusePendingPull() -> bool
Refuse a store change while a Git pull is still queued or running.
Definition pass.cpp:1427
auto initIfUnchanged(const QString &path, const QList< UserInfo > &users, const QString &dir, const QString &passStore, const RecipientsForEditing &read) -> bool
Init(), but only while the list of dir still reads as the caller read it with recipientsForEditing().
Definition pass.cpp:1442
void releaseAutoPush(const QString &folder)
Release the holds a clean re-encryption of folder covers: those for folder itself and everything unde...
Definition pass.cpp:1312
QString m_reportedInsert
The entry of the insert whose report is going out; see reportedInsert().
Definition pass.h:1139
void finishedGenerateGPGKeys(const QString &out, const QString &err)
GenerateGPGKeys() succeeded; the new key pair is in the keyring.
virtual void Copy(const QString srcDir, const QString dest, const bool force)=0
Copy password file or directory.
Enums::PROCESS PROCESS
Alias for Enums::PROCESS used throughout this class.
Definition pass.h:154
void queueInsert(const QString &entry=QString())
Count one insert that has started queueing but not yet reported.
Definition pass.h:853
static auto describeKeyLinesHeldTwice(const std::optional< QHash< QString, QStringList > > &held) -> QString
A message naming each line keyLinesHeldTwice() found and what the user can do about it.
Definition pass.cpp:643
virtual void GitPull()=0
Pull changes from remote Git repository.
virtual auto generatePassword(unsigned int length, const QString &charset) -> QString
Generate random password.
Definition pass.cpp:243
void queueShow(const QString &file)
Remember what a Show() asked for, so its completion can say so.
Definition pass.h:841
virtual void Move(const QString srcDir, const QString dest, const bool force)=0
Move password file or directory.
void statusMsg(const QString &msg, int timeout)
Progress or a non-fatal problem worth a line in the status bar ("Creating backup commit",...
QProcessEnvironment env
The environment the store's processes run in: the system environment plus what updateEnv() sets (PASS...
Definition pass.h:87
virtual void Grep(QString pattern, bool caseInsensitive)=0
Search password content for a pattern.
auto unfinishedGitOperationReason() -> QString
The unfinished git operation in progress in the store, if any.
Definition pass.cpp:1363
void GitPushAutomatic()
GitPush() for an automatic push, the one after a change. A backend that has to make the push later dr...
Definition pass.cpp:1300
PathSpelling
How a path handed to refuseLinkedPath() is spelled.
Definition pass.h:868
@ Configured
As the store is configured or relative to it, the class's path rule. A path spelled through the targe...
Definition pass.h:874
virtual auto fullKeyListing(QString *listing) -> int
The whole public keyring as keyLinesHeldTwice() reads it.
Definition pass.cpp:545
auto boundedRandom(quint32 bound) -> quint32
Generate random number in range.
Definition pass.cpp:1910
void insertFailed(const QString &err, bool written)
Emitted when an Insert() fails through a queued command, before the generic processErrorExit(): the p...
static auto gpgIdVerdictIn(const QString &dir) -> std::optional< SkippedWalk >
What skippedGpgId() concludes at one folder on its way up.
Definition pass.cpp:1579
auto pushIsAutomatic() const -> bool
Whether the GitPush() running now is an automatic one.
Definition pass.cpp:1306
static auto keyLinesHeldTwiceIn(const QStringList &lines, const QString &listing) -> QHash< QString, QStringList >
keyLinesHeldTwice() on a listing already made.
Definition pass.cpp:611
auto runningProcess() const -> Enums::PROCESS
What kind of command is running now.
Definition pass.h:729
void emitProcessFinishedSignal(PROCESS pid, const QString &out, const QString &err)
Emit the signals for a process that exited with 0; called by finished() for everything but PASS_SHOW.
Definition pass.cpp:943
static bool gpgSupportsEd25519(const QString &gpgExecutable={})
Check if GPG supports Ed25519 encryption.
Definition pass.cpp:298
void refuseAsNotPartOfStore(const QString &why)
Refuse an operation on something that is not part of the store.
Definition pass.cpp:1503
static auto maxOutputArgs() -> QStringList
The gpg options that enforce kMaxPlaintextBytes.
Definition pass.cpp:1184
virtual void Remove(QString file, bool isDir)=0
Remove password file or directory.
virtual auto storeGit(const QStringList &args, QString *out) -> bool
Run a git command in the store's repository, blocking.
Definition pass.h:932
Pass()
Construct a Pass instance.
Definition pass.cpp:83
virtual auto insertWritten(const QString &err) const -> bool
Whether the insert that just failed had put its entry in the store before a later step failed....
Definition pass.h:828
virtual auto entriesInitWouldWiden(const QString &dir, const QList< UserInfo > &users) -> QStringList
Entries a pass init of dir with users would hand to someone who cannot read them now (an entry copied...
Definition pass.h:296
void holdAutoPush(const QString &scope)
Hold automatic pushes of the store that holds scope (autoPushHeld()): its re-encryption did not finis...
Definition pass.cpp:1308
void finishedCopy(const QString &out, const QString &err)
A Copy() succeeded; the copy exists beside the original.
virtual void Show(QString file)=0
Show decrypted password file.
void finishedMove(const QString &out, const QString &err)
A Move() succeeded; the entry or folder is under its new name.
auto isIdle() const -> bool
Whether no gpg, git or pass of this backend runs or waits.
Definition pass.h:711
void executeWrapper(PROCESS id, const QString &app, const QStringList &args, bool readStdout=true, bool readStderr=true)
Execute external wrapper command.
Definition pass.cpp:126
void finishedShow(const QString &out, const QString &file, bool lossless=true)
Emitted when a Show() succeeds.
static auto resolveGpgconfCommand(const QString &gpgPath) -> ResolvedGpgconfCommand
Resolve the gpgconf command to kill agents.
Definition pass.cpp:380
static auto exactRecipientArg(const QString &line) -> QString
A bare mail address in gpg's exact form, <address>; any other line as written.
Definition pass.cpp:695
auto refuseLinkedPath(const QString &path, LinkScope scope=LinkScope::EntryAndParents, PathSpelling spelling=PathSpelling::Configured) -> bool
Refuse an operation on something that is, or lies behind, a symbolic link or NTFS junction inside the...
Definition pass.cpp:1321
auto listKeys(QStringList keystrings, bool secret=false) -> QList< UserInfo >
List GPG keys matching patterns.
Definition pass.cpp:763
virtual auto entriesMoveWouldWiden(const QString &src, const QString &dest) -> QStringList
Entries already in the place a pass mv or pass cp of src to dest re-encrypts (the whole destination f...
Definition pass.h:312
QQueue< QString > m_insertedEntries
The entries of the inserts counted in m_insertsPending, in queue order.
Definition pass.h:1137
void finishedGrep(const QList< QPair< QString, QStringList > > &results)
The newest Grep() is over; an empty list means no entry matched.
QHash< QString, SkippedWalk > SkippedWalks
SkippedWalk per absolute folder, for one check of many folders.
Definition pass.h:165
static auto enabledKeyLines(const QList< UserInfo > &users) -> QStringList
The enabled users' key IDs, as Init() writes them to .gpg-id.
Definition pass.cpp:580
void finishedGitPull(const QString &out, const QString &err)
git pull succeeded; entries may have changed on disk.
virtual void GitPush()=0
Push changes to remote Git repository.
bool m_expectedListRefused
Set when refuseChangedList() or refuseBusyForExpectedList() refused during initIfUnchanged().
Definition pass.h:1131
void finishedGitPush(const QString &out, const QString &err)
git push succeeded.
auto recipientsForEditing(const QString &dir, const QString &passStore) -> RecipientsForEditing
The recipients a dialog may preselect for editing the list of dir.
Definition pass.cpp:1745
static auto linkedGpgId(const QString &forFile, const QString &passStore, LinkedWalks *walks=nullptr) -> std::optional< QString >
The link or junction under the name .gpg-id that getGpgIdPath() skips on its way up from forFile,...
Definition pass.cpp:1659
virtual void Insert(QString file, QString value, bool force)=0
Insert or update password.
auto refuseBusyForExpectedList() -> bool
Refuse an Init() under initIfUnchanged() while the executor has work queued or running,...
Definition pass.cpp:1475
virtual void GitPull_b(int timeoutMs)=0
Pull from the remote and wait for it, at most timeoutMs: the pull before an edit, on the GUI thread.
auto keyLinesHeldTwice(const QStringList &lines) -> std::optional< QHash< QString, QStringList > >
The key ID and fingerprint lines of a recipient list that more than one key block holds,...
Definition pass.cpp:590
Executor exec
Internal command executor for queuing and running subprocesses.
Definition pass.h:149
std::optional< ExpectedList > m_expectedList
Set during initIfUnchanged().
Definition pass.h:1128
void processErrorExit(int exitCode, const QString &err)
An operation ended in failure: its process exited non-zero, could not be started or crashed,...
auto stopRunning() -> bool
Stop the queued command that is running now (Executor::stopRunning()); it then ends as a failed run.
Definition pass.h:717
auto runningSerial() const -> quint64
Which run is going (Executor::runningSerial()).
Definition pass.h:722
auto verifySignedList(const GpgIdSigner &signer, const QString &gpgIdFile, QByteArray *contents, QString *why) const -> bool
Whether gpgIdFile is a signed list QtPass accepts: its signature verifies (GpgIdSigner::verifyFile())...
Definition pass.cpp:1555
void init(const AppSettings &settings)
Initialize the Pass instance with a settings snapshot.
Definition pass.cpp:171
auto refuseChangedList() -> bool
Refuse an Init() under initIfUnchanged() when the folder's list no longer reads as the caller read it...
Definition pass.cpp:1452
bool m_pushIsAutomatic
Set while GitPushAutomatic() runs GitPush().
Definition pass.h:1112
auto insertsPending() const -> int
How many inserts have started queueing but not yet reported.
Definition pass.h:245
auto formatInsertError(const QString &friendly, const QString &err) -> QString
Put the translated reason for a failed insert above what gpg itself printed, leaving out the machine-...
Definition pass.cpp:937
auto entryReaders(const QString &path) -> QStringList
The long key IDs an entry is encrypted to, as gpg lists them without anyone's secret key (ENC_TO).
Definition pass.cpp:664
void finishedGitInit(const QString &out, const QString &err)
git init in the store succeeded; the store is a repository now and the tree is re-read.
static auto withoutStatusLines(const QString &err) -> QString
gpg's stderr without its machine-readable [GNUPG:] lines (and without carriage returns),...
Definition pass.cpp:926
static auto heldScopes() -> QSet< QString > &
The folders (cleaned absolute paths) whose re-encryption did not finish, for every store and both bac...
Definition pass.cpp:1282
auto withCurrentGitPin(QProcessEnvironment base) const -> QProcessEnvironment
base with GIT_DIR and GIT_WORK_TREE as the store is now (Util::gitStoreVariables()),...
Definition pass.cpp:1169
void setEnvVar(const QString &name, const QString &value)
Set or remove an environment variable.
Definition pass.cpp:977
static auto loggableArgs(const QStringList &args) -> QStringList
The arguments as they may appear in the debug log: the value of --passphrase and friends,...
Definition pass.cpp:141
auto autoPushHeld() const -> bool
Whether automatic pushes of the current store are held because its last re-encryption did not finish ...
Definition pass.cpp:1291
static auto pullTimedOut(int timeoutMs) -> QString
The status-bar text for a blocking pull stopped at its deadline.
Definition pass.cpp:1940
void updateEnv()
Update environment for subprocesses.
Definition pass.cpp:984
void finishedInit(const QString &out, const QString &err)
An Init() succeeded: the folder's .gpg-id holds the new recipient list.
QHash< QString, std::optional< QString > > LinkedWalks
Definition pass.h:168
void idle()
Nothing of the store's runs or waits any more (isIdle()).
virtual void finished(int id, int exitCode, const QString &out, const QString &err)
Handle process completion.
Definition pass.cpp:860
void critical(const QString &title, const QString &message)
Something went wrong that the user has to be told about in a dialog, such as a refused path or a fail...
auto refuseSkippedGpgId(const QString &file, bool signing, const QString &except=QString(), SkippedWalks *walks=nullptr) -> bool
With signing on, refuse to encrypt file when the lookup passed over its folder's own list (skippedGpg...
Definition pass.cpp:1518
virtual auto readersAnEditWouldAdd(const QString &file) -> EditReaders
Who saving over an existing entry would let read it who may not now.
Definition pass.h:282
auto refuseKeyLinesHeldTwice(const QStringList &lines) -> bool
Refuse, with critical(), a recipient list with a line that more than one key block holds (keyLinesHel...
Definition pass.cpp:568
void generateGPGKeysFailed(const QString &err)
Emitted when GPG key generation fails, alongside the generic processErrorExit(); lets the keygen dial...
static constexpr qint64 kMaxPlaintextBytes
Most bytes of plaintext a gpg decryption may produce.
Definition pass.h:511
int m_insertsPending
Inserts that have started queueing but not yet reported; see queueInsert.
Definition pass.h:1135
static auto getRecipientList(const QString &for_file, const QString &passStore) -> QStringList
Get list of recipients for a password file.
Definition pass.cpp:1833
virtual void Init(QString path, const QList< UserInfo > &users)=0
Initialize new password store.
LinkScope
What refuseLinkedPath() judges.
Definition pass.h:858
@ EntryAndParents
The entry itself and every folder above it in the store.
Definition pass.h:860
void finishedRemove(const QString &out, const QString &err)
A Remove() succeeded; the entry or folder is gone from the store.
auto refuseUnfinishedGitOperation() -> bool
Refuse to change the store while git is mid-rebase, -merge, -cherry-pick or -revert.
Definition pass.cpp:1489
QQueue< QString > m_pendingShows
Files of the Show() calls still in flight, oldest first.
Definition pass.h:1133
static auto parseRecipients(const QByteArray &contents, const QString &sourceName) -> QStringList
Parse the contents of a .gpg-id: one recipient per line, # starts a comment, unusable lines are logge...
Definition pass.cpp:1848
auto refuseFolderOutsideStore(const QString &folder, QString *relative=nullptr) -> bool
Refuse recipients for a folder outside the store, as pass refuses a path with .. in it.
Definition pass.cpp:1347
static constexpr int kBlockingPullMs
How long the pull before an edit may block the window.
Definition pass.h:216
auto generateRandomPassword(const QString &charset, unsigned int length) -> QString
Generate random password from charset.
Definition pass.cpp:1927
The Enums namespace: clipboard behaviour and the identifiers of the subprocess kinds QtPass queues.
Executor, the FIFO queue every gpg, git and pass child process of QtPass goes through,...
Rollback detection for signed .gpg-id files: the generation counter and the record of what was last s...
Enumerators for QtPass configuration and runtime operations.
PROCESS
Identifies different subprocess operations used in QtPass.
Definition enums.h:43
@ INVALID
Definition enums.h:63
@ PROCESS_COUNT
Definition enums.h:62
@ GIT_PUSH
Definition enums.h:49
auto gpgErrorMessage(const QString &err) -> QString
Maps GPG stderr (which may include –status-fd 2 tokens) to a translated user-friendly encryption erro...
Definition pass.cpp:808
PROCESS
Identifies different subprocess operations used in QtPass.
Definition enums.h:43
Plain value-object holding all flat QtPass configuration.
Definition appsettings.h:36
What saving over an existing entry would change about who reads it (readersAnEditWouldAdd()).
Definition pass.h:250
auto operator==(const EditReaders &other) const -> bool
Equal when both say the same.
Definition pass.h:263
QStringList names
Who would read the entry after the save and the question is about, as "name (key ID)"; empty for no q...
Definition pass.h:253
bool notSavedHere
The entry's path was never saved from this device and its folder takes a parent's list,...
Definition pass.h:257
What initIfUnchanged() expects the list to read as, for refuseChangedList(); empty outside it.
Definition pass.h:1117
QString passStore
The store root given to recipientsForEditing().
Definition pass.h:1121
QString dir
The folder given to recipientsForEditing().
Definition pass.h:1119
QStringList recipients
The recipients read then.
Definition pass.h:1125
RecipientsForEditing::State state
The state read then.
Definition pass.h:1123
What a dialog may do with the list of a folder (recipientsForEditing()).
Definition pass.h:604
QStringList recipients
The recipients to preselect; empty when Rejected.
Definition pass.h:627
State state
How the list on disk stood up.
Definition pass.h:625
QString warning
What the dialog should show, if anything.
Definition pass.h:629
State
How the list on disk stood up.
Definition pass.h:606
@ Unsigned
No signing key: the list as it is.
Definition pass.h:608
What skippedGpgId() found on its way up from one folder.
Definition pass.h:158
std::optional< QString > skipped
The skipped .gpg-id, if any.
Definition pass.h:160
QString recordError
The generation record's error, when that is why it was named.
Definition pass.h:162
Represents a command invocation for gpgconf operations.
Definition pass.h:39
QStringList arguments
Full argv list, including any wrapper/prefix args followed by the actual gpgconf operation flags (e....
Definition pass.h:49
QString program
Executable to run — may be a bare name resolved via PATH or a wrapper (e.g. wsl.exe) rather than a di...
Definition pass.h:44
UserInfo, one GPG key as listed by gpg, with the selection flag the recipient dialogs use.