|
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 | PendingInsert |
| struct | UncommittedGpgId |
| A .gpg-id Init() wrote but could not commit. More... | |
| struct | ReencryptResult |
| Outcome of one reencryptPath() run; filled on the worker thread and consumed by finishReencrypt() on the owning thread. 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. | |
| 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) |
| 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 changes to git. | |
| 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 () override |
| Pull with rebase. | |
| void | GitPush () override |
| Push to remote. | |
| void | Show (QString file) override |
| Show decrypted password. | |
| void | Insert (QString file, QString newValue, bool overwrite) override |
| Insert new password. | |
| 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 | 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. | |
| 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 | 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. | |
| 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 | isIdle () const -> bool |
| Whether no gpg, git or pass of this backend runs or waits. | |
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 | 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 | reencryptSingleFile (const QString &fileName, const QStringList &recipients, QString *why) -> bool |
| Re-encrypt single file with new recipients. | |
| auto | decryptEntry (const QString &fileName, QString *plaintext) -> bool |
Decrypt fileName for re-encryption. | |
| auto | encryptFor (const QString &output, const QStringList &recipients, const QString &plaintext) -> bool |
Encrypt plaintext to recipients, into output. | |
| auto | ciphertextHolds (const QString &ciphertext, const QString &plaintext) -> bool |
Decrypt ciphertext again and compare it with plaintext, 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 | 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. | |
| Protected Member Functions inherited from Pass | |
| 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 | refuseSkippedGpgId (const QString &file, bool signing, const QString &except=QString()) -> 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 () |
| 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. | |
| 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 | 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 | |
| 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. | |
| 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 | pullBeforeReencrypt () -> bool |
| Pull before a run, when the store is a Git repository and automatic pulling is on. | |
| auto | entriesToReencrypt (const QString &dir) -> 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). | |
| 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) -> 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) |
| Tell the user a leftover is not a regular file and was left. | |
| void | finishReencrypt (const ReencryptResult &result) |
| Report the outcome of a run and emit endReencryptPath(). | |
| 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. | |
Private Attributes | |
| SimpleTransaction | m_transaction |
| 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. | |
| 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 |
Friends | |
| class | tst_util |
| class | tst_imitatepass |
Additional Inherited Members | |
| 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 | 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) -> 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 | 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 | 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 auto | seedGpgIdFile (const QString &newDir, const QString &passStore) -> bool |
| Seed a new folder's .gpg-id from the recipients it inherits. | |
| Static Public Attributes inherited from Pass | |
| 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. | |
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 40 of file imitatepass.h.
| ImitatePass::ImitatePass | ( | ) |
Construct the backend and connect its content search.
Definition at line 49 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 53 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 334 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 1640 of file imitatepass.cpp.
| 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 1053 of file imitatepass.cpp.
|
protected |
Decrypt ciphertext again and compare it with plaintext, 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 851 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 255 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 870 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 1500 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 1471 of file imitatepass.cpp.
|
protected |
Create git backup commit before re-encryption.
Definition at line 952 of file imitatepass.cpp.
|
protected |
Decrypt fileName for re-encryption.
| fileName | The entry to read. |
| plaintext | Receives what gpg printed, with a trailing newline. |
Definition at line 822 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 672 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 | What to encrypt, fed on stdin. |
Definition at line 839 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. |
Definition at line 1150 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 67 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 83 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 1561 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 1539 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 1421 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 1571 of file imitatepass.cpp.
|
private |
Report the outcome of a run and emit endReencryptPath().
| result | Outcome produced by reencryptFiles(). |
Definition at line 1277 of file imitatepass.cpp.
|
protected |
Read recipients from file.
| fileName | Path to file. |
Definition at line 793 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 450 of file imitatepass.cpp.
| void ImitatePass::gitCommit | ( | const QString & | file, |
| const QString & | msg ) |
Commit changes to git.
| file | Changed file path. |
| msg | Commit message. |
Definition at line 268 of file imitatepass.cpp.
| auto ImitatePass::gitConfigured | ( | ) | const -> bool |
Git is enabled and an executable is configured.
Definition at line 1547 of file imitatepass.cpp.
|
overridevirtual |
Initialize Git repository.
Implements Pass.
Definition at line 114 of file imitatepass.cpp.
|
overridevirtual |
Pull from remote.
Implements Pass.
Definition at line 118 of file imitatepass.cpp.
|
overridevirtual |
Pull with rebase.
Implements Pass.
Definition at line 125 of file imitatepass.cpp.
|
overridevirtual |
Push to remote.
Implements Pass.
Definition at line 140 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 1553 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 494 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 325 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 1646 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.
| path | Root path of the password store. |
| users | List of recipient GPG keys. |
Implements Pass.
Definition at line 543 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 201 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 389 of file imitatepass.h.
|
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 624 of file imitatepass.cpp.
|
overridevirtual |
Move password file.
| src | Source path. |
| dest | Destination path. |
| force | true to overwrite existing destination. |
Implements Pass.
Definition at line 1440 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 106 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 110 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 1628 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 1118 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 1165 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 180 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).
| dir | Directory to scan, recursively. |
Definition at line 716 of file imitatepass.cpp.
|
private |
Worker-thread body: scan dir and re-encrypt stale files.
| dir | Directory passed to reencryptPath(). |
Definition at line 1189 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.
| dir | Directory path. |
Definition at line 1021 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 1012 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 898 of file imitatepass.cpp.
|
private |
gitConfigured(), unless the current run is one reencryptWithoutGit() started.
Definition at line 1331 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 1335 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 500 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 277 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 1352 of file imitatepass.cpp.
|
private |
Tell the user a leftover is not a regular file and was left.
| path | The leftover. |
Definition at line 665 of file imitatepass.cpp.
|
protected |
Resolve destination for move operation.
| src | Source path. |
| dest | Destination path. |
| force | Overwrite existing. |
Definition at line 1376 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. |
Definition at line 684 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 514 of file imitatepass.cpp.
|
overridevirtual |
Show decrypted password.
| file | Path to the password file relative to store root. |
Implements Pass.
Definition at line 146 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 426 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 |
Start the worker thread once the Executor queue is idle.
| dir | Directory passed to reencryptPath(). |
Definition at line 1062 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 94 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 89 of file imitatepass.cpp.
|
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 763 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 379 of file imitatepass.cpp.
|
friend |
Definition at line 44 of file imitatepass.h.
|
friend |
Definition at line 43 of file imitatepass.h.
|
private |
Background search over the decrypted store; relays to finishedGrep.
Definition at line 562 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 589 of file imitatepass.h.
|
private |
The inserts whose gpg step has not ended yet, oldest first.
Definition at line 584 of file imitatepass.h.
|
private |
Set while a re-encryption run is pending or on the worker thread.
Definition at line 615 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 621 of file imitatepass.h.
|
protected |
storeEnvironment() as it was when the worker started; the worker's processes run in it.
Definition at line 332 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 626 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 560 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 567 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 714 of file imitatepass.h.