QtPass 2.0.0
Developer documentation
Loading...
Searching...
No Matches
ImitatePass Class Reference

Implementation that imitates 'pass' when the real tool is unavailable. More...

#include <imitatepass.h>

Inheritance diagram for ImitatePass:
Collaboration diagram for ImitatePass:

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.

Detailed Description

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:

  • Direct GPG encryption/decryption
  • Git operations via direct subprocess calls
  • GPG key management and recipient lists
  • File-based password storage (.gpg files)
  • Re-encryption when recipients change

This is used as a fallback when RealPass cannot be initialized.

Definition at line 40 of file imitatepass.h.

Constructor & Destructor Documentation

◆ ImitatePass()

ImitatePass::ImitatePass ( )

Construct the backend and connect its content search.

Definition at line 49 of file imitatepass.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ~ImitatePass()

ImitatePass::~ImitatePass ( )
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.

Here is the call graph for this function:

Member Function Documentation

◆ addGenerationHeader()

auto ImitatePass::addGenerationHeader ( const QString & gpgIdFile,
const GpgIdSigner & signer,
QByteArray * contents ) -> bool
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.

Parameters
gpgIdFileThe .gpg-id being written.
signerIts signer, which verifies the list on disk.
contentsThe key IDs, one per line; receives the header too.
Returns
false when no generation could be reserved (the user was told); an unrecordable list must not be written, it would let the old one back.

Definition at line 334 of file imitatepass.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ beforeExecute()

void ImitatePass::beforeExecute ( PROCESS id)
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.

Parameters
idProcess identifier.

Reimplemented from Pass.

Definition at line 1640 of file imitatepass.cpp.

Here is the call graph for this function:

◆ cancelReencryptPath()

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.

◆ ciphertextHolds()

auto ImitatePass::ciphertextHolds ( const QString & ciphertext,
const QString & plaintext ) -> bool
protected

Decrypt ciphertext again and compare it with plaintext, so nothing replaces an entry until it is known to hold what it held.

Parameters
ciphertextThe file gpg just wrote.
plaintextWhat it must decrypt to.
Returns
Whether it does.

Definition at line 851 of file imitatepass.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ commitArgs()

auto ImitatePass::commitArgs ( ) -> QStringList
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.

Returns
The arguments, to which the message and paths are appended.

Definition at line 255 of file imitatepass.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ commitReencrypted()

auto ImitatePass::commitReencrypted ( const QString & fileName) -> bool
protected

Stage and commit a re-encrypted entry, when the store is a Git repository QtPass manages.

Parameters
fileNameThe entry that was replaced.
Returns
Whether the repository is up to date with the file; false makes the run count the file as failed, so a partial store is not pushed.

Definition at line 870 of file imitatepass.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Copy()

void ImitatePass::Copy ( const QString src,
const QString dest,
const bool force )
overridevirtual

Copy password file.

Parameters
srcSource path.
destDestination path.
forcetrue to overwrite existing destination.

Implements Pass.

Definition at line 1500 of file imitatepass.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ copyDestination()

auto ImitatePass::copyDestination ( const QString & src,
const QString & dest,
bool force ) -> QString
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.

Parameters
srcThe entry to copy.
destWhere to, a file or a folder.
forceWhether an existing entry may be replaced.
Returns
The file, or an empty string when refused.

Definition at line 1471 of file imitatepass.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ createBackupCommit()

auto ImitatePass::createBackupCommit ( ) -> bool
protected

Create git backup commit before re-encryption.

Returns
true if backup created or not needed, false if backup failed.

Definition at line 952 of file imitatepass.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ decryptEntry()

auto ImitatePass::decryptEntry ( const QString & fileName,
QString * plaintext ) -> bool
protected

Decrypt fileName for re-encryption.

Parameters
fileNameThe entry to read.
plaintextReceives what gpg printed, with a trailing newline.
Returns
Whether gpg decrypted it to something.

Definition at line 822 of file imitatepass.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ dropStaleTemporary()

void ImitatePass::dropStaleTemporary ( const QString & path)
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.

Parameters
pathThe temporary, a regular file.

Definition at line 672 of file imitatepass.cpp.

Here is the caller graph for this function:

◆ encryptFor()

auto ImitatePass::encryptFor ( const QString & output,
const QStringList & recipients,
const QString & plaintext ) -> bool
protected

Encrypt plaintext to recipients, into output.

Parameters
outputWhere gpg writes the ciphertext; outside the store.
recipientsThe keys to encrypt to; gpg.conf adds none.
plaintextWhat to encrypt, fed on stdin.
Returns
Whether gpg wrote the ciphertext.

Definition at line 839 of file imitatepass.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ endReencryptPath

void ImitatePass::endReencryptPath ( )
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.

Here is the caller graph for this function:

◆ entriesToReencrypt()

auto ImitatePass::entriesToReencrypt ( const QString & dir) -> QStringList
private

The entries under dir a run considers, telling the user about anything skipped for not being a regular file.

Parameters
dirDirectory to walk, recursively.
Returns
The .gpg files, links and special files left out.

Definition at line 1150 of file imitatepass.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ execBlocking() [1/2]

auto ImitatePass::execBlocking ( const QString & app,
const QStringList & args,
const QString & input = QString(),
QString * process_out = nullptr,
QString * process_err = nullptr ) -> int
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.

Parameters
appThe program.
argsIts arguments.
inputWhat to write to its stdin.
process_outReceives stdout, if not null.
process_errReceives stderr, if not null.
Returns
Exit code, or -1 when refused, failed to start or interrupted.

Definition at line 67 of file imitatepass.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ execBlocking() [2/2]

auto ImitatePass::execBlocking ( const QString & app,
const QStringList & args,
QString * process_out,
QString * process_err = nullptr ) -> int
nodiscardprotected

Overload capturing stdout (and stderr) without stdin input.

Parameters
appThe program.
argsIts arguments.
process_outReceives stdout.
process_errReceives stderr, if not null.
Returns
As the overload above.

Definition at line 83 of file imitatepass.cpp.

Here is the call graph for this function:

◆ executeGit()

void ImitatePass::executeGit ( PROCESS id,
const QStringList & args,
QString input = QString(),
bool readStdout = true,
bool readStderr = true )

Execute git command.

Parameters
idProcess identifier.
argsGit arguments.
inputInput to stdin.
readStdoutCapture stdout.
readStderrCapture stderr.

Definition at line 1561 of file imitatepass.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ executeGpg()

void ImitatePass::executeGpg ( PROCESS id,
const QStringList & args,
QString input = QString(),
bool readStdout = true,
bool readStderr = true )

Execute GPG command.

Parameters
idProcess identifier.
argsGPG arguments.
inputInput to stdin.
readStdoutCapture stdout.
readStderrCapture stderr.

Definition at line 1539 of file imitatepass.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ executeMoveGit()

void ImitatePass::executeMoveGit ( const QString & src,
const QString & destFile,
bool force )

Execute git move operation.

Parameters
srcSource path.
destFileDestination path.
forceOverwrite existing.

Definition at line 1421 of file imitatepass.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ finished()

void ImitatePass::finished ( int id,
int exitCode,
const QString & out,
const QString & err )
overrideprotectedvirtual

Handle process completion.

Parameters
idProcess identifier.
exitCodeProcess exit code.
outStandard output from the process.
errStandard error from the process.

Reimplemented from Pass.

Definition at line 1571 of file imitatepass.cpp.

Here is the call graph for this function:

◆ finishReencrypt()

void ImitatePass::finishReencrypt ( const ReencryptResult & result)
private

Report the outcome of a run and emit endReencryptPath().

Parameters
resultOutcome produced by reencryptFiles().

Definition at line 1277 of file imitatepass.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getKeysFromFile()

auto ImitatePass::getKeysFromFile ( const QString & fileName) -> QStringList
protected

Read recipients from file.

Parameters
fileNamePath to file.
Returns
List of key IDs.

Definition at line 793 of file imitatepass.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gitAddGpgId()

auto ImitatePass::gitAddGpgId ( const QString & gpgIdFile,
const QString & gpgIdSigFile,
QString * out,
QString * err ) -> int
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.

Parameters
gpgIdFileAbsolute path of the .gpg-id.
gpgIdSigFileAbsolute path of the .gpg-id.sig, or empty when no signing key is configured.
outReceives the concatenated stdout of the git commands.
errReceives the concatenated stderr of the git commands.
Returns
Exit code of the first failing git command, 0 on success.

Definition at line 450 of file imitatepass.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gitCommit()

void ImitatePass::gitCommit ( const QString & file,
const QString & msg )

Commit changes to git.

Parameters
fileChanged file path.
msgCommit message.

Definition at line 268 of file imitatepass.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gitConfigured()

auto ImitatePass::gitConfigured ( ) const -> bool

Git is enabled and an executable is configured.

Returns
true when git commands can actually run.

Definition at line 1547 of file imitatepass.cpp.

Here is the caller graph for this function:

◆ GitInit()

void ImitatePass::GitInit ( )
overridevirtual

Initialize Git repository.

Implements Pass.

Definition at line 114 of file imitatepass.cpp.

Here is the call graph for this function:

◆ GitPull()

void ImitatePass::GitPull ( )
overridevirtual

Pull from remote.

Implements Pass.

Definition at line 118 of file imitatepass.cpp.

Here is the call graph for this function:

◆ GitPull_b()

void ImitatePass::GitPull_b ( )
overridevirtual

Pull with rebase.

Implements Pass.

Definition at line 125 of file imitatepass.cpp.

Here is the call graph for this function:

◆ GitPush()

void ImitatePass::GitPush ( )
overridevirtual

Push to remote.

Implements Pass.

Definition at line 140 of file imitatepass.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gitReady()

auto ImitatePass::gitReady ( ) -> bool

gitConfigured() plus a status message when git is enabled but no executable is configured.

Returns
true when git commands can actually run.

Definition at line 1553 of file imitatepass.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gitTracks()

auto ImitatePass::gitTracks ( const QString & file) -> bool
protected

Check whether git already tracks a file in the store.

Parameters
fileAbsolute path inside the password store.
Returns
true when the file is in the git index.

Definition at line 494 of file imitatepass.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gpgIdSigner()

auto ImitatePass::gpgIdSigner ( ) -> GpgIdSigner
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.

Returns
A signer; cheap to build, valid while m_settings is.

Definition at line 325 of file imitatepass.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Grep()

void ImitatePass::Grep ( QString pattern,
bool caseInsensitive )
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.

Parameters
patternSearch pattern (QRegularExpression).
caseInsensitivetrue for case-insensitive search.

Implements Pass.

Definition at line 1646 of file imitatepass.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Init()

void ImitatePass::Init ( QString path,
const QList< UserInfo > & users )
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.

Parameters
pathRoot path of the password store.
usersList of recipient GPG keys.

Implements Pass.

Definition at line 543 of file imitatepass.cpp.

Here is the call graph for this function:

◆ Insert()

void ImitatePass::Insert ( QString file,
QString newValue,
bool overwrite )
overridevirtual

Insert new password.

Parameters
filePath to the password file.
newValuePassword content to store.
overwritetrue to overwrite an existing file.

Implements Pass.

Definition at line 201 of file imitatepass.cpp.

Here is the call graph for this function:

◆ insertWritten()

auto ImitatePass::insertWritten ( const QString & err) const -> bool
inlinenodiscardoverrideprotectedvirtual

Whether the failed insert had placed its entry (see placeEncryptedFile()) before a later git step failed.

Parameters
errNot needed: the placement is known, not inferred.
Returns
true when the entry is in the store.

Reimplemented from Pass.

Definition at line 389 of file imitatepass.h.

◆ loadVerifiedRecipients()

auto ImitatePass::loadVerifiedRecipients ( const QString & gpgIdFile,
QStringList * recipients,
QString * why = nullptr ) -> bool
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.

Parameters
gpgIdFileThe .gpg-id.
recipientsReceives the recipients; empty on failure.
whyReceives, if not null, what to tell the user on failure: a bad signature, or a signed list older than one accepted before (GpgIdGeneration).
Returns
false when the file cannot be read, the signature is bad or the list is a rollback (with a signing key configured). true otherwise, also for an empty list; the caller decides what an empty list means.

Definition at line 624 of file imitatepass.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Move()

void ImitatePass::Move ( const QString src,
const QString dest,
const bool force )
overridevirtual

Move password file.

Parameters
srcSource path.
destDestination path.
forcetrue to overwrite existing destination.

Implements Pass.

Definition at line 1440 of file imitatepass.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pgit()

auto ImitatePass::pgit ( const QString & path) const -> QString
private

Translate path for git when WSL-routed: wraps in wslpath substitution, otherwise returns path unchanged.

Parameters
pathNative filesystem path.
Returns
Path suitable for the configured git executable.

Definition at line 106 of file imitatepass.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pgpg()

auto ImitatePass::pgpg ( const QString & path) const -> QString
private

Translate path for gpg when WSL-routed: wraps in wslpath substitution, otherwise returns path unchanged.

Parameters
pathNative filesystem path.
Returns
Path suitable for the configured gpg executable.

Definition at line 110 of file imitatepass.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ placeEncryptedFile()

auto ImitatePass::placeEncryptedFile ( const QString & output,
const QString & file,
bool overwrite,
QString * error ) -> bool
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.

Parameters
outputThe file gpg wrote, in a directory of QtPass's own.
fileThe entry's path.
overwriteWhether an entry already there may be replaced.
errorReceives why file could not be written, if not.
Returns
Whether file now holds the new ciphertext.

Definition at line 1628 of file imitatepass.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pullBeforeReencrypt()

auto ImitatePass::pullBeforeReencrypt ( ) -> bool
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.

Returns
Whether re-encrypting may go ahead: false when a failed pull left unmerged files or the check for unmerged files fails.
true if no pull is needed, the pull succeeds, or a failed pull leaves no unmerged files; false if unmerged files remain or their check fails.

Definition at line 1118 of file imitatepass.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ recipientsForDir()

auto ImitatePass::recipientsForDir ( const QString & fileName,
QHash< QString, QStringList > & verified,
QStringList & gpgId,
ReencryptResult & result ) -> bool
private

The verified recipients for the folder fileName sits in.

Parameters
fileNameAn entry in the folder.
verifiedCache of the .gpg-id files already checked.
gpgIdReceives the recipients to encrypt that folder to.
resultMarked cancelled or aborted when the answer is no.
Returns
Whether the run may go on with this folder.

Definition at line 1165 of file imitatepass.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ recipientsForEntry()

auto ImitatePass::recipientsForEntry ( const QString & file,
QStringList * recipients ) -> bool
protected

The recipients to encrypt file to: its folder's .gpg-id, verified when a signing key is set.

Parameters
fileThe entry, absolute.
recipientsReceives the key IDs.
Returns
false when there are none to use (the user was told why).

Definition at line 180 of file imitatepass.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ recoverReencryptLeftovers()

auto ImitatePass::recoverReencryptLeftovers ( const QString & dir) -> bool
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).

Parameters
dirDirectory to scan, recursively.
Returns
false when something was reported that needs a human first.

Definition at line 716 of file imitatepass.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ reencryptFiles()

auto ImitatePass::reencryptFiles ( const QString & dir) -> ReencryptResult
private

Worker-thread body: scan dir and re-encrypt stale files.

Parameters
dirDirectory passed to reencryptPath().
Returns
Counts and the list of files that could not be re-encrypted.

Definition at line 1189 of file imitatepass.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ reencryptPath() [1/2]

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.

Parameters
dirDirectory path.

Definition at line 1021 of file imitatepass.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ reencryptPath() [2/2]

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.

Parameters
dirDirectory path.
settingsThe current settings.

Definition at line 1012 of file imitatepass.cpp.

Here is the call graph for this function:

◆ reencryptProgress

void ImitatePass::reencryptProgress ( int current,
int total )
signal

Re-encryption progress: current of total files checked.

Emitted from the worker thread; connect with a queued (or automatic) connection.

Parameters
currentNumber of files checked so far, including this one.
totalTotal number of files found by the scan.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ reencryptSingleFile()

auto ImitatePass::reencryptSingleFile ( const QString & fileName,
const QStringList & recipients,
QString * why ) -> bool
protected

Re-encrypt single file with new recipients.

Parameters
fileNameFile to re-encrypt.
recipientsNew recipient key IDs.
whyReceives, 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.
Returns
true on success, false on failure.

Definition at line 898 of file imitatepass.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ reencryptUsesGit()

auto ImitatePass::reencryptUsesGit ( ) const -> bool
private

gitConfigured(), unless the current run is one reencryptWithoutGit() started.

Returns
Whether the re-encryption run may call Git.

Definition at line 1331 of file imitatepass.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ reencryptWithoutGit()

void ImitatePass::reencryptWithoutGit ( const QString & dir,
const QString & gitError )
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.

Parameters
dirThe folder whose recipients changed.
gitErrorWhat Git said when the commit failed.

Definition at line 1335 of file imitatepass.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ refuseLinkedGpgIdFolder()

auto ImitatePass::refuseLinkedGpgIdFolder ( const QString & path) -> bool
protected

Refuse a folder, or a .gpg-id/.gpg-id.sig in it, that is a link: writing there would reach outside the store.

Parameters
pathThe folder, with its trailing separator.
Returns
Whether it was refused (and the user told).

Definition at line 500 of file imitatepass.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Remove()

void ImitatePass::Remove ( QString file,
bool isDir )
overridevirtual

Remove password.

Parameters
filePath to the file or directory to remove.
isDirtrue if removing a directory.

Implements Pass.

Definition at line 277 of file imitatepass.cpp.

Here is the call graph for this function:

◆ reportUncommittedGpgId()

void ImitatePass::reportUncommittedGpgId ( const QString & dir,
const QString & gitError,
bool reencrypted )
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.

Parameters
dirThe folder whose recipients changed.
gitErrorWhat Git said when the commit failed.
reencryptedWhether 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.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ reportUnrestorable()

void ImitatePass::reportUnrestorable ( const QString & path)
private

Tell the user a leftover is not a regular file and was left.

Parameters
pathThe leftover.

Definition at line 665 of file imitatepass.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ resolveMoveDestination()

auto ImitatePass::resolveMoveDestination ( const QString & src,
const QString & dest,
bool force ) -> QString
protected

Resolve destination for move operation.

Parameters
srcSource path.
destDestination path.
forceOverwrite existing.
Returns
Resolved destination path.

Definition at line 1376 of file imitatepass.cpp.

Here is the caller graph for this function:

◆ restoreBackup()

auto ImitatePass::restoreBackup ( const QString & path) -> bool
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.

Parameters
pathThe <entry>.reencrypt.bak file.
Returns
Whether nothing needs a human first.

Definition at line 684 of file imitatepass.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ settleSignature()

auto ImitatePass::settleSignature ( const QString & gpgIdFile,
const QByteArray & written,
const GpgIdSigner & signer,
bool useGit,
QString * sigToCommit ) -> bool
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).

Parameters
gpgIdFileThe .gpg-id that was written.
writtenIts bytes, which are what gets signed.
signerWhether and with which keys to sign.
useGitWhether the store is a Git repository QtPass manages.
sigToCommitReceives the signature file to commit, if any.
Returns
false when signing or removing failed (the user was told).

Definition at line 514 of file imitatepass.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Show()

void ImitatePass::Show ( QString file)
overridevirtual

Show decrypted password.

Parameters
filePath to the password file relative to store root.

Implements Pass.

Definition at line 146 of file imitatepass.cpp.

Here is the call graph for this function:

◆ signGpgIdFile()

auto ImitatePass::signGpgIdFile ( const QString & gpgIdFile,
const QByteArray & contents ) -> bool
protected

Sign a .gpg-id with the configured key and verify the result; failures are reported through critical().

Parameters
gpgIdFilePath to .gpg-id file.
contentsThe bytes just written as that file: the signature is made over these, not over whatever is under the name by then.
Returns
true on success, false on failure.

Definition at line 426 of file imitatepass.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ startReencryptPath

void ImitatePass::startReencryptPath ( )
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().

Here is the caller graph for this function:

◆ startReencryptWorker()

void ImitatePass::startReencryptWorker ( const QString & dir)
private

Start the worker thread once the Executor queue is idle.

Parameters
dirDirectory passed to reencryptPath().

Definition at line 1062 of file imitatepass.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ storeGit()

auto ImitatePass::storeGit ( const QStringList & args,
QString * out ) -> bool
overrideprotectedvirtual

Run git with -C <Store tree and entries> in the store, blocking.

Parameters
argsThe git arguments (without the executable or -C).
outReceives stdout; may be null.
Returns
true when git ran and exited 0 (git on and configured).

Reimplemented from Pass.

Definition at line 94 of file imitatepass.cpp.

Here is the call graph for this function:

◆ translatePathForWsl()

auto ImitatePass::translatePathForWsl ( const QString & path,
const QString & exe ) const -> QString
private

Translate path for the given exe when WSL-routed: wraps in wslpath substitution, otherwise returns path unchanged.

Parameters
pathNative filesystem path.
exeExecutable path (checked for "wsl " prefix).
Returns
Path suitable for the given executable.

Definition at line 89 of file imitatepass.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ verifyGpgIdForDir()

auto ImitatePass::verifyGpgIdForDir ( const QString & file,
QHash< QString, QStringList > & verified,
QStringList & gpgId ) -> bool
protected

Recipients for the directory of file, from its verified .gpg-id.

Parameters
filePassword file path.
verifiedCache of .gpg-id path to the recipients its verified contents held; a hit skips gpg and reuses exactly that list.
gpgIdOutput parameter for recipient key IDs, sorted.
Returns
true on success, false when the file is unreadable or its signature is bad (reported through critical()).

Definition at line 763 of file imitatepass.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ writeGpgIdFile()

auto ImitatePass::writeGpgIdFile ( const QString & gpgIdFile,
const QList< UserInfo > & users,
QByteArray * written = nullptr ) -> bool
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.

Parameters
gpgIdFilePath to .gpg-id file.
usersList of recipients.
writtenReceives the exact bytes written, if not null: what the signature is then made over.
Returns
true when the file was written; false after reporting through critical().

Definition at line 379 of file imitatepass.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ tst_imitatepass

friend class tst_imitatepass
friend

Definition at line 44 of file imitatepass.h.

◆ tst_util

friend class tst_util
friend

Definition at line 43 of file imitatepass.h.

Member Data Documentation

◆ m_grep

NativeGrep ImitatePass::m_grep
private

Background search over the decrypted store; relays to finishedGrep.

Definition at line 562 of file imitatepass.h.

◆ m_insertPlaced

bool ImitatePass::m_insertPlaced = false
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.

◆ m_pendingInserts

QQueue<PendingInsert> ImitatePass::m_pendingInserts
private

The inserts whose gpg step has not ended yet, oldest first.

Definition at line 584 of file imitatepass.h.

◆ m_reencryptActive

bool ImitatePass::m_reencryptActive = false
private

Set while a re-encryption run is pending or on the worker thread.

Definition at line 615 of file imitatepass.h.

◆ m_reencryptCancel

std::atomic<bool> ImitatePass::m_reencryptCancel {false}
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.

◆ m_reencryptEnv

QProcessEnvironment ImitatePass::m_reencryptEnv
protected

storeEnvironment() as it was when the worker started; the worker's processes run in it.

Definition at line 332 of file imitatepass.h.

◆ m_reencryptThread

QThread* ImitatePass::m_reencryptThread = nullptr
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.

◆ m_transaction

SimpleTransaction ImitatePass::m_transaction
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.

◆ m_transactionOutput

QString ImitatePass::m_transactionOutput
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.

◆ m_uncommittedGpgId

std::optional<UncommittedGpgId> ImitatePass::m_uncommittedGpgId
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.


The documentation for this class was generated from the following files: