QtPass 2.0.0
Developer documentation
Loading...
Searching...
No Matches
Pass Class Referenceabstract

Abstract base class for password store operations. More...

#include <pass.h>

Inheritance diagram for Pass:
Collaboration diagram for Pass:

Classes

struct  SkippedWalk
 What skippedGpgId() found on its way up from one folder. More...
struct  EditReaders
 What saving over an existing entry would change about who reads it (readersAnEditWouldAdd()). More...
struct  RecipientsForEditing
 What a dialog may do with the list of a folder (recipientsForEditing()). More...
struct  ExpectedList
 What initIfUnchanged() expects the list to read as, for refuseChangedList(); empty outside it. More...

Public Types

using SkippedWalks = QHash<QString, SkippedWalk>
 SkippedWalk per absolute folder, for one check of many folders.
using LinkedWalks = QHash<QString, std::optional<QString>>

Signals

void idle ()
 Nothing of the store's runs or waits any more (isIdle()).
void startingExecuteWrapper ()
 Emitted each time a queued process is about to start, and by the refusals that go on to emit processErrorExit().
void statusMsg (const QString &msg, int timeout)
 Progress or a non-fatal problem worth a line in the status bar ("Creating backup commit", "Git pull failed: ...").
void critical (const QString &title, const QString &message)
 Something went wrong that the user has to be told about in a dialog, such as a refused path or a failed backup commit.
void processErrorExit (int exitCode, const QString &err)
 An operation ended in failure: its process exited non-zero, could not be started or crashed, or the operation was refused.
void finishedAnyWithPid (const QString &out, const QString &err, Enums::PROCESS pid)
 A process of any kind finished successfully and its output cannot contain a secret.
void finishedGitInit (const QString &out, const QString &err)
 git init in the store succeeded; the store is a repository now and the tree is re-read.
void finishedGitPull (const QString &out, const QString &err)
 git pull succeeded; entries may have changed on disk.
void finishedGitPush (const QString &out, const QString &err)
 git push succeeded.
void finishedShow (const QString &out, const QString &file, bool lossless=true)
 Emitted when a Show() succeeds.
void finishedInsert (const QString &out, const QString &err)
 An Insert() succeeded: the entry is in the store and, with Git in use, committed.
void finishedRemove (const QString &out, const QString &err)
 A Remove() succeeded; the entry or folder is gone from the store.
void finishedInit (const QString &out, const QString &err)
 An Init() succeeded: the folder's .gpg-id holds the new recipient list.
void finishedMove (const QString &out, const QString &err)
 A Move() succeeded; the entry or folder is under its new name.
void finishedCopy (const QString &out, const QString &err)
 A Copy() succeeded; the copy exists beside the original.
void finishedGenerateGPGKeys (const QString &out, const QString &err)
 GenerateGPGKeys() succeeded; the new key pair is in the keyring.
void generateGPGKeysFailed (const QString &err)
 Emitted when GPG key generation fails, alongside the generic processErrorExit(); lets the keygen dialog react to its own failure only, not to any other command failing meanwhile.
void insertFailed (const QString &err, bool written)
 Emitted when an Insert() fails through a queued command, before the generic processErrorExit(): the process exited non-zero, crashed or could not be started, or the entry could not be put in place afterwards. Lets the password dialog keep what was typed and say why, without reacting to any other command failing meanwhile. An insert refused before anything is queued does not emit it.
void finishedGrep (const QList< QPair< QString, QStringList > > &results)
 The newest Grep() is over; an empty list means no entry matched.

Public Member Functions

 Pass ()
 Construct a Pass instance.
void init (const AppSettings &settings)
 Initialize the Pass instance with a settings snapshot.
virtual void GitInit ()=0
 Initialize Git repository in password store.
virtual void GitPull ()=0
 Pull changes from remote Git repository.
virtual void GitPull_b (int timeoutMs)=0
 Pull from the remote and wait for it, at most timeoutMs: the pull before an edit, on the GUI thread.
virtual void GitPush ()=0
 Push changes to remote Git repository.
virtual void Show (QString file)=0
 Show decrypted password file.
virtual void Insert (QString file, QString value, bool force)=0
 Insert or update password.
auto insertsPending () const -> int
 How many inserts have started queueing but not yet reported.
virtual auto readersAnEditWouldAdd (const QString &file) -> EditReaders
 Who saving over an existing entry would let read it who may not now.
virtual auto entriesInitWouldWiden (const QString &dir, const QList< UserInfo > &users) -> QStringList
 Entries a pass init of dir with users would hand to someone who cannot read them now (an entry copied in from a folder they are not on), less whom the change adds. pass re-encrypts every entry itself, so the caller asks before it runs. None by default; the pass backend tells.
virtual auto entriesMoveWouldWiden (const QString &src, const QString &dest) -> QStringList
 Entries already in the place a pass mv or pass cp of src to dest re-encrypts (the whole destination folder) that would gain a reader they do not have. What is moved or copied itself is the user's own and not counted. None by default.
auto entryReaders (const QString &path) -> QStringList
 The long key IDs an entry is encrypted to, as gpg lists them without anyone's secret key (ENC_TO).
auto reportedInsert () const -> QString
 The entry whose insert is reporting now: set while finishedInsert() or insertFailed() goes out, empty otherwise.
virtual void Remove (QString file, bool isDir)=0
 Remove password file or directory.
virtual void Move (const QString srcDir, const QString dest, const bool force)=0
 Move password file or directory.
virtual void Copy (const QString srcDir, const QString dest, const bool force)=0
 Copy password file or directory.
virtual void Init (QString path, const QList< UserInfo > &users)=0
 Initialize new password store.
virtual void Grep (QString pattern, bool caseInsensitive)=0
 Search password content for a pattern.
virtual void CancelGrep ()
 Stop a running Grep(): the walk ends at the next entry and the gpg decrypting one is terminated. Its (partial) result still arrives through finishedGrep(). Does nothing when no search runs.
virtual auto generatePassword (unsigned int length, const QString &charset) -> QString
 Generate random password.
void GenerateGPGKeys (QString batch)
 Generate GPG keys using batch script.
auto listKeys (QStringList keystrings, bool secret=false) -> QList< UserInfo >
 List GPG keys matching patterns.
virtual auto encryptionReaches (const QStringList &recipients) -> std::optional< QStringList >
 The keys a gpg encryption to recipients reaches: a throwaway encryption outside the store, read back for whom it went to.
virtual auto recipientArgument (const QString &line) const -> QString
 The -r argument for one recipient line, as this backend's encryption hands it to gpg: the probe (encryptionReaches()) must reach what the encryption will. The native backend matches a bare address exactly (exactRecipientArg()).
auto keyLinesHeldTwice (const QStringList &lines) -> std::optional< QHash< QString, QStringList > >
 The key ID and fingerprint lines of a recipient list that more than one key block holds, with those blocks.
auto exportPublicKeys (const QString &gpg, const QStringList &keys, QString *out, QString *err) -> int
 gpg --armor --export of keys, in the store's environment: the keyring keyLinesHeldTwice() reads.
auto listKeys (const QString &keystring="", bool secret=false) -> QList< UserInfo >
 List GPG keys.
void updateEnv ()
 Update environment for subprocesses.
auto recipientsForEditing (const QString &dir, const QString &passStore) -> RecipientsForEditing
 The recipients a dialog may preselect for editing the list of dir.
auto initIfUnchanged (const QString &path, const QList< UserInfo > &users, const QString &dir, const QString &passStore, const RecipientsForEditing &read) -> bool
 Init(), but only while the list of dir still reads as the caller read it with recipientsForEditing().
auto isIdle () const -> bool
 Whether no gpg, git or pass of this backend runs or waits.
auto stopRunning () -> bool
 Stop the queued command that is running now (Executor::stopRunning()); it then ends as a failed run.
auto runningSerial () const -> quint64
 Which run is going (Executor::runningSerial()).
auto runningProcess () const -> Enums::PROCESS
 What kind of command is running now.
auto isPushing () const -> bool
 Whether a Git push of this backend is queued or running.
auto autoPushHeld () const -> bool
 Whether automatic pushes of the current store are held because its last re-encryption did not finish cleanly.
void GitPushAutomatic ()
 GitPush() for an automatic push, the one after a change. A backend that has to make the push later drops it then if the store is held by that time (autoPushHeld()); a push by hand (GitPush()) still goes.

Static Public Member Functions

static bool gpgSupportsEd25519 (const QString &gpgExecutable={})
 Check if GPG supports Ed25519 encryption.
static QString getDefaultKeyTemplate (const QString &gpgExecutable={})
 Get default key template for new GPG keys.
static auto exactRecipientArg (const QString &line) -> QString
 A bare mail address in gpg's exact form, <address>; any other line as written.
static auto keyLinesHeldTwiceIn (const QStringList &lines, const QString &listing) -> QHash< QString, QStringList >
 keyLinesHeldTwice() on a listing already made.
static auto describeKeyLinesHeldTwice (const std::optional< QHash< QString, QStringList > > &held) -> QString
 A message naming each line keyLinesHeldTwice() found and what the user can do about it.
static auto pullTimedOut (int timeoutMs) -> QString
 The status-bar text for a blocking pull stopped at its deadline.
static auto maxOutputArgs () -> QStringList
 The gpg options that enforce kMaxPlaintextBytes.
static auto resolveGpgconfCommand (const QString &gpgPath) -> ResolvedGpgconfCommand
 Resolve the gpgconf command to kill agents.
static auto getGpgIdPath (const QString &for_file, const QString &passStore) -> QString
 Get .gpg-id file path for a password file.
static auto skippedGpgId (const QString &forFile, const QString &passStore, QString *recordError=nullptr, SkippedWalks *walks=nullptr) -> std::optional< QString >
 The folder list getGpgIdPath() passed over on its way up to the one it returns, if it passed one over that a signed store must not.
static auto linkedGpgId (const QString &forFile, const QString &passStore, LinkedWalks *walks=nullptr) -> std::optional< QString >
 The link or junction under the name .gpg-id that getGpgIdPath() skips on its way up from forFile, if it skips one before the list it returns.
static auto getRecipientList (const QString &for_file, const QString &passStore) -> QStringList
 Get list of recipients for a password file.
static auto parseRecipients (const QByteArray &contents, const QString &sourceName) -> QStringList
 Parse the contents of a .gpg-id: one recipient per line, # starts a comment, unusable lines are logged and skipped.
static auto passReadsDifferently (const QByteArray &contents) -> QString
 Why pass would read a .gpg-id differently from parseRecipients(), if it would.
static auto loggableArgs (const QStringList &args) -> QStringList
 The arguments as they may appear in the debug log: the value of --passphrase and friends, and otpauth URIs, are replaced.

Static Public Attributes

static constexpr int kBlockingPullMs = 30000
 How long the pull before an edit may block the window.
static constexpr qint64 kMaxPlaintextBytes = 64LL * 1024 * 1024
 Most bytes of plaintext a gpg decryption may produce.

Protected Types

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.

Protected Slots

virtual void finished (int id, int exitCode, const QString &out, const QString &err)
 Handle process completion.

Protected Member Functions

virtual auto fullKeyListing (QString *listing) -> int
 The whole public keyring as keyLinesHeldTwice() reads it.
auto refuseKeyLinesHeldTwice (const QStringList &lines) -> bool
 Refuse, with critical(), a recipient list with a line that more than one key block holds (keyLinesHeldTwice()).
auto storeEnvironment () const -> QProcessEnvironment
 The environment QtPass runs the store's processes in.
auto withCurrentGitPin (QProcessEnvironment base) const -> QProcessEnvironment
 base with GIT_DIR and GIT_WORK_TREE as the store is now (Util::gitStoreVariables()), not as it was at updateEnv(): a .git that appeared or changed hands since then is judged when Git runs.
auto pushIsAutomatic () const -> bool
 Whether the GitPush() running now is an automatic one.
void holdAutoPush (const QString &scope)
 Hold automatic pushes of the store that holds scope (autoPushHeld()): its re-encryption did not finish cleanly.
void releaseAutoPush (const QString &folder)
 Release the holds a clean re-encryption of folder covers: those for folder itself and everything under it. Holds for other folders stay.
auto refuseSkippedGpgId (const QString &file, bool signing, const QString &except=QString(), SkippedWalks *walks=nullptr) -> bool
 With signing on, refuse to encrypt file when the lookup passed over its folder's own list (skippedGpgId()): the parent's list is not what was signed for it.
auto verifySignedList (const GpgIdSigner &signer, const QString &gpgIdFile, QByteArray *contents, QString *why) const -> bool
 Whether gpgIdFile is a signed list QtPass accepts: its signature verifies (GpgIdSigner::verifyFile()), and it is current and bound to the folder it lies in (GpgIdGeneration::accept()), so an older authentic list put back, or one signed for another folder, is refused.
virtual auto insertWritten (const QString &err) const -> bool
 Whether the insert that just failed had put its entry in the store before a later step failed. The backend that writes the entry knows; this default says no.
void queueShow (const QString &file)
 Remember what a Show() asked for, so its completion can say so.
void queueInsert (const QString &entry=QString())
 Count one insert that has started queueing but not yet reported.
auto refuseLinkedPath (const QString &path, LinkScope scope=LinkScope::EntryAndParents, PathSpelling spelling=PathSpelling::Configured) -> bool
 Refuse an operation on something that is, or lies behind, a symbolic link or NTFS junction inside the store.
auto refuseFolderOutsideStore (const QString &folder, QString *relative=nullptr) -> bool
 Refuse recipients for a folder outside the store, as pass refuses a path with .. in it.
virtual auto storeGit (const QStringList &args, QString *out) -> bool
 Run a git command in the store's repository, blocking.
auto refuseUnfinishedGitOperation () -> bool
 Refuse to change the store while git is mid-rebase, -merge, -cherry-pick or -revert.
auto unfinishedGitOperationReason () -> QString
 The unfinished git operation in progress in the store, if any.
auto refusePendingPull () -> bool
 Refuse a store change while a Git pull is still queued or running.
auto refuseChangedList () -> bool
 Refuse an Init() under initIfUnchanged() when the folder's list no longer reads as the caller read it.
auto refuseBusyForExpectedList () -> bool
 Refuse an Init() under initIfUnchanged() while the executor has work queued or running, for a backend whose external tool writes the list only when its process runs.
void executeWrapper (PROCESS id, const QString &app, const QStringList &args, bool readStdout=true, bool readStderr=true)
 Execute external wrapper command.
auto generateRandomPassword (const QString &charset, unsigned int length) -> QString
 Generate random password from charset.
auto boundedRandom (quint32 bound) -> quint32
 Generate random number in range.
void setEnvVar (const QString &name, const QString &value)
 Set or remove an environment variable.
void pinStoreGitAttributes ()
 Pin byte-for-byte Git attributes for the store's encrypted files.
void executeWrapper (PROCESS id, const QString &app, const QStringList &args, QString input, bool readStdout, bool readStderr)
 Execute wrapper with input.
virtual void beforeExecute (PROCESS id)
 Hook invoked just before a wrapped command is dispatched.

Static Protected Member Functions

static auto enabledKeyLines (const QList< UserInfo > &users) -> QStringList
 The enabled users' key IDs, as Init() writes them to .gpg-id.
static auto withoutStatusLines (const QString &err) -> QString
 gpg's stderr without its machine-readable [GNUPG:] lines (and without carriage returns), as a person reads it.

Protected Attributes

AppSettings m_settings
 Application settings snapshot injected at init() time.
Executor exec
 Internal command executor for queuing and running subprocesses.

Private Member Functions

auto scopePath (const QString &path) const -> QString
 path as an absolute, cleaned path, relative ones taken from the current store.
void handleProcessError (PROCESS pid, int exitCode, const QString &out, const QString &err)
 Report a process that exited non-zero; called by finished().
auto formatInsertError (const QString &friendly, const QString &err) -> QString
 Put the translated reason for a failed insert above what gpg itself printed, leaving out the machine-readable [GNUPG:] lines.
void emitProcessFinishedSignal (PROCESS pid, const QString &out, const QString &err)
 Emit the signals for a process that exited with 0; called by finished() for everything but PASS_SHOW.
void refuseAsNotPartOfStore (const QString &why)
 Refuse an operation on something that is not part of the store.

Static Private Member Functions

static auto gpgIdVerdictIn (const QString &dir) -> std::optional< SkippedWalk >
 What skippedGpgId() concludes at one folder on its way up.
static auto heldScopes () -> QSet< QString > &
 The folders (cleaned absolute paths) whose re-encryption did not finish, for every store and both backends.

Private Attributes

bool wrapperRunning {false}
 Unused; kept from the time Pass tracked the running wrapper.
QProcessEnvironment env
 The environment the store's processes run in: the system environment plus what updateEnv() sets (PASSWORD_STORE_ variables, GNUPGHOME, PATH additions, WSLENV). Read through storeEnvironment().
bool m_pushIsAutomatic = false
 Set while GitPushAutomatic() runs GitPush().
std::optional< ExpectedList > m_expectedList
 Set during initIfUnchanged().
bool m_expectedListRefused = false
 Set when refuseChangedList() or refuseBusyForExpectedList() refused during initIfUnchanged().
QQueue< QString > m_pendingShows
 Files of the Show() calls still in flight, oldest first.
int m_insertsPending = 0
 Inserts that have started queueing but not yet reported; see queueInsert.
QQueue< QString > m_insertedEntries
 The entries of the inserts counted in m_insertsPending, in queue order.
QString m_reportedInsert
 The entry of the insert whose report is going out; see reportedInsert().

Detailed Description

Abstract base class for password store operations.

Pass provides an abstraction layer for password management, supporting both the native 'pass' utility and gopass/imitation backends. It handles:

  • Password file operations (show, insert, remove, move, copy)
  • GPG key management and Git integration
  • OTP generation
  • Random password generation

Subclasses must implement Git and password operations.

Paths: the operations take a path relative to the store, or an absolute path spelled from the store as configured (passStore), as the store tree and the dialogs build them. The link checks, pass names and Git paths are worked out against that spelling. A path spelled through the target of a store root that is itself a link is not under the store as named. Init() places such a folder from its canonical path; the other operations would check only the entry itself for a link and give pass and Git ../ names, so callers must not hand one over. Resolving every link instead is no way out: a removal would then reach a link's target, not the link.

Definition at line 77 of file pass.h.

Member Typedef Documentation

◆ LinkedWalks

using Pass::LinkedWalks = QHash<QString, std::optional<QString>>

What linkedGpgId() found on its way up, per absolute folder, for one check of many folders.

Definition at line 168 of file pass.h.

◆ PROCESS

using Pass::PROCESS = Enums::PROCESS
protected

Alias for Enums::PROCESS used throughout this class.

Definition at line 154 of file pass.h.

◆ SkippedWalks

using Pass::SkippedWalks = QHash<QString, SkippedWalk>

SkippedWalk per absolute folder, for one check of many folders.

Definition at line 165 of file pass.h.

Member Enumeration Documentation

◆ LinkScope

enum class Pass::LinkScope
strongprotected

What refuseLinkedPath() judges.

Enumerator
EntryAndParents 

The entry itself and every folder above it in the store.

ParentsOnly 

Only the folders above it: a removal unlinks a link and touches nothing behind it.

Definition at line 858 of file pass.h.

◆ PathSpelling

enum class Pass::PathSpelling
strongprotected

How a path handed to refuseLinkedPath() is spelled.

Enumerator
Configured 

As the store is configured or relative to it, the class's path rule. A path spelled through the target of a linked store root is then logged as a warning, so tests catch a caller that hands one over.

PlacedByCaller 

Through the target of a linked store root, by a caller that places such a folder itself (Init()): not logged.

Definition at line 868 of file pass.h.

Constructor & Destructor Documentation

◆ Pass()

Pass::Pass ( )

Construct a Pass instance.

Definition at line 83 of file pass.cpp.

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

Member Function Documentation

◆ autoPushHeld()

auto Pass::autoPushHeld ( ) const -> bool
nodiscard

Whether automatic pushes of the current store are held because its last re-encryption did not finish cleanly.

The recipients change is committed locally first, so after a failed or cancelled re-encryption the next automatic push (after any later edit) would publish a .gpg-id whose entries are partly still encrypted to the previous recipients. Held while any folder of the store has such a run outstanding, until a clean re-encryption covers it; a push the user asks for is not held. Shared by both backends, so switching between them keeps it; kept for this session only.

Returns
true when an automatic push of the current store should not run.

Definition at line 1291 of file pass.cpp.

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

◆ beforeExecute()

void Pass::beforeExecute ( PROCESS id)
protectedvirtual

Hook invoked just before a wrapped command is dispatched.

Default is a no-op; backends override it to wrap execution (e.g. ImitatePass registers a transaction). Keeps the dispatch surface a single non-virtual executeWrapper instead of an overridden one.

Parameters
idProcess identifier of the command about to run.

Reimplemented in ImitatePass.

Definition at line 169 of file pass.cpp.

Here is the caller graph for this function:

◆ boundedRandom()

auto Pass::boundedRandom ( quint32 bound) -> quint32
protected

Generate random number in range.

Parameters
boundUpper bound (exclusive).
Returns
Random number.

Definition at line 1910 of file pass.cpp.

Here is the caller graph for this function:

◆ CancelGrep()

virtual void Pass::CancelGrep ( )
inlinevirtual

Stop a running Grep(): the walk ends at the next entry and the gpg decrypting one is terminated. Its (partial) result still arrives through finishedGrep(). Does nothing when no search runs.

Reimplemented in ImitatePass, and RealPass.

Definition at line 384 of file pass.h.

◆ Copy()

virtual void Pass::Copy ( const QString srcDir,
const QString dest,
const bool force )
pure virtual

Copy password file or directory.

Parameters
srcDirSource path.
destDestination path.
forceOverwrite existing.

Implemented in ImitatePass, and RealPass.

◆ critical

void Pass::critical ( const QString & title,
const QString & message )
signal

Something went wrong that the user has to be told about in a dialog, such as a refused path or a failed backup commit.

Says only what happened; it does not by itself mean an operation is over. Every failure reported through the command queue goes on to processErrorExit(), and so do some refusals. Other checks made before anything is queued, such as an entry that already exists or a recipient list that cannot be used, emit this signal and nothing else.

Parameters
titleTranslated dialog title.
messageTranslated description.
Here is the caller graph for this function:

◆ describeKeyLinesHeldTwice()

auto Pass::describeKeyLinesHeldTwice ( const std::optional< QHash< QString, QStringList > > & held) -> QString
static

A message naming each line keyLinesHeldTwice() found and what the user can do about it.

Parameters
heldAs keyLinesHeldTwice() returned it: not empty, or nothing for a keyring that could not be listed.
Returns
The message.

Definition at line 643 of file pass.cpp.

Here is the caller graph for this function:

◆ emitProcessFinishedSignal()

void Pass::emitProcessFinishedSignal ( PROCESS pid,
const QString & out,
const QString & err )
private

Emit the signals for a process that exited with 0; called by finished() for everything but PASS_SHOW.

finishedAnyWithPid() goes out only for a process whose output cannot hold a secret (Enums::processInfo()), then the signal of that kind of process (finishedGitPull() and so on), if it has one.

Parameters
pidWhich kind of process finished.
outIts stdout.
errIts stderr.

Definition at line 943 of file pass.cpp.

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

◆ enabledKeyLines()

auto Pass::enabledKeyLines ( const QList< UserInfo > & users) -> QStringList
staticprotected

The enabled users' key IDs, as Init() writes them to .gpg-id.

Parameters
usersThe users the dialog handed over.
Returns
Their lines.

Definition at line 580 of file pass.cpp.

Here is the caller graph for this function:

◆ encryptionReaches()

auto Pass::encryptionReaches ( const QStringList & recipients) -> std::optional< QStringList >
virtual

The keys a gpg encryption to recipients reaches: a throwaway encryption outside the store, read back for whom it went to.

What -r makes of each line, where listKeys() searches: a key that only resembles a recipient (a user ID that contains its address, a subkey bound to its key) is not reached. No key lookups over the network (--no-auto-key-locate), so opening a dialog fetches nothing.

Parameters
recipientsThe lines of a recipient list.
Returns
The long key IDs (upper case) of the keys and subkeys encrypted to, possibly empty when gpg did not say; nothing when gpg could not encrypt to the list.

Definition at line 707 of file pass.cpp.

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

◆ entriesInitWouldWiden()

virtual auto Pass::entriesInitWouldWiden ( const QString & dir,
const QList< UserInfo > & users ) -> QStringList
inlinevirtual

Entries a pass init of dir with users would hand to someone who cannot read them now (an entry copied in from a folder they are not on), less whom the change adds. pass re-encrypts every entry itself, so the caller asks before it runs. None by default; the pass backend tells.

Parameters
dirThe folder, as Init() gets it.
usersThe recipients Init() would write.
Returns
The entries' absolute paths.

Reimplemented in RealPass.

Definition at line 296 of file pass.h.

Here is the caller graph for this function:

◆ entriesMoveWouldWiden()

virtual auto Pass::entriesMoveWouldWiden ( const QString & src,
const QString & dest ) -> QStringList
inlinevirtual

Entries already in the place a pass mv or pass cp of src to dest re-encrypts (the whole destination folder) that would gain a reader they do not have. What is moved or copied itself is the user's own and not counted. None by default.

Parameters
srcThe entry or folder moved or copied.
destWhere it goes.
Returns
The entries' absolute paths.

Reimplemented in RealPass.

Definition at line 312 of file pass.h.

◆ entryReaders()

auto Pass::entryReaders ( const QString & path) -> QStringList

The long key IDs an entry is encrypted to, as gpg lists them without anyone's secret key (ENC_TO).

Parameters
pathThe entry.
Returns
The IDs in upper case; empty when gpg could not tell.

Definition at line 664 of file pass.cpp.

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

◆ exactRecipientArg()

auto Pass::exactRecipientArg ( const QString & line) -> QString
static

A bare mail address in gpg's exact form, <address>; any other line as written.

gpg reads a bare address as a case-insensitive substring of the user ID: bob@example.com also matches notbob@example.com, and once Bob's key is unusable gpg takes that one without a word. In angle brackets only that address matches. Lines with their own gpg prefix (=, <, @, *, +, #, &), spaces, or no @ are left alone.

Parameters
lineOne recipient line.
Returns
The argument.

Definition at line 695 of file pass.cpp.

Here is the caller graph for this function:

◆ executeWrapper() [1/2]

void Pass::executeWrapper ( PROCESS id,
const QString & app,
const QStringList & args,
bool readStdout = true,
bool readStderr = true )
protected

Execute external wrapper command.

Parameters
idProcess identifier.
appExecutable path.
argsCommand arguments.
readStdoutCapture stdout.
readStderrCapture stderr.

Definition at line 126 of file pass.cpp.

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

◆ executeWrapper() [2/2]

void Pass::executeWrapper ( PROCESS id,
const QString & app,
const QStringList & args,
QString input,
bool readStdout,
bool readStderr )
protected

Execute wrapper with input.

Parameters
idProcess identifier.
appExecutable path.
argsCommand arguments.
inputInput to pass to stdin.
readStdoutCapture stdout.
readStderrCapture stderr.

Definition at line 132 of file pass.cpp.

Here is the call graph for this function:

◆ exportPublicKeys()

auto Pass::exportPublicKeys ( const QString & gpg,
const QStringList & keys,
QString * out,
QString * err ) -> int

gpg --armor --export of keys, in the store's environment: the keyring keyLinesHeldTwice() reads.

Parameters
gpgThe gpg executable.
keysThe key IDs or fingerprints.
outReceives the armoured keys.
errReceives gpg's messages.
Returns
gpg's exit code.

Definition at line 558 of file pass.cpp.

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

◆ finished

void Pass::finished ( int id,
int exitCode,
const QString & out,
const QString & err )
protectedvirtualslot

Handle process completion.

Parameters
idProcess identifier.
exitCodeProcess exit code.
outStandard output.
errStandard error.

Reimplemented in ImitatePass, and RealPass.

Definition at line 860 of file pass.cpp.

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

◆ finishedAnyWithPid

void Pass::finishedAnyWithPid ( const QString & out,
const QString & err,
Enums::PROCESS pid )
signal

A process of any kind finished successfully and its output cannot contain a secret.

Feeds the process output panel. Processes whose output may hold a decrypted entry (Enums::processInfo()) never emit it, so a receiver may log or display out and err as they are.

Parameters
outStandard output from the process.
errStandard error from the process.
pidWhich kind of process it was.
Here is the caller graph for this function:

◆ finishedCopy

void Pass::finishedCopy ( const QString & out,
const QString & err )
signal

A Copy() succeeded; the copy exists beside the original.

Parameters
outStandard output.
errStandard error.
Here is the caller graph for this function:

◆ finishedGenerateGPGKeys

void Pass::finishedGenerateGPGKeys ( const QString & out,
const QString & err )
signal

GenerateGPGKeys() succeeded; the new key pair is in the keyring.

The key generation dialog closes on it. A failure emits generateGPGKeysFailed() instead.

Parameters
outStandard output.
errStandard error.
Here is the caller graph for this function:

◆ finishedGitInit

void Pass::finishedGitInit ( const QString & out,
const QString & err )
signal

git init in the store succeeded; the store is a repository now and the tree is re-read.

Parameters
outStandard output.
errStandard error.
Here is the caller graph for this function:

◆ finishedGitPull

void Pass::finishedGitPull ( const QString & out,
const QString & err )
signal

git pull succeeded; entries may have changed on disk.

Parameters
outStandard output.
errStandard error.
Here is the caller graph for this function:

◆ finishedGitPush

void Pass::finishedGitPush ( const QString & out,
const QString & err )
signal

git push succeeded.

Parameters
outStandard output.
errStandard error.
Here is the caller graph for this function:

◆ finishedGrep

void Pass::finishedGrep ( const QList< QPair< QString, QStringList > > & results)
signal

The newest Grep() is over; an empty list means no entry matched.

Comes from NativeGrep on both backends and bypasses finished(), since the matching lines are decrypted content. A search superseded by a newer one never reports.

Parameters
resultsList of (entry path, matching lines) pairs.
Here is the caller graph for this function:

◆ finishedInit

void Pass::finishedInit ( const QString & out,
const QString & err )
signal

An Init() succeeded: the folder's .gpg-id holds the new recipient list.

Parameters
outStandard output.
errStandard error.
Here is the caller graph for this function:

◆ finishedInsert

void Pass::finishedInsert ( const QString & out,
const QString & err )
signal

An Insert() succeeded: the entry is in the store and, with Git in use, committed.

In ImitatePass this ends the whole transaction (gpg, then git add and commit), not just the gpg step. The password dialog closes on it. A failure reported through the command queue goes out as insertFailed() and processErrorExit() instead; an insert refused before anything is queued emits neither this signal nor insertFailed().

Parameters
outStandard output of the operation's processes.
errStandard error.
Here is the caller graph for this function:

◆ finishedMove

void Pass::finishedMove ( const QString & out,
const QString & err )
signal

A Move() succeeded; the entry or folder is under its new name.

Parameters
outStandard output.
errStandard error.
Here is the caller graph for this function:

◆ finishedRemove

void Pass::finishedRemove ( const QString & out,
const QString & err )
signal

A Remove() succeeded; the entry or folder is gone from the store.

Parameters
outStandard output.
errStandard error.
Here is the caller graph for this function:

◆ finishedShow

void Pass::finishedShow ( const QString & out,
const QString & file,
bool lossless = true )
signal

Emitted when a Show() succeeds.

Requests complete in the order they were queued, so file is the argument of the Show() this result belongs to. Every receiver checks it against what it asked for; a failed decrypt emits processErrorExit() instead and never finishedShow().

Parameters
outDecrypted password file content, as text: fine to show or copy, but only to write back when lossless.
fileThe Show() argument this content is for.
losslessfalse when out does not encode back to the entry's bytes (they are not UTF-8, or begin with a byte order mark), so saving it would change the entry (Executor::lastOutputLossless()).
Here is the caller graph for this function:

◆ formatInsertError()

auto Pass::formatInsertError ( const QString & friendly,
const QString & err ) -> QString
private

Put the translated reason for a failed insert above what gpg itself printed, leaving out the machine-readable [GNUPG:] lines.

Parameters
friendlyMessage from gpgErrorMessage().
errgpg's stderr.
Returns
friendly, followed by the human-readable rest of err when there is any.

Definition at line 937 of file pass.cpp.

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

◆ fullKeyListing()

auto Pass::fullKeyListing ( QString * listing) -> int
protectedvirtual

The whole public keyring as keyLinesHeldTwice() reads it.

Parameters
listingReceives the colon listing.
Returns
gpg's exit code; -1 when it did not start.

Reimplemented in ImitatePass.

Definition at line 545 of file pass.cpp.

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

◆ GenerateGPGKeys()

void Pass::GenerateGPGKeys ( QString batch)

Generate GPG keys using batch script.

Parameters
batchGPG batch script content.

Definition at line 420 of file pass.cpp.

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

◆ generateGPGKeysFailed

void Pass::generateGPGKeysFailed ( const QString & err)
signal

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.

Parameters
errWhat gpg (or the setup) reported.
Here is the caller graph for this function:

◆ generatePassword()

auto Pass::generatePassword ( unsigned int length,
const QString & charset ) -> QString
virtual

Generate random password.

Parameters
lengthPassword length.
charsetCharacter set to use.
Returns
Generated password.

Definition at line 243 of file pass.cpp.

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

◆ generateRandomPassword()

auto Pass::generateRandomPassword ( const QString & charset,
unsigned int length ) -> QString
protected

Generate random password from charset.

Parameters
charsetCharacter set.
lengthPassword length.
Returns
Generated password.

Definition at line 1927 of file pass.cpp.

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

◆ getDefaultKeyTemplate()

QString Pass::getDefaultKeyTemplate ( const QString & gpgExecutable = {})
static

Get default key template for new GPG keys.

Parameters
gpgExecutablePath to the gpg binary (defaults to "gpg").
Returns
Default template string.

Definition at line 317 of file pass.cpp.

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

◆ getGpgIdPath()

auto Pass::getGpgIdPath ( const QString & for_file,
const QString & passStore ) -> QString
static

Get .gpg-id file path for a password file.

Parameters
for_filePath to password file.
passStoreRoot directory of the password store.
Returns
Path to .gpg-id file.

Definition at line 1511 of file pass.cpp.

Here is the caller graph for this function:

◆ getRecipientList()

auto Pass::getRecipientList ( const QString & for_file,
const QString & passStore ) -> QStringList
static

Get list of recipients for a password file.

Parameters
for_filePath to password file.
passStoreRoot directory of the password store.
Returns
List of recipient key IDs.

Definition at line 1833 of file pass.cpp.

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

◆ GitInit()

virtual void Pass::GitInit ( )
pure virtual

Initialize Git repository in password store.

Implemented in ImitatePass, and RealPass.

◆ GitPull()

virtual void Pass::GitPull ( )
pure virtual

Pull changes from remote Git repository.

Implemented in ImitatePass, and RealPass.

◆ GitPull_b()

virtual void Pass::GitPull_b ( int timeoutMs)
pure virtual

Pull from the remote and wait for it, at most timeoutMs: the pull before an edit, on the GUI thread.

A remote that never answers froze the window, autoclear timers included, until git gave up, which it may never do. Past the deadline git is stopped and the status bar says the pull did not finish.

Parameters
timeoutMsMost milliseconds to wait (kBlockingPullMs from the window).

Implemented in ImitatePass, and RealPass.

◆ GitPush()

virtual void Pass::GitPush ( )
pure virtual

Push changes to remote Git repository.

Implemented in ImitatePass, and RealPass.

Here is the caller graph for this function:

◆ GitPushAutomatic()

void Pass::GitPushAutomatic ( )

GitPush() for an automatic push, the one after a change. A backend that has to make the push later drops it then if the store is held by that time (autoPushHeld()); a push by hand (GitPush()) still goes.

Definition at line 1300 of file pass.cpp.

Here is the call graph for this function:

◆ gpgIdVerdictIn()

auto Pass::gpgIdVerdictIn ( const QString & dir) -> std::optional< SkippedWalk >
staticprivate

What skippedGpgId() concludes at one folder on its way up.

Parameters
dirAbsolute folder path.
Returns
Nothing when the folder has no list and never had one here, so the walk goes on; else the answer: no skipped list when the folder has its own, or its .gpg-id path when that is a link, is gone after it was accepted, or the record cannot be read (with the record's error).

Definition at line 1579 of file pass.cpp.

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

◆ gpgSupportsEd25519()

bool Pass::gpgSupportsEd25519 ( const QString & gpgExecutable = {})
static

Check if GPG supports Ed25519 encryption.

Parameters
gpgExecutablePath to the gpg binary (defaults to "gpg").
Returns
true if Ed25519 is supported.

Definition at line 298 of file pass.cpp.

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

◆ Grep()

virtual void Pass::Grep ( QString pattern,
bool caseInsensitive )
pure virtual

Search password content for a pattern.

Both backends decrypt each entry with gpg and match it in-process (NativeGrep), never through pass grep, so the pattern is one dialect for both: QRegularExpression, Perl-compatible (PCRE).

Parameters
patternSearch pattern, a Perl-compatible regular expression.
caseInsensitivetrue for case-insensitive search.

Implemented in ImitatePass, and RealPass.

◆ handleProcessError()

void Pass::handleProcessError ( PROCESS pid,
int exitCode,
const QString & out,
const QString & err )
private

Report a process that exited non-zero; called by finished().

Always ends in processErrorExit(). A failed insert first emits insertFailed(), and critical() too when the entry was written and only a git step after it failed; failed key generation first emits generateGPGKeysFailed().

Parameters
pidWhich kind of process failed.
exitCodeIts exit code.
outIts stdout; not used.
errIts stderr, or the Executor's message for a failed start.

Definition at line 896 of file pass.cpp.

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

◆ heldScopes()

auto Pass::heldScopes ( ) -> QSet< QString > &
staticprivate

The folders (cleaned absolute paths) whose re-encryption did not finish, for every store and both backends.

Returns
The shared set, for this session.

Definition at line 1282 of file pass.cpp.

Here is the caller graph for this function:

◆ holdAutoPush()

void Pass::holdAutoPush ( const QString & scope)
protected

Hold automatic pushes of the store that holds scope (autoPushHeld()): its re-encryption did not finish cleanly.

Parameters
scopeThe folder (or entry) the run re-encrypted, absolute or relative to the current store.

Definition at line 1308 of file pass.cpp.

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

◆ idle

void Pass::idle ( )
signal

Nothing of the store's runs or waits any more (isIdle()).

Emitted when the command queue drains. The main window re-enables the profile selector on it: switching stores is held back while commands for the current one are still queued.

Here is the caller graph for this function:

◆ Init()

virtual void Pass::Init ( QString path,
const QList< UserInfo > & users )
pure virtual

Initialize new password store.

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

Implemented in ImitatePass, and RealPass.

Here is the caller graph for this function:

◆ init()

void Pass::init ( const AppSettings & settings)

Initialize the Pass instance with a settings snapshot.

Parameters
settingsApplication settings to use for this backend lifetime.

Definition at line 171 of file pass.cpp.

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

◆ initIfUnchanged()

auto Pass::initIfUnchanged ( const QString & path,
const QList< UserInfo > & users,
const QString & dir,
const QString & passStore,
const RecipientsForEditing & read ) -> bool

Init(), but only while the list of dir still reads as the caller read it with recipientsForEditing().

The users dialog ticks its selection from the list it read, and writes the whole selection: a newer list that arrived meanwhile (a pull in a terminal, a sync) would be replaced by the old one plus the change. The backend reads the list again at the last point before it writes (or starts pass init) and refuses with refuseChangedList() when it differs.

Parameters
pathFolder to initialize, as for Init().
usersRecipients, as for Init().
dirThe folder the list was read for, as given to recipientsForEditing().
passStoreThe store root given to recipientsForEditing().
readWhat recipientsForEditing() returned then; its warning is not compared.
Returns
false when refuseChangedList() or refuseBusyForExpectedList() refused, so the caller can keep its selection; true otherwise, also when Init() refused for another reason it reported itself.

Definition at line 1442 of file pass.cpp.

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

◆ Insert()

virtual void Pass::Insert ( QString file,
QString value,
bool force )
pure virtual

Insert or update password.

Parameters
filePath to password file.
valuePassword content to store.
forceOverwrite existing file.

Implemented in ImitatePass, and RealPass.

Here is the caller graph for this function:

◆ insertFailed

void Pass::insertFailed ( const QString & err,
bool written )
signal

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.

Parameters
errWhat gpg, pass or the placement of the entry reported.
writtentrue when this insert did put the entry in the store and only a later step (git add or commit) failed.
Here is the caller graph for this function:

◆ insertsPending()

auto Pass::insertsPending ( ) const -> int
inlinenodiscard

How many inserts have started queueing but not yet reported.

One Insert() still in the command queue, or running, counts here until its PASS_INSERT result goes out. A PasswordDialog reads this just before its own Insert() so it can tell an earlier insert's report (which it is also connected to, once a hanging queue let it open while its save was still pending) from its own.

Returns
The number of inserts awaiting their report.

Definition at line 245 of file pass.h.

Here is the caller graph for this function:

◆ insertWritten()

virtual auto Pass::insertWritten ( const QString & err) const -> bool
inlinenodiscardprotectedvirtual

Whether the insert that just failed had put its entry in the store before a later step failed. The backend that writes the entry knows; this default says no.

Parameters
errWhat the failed insert reported on stderr.
Returns
true when the failed insert's entry was written.

Reimplemented in ImitatePass, and RealPass.

Definition at line 828 of file pass.h.

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

◆ isIdle()

auto Pass::isIdle ( ) const -> bool
inlinenodiscard

Whether no gpg, git or pass of this backend runs or waits.

Returns
true when its executor is idle.

Definition at line 711 of file pass.h.

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

◆ isPushing()

auto Pass::isPushing ( ) const -> bool
inlinenodiscard

Whether a Git push of this backend is queued or running.

Returns
true while one waits or runs.

Definition at line 740 of file pass.h.

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

◆ keyLinesHeldTwice()

auto Pass::keyLinesHeldTwice ( const QStringList & lines) -> std::optional< QHash< QString, QStringList > >

The key ID and fingerprint lines of a recipient list that more than one key block holds, with those blocks.

gpg resolves -r <fingerprint> among primary keys and subkeys, and anyone can bind another person's public key to their own as a subkey: after importing such a key, a line meant for one person may encrypt to the other. Such a line is refused, not guessed at.

Parameters
linesThe lines of a recipient list.
Returns
Each such line, mapped to its holders as "name (key ID)"; nothing when the keyring could not be listed, so a failed listing is not taken for a clean one.

Definition at line 590 of file pass.cpp.

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

◆ keyLinesHeldTwiceIn()

auto Pass::keyLinesHeldTwiceIn ( const QStringList & lines,
const QString & listing ) -> QHash< QString, QStringList >
static

keyLinesHeldTwice() on a listing already made.

Parameters
linesThe lines of a recipient list.
listingOutput of gpg --with-colons --with-fingerprint --with-subkey-fingerprint --list-keys.
Returns
As keyLinesHeldTwice().

Definition at line 611 of file pass.cpp.

Here is the caller graph for this function:

◆ linkedGpgId()

auto Pass::linkedGpgId ( const QString & forFile,
const QString & passStore,
LinkedWalks * walks = nullptr ) -> std::optional< QString >
static

The link or junction under the name .gpg-id that getGpgIdPath() skips on its way up from forFile, if it skips one before the list it returns.

pass follows such a link and encrypts to the recipients of the file it points to, while QtPass shows and checks the list of a folder above it. Unlike skippedGpgId(), this asks no generation record and includes the store root, so it applies with or without a signing key.

Parameters
forFileEntry or folder, as for getGpgIdPath().
passStoreRoot directory of the password store.
walksWhat earlier calls found per folder, for one check of many folders (RealPass::refuseUnverifiedTree()); read and extended, so each folder is looked at once. Null for none.
Returns
The linked .gpg-id path, or nothing when the walk meets none.

Definition at line 1659 of file pass.cpp.

Here is the caller graph for this function:

◆ listKeys() [1/2]

auto Pass::listKeys ( const QString & keystring = "",
bool secret = false ) -> QList< UserInfo >

List GPG keys.

Parameters
keystringSearch pattern.
secretInclude secret keys.
Returns
List of matching keys.

Definition at line 779 of file pass.cpp.

Here is the call graph for this function:

◆ listKeys() [2/2]

auto Pass::listKeys ( QStringList keystrings,
bool secret = false ) -> QList< UserInfo >

List GPG keys matching patterns.

Parameters
keystringsList of search patterns.
secretInclude secret keys.
Returns
List of matching keys.

Definition at line 763 of file pass.cpp.

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

◆ loggableArgs()

auto Pass::loggableArgs ( const QStringList & args) -> QStringList
static

The arguments as they may appear in the debug log: the value of --passphrase and friends, and otpauth URIs, are replaced.

Parameters
argsThe argv about to be run.
Returns
The same list with secret-shaped values redacted.

Definition at line 141 of file pass.cpp.

Here is the caller graph for this function:

◆ maxOutputArgs()

auto Pass::maxOutputArgs ( ) -> QStringList
static

The gpg options that enforce kMaxPlaintextBytes.

Returns
"--max-output" and the limit, for a gpg decryption's arguments.

Definition at line 1184 of file pass.cpp.

Here is the caller graph for this function:

◆ Move()

virtual void Pass::Move ( const QString srcDir,
const QString dest,
const bool force )
pure virtual

Move password file or directory.

Parameters
srcDirSource path.
destDestination path.
forceOverwrite existing.

Implemented in ImitatePass, and RealPass.

◆ parseRecipients()

auto Pass::parseRecipients ( const QByteArray & contents,
const QString & sourceName ) -> QStringList
static

Parse the contents of a .gpg-id: one recipient per line, # starts a comment, unusable lines are logged and skipped.

Parameters
contentsThe file's bytes.
sourceNameWhere they came from, for the log.
Returns
The recipient key IDs in file order.

Definition at line 1848 of file pass.cpp.

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

◆ passReadsDifferently()

auto Pass::passReadsDifferently ( const QByteArray & contents) -> QString
static

Why pass would read a .gpg-id differently from parseRecipients(), if it would.

pass reads the list with while read -r, which keeps NUL-free bytes as they are, strips only blanks and tabs, and drops a last line without a line feed; parseRecipients() decodes UTF-8 (losing a byte-order mark and invalid bytes), trims every kind of whitespace and skips a line that starts with a dash. Where the two differ, the Users dialog shows other recipients than pass encrypts to.

Parameters
contentsThe file's bytes.
Returns
The first difference, as a phrase for a message; empty when both read the same recipients.

Definition at line 1869 of file pass.cpp.

Here is the caller graph for this function:

◆ pinStoreGitAttributes()

void Pass::pinStoreGitAttributes ( )
protected

Pin byte-for-byte Git attributes for the store's encrypted files.

Writes override lines for *.gpg, .gpg-id and .gpg-id.sig into the store repository's private info/attributes, which outranks any in-tree .gitattributes a co-writer may push (*.gpg text, a working-tree-encoding or a filter) that would otherwise make Git rewrite the ciphertext QtPass commits so it no longer decrypts. Written only when the store is its own Git repository (a .git directory); a worktree .git file or a store nested in a larger repository is left untouched. Idempotent: marked and rewritten only when absent or changed.

Definition at line 1100 of file pass.cpp.

Here is the caller graph for this function:

◆ processErrorExit

void Pass::processErrorExit ( int exitCode,
const QString & err )
signal

An operation ended in failure: its process exited non-zero, could not be started or crashed, or the operation was refused.

The counterpart of the finished... signals for an operation that queued a command: it ends in one or the other. The main window releases the busy state and shows err in the password pane. One case emits both: when RealPass has removed a linked folder but could not commit that, this signal is followed by finishedRemove(), because the store did change.

Before anything is queued the paths differ, so a caller must not wait for this signal after every call. A path behind a link and an unfinished Git operation are refused with startingExecuteWrapper(), critical() and this signal. Other early checks, such as an entry that already exists, emit critical() alone and return.

insertFailed() and generateGPGKeysFailed() are emitted before this signal whenever their operation fails through a queued command, be it a non-zero exit, a crash or a process that could not be started, so their dialogs need not guess whose failure it is. generateGPGKeysFailed() also comes first when no gpg executable is configured and nothing is queued at all. A refusal that reaches this signal without queuing anything emits neither of them.

Parameters
exitCodeExit code of the process; -1 when it did not exit normally, 1 for a refusal.
errWhat to show the user: stderr, or a translated message.
Here is the caller graph for this function:

◆ pullTimedOut()

auto Pass::pullTimedOut ( int timeoutMs) -> QString
staticnodiscard

The status-bar text for a blocking pull stopped at its deadline.

Parameters
timeoutMsThe deadline that passed.
Returns
The message.

Definition at line 1940 of file pass.cpp.

Here is the caller graph for this function:

◆ pushIsAutomatic()

auto Pass::pushIsAutomatic ( ) const -> bool
nodiscardprotected

Whether the GitPush() running now is an automatic one.

Returns
true inside GitPushAutomatic().

Definition at line 1306 of file pass.cpp.

Here is the caller graph for this function:

◆ queueInsert()

void Pass::queueInsert ( const QString & entry = QString())
inlineprotected

Count one insert that has started queueing but not yet reported.

Backends call this where Insert() queues its work, past every refusal; Pass::finished() counts it off again when the insert reports. Each queued insert reports once, as a PASS_INSERT, so the count tracks the inserts in flight. A dialog reads insertsPending() before its own Insert() to learn how many earlier reports are not its own.

Parameters
entryAbsolute path of the entry file the insert writes, handed out by reportedInsert() while its report goes out.

Definition at line 853 of file pass.h.

Here is the caller graph for this function:

◆ queueShow()

void Pass::queueShow ( const QString & file)
inlineprotected

Remember what a Show() asked for, so its completion can say so.

Backends call this first thing in Show(); Pass::finished() pops the entry again on success or failure. The Executor runs one queue in order, so the two stay aligned.

Parameters
fileThe Show() argument.

Definition at line 841 of file pass.h.

Here is the caller graph for this function:

◆ readersAnEditWouldAdd()

virtual auto Pass::readersAnEditWouldAdd ( const QString & file) -> EditReaders
inlinevirtual

Who saving over an existing entry would let read it who may not now.

Asked by the edit dialog before Insert(), so a list that changed under the entry (a folder renamed past its own signed list, say) does not widen it unasked. Those who read it now come from the entry's recipient IDs, which whoever can push can write; so with a signing key, an entry at a path this device never saved (EntryRecord) whose folder takes a parent's list is asked about whatever its IDs say. None by default; the native backend tells.

Parameters
fileThe entry, relative to the store, without ".gpg".
Returns
The answer; empty names when nothing needs asking or it cannot be told (new entry, unreadable list).

Reimplemented in ImitatePass.

Definition at line 282 of file pass.h.

Here is the caller graph for this function:

◆ recipientArgument()

auto Pass::recipientArgument ( const QString & line) const -> QString
nodiscardvirtual

The -r argument for one recipient line, as this backend's encryption hands it to gpg: the probe (encryptionReaches()) must reach what the encryption will. The native backend matches a bare address exactly (exactRecipientArg()).

Parameters
lineOne recipient line.
Returns
The argument.

Reimplemented in RealPass.

Definition at line 703 of file pass.cpp.

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

◆ recipientsForEditing()

auto Pass::recipientsForEditing ( const QString & dir,
const QString & passStore ) -> RecipientsForEditing

The recipients a dialog may preselect for editing the list of dir.

With a signing key configured, only a list whose signature, generation and folder binding are all accepted: the Users dialog preselects what it loads and OK writes and signs the selection, so a list read unauthenticated would turn an attacker's unsigned edit into a genuinely signed one with one click. The one exception is an authentic list the generation record calls older (the recovery from a rollback goes through this dialog): preselected, with the reason shown for review. Anything else that fails preselects nothing and says why. Without a signing key, the list as it is.

Parameters
dirFolder whose list is edited; empty for the store root.
passStoreThe store the folder belongs to: the dialog's, which for a profile being set up is not this backend's.
Returns
The state, the recipients to preselect and the warning to show.

Definition at line 1745 of file pass.cpp.

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

◆ refuseAsNotPartOfStore()

void Pass::refuseAsNotPartOfStore ( const QString & why)
private

Refuse an operation on something that is not part of the store.

Emits startingExecuteWrapper(), critical() and processErrorExit(), so an interface that arms itself when an operation starts is released again although nothing was started. refuseLinkedPath() and refuseFolderOutsideStore() say why.

Parameters
whyTranslated reason, shown to the user.

Definition at line 1503 of file pass.cpp.

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

◆ refuseBusyForExpectedList()

auto Pass::refuseBusyForExpectedList ( ) -> bool
protected

Refuse an Init() under initIfUnchanged() while the executor has work queued or running, for a backend whose external tool writes the list only when its process runs.

refuseChangedList() can only compare when the request is made. With nothing ahead of it, pass init starts right away and the gap stays that of a process start.

Returns
true when critical() and processErrorExit() were emitted and the caller must stop.

Definition at line 1475 of file pass.cpp.

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

◆ refuseChangedList()

auto Pass::refuseChangedList ( ) -> bool
protected

Refuse an Init() under initIfUnchanged() when the folder's list no longer reads as the caller read it.

Called by each backend at the last point before the list is written or pass init is started. Outside initIfUnchanged() nothing is compared.

Returns
true when critical() and processErrorExit() were emitted and the caller must stop.

Definition at line 1452 of file pass.cpp.

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

◆ refuseFolderOutsideStore()

auto Pass::refuseFolderOutsideStore ( const QString & folder,
QString * relative = nullptr ) -> bool
protected

Refuse recipients for a folder outside the store, as pass refuses a path with .. in it.

ImitatePass would write a .gpg-id that the store never reads, and pass init --path would take the folder's absolute path as a folder under the store. Links on the way are resolved, as for the store root.

Parameters
folderThe folder, absolute.
relativeWhere the folder lies in the store, as PathValidator::storeRelativePath() gives it (empty for the root), when it is not refused; may be null.
Returns
true when critical() and processErrorExit() were emitted and the caller must stop.

Definition at line 1347 of file pass.cpp.

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

◆ refuseKeyLinesHeldTwice()

auto Pass::refuseKeyLinesHeldTwice ( const QStringList & lines) -> bool
protected

Refuse, with critical(), a recipient list with a line that more than one key block holds (keyLinesHeldTwice()).

Parameters
linesThe lines of the list.
Returns
true when refused.

Definition at line 568 of file pass.cpp.

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

◆ refuseLinkedPath()

auto Pass::refuseLinkedPath ( const QString & path,
LinkScope scope = LinkScope::EntryAndParents,
PathSpelling spelling = PathSpelling::Configured ) -> bool
protected

Refuse an operation on something that is, or lies behind, a symbolic link or NTFS junction inside the store.

The store tree shows a linked entry or folder like any other, and gpg, pass and QFile all follow links, so without this a planted link would have an entry shown, edited, copied or written outside the store, with the store's recipients. The configured store root itself may be a link (a synced folder); that is not judged.

Parameters
pathStore-relative (as Show/Insert/Remove get it, .gpg included where it applies) or absolute (as Move/Copy get it).
scopeWhether the entry itself counts, or only the folders it lies in (a removal).
spellingWhether path follows the class's path rule, or the caller places a target-spelled path itself (Init()).
Returns
true when critical() and processErrorExit() were emitted and the caller must stop.

Definition at line 1321 of file pass.cpp.

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

◆ refusePendingPull()

auto Pass::refusePendingPull ( ) -> bool
protected

Refuse a store change while a Git pull is still queued or running.

An operation checks the repository when it is requested, but a pull queued before it (the asynchronous Update) has not run yet, so a conflict it will cause is not visible. For operations that commit without a later point to re-check (every delete, move and copy, and the pass backend, whose single pass insert commits by itself), refuse while the pull is in flight so the change cannot land in the conflict it leaves. Nothing is refused when Git is off or no pull is pending.

Returns
true when critical() and processErrorExit() were emitted and the caller must stop.

Definition at line 1427 of file pass.cpp.

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

◆ refuseSkippedGpgId()

auto Pass::refuseSkippedGpgId ( const QString & file,
bool signing,
const QString & except = QString(),
SkippedWalks * walks = nullptr ) -> bool
protected

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.

Parameters
fileThe entry or folder about to be encrypted to.
signingWhether a signing key is set (signed lists in use).
exceptA list about to be written (by pass init), which may be missing now without that being refused.
walksPassed on to skippedGpgId(); null for none.
Returns
Whether it was refused (and the user told).

Definition at line 1518 of file pass.cpp.

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

◆ refuseUnfinishedGitOperation()

auto Pass::refuseUnfinishedGitOperation ( ) -> bool
protected

Refuse to change the store while git is mid-rebase, -merge, -cherry-pick or -revert.

A pull that stopped in a conflict leaves the repository part-way through an operation. Committing a save or a re-encryption into it lands the change on a detached HEAD (a later git rebase --abort drops it) or concludes the merge in favour of the local copy (pushing over a colleague's change). Every store-changing operation calls this at its entry, next to refuseLinkedPath(), so the change is refused before gpg or pass runs and the dialog keeps what was typed. Nothing is refused when git is off, the store is not a repository, or git gives no answer. A HEAD detached by hand (no operation in progress) is deliberately accepted.

Returns
true when critical() and processErrorExit() were emitted and the caller must stop.

Definition at line 1489 of file pass.cpp.

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

◆ releaseAutoPush()

void Pass::releaseAutoPush ( const QString & folder)
protected

Release the holds a clean re-encryption of folder covers: those for folder itself and everything under it. Holds for other folders stay.

Parameters
folderThe folder the clean run re-encrypted, absolute or relative to the current store.

Definition at line 1312 of file pass.cpp.

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

◆ Remove()

virtual void Pass::Remove ( QString file,
bool isDir )
pure virtual

Remove password file or directory.

Parameters
filePath to remove.
isDirtrue if removing a directory.

Implemented in ImitatePass, and RealPass.

◆ reportedInsert()

auto Pass::reportedInsert ( ) const -> QString
inlinenodiscard

The entry whose insert is reporting now: set while finishedInsert() or insertFailed() goes out, empty otherwise.

Inserts report in the order they were queued, so each report is matched to the entry its Insert() named. A window refreshing after a save shows only that entry again, not whatever row is selected by then.

Returns
Absolute path of the entry file (with .gpg), as the backend wrote it; empty outside a report, or for a report no queued insert accounts for.

Definition at line 336 of file pass.h.

Here is the caller graph for this function:

◆ resolveGpgconfCommand()

auto Pass::resolveGpgconfCommand ( const QString & gpgPath) -> ResolvedGpgconfCommand
static

Resolve the gpgconf command to kill agents.

Parameters
gpgPathPath to gpg executable.
Returns
Resolved command with program and arguments.

Definition at line 380 of file pass.cpp.

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

◆ runningProcess()

auto Pass::runningProcess ( ) const -> Enums::PROCESS
inlinenodiscard

What kind of command is running now.

Returns
Its Enums::PROCESS, or Enums::INVALID when nothing runs.

Definition at line 729 of file pass.h.

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

◆ runningSerial()

auto Pass::runningSerial ( ) const -> quint64
inlinenodiscard

Which run is going (Executor::runningSerial()).

Returns
A number no other run had, or 0 when nothing runs.

Definition at line 722 of file pass.h.

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

◆ scopePath()

auto Pass::scopePath ( const QString & path) const -> QString
nodiscardprivate

path as an absolute, cleaned path, relative ones taken from the current store.

Parameters
pathA folder or entry.
Returns
The cleaned absolute path.

Definition at line 1287 of file pass.cpp.

Here is the caller graph for this function:

◆ setEnvVar()

void Pass::setEnvVar ( const QString & name,
const QString & value )
protected

Set or remove an environment variable.

Parameters
nameVariable name (e.g. "PASSWORD_STORE_DIR"), no trailing '='.
valueNew value; an empty string removes the variable entirely.

Definition at line 977 of file pass.cpp.

Here is the caller graph for this function:

◆ Show()

virtual void Pass::Show ( QString file)
pure virtual

Show decrypted password file.

Parameters
filePath to password file relative to store root.

Implemented in ImitatePass, and RealPass.

Here is the caller graph for this function:

◆ skippedGpgId()

auto Pass::skippedGpgId ( const QString & forFile,
const QString & passStore,
QString * recordError = nullptr,
SkippedWalks * walks = nullptr ) -> std::optional< QString >
static

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.

getGpgIdPath() skips a .gpg-id that is missing, a link or a junction and falls back to a parent folder's list, as pass does. In a signed store that lets anyone who can write to it, without the signing key, move a folder's entries to the parent's (also validly signed) recipients by removing or linking the folder's own list. This names the first such list between the start and the folder of the list found (that folder and the store root excluded): one that is under the name but not a regular file, or one that is gone although this device has accepted a list at that path before (GpgIdGeneration::remembered()). When the generation record cannot be read, whether a list was accepted at a path cannot be told: the first folder without its own list is named then too (fail closed), and recordError says why.

Parameters
forFileEntry or folder, as for getGpgIdPath().
passStoreRoot directory of the password store.
recordErrorReceives the record's error when it could not be read, if not null; left untouched otherwise.
walksWhat earlier calls found per folder, for one check of many folders (RealPass::refuseUnverifiedTree()); read and extended, so each folder is looked up once. Null for none.
Returns
The skipped .gpg-id path, or nothing when the list found is the one that applies.

Definition at line 1609 of file pass.cpp.

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

◆ startingExecuteWrapper

void Pass::startingExecuteWrapper ( )
signal

Emitted each time a queued process is about to start, and by the refusals that go on to emit processErrorExit().

The main window shows the busy state on it. An operation made of several processes emits it once per process; the operation then ends with a finished... signal or with processErrorExit().

Here is the caller graph for this function:

◆ statusMsg

void Pass::statusMsg ( const QString & msg,
int timeout )
signal

Progress or a non-fatal problem worth a line in the status bar ("Creating backup commit", "Git pull failed: ...").

Nothing depends on it being shown; an error the user must see goes out as critical() instead.

Parameters
msgTranslated status text.
timeoutHow long to show it, in milliseconds.
Here is the caller graph for this function:

◆ stopRunning()

auto Pass::stopRunning ( ) -> bool
inline

Stop the queued command that is running now (Executor::stopRunning()); it then ends as a failed run.

Returns
Whether one was running.

Definition at line 717 of file pass.h.

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

◆ storeEnvironment()

auto Pass::storeEnvironment ( ) const -> QProcessEnvironment
inlinenodiscardprotected

The environment QtPass runs the store's processes in.

What updateEnv() made: the git ceiling and the PASSWORD_STORE_ variables QtPass's own environment does not carry. For blocking calls that start their own process.

Returns
A copy of the environment.

Definition at line 124 of file pass.h.

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

◆ storeGit()

virtual auto Pass::storeGit ( const QStringList & args,
QString * out ) -> bool
inlineprotectedvirtual

Run a git command in the store's repository, blocking.

The two backends reach git differently: ImitatePass runs the configured git with -C <Store tree and entries>, RealPass runs pass git. The default (no git) answers false. Used by refuseUnfinishedGitOperation() to ask the repository its state before an operation changes the store.

Parameters
argsThe git arguments (without the executable or -C).
outReceives the command's standard output; may be null.
Returns
true when git ran and exited 0, false otherwise (git off, the store is not a repository, or git failed).

Reimplemented in ImitatePass, and RealPass.

Definition at line 932 of file pass.h.

Here is the caller graph for this function:

◆ unfinishedGitOperationReason()

auto Pass::unfinishedGitOperationReason ( ) -> QString
protected

The unfinished git operation in progress in the store, if any.

The detection behind refuseUnfinishedGitOperation(), without emitting a refusal: a backend re-checks it when a save's gpg step has finished (a pull queued before the save, from the asynchronous Update, may have finished and left a conflict meanwhile) so the entry is not placed or committed into the operation.

Returns
A ready-to-show reason naming the operation (rebase, merge, cherry-pick or revert), or an empty string when none is in progress, git is off, or the store is not a repository.

Definition at line 1363 of file pass.cpp.

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

◆ updateEnv()

void Pass::updateEnv ( )

Update environment for subprocesses.

Definition at line 984 of file pass.cpp.

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

◆ verifySignedList()

auto Pass::verifySignedList ( const GpgIdSigner & signer,
const QString & gpgIdFile,
QByteArray * contents,
QString * why ) const -> bool
protected

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.

Parameters
signerThe verifier, with the configured signing keys.
gpgIdFileThe .gpg-id.
contentsReceives the verified bytes.
whyReceives why a current-and-bound check refused the list; left as it is when the signature itself does not verify.
Returns
Whether the list may be encrypted to.

Definition at line 1555 of file pass.cpp.

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

◆ withCurrentGitPin()

auto Pass::withCurrentGitPin ( QProcessEnvironment base) const -> QProcessEnvironment
nodiscardprotected

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.

Parameters
baseThe environment to update.
Returns
base, the two variables recomputed (left as they are when the store keeps to a parent repository or there is none).

Definition at line 1169 of file pass.cpp.

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

◆ withoutStatusLines()

auto Pass::withoutStatusLines ( const QString & err) -> QString
staticprotected

gpg's stderr without its machine-readable [GNUPG:] lines (and without carriage returns), as a person reads it.

Parameters
errgpg's (or pass's) standard error.
Returns
The remaining lines, joined with "\n".

Definition at line 926 of file pass.cpp.

Here is the caller graph for this function:

Member Data Documentation

◆ env

QProcessEnvironment Pass::env
private

The environment the store's processes run in: the system environment plus what updateEnv() sets (PASSWORD_STORE_ variables, GNUPGHOME, PATH additions, WSLENV). Read through storeEnvironment().

Definition at line 87 of file pass.h.

◆ exec

Executor Pass::exec
protected

Internal command executor for queuing and running subprocesses.

Definition at line 149 of file pass.h.

◆ kBlockingPullMs

int Pass::kBlockingPullMs = 30000
staticconstexpr

How long the pull before an edit may block the window.

Definition at line 216 of file pass.h.

◆ kMaxPlaintextBytes

qint64 Pass::kMaxPlaintextBytes = 64LL * 1024 * 1024
staticconstexpr

Most bytes of plaintext a gpg decryption may produce.

An OpenPGP message is compressed, so a small entry in a shared store can decompress to gigabytes; gpg stops at this many (–max-output) instead of filling QtPass's memory. Far above any real entry.

Definition at line 511 of file pass.h.

◆ m_expectedList

std::optional<ExpectedList> Pass::m_expectedList
private

Set during initIfUnchanged().

Definition at line 1128 of file pass.h.

◆ m_expectedListRefused

bool Pass::m_expectedListRefused = false
private

Set when refuseChangedList() or refuseBusyForExpectedList() refused during initIfUnchanged().

Definition at line 1131 of file pass.h.

◆ m_insertedEntries

QQueue<QString> Pass::m_insertedEntries
private

The entries of the inserts counted in m_insertsPending, in queue order.

Definition at line 1137 of file pass.h.

◆ m_insertsPending

int Pass::m_insertsPending = 0
private

Inserts that have started queueing but not yet reported; see queueInsert.

Definition at line 1135 of file pass.h.

◆ m_pendingShows

QQueue<QString> Pass::m_pendingShows
private

Files of the Show() calls still in flight, oldest first.

Definition at line 1133 of file pass.h.

◆ m_pushIsAutomatic

bool Pass::m_pushIsAutomatic = false
private

Set while GitPushAutomatic() runs GitPush().

Definition at line 1112 of file pass.h.

◆ m_reportedInsert

QString Pass::m_reportedInsert
private

The entry of the insert whose report is going out; see reportedInsert().

Definition at line 1139 of file pass.h.

◆ m_settings

AppSettings Pass::m_settings
protected

Application settings snapshot injected at init() time.

Populated by init(AppSettings) and valid for the lifetime of this backend instance. Subclasses read it in place of calling QtPassSettings directly.

Definition at line 145 of file pass.h.

◆ wrapperRunning

bool Pass::wrapperRunning {false}
private

Unused; kept from the time Pass tracked the running wrapper.

Definition at line 81 of file pass.h.


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