19#include <QProcessEnvironment>
75class Pass :
public QObject {
85 QProcessEnvironment
env;
109 -> QProcessEnvironment;
151 ~Pass()
override =
default;
176 virtual void Show(QString file) = 0;
183 virtual void Insert(QString file, QString value,
bool force) = 0;
200 virtual void Remove(QString file,
bool isDir) = 0;
207 virtual void Move(
const QString srcDir,
const QString dest,
208 const bool force) = 0;
215 virtual void Copy(
const QString srcDir,
const QString dest,
216 const bool force) = 0;
222 virtual void Init(QString path,
const QList<UserInfo> &users) = 0;
233 virtual void Grep(QString pattern,
bool caseInsensitive) = 0;
256 auto listKeys(QStringList keystrings,
bool secret =
false) -> QList<UserInfo>;
263 auto listKeys(
const QString &keystring =
"",
bool secret =
false)
299 static auto getGpgIdPath(
const QString &for_file,
const QString &passStore)
324 static auto skippedGpgId(
const QString &forFile,
const QString &passStore,
325 QString *recordError =
nullptr)
326 -> std::optional<QString>;
334 const QString &passStore) -> QStringList;
396 const QString &sourceName) -> QStringList;
403 static auto loggableArgs(
const QStringList &args) -> QStringList;
416 static auto seedGpgIdFile(
const QString &newDir,
const QString &passStore)
437 const QString &except = QString()) -> bool;
452 QByteArray *contents, QString *why)
const -> bool;
461 [[nodiscard]]
virtual auto insertWritten(
const QString &err)
const ->
bool {
546 QString *relative =
nullptr) -> bool;
560 virtual auto storeGit(
const QStringList &args, QString *out) ->
bool {
622 bool readStdout =
true,
bool readStderr =
true);
643 void setEnvVar(
const QString &name,
const QString &value);
655 QString input,
bool readStdout,
bool readStderr);
674 virtual void finished(
int id,
int exitCode,
const QString &out,
771 void critical(
const QString &title,
const QString &message);
AppSettings, the value object holding every flat QtPass setting.
Runs non-interactive external commands in FIFO order using a single QProcess.
auto isIdle() const -> bool
Whether no command is running and nothing is queued.
The detached signature on a store's .gpg-id: whether the configured signing key is usable,...
auto storeEnvironment() const -> QProcessEnvironment
The environment QtPass runs the store's processes in.
void startingExecuteWrapper()
Emitted each time a queued process is about to start, and by the refusals that go on to emit processE...
bool wrapperRunning
Unused; kept from the time Pass tracked the running wrapper.
virtual void beforeExecute(PROCESS id)
Hook invoked just before a wrapped command is dispatched.
void GenerateGPGKeys(QString batch)
Generate GPG keys using batch script.
static QString getDefaultKeyTemplate(const QString &gpgExecutable={})
Get default key template for new GPG keys.
void finishedAnyWithPid(const QString &out, const QString &err, Enums::PROCESS pid)
A process of any kind finished successfully and its output cannot contain a secret.
void finishedInsert(const QString &out, const QString &err)
An Insert() succeeded: the entry is in the store and, with Git in use, committed.
AppSettings m_settings
Application settings snapshot injected at init() time.
static auto getGpgIdPath(const QString &for_file, const QString &passStore) -> QString
Get .gpg-id file path for a password file.
void handleProcessError(PROCESS pid, int exitCode, const QString &out, const QString &err)
Report a process that exited non-zero; called by finished().
virtual void GitInit()=0
Initialize Git repository in password store.
auto refusePendingPull() -> bool
Refuse a store change while a Git pull is still queued or running.
void finishedGenerateGPGKeys(const QString &out, const QString &err)
GenerateGPGKeys() succeeded; the new key pair is in the keyring.
virtual void Copy(const QString srcDir, const QString dest, const bool force)=0
Copy password file or directory.
Enums::PROCESS PROCESS
Alias for Enums::PROCESS used throughout this class.
virtual void GitPull()=0
Pull changes from remote Git repository.
virtual auto generatePassword(unsigned int length, const QString &charset) -> QString
Generate random password.
void queueShow(const QString &file)
Remember what a Show() asked for, so its completion can say so.
virtual void Move(const QString srcDir, const QString dest, const bool force)=0
Move password file or directory.
void finishedShow(const QString &out, const QString &file)
Emitted when a Show() succeeds.
void statusMsg(const QString &msg, int timeout)
Progress or a non-fatal problem worth a line in the status bar ("Creating backup commit",...
QProcessEnvironment env
The environment the store's processes run in: the system environment plus what updateEnv() sets (PASS...
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 (skippedGpg...
virtual void Grep(QString pattern, bool caseInsensitive)=0
Search password content for a pattern.
auto unfinishedGitOperationReason() -> QString
The unfinished git operation in progress in the store, if any.
PathSpelling
How a path handed to refuseLinkedPath() is spelled.
@ Configured
As the store is configured or relative to it, the class's path rule. A path spelled through the targe...
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...
auto boundedRandom(quint32 bound) -> quint32
Generate random number in range.
void insertFailed(const QString &err, bool written)
Emitted when an Insert() fails through a queued command, before the generic processErrorExit(): the p...
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.
static bool gpgSupportsEd25519(const QString &gpgExecutable={})
Check if GPG supports Ed25519 encryption.
void refuseAsNotPartOfStore(const QString &why)
Refuse an operation on something that is not part of the store.
static auto maxOutputArgs() -> QStringList
The gpg options that enforce kMaxPlaintextBytes.
static auto seedGpgIdFile(const QString &newDir, const QString &passStore) -> bool
Seed a new folder's .gpg-id from the recipients it inherits.
virtual void Remove(QString file, bool isDir)=0
Remove password file or directory.
virtual auto storeGit(const QStringList &args, QString *out) -> bool
Run a git command in the store's repository, blocking.
Pass()
Construct a Pass instance.
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....
void finishedCopy(const QString &out, const QString &err)
A Copy() succeeded; the copy exists beside the original.
virtual void Show(QString file)=0
Show decrypted password file.
void finishedMove(const QString &out, const QString &err)
A Move() succeeded; the entry or folder is under its new name.
auto isIdle() const -> bool
Whether no gpg, git or pass of this backend runs or waits.
void executeWrapper(PROCESS id, const QString &app, const QStringList &args, bool readStdout=true, bool readStderr=true)
Execute external wrapper command.
static auto resolveGpgconfCommand(const QString &gpgPath) -> ResolvedGpgconfCommand
Resolve the gpgconf command to kill agents.
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...
auto listKeys(QStringList keystrings, bool secret=false) -> QList< UserInfo >
List GPG keys matching patterns.
void finishedGrep(const QList< QPair< QString, QStringList > > &results)
The newest Grep() is over; an empty list means no entry matched.
virtual void GitPull_b()=0
Pull with rebase from remote.
void finishedGitPull(const QString &out, const QString &err)
git pull succeeded; entries may have changed on disk.
virtual void GitPush()=0
Push changes to remote Git repository.
void finishedGitPush(const QString &out, const QString &err)
git push succeeded.
auto recipientsForEditing(const QString &dir, const QString &passStore) -> RecipientsForEditing
The recipients a dialog may preselect for editing the list of dir.
virtual void Insert(QString file, QString value, bool force)=0
Insert or update password.
Executor exec
Internal command executor for queuing and running subprocesses.
void processErrorExit(int exitCode, const QString &err)
An operation ended in failure: its process exited non-zero, could not be started or crashed,...
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())...
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.
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-...
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.
auto withCurrentGitPin(QProcessEnvironment base) const -> QProcessEnvironment
base with GIT_DIR and GIT_WORK_TREE as the store is now (Util::gitStoreVariables()),...
void setEnvVar(const QString &name, const QString &value)
Set or remove an environment variable.
static auto loggableArgs(const QStringList &args) -> QStringList
The arguments as they may appear in the debug log: the value of --passphrase and friends,...
void updateEnv()
Update environment for subprocesses.
void finishedInit(const QString &out, const QString &err)
An Init() succeeded: the folder's .gpg-id holds the new recipient list.
void idle()
Nothing of the store's runs or waits any more (isIdle()).
virtual void finished(int id, int exitCode, const QString &out, const QString &err)
Handle process completion.
void critical(const QString &title, const QString &message)
Something went wrong that the user has to be told about in a dialog, such as a refused path or a fail...
void generateGPGKeysFailed(const QString &err)
Emitted when GPG key generation fails, alongside the generic processErrorExit(); lets the keygen dial...
static constexpr qint64 kMaxPlaintextBytes
Most bytes of plaintext a gpg decryption may produce.
int m_insertsPending
Inserts that have started queueing but not yet reported; see queueInsert.
static auto getRecipientList(const QString &for_file, const QString &passStore) -> QStringList
Get list of recipients for a password file.
virtual void Init(QString path, const QList< UserInfo > &users)=0
Initialize new password store.
LinkScope
What refuseLinkedPath() judges.
@ EntryAndParents
The entry itself and every folder above it in the store.
void finishedRemove(const QString &out, const QString &err)
A Remove() succeeded; the entry or folder is gone from the store.
auto refuseUnfinishedGitOperation() -> bool
Refuse to change the store while git is mid-rebase, -merge, -cherry-pick or -revert.
void queueInsert()
Count one insert that has started queueing but not yet reported.
QQueue< QString > m_pendingShows
Files of the Show() calls still in flight, oldest first.
static auto parseRecipients(const QByteArray &contents, const QString &sourceName) -> QStringList
Parse the contents of a .gpg-id: one recipient per line, # starts a comment, unusable lines are logge...
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 generateRandomPassword(const QString &charset, unsigned int length) -> QString
Generate random password from charset.
The Enums namespace: clipboard behaviour and the identifiers of the subprocess kinds QtPass queues.
Executor, the FIFO queue every gpg, git and pass child process of QtPass goes through,...
Rollback detection for signed .gpg-id files: the generation counter and the record of what was last s...
PROCESS
Identifies different subprocess operations used in QtPass.
auto gpgErrorMessage(const QString &err) -> QString
Maps GPG stderr (which may include –status-fd 2 tokens) to a translated user-friendly encryption erro...
PROCESS
Identifies different subprocess operations used in QtPass.
Plain value-object holding all flat QtPass configuration.
What a dialog may do with the list of a folder (recipientsForEditing()).
QStringList recipients
The recipients to preselect; empty when Rejected.
State state
How the list on disk stood up.
QString warning
What the dialog should show, if anything.
State
How the list on disk stood up.
@ Unsigned
No signing key: the list as it is.
Represents a command invocation for gpgconf operations.
QStringList arguments
Full argv list, including any wrapper/prefix args followed by the actual gpgconf operation flags (e....
QString program
Executable to run — may be a bare name resolved via PATH or a wrapper (e.g. wsl.exe) rather than a di...
UserInfo, one GPG key as listed by gpg, with the selection flag the recipient dialogs use.