|
QtPass 2.0.0
Developer documentation
|
Implementation that imitates 'pass' when the real tool is unavailable. More...
#include <imitatepass.h>
Classes | |
| class | TransactionHelper |
| RAII helper for wrapping operations in transactions. More... | |
| struct | PendingMove |
| A move whose re-encryption is decided once it has run. More... | |
| struct | PendingInsert |
| struct | UncommittedGpgId |
| A .gpg-id Init() wrote but could not commit. More... | |
| struct | WrittenGpgId |
| The .gpg-id Init() wrote for the run it starts: the recipients the user ticked, as written. More... | |
| struct | PreviousList |
| The list a folder had before Init() replaced it, for the run it starts. It tells whom the change added (who then gains every entry, as adding someone means) and whom it removed (who may still read an entry left alone). An entry is not compared with it: the worker asks before an entry gains anyone on the new list other than those added. More... | |
| struct | Agreed |
| What the user was shown for an entry: its bytes and its folder's keys. More... | |
| struct | ReencryptResult |
| Outcome of one reencryptPath() run; filled on the worker thread and consumed by finishReencrypt() on the owning thread. More... | |
| struct | ListKeys |
| struct | WhoReads |
| struct | ReaderChange |
| How re-encrypting one entry changes who can read it. More... | |
Signals | |
| void | startReencryptPath () |
| A reencryptPath() run is about to start its worker thread. | |
| void | endReencryptPath () |
| A reencryptPath() run is over, whether it finished, failed, was cancelled or was refused; the main window releases the interface. | |
| void | reencryptProgress (int current, int total) |
Re-encryption progress: current of total files checked. | |
| void | unexpectedRecipients (const QString &dir, const QStringList &files, const QStringList &details) |
A run left files alone: re-encrypting one would let someone on its folder's list read it who cannot now, and whom the change of the list did not add. An entry copied in from a folder they cannot read must not reach them without the user's say. reencryptAlso() takes them once the user agreed. Emitted after endReencryptPath(). | |
| Signals inherited from Pass | |
| void | idle () |
| Nothing of the store's runs or waits any more (isIdle()). | |
| void | startingExecuteWrapper () |
| Emitted each time a queued process is about to start, and by the refusals that go on to emit processErrorExit(). | |
| void | statusMsg (const QString &msg, int timeout) |
| Progress or a non-fatal problem worth a line in the status bar ("Creating backup commit", "Git pull failed: ..."). | |
| 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 failed backup commit. | |
| void | processErrorExit (int exitCode, const QString &err) |
| An operation ended in failure: its process exited non-zero, could not be started or crashed, or the operation was refused. | |
| 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 | 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. | |
| void | finishedGitPull (const QString &out, const QString &err) |
| git pull succeeded; entries may have changed on disk. | |
| void | finishedGitPush (const QString &out, const QString &err) |
| git push succeeded. | |
| void | finishedShow (const QString &out, const QString &file, bool lossless=true) |
| Emitted when a Show() succeeds. | |
| void | finishedInsert (const QString &out, const QString &err) |
| An Insert() succeeded: the entry is in the store and, with Git in use, committed. | |
| void | finishedRemove (const QString &out, const QString &err) |
| A Remove() succeeded; the entry or folder is gone from the store. | |
| void | finishedInit (const QString &out, const QString &err) |
| An Init() succeeded: the folder's .gpg-id holds the new recipient list. | |
| void | finishedMove (const QString &out, const QString &err) |
| A Move() succeeded; the entry or folder is under its new name. | |
| void | finishedCopy (const QString &out, const QString &err) |
| A Copy() succeeded; the copy exists beside the original. | |
| void | finishedGenerateGPGKeys (const QString &out, const QString &err) |
| GenerateGPGKeys() succeeded; the new key pair is in the keyring. | |
| void | generateGPGKeysFailed (const QString &err) |
| Emitted when GPG key generation fails, alongside the generic processErrorExit(); lets the keygen dialog react to its own failure only, not to any other command failing meanwhile. | |
| void | insertFailed (const QString &err, bool written) |
| Emitted when an Insert() fails through a queued command, before the generic processErrorExit(): the process exited non-zero, crashed or could not be started, or the entry could not be put in place afterwards. Lets the password dialog keep what was typed and say why, without reacting to any other command failing meanwhile. An insert refused before anything is queued does not emit it. | |
| void | finishedGrep (const QList< QPair< QString, QStringList > > &results) |
| The newest Grep() is over; an empty list means no entry matched. | |
Public Member Functions | |
| void | executeMoveGit (const QString &src, const QString &destFile, bool force) |
| Execute git move operation. | |
| void | gitCommit (const QString &file, const QString &msg) |
| Commit one path to git. | |
| void | gitCommit (const QStringList &files, const QString &msg) |
| Commit these paths and nothing else: a change someone staged meanwhile stays staged, out of a commit autoPush would send. | |
| void | executeGit (PROCESS id, const QStringList &args, QString input=QString(), bool readStdout=true, bool readStderr=true) |
| Execute git command. | |
| auto | gitConfigured () const -> bool |
| Git is enabled and an executable is configured. | |
| auto | gitReady () -> bool |
| gitConfigured() plus a status message when git is enabled but no executable is configured. | |
| void | executeGpg (PROCESS id, const QStringList &args, QString input=QString(), bool readStdout=true, bool readStderr=true) |
| Execute GPG command. | |
| ImitatePass () | |
| Construct the backend and connect its content search. | |
| ~ImitatePass () override | |
| Cancel a running content search, and cancel and join a running re-encryption worker, before the members they use go away. | |
| void | GitInit () override |
| Initialize Git repository. | |
| void | GitPull () override |
| Pull from remote. | |
| void | GitPull_b (int timeoutMs) override |
Run git pull in the store and wait for it, at most timeoutMs. | |
| void | GitPush () override |
| Push to remote. While a re-encryption runs the push is held (Users ▸ OK and a copy ask for it as soon as their commit is made, before the worker is done) and made when the run ends with every file re-encrypted; after a failed or cancelled run nothing is pushed. | |
| void | Show (QString file) override |
| Show decrypted password. | |
| void | Insert (QString file, QString newValue, bool overwrite) override |
| Insert new password. | |
| auto | readersAnEditWouldAdd (const QString &file) -> EditReaders override |
| Who saving over an existing entry would let read it who may not now. | |
| void | Remove (QString file, bool isDir) override |
| Remove password. | |
| void | Init (QString path, const QList< UserInfo > &users) override |
| Initialize store. | |
| void | reencryptPath (const QString &dir) |
| Re-encrypt entire directory. | |
| void | reencryptPath (const QString &dir, const AppSettings &settings) |
Re-encrypt dir under settings, the current profile's. | |
| void | cancelReencryptPath () |
| Ask a running reencryptPath() to stop. | |
| void | reencryptAlso (const QString &dir, const QStringList &files, const AppSettings &settings) |
Re-encrypt files in dir after the user agreed to it. | |
| void | Move (const QString src, const QString dest, const bool force) override |
| Move password file. | |
| void | Copy (const QString src, const QString dest, const bool force) override |
| Copy password file. | |
| void | Grep (QString pattern, bool caseInsensitive) override |
| Search all password content by GPG-decrypting each .gpg file. | |
| void | CancelGrep () override |
| Stop the running search (NativeGrep::cancel()). | |
| Public Member Functions inherited from Pass | |
| Pass () | |
| Construct a Pass instance. | |
| void | init (const AppSettings &settings) |
| Initialize the Pass instance with a settings snapshot. | |
| auto | insertsPending () const -> int |
| How many inserts have started queueing but not yet reported. | |
| 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 in from a folder they are not on), less whom the change adds. pass re-encrypts every entry itself, so the caller asks before it runs. None by default; the pass backend tells. | |
| 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 folder) that would gain a reader they do not have. What is moved or copied itself is the user's own and not counted. None by default. | |
| 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). | |
| auto | reportedInsert () const -> QString |
| The entry whose insert is reporting now: set while finishedInsert() or insertFailed() goes out, empty otherwise. | |
| virtual auto | generatePassword (unsigned int length, const QString &charset) -> QString |
| Generate random password. | |
| void | GenerateGPGKeys (QString batch) |
| Generate GPG keys using batch script. | |
| auto | listKeys (QStringList keystrings, bool secret=false) -> QList< UserInfo > |
| List GPG keys matching patterns. | |
| virtual auto | encryptionReaches (const QStringList &recipients) -> std::optional< QStringList > |
The keys a gpg encryption to recipients reaches: a throwaway encryption outside the store, read back for whom it went to. | |
| 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 (encryptionReaches()) must reach what the encryption will. The native backend matches a bare address exactly (exactRecipientArg()). | |
| 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, with those blocks. | |
| 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. | |
| auto | listKeys (const QString &keystring="", bool secret=false) -> QList< UserInfo > |
| List GPG keys. | |
| void | updateEnv () |
| Update environment for subprocesses. | |
| auto | recipientsForEditing (const QString &dir, const QString &passStore) -> RecipientsForEditing |
The recipients a dialog may preselect for editing the list of dir. | |
| 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(). | |
| auto | isIdle () const -> bool |
| Whether no gpg, git or pass of this backend runs or waits. | |
| auto | stopRunning () -> bool |
| Stop the queued command that is running now (Executor::stopRunning()); it then ends as a failed run. | |
| auto | runningSerial () const -> quint64 |
| Which run is going (Executor::runningSerial()). | |
| auto | runningProcess () const -> Enums::PROCESS |
| What kind of command is running now. | |
| auto | isPushing () const -> bool |
| Whether a Git push of this backend is queued or running. | |
| auto | autoPushHeld () const -> bool |
| Whether automatic pushes of the current store are held because its last re-encryption did not finish cleanly. | |
| void | GitPushAutomatic () |
| GitPush() for an automatic push, the one after a change. A backend that has to make the push later drops it then if the store is held by that time (autoPushHeld()); a push by hand (GitPush()) still goes. | |
Protected Member Functions | |
| auto | gpgIdSigner () -> GpgIdSigner |
| The signer for this store's .gpg-id, bound to the configured gpg and signing keys and to execBlocking(), so a verification on the re-encryption worker can be interrupted like every other gpg run there. | |
| auto | loadVerifiedRecipients (const QString &gpgIdFile, QStringList *recipients, QString *why=nullptr) -> bool |
| Read a .gpg-id, verify its detached signature and parse the recipients from the bytes that were verified. | |
| auto | writeGpgIdFile (const QString &gpgIdFile, const QList< UserInfo > &users, QByteArray *written=nullptr) -> bool |
| Write the enabled recipients to a .gpg-id, atomically: a write that fails halfway (full disk, dead network share) leaves the previous file in place instead of a truncated list that would then be signed and encrypted to. | |
| auto | signGpgIdFile (const QString &gpgIdFile, const QByteArray &contents) -> bool |
| Sign a .gpg-id with the configured key and verify the result; failures are reported through critical(). | |
| auto | refuseLinkedGpgIdFolder (const QString &path) -> bool |
| Refuse a folder, or a .gpg-id/.gpg-id.sig in it, that is a link: writing there would reach outside the store. | |
| auto | recipientsForEntry (const QString &file, QStringList *recipients) -> bool |
The recipients to encrypt file to: its folder's .gpg-id, verified when a signing key is set. | |
| auto | copyDestination (const QString &src, const QString &dest, bool force) -> QString |
The file a copy of src to dest writes: like pass cp, into an existing folder with .gpg appended. Refused (the user told) when it is a link, the source itself, or taken and force is off. | |
| auto | addGenerationHeader (const QString &gpgIdFile, const GpgIdSigner &signer, QByteArray *contents) -> bool |
| Put the generation header on a list that is about to be signed: reserve a generation above what this device accepted and what the verified list on disk says, and bind the list to its folder, so no older or relocated signed list comes back. | |
| auto | settleSignature (const QString &gpgIdFile, const QByteArray &written, const GpgIdSigner &signer, bool useGit, QString *sigToCommit) -> bool |
| Bring the signature in line with the list just written: a new one when signing is on, the old one removed when it is off (pass and other clients would reject the new list under it). | |
| auto | gitAddGpgId (const QString &gpgIdFile, const QString &gpgIdSigFile, QString *out, QString *err) -> int |
| Stage a .gpg-id and, when given, its .sig, and commit both in one commit, so no commit in the history has a recipient list without the signature that covers it. Nothing is committed when neither file changed. | |
| auto | commitName (const QString &path) const -> QString |
| How a commit message names a file of the store: relative to the store, without .gpg ("work/bank", "work/.gpg-id"), never the local path, which the shared history would carry to everyone. | |
| auto | gitTracks (const QString &file) -> bool |
| Check whether git already tracks a file in the store. | |
| auto | commitArgs () -> QStringList |
| The start of a git commit for the store: "commit", and "-S" when git config pass.signcommits is true there, as pass signs its own. | |
| auto | verifyGpgIdForDir (const QString &file, QHash< QString, QStringList > &verified, QStringList &gpgId) -> bool |
Recipients for the directory of file, from its verified .gpg-id. | |
| auto | createBackupCommit () -> bool |
| Create git backup commit before re-encryption. | |
| auto | getKeysFromFile (const QString &fileName) -> QStringList |
| Read recipients from file. | |
| auto | primaryKeysOf (const QStringList &ids, QHash< QString, QString > &primaries, QHash< QString, QString > &names) -> QSet< QString > |
| The primary keys behind key IDs from an entry (ENC_TO). | |
| auto | keysEncryptedTo (const QStringList &recipients, QHash< QString, QString > &primaries, QHash< QString, QString > &names, bool lookUp=true) -> std::optional< QSet< QString > > |
The primary keys gpg encrypts to for recipients, found by a throwaway encryption outside the store with the arguments a real one uses, so groups, ! suffixes and key lookups count as -r makes them. | |
| auto | entryHash (const QString &file) const -> QByteArray |
| SHA-256 of an entry's bytes, read as a regular file without following a link. | |
| auto | reencryptSingleFile (const QString &fileName, const QStringList &recipients, QString *why) -> bool |
| Re-encrypt single file with new recipients. | |
| auto | decryptEntry (const QString &fileName, QByteArray *plaintext, QString *why) -> bool |
Decrypt fileName for re-encryption. | |
| auto | encryptFor (const QString &output, const QStringList &recipients, const QByteArray &plaintext) -> bool |
Encrypt plaintext to recipients, into output. | |
| auto | ciphertextHolds (const QString &ciphertext, const QByteArray &plaintext) -> bool |
Decrypt ciphertext again and compare it with plaintext, byte for byte, so nothing replaces an entry until it is known to hold what it held. | |
| auto | commitReencrypted (const QString &fileName) -> bool |
| Stage and commit a re-encrypted entry, when the store is a Git repository QtPass manages. | |
| auto | resolveMoveDestination (const QString &src, const QString &dest, bool force) -> QString |
| Resolve destination for move operation. | |
| auto | execBlocking (const QString &app, const QStringList &args, const QString &input=QString(), QString *process_out=nullptr, QString *process_err=nullptr) -> int |
| Executor::executeBlocking() for the re-encryption helpers. | |
| auto | execBlocking (const QString &app, const QStringList &args, QString *process_out, QString *process_err=nullptr) -> int |
| Overload capturing stdout (and stderr) without stdin input. | |
| auto | execBlockingRaw (const QString &app, const QStringList &args, const QByteArray &input, QByteArray *process_out) -> int |
| execBlocking() on bytes (Executor::executeBlockingRaw()), for an entry's plaintext, which need not be UTF-8. | |
| auto | prepareBlocking (QProcess &process) -> const std::atomic_bool * |
Give process the environment for the calling thread: the store's on the owning thread, the re-encryption run's on its worker. | |
| auto | storeGit (const QStringList &args, QString *out) -> bool override |
| Run git with -C <Store tree and entries> in the store, blocking. | |
| void | finished (int id, int exitCode, const QString &out, const QString &err) override |
| Handle process completion. | |
| auto | insertWritten (const QString &err) const -> bool override |
| Whether the failed insert had placed its entry (see placeEncryptedFile()) before a later git step failed. | |
| void | beforeExecute (PROCESS id) override |
| Open a transaction for every execution. | |
| auto | fullKeyListing (QString *listing) -> int override |
| Pass::fullKeyListing() in the calling thread's environment, so a re-encryption run's worker lists the store's keyring. | |
| Protected Member Functions inherited from Pass | |
| auto | refuseKeyLinesHeldTwice (const QStringList &lines) -> bool |
| Refuse, with critical(), a recipient list with a line that more than one key block holds (keyLinesHeldTwice()). | |
| auto | storeEnvironment () const -> QProcessEnvironment |
| The environment QtPass runs the store's processes in. | |
| auto | withCurrentGitPin (QProcessEnvironment base) const -> QProcessEnvironment |
base with GIT_DIR and GIT_WORK_TREE as the store is now (Util::gitStoreVariables()), not as it was at updateEnv(): a .git that appeared or changed hands since then is judged when Git runs. | |
| auto | pushIsAutomatic () const -> bool |
| Whether the GitPush() running now is an automatic one. | |
| void | holdAutoPush (const QString &scope) |
Hold automatic pushes of the store that holds scope (autoPushHeld()): its re-encryption did not finish cleanly. | |
| void | releaseAutoPush (const QString &folder) |
Release the holds a clean re-encryption of folder covers: those for folder itself and everything under it. Holds for other folders stay. | |
| 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 (skippedGpgId()): the parent's list is not what was signed for it. | |
| 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()), and it is current and bound to the folder it lies in (GpgIdGeneration::accept()), so an older authentic list put back, or one signed for another folder, is refused. | |
| void | queueShow (const QString &file) |
| Remember what a Show() asked for, so its completion can say so. | |
| void | queueInsert (const QString &entry=QString()) |
| Count one insert that has started queueing but not yet reported. | |
| 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 store. | |
| 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. | |
| auto | refuseUnfinishedGitOperation () -> bool |
| Refuse to change the store while git is mid-rebase, -merge, -cherry-pick or -revert. | |
| auto | unfinishedGitOperationReason () -> QString |
| The unfinished git operation in progress in the store, if any. | |
| auto | refusePendingPull () -> bool |
| Refuse a store change while a Git pull is still queued or running. | |
| auto | refuseChangedList () -> bool |
| Refuse an Init() under initIfUnchanged() when the folder's list no longer reads as the caller read it. | |
| auto | refuseBusyForExpectedList () -> bool |
| Refuse an Init() under initIfUnchanged() while the executor has work queued or running, for a backend whose external tool writes the list only when its process runs. | |
| void | executeWrapper (PROCESS id, const QString &app, const QStringList &args, bool readStdout=true, bool readStderr=true) |
| Execute external wrapper command. | |
| auto | generateRandomPassword (const QString &charset, unsigned int length) -> QString |
| Generate random password from charset. | |
| auto | boundedRandom (quint32 bound) -> quint32 |
| Generate random number in range. | |
| void | setEnvVar (const QString &name, const QString &value) |
| Set or remove an environment variable. | |
| void | pinStoreGitAttributes () |
| Pin byte-for-byte Git attributes for the store's encrypted files. | |
| void | executeWrapper (PROCESS id, const QString &app, const QStringList &args, QString input, bool readStdout, bool readStderr) |
| Execute wrapper with input. | |
Protected Attributes | |
| QProcessEnvironment | m_reencryptEnv |
| Protected Attributes inherited from Pass | |
| AppSettings | m_settings |
| Application settings snapshot injected at init() time. | |
| Executor | exec |
| Internal command executor for queuing and running subprocesses. | |
Private Member Functions | |
| void | startMovedReencrypts () |
| Start the runs in m_movedToReencrypt, one at a time, while none is in flight; then send a deferred push once nothing is left. | |
| void | sendDeferredPush () |
| Make the push GitPush() deferred, once no run is in flight and no move is waiting; an automatic one only while the store is not held. | |
| void | reencryptMoved (const PendingMove &move) |
Queue a re-encryption of what move moved, if it moved and another .gpg-id applies where it landed; a folder that has its own list is left as it is. Only that entry or folder, not what is around it; startMovedReencrypts() starts it. | |
| auto | refuseOverlappingMove (const QString &src, const QString &destFile) -> bool |
Refuse a move of src to destFile that touches what an earlier move or a re-encryption still has to settle: moving it again meanwhile would leave the run for the place it is no longer at. | |
| auto | placeEncryptedFile (const QString &output, const QString &file, bool overwrite, QString *error) -> bool |
Bring the ciphertext gpg wrote to output into the store as file (Util::copyFileReplacing): through a temporary created next to the entry and written by its open handle, then the operating system's rename, which replaces the entry under that name (or, without overwrite, fails when one has appeared) and follows nothing. Reports nothing itself: Insert()'s finished() routes the reason through the failed-operation path once the queued git steps are cancelled, and re-encryption lists it in the run's summary. | |
| auto | placePendingInsert (int exitCode, QString *error) -> int |
| Finish the oldest pending insert after its gpg step: place the ciphertext with placeEncryptedFile(), unless gpg failed or a Git operation stopped half-way meanwhile. Sets m_insertPlaced. | |
| void | startReencryptWorker (const QString &dir) |
| Start the worker thread once the Executor queue is idle. | |
| auto | reencryptFiles (const QString &dir) -> ReencryptResult |
Worker-thread body: scan dir and re-encrypt stale files. | |
| auto | startReencryptRun (const QString &dir, ReencryptResult &result) -> bool |
The checks a run makes after its own pull, before it writes: no unfinished Git operation, dir not a link or behind one, the list Init() wrote unchanged by the pull; then the leftovers of an interrupted run, and the backup commit. | |
| auto | isTrustedEntry (const QString &fileName, const QSet< QString > &listNow) const -> bool |
| Whether an entry that would gain readers is taken without a question: the user moved or copied it in, or agreed to it in reencryptAlso() while its bytes and its list's keys are unchanged. | |
| auto | listKeysFor (const QString &gpgIdPath, const QStringList &gpgId, WhoReads &who) -> const ListKeys & |
The keys of the list at gpgIdPath, worked out once per run. | |
| auto | readerChangeOf (const QString &fileName, const QStringList &keys, const ListKeys &lk, WhoReads &who) -> ReaderChange |
| Who would gain an entry by re-encrypting it to its list, other than those this change added, and who was taken off and still reads it. | |
| auto | holdForAgreement (const QString &fileName, const QStringList &keys, const ReaderChange &change, const WhoReads &who, ReencryptResult &result) -> bool |
| Leave an entry that would gain readers for the user: named in the question after the run, with the bytes it is named for, or reported as failed when its bytes cannot be read to hold a yes to. | |
| auto | reencryptEntry (const QString &fileName, const QStringList &gpgId, WhoReads &who, ReencryptResult &result) -> bool |
Check one entry and re-encrypt it to gpgId when it is not encrypted to those keys yet, unless it would gain readers no one agreed to. | |
| auto | pullBeforeReencrypt () -> bool |
| Pull before a run, when the store is a Git repository and automatic pulling is on. | |
| auto | entriesToReencrypt (const QString &dir, QStringList *failed) -> QStringList |
The entries under dir a run considers, telling the user about anything skipped for not being a regular file. | |
| auto | recipientsForDir (const QString &fileName, QHash< QString, QStringList > &verified, QStringList &gpgId, ReencryptResult &result) -> bool |
The verified recipients for the folder fileName sits in. | |
| auto | recoverReencryptLeftovers (const QString &dir) -> bool |
Deal with what a crashed or failed earlier run left under dir before touching anything: stale temporaries (today's staged .qtpass-XXXXXX.tmp, 1.8.x's <entry>.reencrypt.tmp, the <entry>.XXXXXX.tmp of builds in between) are removed unless they were modified within the hour, where they may be another QtPass's write in flight on a shared store; a 1.8.x <entry>.reencrypt.bak whose original is missing is put back, one next to a present original is reported and left alone (both are valid ciphertexts, the choice is the user's). Whatever needs a human is reported in one critical(), the list capped. | |
| void | dropStaleTemporary (const QString &path) |
| Remove a stale temporary a crashed run left, unless it was modified within the hour: on a shared store it may be another QtPass's write in flight under the same name. | |
| auto | restoreBackup (const QString &path, QStringList &problems) -> bool |
| Put a 1.8.x backup back in its entry's place when the entry is missing; report it when both exist (both are valid ciphertexts, the choice is the user's) or when the rename fails. | |
| void | reportUnrestorable (const QString &path, QStringList &problems) |
| Note for the user that a leftover is not a regular file and was left. | |
| void | finishReencrypt (const ReencryptResult &result) |
| Report the outcome of a run and emit endReencryptPath(). | |
| void | reportFailedEntries (const QStringList &failed) |
| Tell the user which entries a run could not re-encrypt, the first few by name. | |
| auto | settleAutoPushHold (const ReencryptResult &result, bool agreedRun) -> bool |
| Bring the record of entries a removed recipient still reads up to date with a run, and hold the automatic push for the run's folder when the change is not done there, or release it after a full, clean run. | |
| void | reportReencryptOutcome (const ReencryptResult &result, bool stillRead) |
| The status line for a run, and the push after it when one is due and nothing holds it. | |
| void | rememberUnexpected (const ReencryptResult &result) |
| Keep what the run named in unexpectedRecipients(), with the bytes and readers it was named for: reencryptAlso() takes the user's yes from there. | |
| auto | refuseInitBeforeWrite (const QString &gpgIdFile, const GpgIdSigner &signer) -> bool |
| The checks Init() runs before it writes anything: no re-encryption running, the signing key's secret key available, the list and its signature free or regular files, and the list unchanged since the users dialog read it. Each refusal is shown. | |
| auto | previousListOf (const QString &path, const QString &gpgIdFile) -> std::optional< PreviousList > |
The verified list the entries of path were encrypted to before Init() replaces it, as the PreviousList of the run it starts. | |
| void | keepPreviousList (const QString &gpgIdFile, const std::optional< PreviousList > &previous) |
Take previous as the PreviousList of the run Init() starts for gpgIdFile, unless a run is active or an earlier, unfinished run of the same list left one: that one still tells whom the changes removed. | |
| void | reencryptAfterFailedCommit (const QString &path, int gitExit, const QString &gitOut, const QString &gitErr, const QString &gpgIdFile, const std::optional< PreviousList > &previous) |
| After Init() wrote the new list but could not commit it: report Git's failure and re-encrypt without Git all the same, so nobody just removed can still read the entries. | |
| auto | reencryptUsesGit () const -> bool |
| gitConfigured(), unless the current run is one reencryptWithoutGit() started. | |
| void | reencryptWithoutGit (const QString &dir, const QString &gitError) |
Re-encrypt dir to the .gpg-id Init() wrote although its commit failed, without any Git step (they would fail the same way), and tell the user afterwards that the change is not committed. | |
| void | reportUncommittedGpgId (const QString &dir, const QString &gitError, bool reencrypted) |
Tell the user that the recipients of dir changed on disk but the change is not committed, and whether the entries were re-encrypted. | |
| auto | translatePathForWsl (const QString &path, const QString &exe) const -> QString |
Translate path for the given exe when WSL-routed: wraps in wslpath substitution, otherwise returns path unchanged. | |
| auto | pgit (const QString &path) const -> QString |
Translate path for git when WSL-routed: wraps in wslpath substitution, otherwise returns path unchanged. | |
| auto | pgpg (const QString &path) const -> QString |
Translate path for gpg when WSL-routed: wraps in wslpath substitution, otherwise returns path unchanged. | |
Static Private Member Functions | |
| static auto | namedReaders (const QSet< QString > &fprs, const QHash< QString, QString > &names) -> QString |
The names of fprs for a question or a failure, sorted. | |
Private Attributes | |
| SimpleTransaction | m_transaction |
| QQueue< PendingMove > | m_pendingMoves |
| Moves through Git, in order, each settled when its PASS_MOVE ends. | |
| QStringList | m_movedToReencrypt |
| bool | m_deferredPushByHand = false |
| NativeGrep | m_grep |
| Background search over the decrypted store; relays to finishedGrep. | |
| QString | m_transactionOutput |
| stdout of the steps of the transaction in flight, collected by finished() and handed on, then cleared, when its last step ends. | |
| QQueue< PendingInsert > | m_pendingInserts |
| The inserts whose gpg step has not ended yet, oldest first. | |
| bool | m_insertPlaced = false |
| bool | m_reencryptActive = false |
| Set while a re-encryption run is pending or on the worker thread. | |
| bool | m_pushAfterReencrypt = false |
| QString | m_reencryptScope |
| The folder the re-encryption in flight covers, for the push hold. | |
| bool | m_reencryptPushing = false |
| Set while finishReencrypt() pushes, so GitPush() does not hold it. | |
| std::atomic< bool > | m_reencryptCancel {false} |
| QThread * | m_reencryptThread = nullptr |
| The re-encryption worker while it runs, null otherwise. The destructor sets m_reencryptCancel and joins it. | |
| std::optional< UncommittedGpgId > | m_uncommittedGpgId |
| std::optional< WrittenGpgId > | m_writtenGpgId |
| std::optional< PreviousList > | m_previousList |
| QStringList | m_reencryptTrusted |
| QHash< QString, Agreed > | m_reencryptAgreed |
| QHash< QString, Agreed > | m_lastUnexpected |
| QHash< QString, QSet< QString > > | m_removedReaders |
Friends | |
| class | tst_util |
| class | tst_imitatepass |
Additional Inherited Members | |
| Public Types inherited from Pass | |
| using | SkippedWalks = QHash<QString, SkippedWalk> |
| SkippedWalk per absolute folder, for one check of many folders. | |
| using | LinkedWalks = QHash<QString, std::optional<QString>> |
| Static Public Member Functions inherited from Pass | |
| static bool | gpgSupportsEd25519 (const QString &gpgExecutable={}) |
| Check if GPG supports Ed25519 encryption. | |
| static QString | getDefaultKeyTemplate (const QString &gpgExecutable={}) |
| Get default key template for new GPG keys. | |
| static auto | exactRecipientArg (const QString &line) -> QString |
| A bare mail address in gpg's exact form, <address>; any other line as written. | |
| static auto | keyLinesHeldTwiceIn (const QStringList &lines, const QString &listing) -> QHash< QString, QStringList > |
| keyLinesHeldTwice() on a listing already made. | |
| 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. | |
| static auto | pullTimedOut (int timeoutMs) -> QString |
| The status-bar text for a blocking pull stopped at its deadline. | |
| static auto | maxOutputArgs () -> QStringList |
| The gpg options that enforce kMaxPlaintextBytes. | |
| static auto | resolveGpgconfCommand (const QString &gpgPath) -> ResolvedGpgconfCommand |
| Resolve the gpgconf command to kill agents. | |
| static auto | getGpgIdPath (const QString &for_file, const QString &passStore) -> QString |
| Get .gpg-id file path for a password file. | |
| 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 that a signed store must not. | |
| 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, if it skips one before the list it returns. | |
| static auto | getRecipientList (const QString &for_file, const QString &passStore) -> QStringList |
| Get list of recipients for a password file. | |
| 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 logged and skipped. | |
| static auto | passReadsDifferently (const QByteArray &contents) -> QString |
| Why pass would read a .gpg-id differently from parseRecipients(), if it would. | |
| static auto | loggableArgs (const QStringList &args) -> QStringList |
| The arguments as they may appear in the debug log: the value of --passphrase and friends, and otpauth URIs, are replaced. | |
| Static Public Attributes inherited from Pass | |
| static constexpr int | kBlockingPullMs = 30000 |
| How long the pull before an edit may block the window. | |
| static constexpr qint64 | kMaxPlaintextBytes = 64LL * 1024 * 1024 |
| Most bytes of plaintext a gpg decryption may produce. | |
| Protected Types inherited from Pass | |
| enum class | LinkScope { EntryAndParents , ParentsOnly } |
| What refuseLinkedPath() judges. More... | |
| enum class | PathSpelling { Configured , PlacedByCaller } |
| How a path handed to refuseLinkedPath() is spelled. More... | |
| using | PROCESS = Enums::PROCESS |
| Alias for Enums::PROCESS used throughout this class. | |
| Static Protected Member Functions inherited from Pass | |
| static auto | enabledKeyLines (const QList< UserInfo > &users) -> QStringList |
| The enabled users' key IDs, as Init() writes them to .gpg-id. | |
| static auto | withoutStatusLines (const QString &err) -> QString |
| gpg's stderr without its machine-readable [GNUPG:] lines (and without carriage returns), as a person reads it. | |
Implementation that imitates 'pass' when the real tool is unavailable.
ImitatePass provides a complete password store implementation using direct GPG operations when 'pass' is not installed or not enabled. It handles:
This is used as a fallback when RealPass cannot be initialized.
Definition at line 41 of file imitatepass.h.
| ImitatePass::ImitatePass | ( | ) |
Construct the backend and connect its content search.
Definition at line 54 of file imitatepass.cpp.
|
override |
Cancel a running content search, and cancel and join a running re-encryption worker, before the members they use go away.
Definition at line 58 of file imitatepass.cpp.
|
protected |
Put the generation header on a list that is about to be signed: reserve a generation above what this device accepted and what the verified list on disk says, and bind the list to its folder, so no older or relocated signed list comes back.
| gpgIdFile | The .gpg-id being written. |
| signer | Its signer, which verifies the list on disk. |
| contents | The key IDs, one per line; receives the header too. |
Definition at line 505 of file imitatepass.cpp.
|
overrideprotectedvirtual |
Open a transaction for every execution.
In native (imitate) mode each wrapped command is a git/gpg transaction; register it before the subprocess runs.
| id | Process identifier. |
Reimplemented from Pass.
Definition at line 2790 of file imitatepass.cpp.
|
inlineoverridevirtual |
Stop the running search (NativeGrep::cancel()).
Reimplemented from Pass.
Definition at line 694 of file imitatepass.h.
| void ImitatePass::cancelReencryptPath | ( | ) |
Ask a running reencryptPath() to stop.
Only sets a flag. The worker starts no further gpg or git process, and the one it is blocked on (gpg waiting on pinentry, say) is terminated by the worker itself, and killed if it is still running after a short grace period, so the cancel takes effect promptly rather than after the current file. The store stays consistent: reencryptSingleFile() only replaces a file once the new ciphertext is verified, so an interrupted file is left untouched, or already re-encrypted but not yet committed when git was the process that was interrupted. The remaining files are left untouched and the interrupted file is not reported as a failure. endReencryptPath() is still emitted when the worker has stopped.
Definition at line 1626 of file imitatepass.cpp.
|
protected |
Decrypt ciphertext again and compare it with plaintext, byte for byte, so nothing replaces an entry until it is known to hold what it held.
| ciphertext | The file gpg just wrote. |
| plaintext | What it must decrypt to. |
Definition at line 1326 of file imitatepass.cpp.
|
protected |
The start of a git commit for the store: "commit", and "-S" when git config pass.signcommits is true there, as pass signs its own.
Definition at line 406 of file imitatepass.cpp.
|
nodiscardprotected |
How a commit message names a file of the store: relative to the store, without .gpg ("work/bank", "work/.gpg-id"), never the local path, which the shared history would carry to everyone.
| path | Absolute path, normally inside the store. |
Definition at line 2443 of file imitatepass.cpp.
|
protected |
Stage and commit a re-encrypted entry, when the store is a Git repository QtPass manages.
| fileName | The entry that was replaced. |
Definition at line 1348 of file imitatepass.cpp.
|
overridevirtual |
Copy password file.
| src | Source path. |
| dest | Destination path. |
| force | true to overwrite existing destination. |
Implements Pass.
Definition at line 2615 of file imitatepass.cpp.
|
protected |
The file a copy of src to dest writes: like pass cp, into an existing folder with .gpg appended. Refused (the user told) when it is a link, the source itself, or taken and force is off.
| src | The entry to copy. |
| dest | Where to, a file or a folder. |
| force | Whether an existing entry may be replaced. |
Definition at line 2586 of file imitatepass.cpp.
|
protected |
Create git backup commit before re-encryption.
Definition at line 1455 of file imitatepass.cpp.
|
protected |
Decrypt fileName for re-encryption.
Bytes, not text: an entry that is not UTF-8 (a Latin-1 password, a binary key) went through QString before, and every such byte came back as U+FFFD in the re-encrypted entry. The entry is read without following a link and given to gpg on stdin, so a link put under its name since the run listed it is refused.
| fileName | The entry to read. |
| plaintext | Receives exactly what gpg printed. |
| why | Set when the entry is no longer a regular file; may be null. |
Definition at line 1272 of file imitatepass.cpp.
|
private |
Remove a stale temporary a crashed run left, unless it was modified within the hour: on a shared store it may be another QtPass's write in flight under the same name.
| path | The temporary, a regular file. |
Definition at line 950 of file imitatepass.cpp.
|
protected |
Encrypt plaintext to recipients, into output.
| output | Where gpg writes the ciphertext; outside the store. |
| recipients | The keys to encrypt to; gpg.conf adds none. |
| plaintext | The bytes to encrypt, fed on stdin. |
Definition at line 1313 of file imitatepass.cpp.
|
signal |
A reencryptPath() run is over, whether it finished, failed, was cancelled or was refused; the main window releases the interface.
Also emitted without a preceding startReencryptPath() when the folder is refused before anything starts.
|
private |
The entries under dir a run considers, telling the user about anything skipped for not being a regular file.
| dir | Directory to walk, recursively. |
| failed | Receives a failure line for every folder that could not be read: its entries are not in the result, and the run must not pass for complete. |
Definition at line 1745 of file imitatepass.cpp.
|
protected |
SHA-256 of an entry's bytes, read as a regular file without following a link.
| file | The entry, absolute. |
Definition at line 1223 of file imitatepass.cpp.
|
nodiscardprotected |
Executor::executeBlocking() for the re-encryption helpers.
Runs in the store's environment (storeEnvironment(); on the worker, the copy taken when it started), which carries the git ceiling QtPass's own does not. On the owning thread this is a plain blocking run. On the worker thread it hands m_reencryptCancel to the cancellable executeBlocking() overload: nothing is started once the flag is set, and a process that is running when it gets set is terminated (then killed) by the worker thread, which is what lets cancelReencryptPath() and the destructor interrupt an active gpg or git without touching its QProcess or pid.
| app | The program. |
| args | Its arguments. |
| input | What to write to its stdin. |
| process_out | Receives stdout, if not null. |
| process_err | Receives stderr, if not null. |
Definition at line 84 of file imitatepass.cpp.
|
nodiscardprotected |
Overload capturing stdout (and stderr) without stdin input.
| app | The program. |
| args | Its arguments. |
| process_out | Receives stdout. |
| process_err | Receives stderr, if not null. |
Definition at line 102 of file imitatepass.cpp.
|
nodiscardprotected |
execBlocking() on bytes (Executor::executeBlockingRaw()), for an entry's plaintext, which need not be UTF-8.
| app | The program. |
| args | Its arguments. |
| input | Bytes to write to its stdin (empty = none). |
| process_out | Receives stdout as written, if not null. |
Definition at line 93 of file imitatepass.cpp.
| void ImitatePass::executeGit | ( | PROCESS | id, |
| const QStringList & | args, | ||
| QString | input = QString(), | ||
| bool | readStdout = true, | ||
| bool | readStderr = true ) |
Execute git command.
| id | Process identifier. |
| args | Git arguments. |
| input | Input to stdin. |
| readStdout | Capture stdout. |
| readStderr | Capture stderr. |
Definition at line 2691 of file imitatepass.cpp.
| void ImitatePass::executeGpg | ( | PROCESS | id, |
| const QStringList & | args, | ||
| QString | input = QString(), | ||
| bool | readStdout = true, | ||
| bool | readStderr = true ) |
Execute GPG command.
| id | Process identifier. |
| args | GPG arguments. |
| input | Input to stdin. |
| readStdout | Capture stdout. |
| readStderr | Capture stderr. |
Definition at line 2669 of file imitatepass.cpp.
| void ImitatePass::executeMoveGit | ( | const QString & | src, |
| const QString & | destFile, | ||
| bool | force ) |
Execute git move operation.
| src | Source path. |
| destFile | Destination path. |
| force | Overwrite existing. |
Definition at line 2426 of file imitatepass.cpp.
|
overrideprotectedvirtual |
Handle process completion.
| id | Process identifier. |
| exitCode | Process exit code. |
| out | Standard output from the process. |
| err | Standard error from the process. |
Reimplemented from Pass.
Definition at line 2701 of file imitatepass.cpp.
|
private |
Report the outcome of a run and emit endReencryptPath().
| result | Outcome produced by reencryptFiles(). |
Definition at line 2147 of file imitatepass.cpp.
|
overrideprotectedvirtual |
Pass::fullKeyListing() in the calling thread's environment, so a re-encryption run's worker lists the store's keyring.
| listing | Receives the colon listing. |
Reimplemented from Pass.
Definition at line 730 of file imitatepass.cpp.
|
protected |
Read recipients from file.
| fileName | Path to file. |
Definition at line 1106 of file imitatepass.cpp.
|
protected |
Stage a .gpg-id and, when given, its .sig, and commit both in one commit, so no commit in the history has a recipient list without the signature that covers it. Nothing is committed when neither file changed.
| gpgIdFile | Absolute path of the .gpg-id. |
| gpgIdSigFile | Absolute path of the .gpg-id.sig, or empty when no signing key is configured. |
| out | Receives the concatenated stdout of the git commands. |
| err | Receives the concatenated stderr of the git commands. |
Definition at line 637 of file imitatepass.cpp.
| void ImitatePass::gitCommit | ( | const QString & | file, |
| const QString & | msg ) |
Commit one path to git.
| file | Changed file path. |
| msg | Commit message. |
Definition at line 419 of file imitatepass.cpp.
| void ImitatePass::gitCommit | ( | const QStringList & | files, |
| const QString & | msg ) |
Commit these paths and nothing else: a change someone staged meanwhile stays staged, out of a commit autoPush would send.
| files | Changed paths (a moved entry's old and new path). |
| msg | Commit message. |
Definition at line 423 of file imitatepass.cpp.
| auto ImitatePass::gitConfigured | ( | ) | const -> bool |
Git is enabled and an executable is configured.
Definition at line 2677 of file imitatepass.cpp.
|
overridevirtual |
Initialize Git repository.
Implements Pass.
Definition at line 133 of file imitatepass.cpp.
|
overridevirtual |
Pull from remote.
Implements Pass.
Definition at line 137 of file imitatepass.cpp.
|
overridevirtual |
Run git pull in the store and wait for it, at most timeoutMs.
| timeoutMs | Most milliseconds to wait (Pass::kBlockingPullMs). |
Implements Pass.
Definition at line 144 of file imitatepass.cpp.
|
overridevirtual |
Push to remote. While a re-encryption runs the push is held (Users ▸ OK and a copy ask for it as soon as their commit is made, before the worker is done) and made when the run ends with every file re-encrypted; after a failed or cancelled run nothing is pushed.
Implements Pass.
Definition at line 166 of file imitatepass.cpp.
| auto ImitatePass::gitReady | ( | ) | -> bool |
gitConfigured() plus a status message when git is enabled but no executable is configured.
Definition at line 2683 of file imitatepass.cpp.
|
protected |
Check whether git already tracks a file in the store.
| file | Absolute path inside the password store. |
Definition at line 681 of file imitatepass.cpp.
|
protected |
The signer for this store's .gpg-id, bound to the configured gpg and signing keys and to execBlocking(), so a verification on the re-encryption worker can be interrupted like every other gpg run there.
Definition at line 494 of file imitatepass.cpp.
|
overridevirtual |
Search all password content by GPG-decrypting each .gpg file.
Pattern is interpreted as a QRegularExpression (PCRE-like); RealPass::Grep uses the same search, so both backends match alike.
| pattern | Search pattern (QRegularExpression). |
| caseInsensitive | true for case-insensitive search. |
Implements Pass.
Definition at line 2796 of file imitatepass.cpp.
|
private |
Leave an entry that would gain readers for the user: named in the question after the run, with the bytes it is named for, or reported as failed when its bytes cannot be read to hold a yes to.
| fileName | The entry. |
| keys | The recipient key IDs it is encrypted to. |
| change | Who gains it and who still reads it. |
| who | The run's record of key IDs and names. |
| result | Gets the question or the failure. |
Definition at line 2032 of file imitatepass.cpp.
|
overridevirtual |
Initialize store.
Writes (and signs) the folder's .gpg-id, commits it when Git is used and re-encrypts the folder to it. When that commit fails the entries are still re-encrypted, without any Git step, and a critical() afterwards says the change is not committed and whether the re-encryption completed. Nothing is written while .gpg-id or .gpg-id.sig is there as something other than a regular file (a folder).
| path | Root path of the password store. |
| users | List of recipient GPG keys. |
Implements Pass.
Definition at line 741 of file imitatepass.cpp.
|
overridevirtual |
Insert new password.
| file | Path to the password file. |
| newValue | Password content to store. |
| overwrite | true to overwrite an existing file. |
Implements Pass.
Definition at line 347 of file imitatepass.cpp.
|
inlinenodiscardoverrideprotectedvirtual |
Whether the failed insert had placed its entry (see placeEncryptedFile()) before a later git step failed.
| err | Not needed: the placement is known, not inferred. |
Reimplemented from Pass.
Definition at line 469 of file imitatepass.h.
|
nodiscardprivate |
Whether an entry that would gain readers is taken without a question: the user moved or copied it in, or agreed to it in reencryptAlso() while its bytes and its list's keys are unchanged.
| fileName | The entry. |
| listNow | The keys its list encrypts to now. |
Definition at line 1924 of file imitatepass.cpp.
|
private |
Take previous as the PreviousList of the run Init() starts for gpgIdFile, unless a run is active or an earlier, unfinished run of the same list left one: that one still tells whom the changes removed.
| gpgIdFile | The .gpg-id Init() wrote. |
| previous | The list it replaced, if verified. |
Definition at line 823 of file imitatepass.cpp.
|
protected |
The primary keys gpg encrypts to for recipients, found by a throwaway encryption outside the store with the arguments a real one uses, so groups, ! suffixes and key lookups count as -r makes them.
| recipients | A recipient list. |
| primaries | As for primaryKeysOf(). |
| names | As for primaryKeysOf(). |
| lookUp | Whether gpg may look keys up (auto-key-locate, WKD) as a real encryption would; false for a list being replaced, whose removed recipients should not be fetched over the network. |
Definition at line 1231 of file imitatepass.cpp.
|
private |
The keys of the list at gpgIdPath, worked out once per run.
| gpgIdPath | The .gpg-id the entry falls under. |
| gpgId | The recipients read from it. |
| who | The run's record; the result is kept in it. |
Definition at line 1942 of file imitatepass.cpp.
|
protected |
Read a .gpg-id, verify its detached signature and parse the recipients from the bytes that were verified.
One read serves both the check and the parse, so a file swapped in between cannot smuggle in a recipient the signature never covered.
| gpgIdFile | The .gpg-id. |
| recipients | Receives the recipients; empty on failure. |
| why | Receives, if not null, what to tell the user on failure: a bad signature, or a signed list older than one accepted before (GpgIdGeneration). |
Definition at line 901 of file imitatepass.cpp.
|
overridevirtual |
Move password file.
As pass mv, what moved is then re-encrypted for the recipients where it landed, when another .gpg-id applies there than where it came from (a folder with its own list takes that along): see reencryptMoved(). With Git that happens once the queued git mv has run. No message box opens while the move's Git commands are being queued.
| src | Source path. |
| dest | Destination path. |
| force | true to overwrite existing destination. |
Implements Pass.
Definition at line 2456 of file imitatepass.cpp.
|
staticprivate |
The names of fprs for a question or a failure, sorted.
| fprs | Primary fingerprints, or kUnknownReader. |
| names | Fingerprint to name, as the run learnt them. |
Definition at line 2017 of file imitatepass.cpp.
|
private |
Translate path for git when WSL-routed: wraps in wslpath substitution, otherwise returns path unchanged.
| path | Native filesystem path. |
Definition at line 125 of file imitatepass.cpp.
|
private |
Translate path for gpg when WSL-routed: wraps in wslpath substitution, otherwise returns path unchanged.
| path | Native filesystem path. |
Definition at line 129 of file imitatepass.cpp.
|
private |
Bring the ciphertext gpg wrote to output into the store as file (Util::copyFileReplacing): through a temporary created next to the entry and written by its open handle, then the operating system's rename, which replaces the entry under that name (or, without overwrite, fails when one has appeared) and follows nothing. Reports nothing itself: Insert()'s finished() routes the reason through the failed-operation path once the queued git steps are cancelled, and re-encryption lists it in the run's summary.
| output | The file gpg wrote, in a directory of QtPass's own. |
| file | The entry's path. |
| overwrite | Whether an entry already there may be replaced. |
| error | Receives why file could not be written, if not. |
file now holds the new ciphertext. Definition at line 2778 of file imitatepass.cpp.
|
private |
Finish the oldest pending insert after its gpg step: place the ciphertext with placeEncryptedFile(), unless gpg failed or a Git operation stopped half-way meanwhile. Sets m_insertPlaced.
| exitCode | The gpg step's exit code. |
| error | Receives why the entry was not placed, if so. |
exitCode when gpg failed, 1 when the entry was not placed, else 0. Definition at line 2748 of file imitatepass.cpp.
|
protected |
Give process the environment for the calling thread: the store's on the owning thread, the re-encryption run's on its worker.
| process | The process to set up. |
Definition at line 72 of file imitatepass.cpp.
|
private |
The verified list the entries of path were encrypted to before Init() replaces it, as the PreviousList of the run it starts.
| path | The folder, in the store's own spelling, with a trailing separator. |
| gpgIdFile | The .gpg-id Init() writes there. |
Definition at line 888 of file imitatepass.cpp.
|
protected |
The primary keys behind key IDs from an entry (ENC_TO).
| ids | Long key IDs of encryption subkeys. |
| primaries | Key ID to primary fingerprint, filled from one key listing on first use. |
| names | Primary fingerprint to its first user ID, filled with it. |
Definition at line 1192 of file imitatepass.cpp.
|
private |
Pull before a run, when the store is a Git repository and automatic pulling is on.
Pull before re-encryption when automatic pulling is configured.
Definition at line 1693 of file imitatepass.cpp.
|
private |
Who would gain an entry by re-encrypting it to its list, other than those this change added, and who was taken off and still reads it.
| fileName | The entry. |
| keys | The recipient key IDs it is encrypted to. |
| lk | Its list's keys (listKeysFor()). |
| who | The run's record of key IDs and names. |
Definition at line 1967 of file imitatepass.cpp.
|
overridevirtual |
Who saving over an existing entry would let read it who may not now.
Asked by the edit dialog before Insert(), so a list that changed under the entry (a folder renamed past its own signed list, say) does not widen it unasked. Those who read it now come from the entry's recipient IDs, which whoever can push can write; so with a signing key, an entry at a path this device never saved (EntryRecord) whose folder takes a parent's list is asked about whatever its IDs say. None by default; the native backend tells.
| file | The entry, relative to the store, without ".gpg". |
Reimplemented from Pass.
Definition at line 282 of file imitatepass.cpp.
|
private |
The verified recipients for the folder fileName sits in.
| fileName | An entry in the folder. |
| verified | Cache of the .gpg-id files already checked. |
| gpgId | Receives the recipients to encrypt that folder to. |
| result | Marked cancelled or aborted when the answer is no. |
Definition at line 1781 of file imitatepass.cpp.
|
protected |
The recipients to encrypt file to: its folder's .gpg-id, verified when a signing key is set.
| file | The entry, absolute. |
| recipients | Receives the key IDs. |
Definition at line 261 of file imitatepass.cpp.
|
private |
Deal with what a crashed or failed earlier run left under dir before touching anything: stale temporaries (today's staged .qtpass-XXXXXX.tmp, 1.8.x's <entry>.reencrypt.tmp, the <entry>.XXXXXX.tmp of builds in between) are removed unless they were modified within the hour, where they may be another QtPass's write in flight on a shared store; a 1.8.x <entry>.reencrypt.bak whose original is missing is put back, one next to a present original is reported and left alone (both are valid ciphertexts, the choice is the user's). Whatever needs a human is reported in one critical(), the list capped.
| dir | Directory to scan, recursively. |
Definition at line 999 of file imitatepass.cpp.
|
private |
After Init() wrote the new list but could not commit it: report Git's failure and re-encrypt without Git all the same, so nobody just removed can still read the entries.
| path | The folder, in the store's own spelling. |
| gitExit | Git's exit code. |
| gitOut | Git's standard output. |
| gitErr | Git's error output, shown as the reason when not empty. |
| gpgIdFile | The .gpg-id Init() wrote. |
| previous | The list it replaced, if verified. |
Definition at line 835 of file imitatepass.cpp.
| void ImitatePass::reencryptAlso | ( | const QString & | dir, |
| const QStringList & | files, | ||
| const AppSettings & | settings ) |
Re-encrypt files in dir after the user agreed to it.
A run leaves alone an entry encrypted to other keys than its folder had (unexpectedRecipients()): someone who can read one folder could have copied it in from a folder they cannot read, and re-encrypting it would hand them its plaintext. This runs dir again with files taken as they are. Only entries the last run named, each only while its bytes are those it was named with; the run takes those and nothing else.
| dir | The folder of the run that found them. |
| files | The entries, as unexpectedRecipients() named them. |
| settings | The current settings, as for reencryptPath(). |
Definition at line 2307 of file imitatepass.cpp.
|
private |
Check one entry and re-encrypt it to gpgId when it is not encrypted to those keys yet, unless it would gain readers no one agreed to.
| fileName | The entry. |
| gpgId | The recipients of its folder. |
| who | The run's record of who reads what. |
| result | Gets the entry's outcome. |
Definition at line 2087 of file imitatepass.cpp.
|
private |
Worker-thread body: scan dir and re-encrypt stale files.
| dir | Directory passed to reencryptPath(). |
Definition at line 1805 of file imitatepass.cpp.
|
private |
Queue a re-encryption of what move moved, if it moved and another .gpg-id applies where it landed; a folder that has its own list is left as it is. Only that entry or folder, not what is around it; startMovedReencrypts() starts it.
| move | The move, as Move() recorded it. |
Definition at line 2554 of file imitatepass.cpp.
| void ImitatePass::reencryptPath | ( | const QString & | dir | ) |
Re-encrypt entire directory.
Emits startReencryptPath() synchronously, then runs the scan and the per-file gpg calls on a worker thread. Progress is reported through reencryptProgress(); per-file failures are collected and reported in a single critical() once the run is over, followed by endReencryptPath(). A second call while a run is active is ignored. Dot-named entries (.env.gpg) are re-encrypted too, as with pass init; hidden folders (.git, .stversions) are not entered.
| dir | Directory path, or one entry's .gpg file (a move re-encrypts what it moved, not the folder around it). |
Definition at line 1590 of file imitatepass.cpp.
| void ImitatePass::reencryptPath | ( | const QString & | dir, |
| const AppSettings & | settings ) |
Re-encrypt dir under settings, the current profile's.
This backend re-encrypts also when pass is the active one, and then is not re-initialised on a profile switch: without this it would decrypt the current profile's entries and encrypt them to the recipients and signing policy of the profile it last ran for. The settings are taken only when no run is active, so a running one keeps its own.
| dir | Directory path. |
| settings | The current settings. |
Definition at line 1581 of file imitatepass.cpp.
|
signal |
Re-encryption progress: current of total files checked.
Emitted from the worker thread; connect with a queued (or automatic) connection.
| current | Number of files checked so far, including this one. |
| total | Total number of files found by the scan. |
|
protected |
Re-encrypt single file with new recipients.
| fileName | File to re-encrypt. |
| recipients | New recipient key IDs. |
| why | Receives, for a failure the user can act on (the new ciphertext could not be put under the entry's name), the reason for the run's summary; left empty for a gpg failure, which is logged. |
Definition at line 1375 of file imitatepass.cpp.
|
private |
gitConfigured(), unless the current run is one reencryptWithoutGit() started.
Definition at line 2336 of file imitatepass.cpp.
|
private |
Re-encrypt dir to the .gpg-id Init() wrote although its commit failed, without any Git step (they would fail the same way), and tell the user afterwards that the change is not committed.
| dir | The folder whose recipients changed. |
| gitError | What Git said when the commit failed. |
Definition at line 2340 of file imitatepass.cpp.
|
private |
The checks Init() runs before it writes anything: no re-encryption running, the signing key's secret key available, the list and its signature free or regular files, and the list unchanged since the users dialog read it. Each refusal is shown.
| gpgIdFile | The .gpg-id Init() is to write. |
| signer | The store's signer. |
Definition at line 851 of file imitatepass.cpp.
|
protected |
Refuse a folder, or a .gpg-id/.gpg-id.sig in it, that is a link: writing there would reach outside the store.
| path | The folder, with its trailing separator. |
Definition at line 687 of file imitatepass.cpp.
|
private |
Refuse a move of src to destFile that touches what an earlier move or a re-encryption still has to settle: moving it again meanwhile would leave the run for the place it is no longer at.
| src | What is to be moved. |
| destFile | Where to, as resolveMoveDestination() gave it. |
Definition at line 2521 of file imitatepass.cpp.
|
private |
Keep what the run named in unexpectedRecipients(), with the bytes and readers it was named for: reencryptAlso() takes the user's yes from there.
| result | The run's outcome. |
Definition at line 2296 of file imitatepass.cpp.
|
overridevirtual |
Remove password.
| file | Path to the file or directory to remove. |
| isDir | true if removing a directory. |
Implements Pass.
Definition at line 431 of file imitatepass.cpp.
|
private |
Tell the user which entries a run could not re-encrypt, the first few by name.
| failed | The entries that failed; nothing is shown when empty. |
Definition at line 2192 of file imitatepass.cpp.
|
private |
The status line for a run, and the push after it when one is due and nothing holds it.
| result | The run's outcome. |
| stillRead | Whether a removed recipient still reads an entry in the run's folder (settleAutoPushHold()). |
Definition at line 2247 of file imitatepass.cpp.
|
private |
Tell the user that the recipients of dir changed on disk but the change is not committed, and whether the entries were re-encrypted.
| dir | The folder whose recipients changed. |
| gitError | What Git said when the commit failed. |
| reencrypted | Whether every entry was re-encrypted to the new recipients; false means some or all are still encrypted to the previous ones. |
Definition at line 2357 of file imitatepass.cpp.
|
private |
Note for the user that a leftover is not a regular file and was left.
| path | The leftover. |
| problems | Gets the sentence for it. |
Definition at line 943 of file imitatepass.cpp.
|
protected |
Resolve destination for move operation.
| src | Source path. |
| dest | Destination path. |
| force | Overwrite existing. |
Definition at line 2381 of file imitatepass.cpp.
|
private |
Put a 1.8.x backup back in its entry's place when the entry is missing; report it when both exist (both are valid ciphertexts, the choice is the user's) or when the rename fails.
| path | The <entry>.reencrypt.bak file. |
| problems | Gets what to tell the user, if anything. |
Definition at line 962 of file imitatepass.cpp.
|
private |
Make the push GitPush() deferred, once no run is in flight and no move is waiting; an automatic one only while the store is not held.
Definition at line 182 of file imitatepass.cpp.
|
private |
Bring the record of entries a removed recipient still reads up to date with a run, and hold the automatic push for the run's folder when the change is not done there, or release it after a full, clean run.
| result | The run's outcome. |
| agreedRun | Whether the run took only entries the user agreed to, which settles those, not the folder's other holds. |
Definition at line 2207 of file imitatepass.cpp.
|
protected |
Bring the signature in line with the list just written: a new one when signing is on, the old one removed when it is off (pass and other clients would reject the new list under it).
| gpgIdFile | The .gpg-id that was written. |
| written | Its bytes, which are what gets signed. |
| signer | Whether and with which keys to sign. |
| useGit | Whether the store is a Git repository QtPass manages. |
| sigToCommit | Receives the signature file to commit, if any. |
Definition at line 701 of file imitatepass.cpp.
|
overridevirtual |
Show decrypted password.
| file | Path to the password file relative to store root. |
Implements Pass.
Definition at line 217 of file imitatepass.cpp.
|
protected |
Sign a .gpg-id with the configured key and verify the result; failures are reported through critical().
| gpgIdFile | Path to .gpg-id file. |
| contents | The bytes just written as that file: the signature is made over these, not over whatever is under the name by then. |
Definition at line 613 of file imitatepass.cpp.
|
private |
Start the runs in m_movedToReencrypt, one at a time, while none is in flight; then send a deferred push once nothing is left.
Definition at line 199 of file imitatepass.cpp.
|
signal |
A reencryptPath() run is about to start its worker thread.
The main window disables the interface and shows a progress dialog with a Cancel button on it. Always followed by endReencryptPath().
|
private |
The checks a run makes after its own pull, before it writes: no unfinished Git operation, dir not a link or behind one, the list Init() wrote unchanged by the pull; then the leftovers of an interrupted run, and the backup commit.
| dir | Directory passed to reencryptPath(). |
| result | Marked aborted or cancelled when the run stops. |
Definition at line 1849 of file imitatepass.cpp.
|
private |
Start the worker thread once the Executor queue is idle.
| dir | Directory passed to reencryptPath(). |
Definition at line 1637 of file imitatepass.cpp.
|
overrideprotectedvirtual |
Run git with -C <Store tree and entries> in the store, blocking.
| args | The git arguments (without the executable or -C). |
| out | Receives stdout; may be null. |
Reimplemented from Pass.
Definition at line 113 of file imitatepass.cpp.
|
private |
Translate path for the given exe when WSL-routed: wraps in wslpath substitution, otherwise returns path unchanged.
| path | Native filesystem path. |
| exe | Executable path (checked for "wsl " prefix). |
Definition at line 108 of file imitatepass.cpp.
|
signal |
A run left files alone: re-encrypting one would let someone on its folder's list read it who cannot now, and whom the change of the list did not add. An entry copied in from a folder they cannot read must not reach them without the user's say. reencryptAlso() takes them once the user agreed. Emitted after endReencryptPath().
| dir | The folder of the run. |
| files | The entries left alone, absolute. |
| details | For each, who would gain it, and who was removed from the list and still reads it (the run then holds the automatic push). |
|
protected |
Recipients for the directory of file, from its verified .gpg-id.
| file | Password file path. |
| verified | Cache of .gpg-id path to the recipients its verified contents held; a hit skips gpg and reuses exactly that list. |
| gpgId | Output parameter for recipient key IDs, sorted. |
Definition at line 1067 of file imitatepass.cpp.
|
protected |
Write the enabled recipients to a .gpg-id, atomically: a write that fails halfway (full disk, dead network share) leaves the previous file in place instead of a truncated list that would then be signed and encrypted to.
| gpgIdFile | Path to .gpg-id file. |
| users | List of recipients. |
| written | Receives the exact bytes written, if not null: what the signature is then made over. |
Definition at line 566 of file imitatepass.cpp.
|
friend |
Definition at line 45 of file imitatepass.h.
|
friend |
Definition at line 44 of file imitatepass.h.
|
private |
The deferred push (m_pushAfterReencrypt) includes one asked for by hand, which a hold (autoPushHeld()) does not stop.
Definition at line 717 of file imitatepass.h.
|
private |
Background search over the decrypted store; relays to finishedGrep.
Definition at line 747 of file imitatepass.h.
|
private |
The insert whose gpg step ended last placed its entry in the store; its git steps may still fail. Set per gpg completion in finished(), not per Insert() call, so a second queued insert's failure is not reported with an earlier insert's answer.
Definition at line 774 of file imitatepass.h.
|
private |
What the last run named (unexpectedRecipients()), with what was shown; reencryptAlso() takes the user's yes from here.
Definition at line 1132 of file imitatepass.h.
|
private |
What settled moves still need re-encrypted: one run each, started by startMovedReencrypts() once no run is in flight. Pushes wait for them.
Definition at line 714 of file imitatepass.h.
|
private |
The inserts whose gpg step has not ended yet, oldest first.
Definition at line 769 of file imitatepass.h.
|
private |
Moves through Git, in order, each settled when its PASS_MOVE ends.
Definition at line 711 of file imitatepass.h.
|
private |
Set by Init() for the run it starts and cleared by finishReencrypt(). Written only on the owning thread while no worker runs.
Definition at line 1068 of file imitatepass.h.
|
private |
A push was asked for while a run was active (GitPush()); the run makes it at its end, when every file went through.
Definition at line 813 of file imitatepass.h.
|
private |
Set while a re-encryption run is pending or on the worker thread.
Definition at line 810 of file imitatepass.h.
|
private |
The entries the user agreed to in reencryptAlso(), with what they were shown: the run takes only these, and each only while its bytes and its folder's keys are unchanged. Same lifetime as m_reencryptTrusted.
Definition at line 1129 of file imitatepass.h.
|
private |
Set by cancelReencryptPath() and the destructor; read by the worker between files and polled by Executor::executeBlocking() while the worker waits on a process, which the worker then ends itself. The flag is the only thing shared with the worker: its QProcess is not thread-safe and is never touched from another thread.
Definition at line 823 of file imitatepass.h.
|
protected |
storeEnvironment() as it was when the worker started; the worker's processes run in it.
Definition at line 391 of file imitatepass.h.
|
private |
Set while finishReencrypt() pushes, so GitPush() does not hold it.
Definition at line 817 of file imitatepass.h.
|
private |
The folder the re-encryption in flight covers, for the push hold.
Definition at line 815 of file imitatepass.h.
|
private |
The re-encryption worker while it runs, null otherwise. The destructor sets m_reencryptCancel and joins it.
Definition at line 828 of file imitatepass.h.
|
private |
Entries or folders the current run re-encrypts whatever they are encrypted to: what the user moved or copied there. Cleared by finishReencrypt(); written only on the owning thread while no worker runs.
Definition at line 1120 of file imitatepass.h.
|
private |
Entries left alone that a recipient taken off their folder's list still reads, by whom: the automatic push for their folder waits until a run re-encrypts them, finds nobody removed reading them, or they are gone. Kept across runs; written only on the owning thread while no worker runs.
Definition at line 1138 of file imitatepass.h.
|
private |
Groups the git/gpg processes of one operation (Insert, Remove, Move, Copy) into a single completion; see finished() and TransactionHelper.
Definition at line 699 of file imitatepass.h.
|
private |
stdout of the steps of the transaction in flight, collected by finished() and handed on, then cleared, when its last step ends.
Definition at line 752 of file imitatepass.h.
|
private |
Set by reencryptWithoutGit() for the run it starts and cleared by finishReencrypt(): that run does no Git at all (no pull, backup commit, per-entry commit or push) and ends with reportUncommittedGpgId(). Written only on the owning thread while no worker runs; the worker only reads it, through reencryptUsesGit().
Definition at line 1040 of file imitatepass.h.
|
private |
Set by Init() for the run it starts and cleared by finishReencrypt(), or at once when that run is refused before it starts. After its pull the worker stops when the list no longer holds these bytes: a merge changed the recipients the user chose. Written only on the owning thread while no worker runs; the worker only reads it.
Definition at line 1054 of file imitatepass.h.