QtPass 2.0.0
Developer documentation
Loading...
Searching...
No Matches
realpass.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2016 Anne Jan Brouwer
2// SPDX-License-Identifier: GPL-3.0-or-later
8#ifndef SRC_REALPASS_H_
9#define SRC_REALPASS_H_
10
11#include "nativegrep.h"
12#include "pass.h"
13
14class GpgIdSigner;
15#include <QQueue>
16#include <QSet>
17
32class RealPass : public Pass {
38 struct LinkCommit {
39 QString rel;
43 QProcessEnvironment environment;
44 };
45
47 QQueue<LinkCommit> m_linkCommits;
48
56 void finishLinkCommit(const LinkCommit &commit, const QString &out,
57 const QString &err);
58
67 void executePass(PROCESS id, const QStringList &args,
68 QString input = QString(), bool readStdout = true,
69 bool readStderr = true);
79 void passMoveOrCopy(PROCESS id, const QString &subcommand, const QString &src,
80 const QString &dest, bool force);
89 auto passName(const QString &path, bool stripGpg) const -> QString;
90
100 [[nodiscard]] auto insertWritten(const QString &err) const -> bool override;
101
110 auto refuseUnverifiedList(const QString &file) -> bool;
111
118 auto storeGit(const QStringList &args, QString *out) -> bool override;
119
136 auto refuseUnverifiedTree(const QString &dir, bool onlyListsWithin,
137 const QString &except = QString()) -> bool;
138
143 auto listSigner() -> GpgIdSigner;
144
158 auto refuseList(const QString &file, const GpgIdSigner &signer,
159 QSet<QString> &verified, const QString &within = QString(),
160 const QString &except = QString()) -> bool;
161
170 void onDequeuing(int id, bool completes);
171
178 static auto entryFingerprint(const QString &path) -> QByteArray;
179
183 QString target;
184 QByteArray before;
185 };
186
187 QQueue<QString> m_insertQueue;
191 QQueue<InsertRecord> m_insertPending;
194
195public:
199 RealPass();
203 ~RealPass() override;
204
205 // Git operations
209 void GitInit() override;
213 void GitPull() override;
217 void GitPull_b() override;
221 void GitPush() override;
222
223 // Password operations
228 void Show(QString file) override;
235 void Insert(QString file, QString newValue, bool overwrite) override;
247 void Remove(QString file, bool isDir) override;
253 void Init(QString path, const QList<UserInfo> &users) override;
254
255protected:
264 void finished(int id, int exitCode, const QString &out,
265 const QString &err) override;
266
267 // Pass interface
268public:
275 void Move(const QString src, const QString dest, const bool force) override;
282 void Copy(const QString src, const QString dest, const bool force) override;
293 void Grep(QString pattern, bool caseInsensitive) override;
294};
295
296#endif // SRC_REALPASS_H_
The detached signature on a store's .gpg-id: whether the configured signing key is usable,...
Definition gpgidsigner.h:28
Full-text search over a password store without pass grep: every .gpg file is decrypted with gpg on a ...
Definition nativegrep.h:31
Enums::PROCESS PROCESS
Alias for Enums::PROCESS used throughout this class.
Definition pass.h:126
Pass()
Construct a Pass instance.
Definition pass.cpp:61
NativeGrep m_grep
Definition realpass.h:35
void finishLinkCommit(const LinkCommit &commit, const QString &out, const QString &err)
Judge a queued linked-folder removal commit by what is left staged in the store it ran in: pass git e...
Definition realpass.cpp:350
void Remove(QString file, bool isDir) override
Remove an entry or folder with pass rm.
Definition realpass.cpp:255
void Init(QString path, const QList< UserInfo > &users) override
Initialize password store.
Definition realpass.cpp:377
void Copy(const QString src, const QString dest, const bool force) override
Copy password file or directory.
Definition realpass.cpp:430
auto storeGit(const QStringList &args, QString *out) -> bool override
Run a git command in the store through pass git, blocking.
Definition realpass.cpp:178
QQueue< InsertRecord > m_insertPending
Definition realpass.h:191
auto refuseList(const QString &file, const GpgIdSigner &signer, QSet< QString > &verified, const QString &within=QString(), const QString &except=QString()) -> bool
The checks of refuseUnverifiedList() for file's nearest list, once per list.
Definition realpass.cpp:77
void Insert(QString file, QString newValue, bool overwrite) override
Insert new password.
Definition realpass.cpp:190
void Show(QString file) override
Show decrypted password.
Definition realpass.cpp:57
InsertRecord m_insertDone
The insert whose completion is being handled.
Definition realpass.h:193
void GitPull_b() override
Pull with rebase.
Definition realpass.cpp:45
RealPass()
Construct a RealPass instance.
Definition realpass.cpp:36
void onDequeuing(int id, bool completes)
The executor is about to run (or drop) its next item: for an insert, take its entry from m_insertQueu...
Definition realpass.cpp:215
void passMoveOrCopy(PROCESS id, const QString &subcommand, const QString &src, const QString &dest, bool force)
Shared implementation of Move and Copy via pass mv/pass cp.
Definition realpass.cpp:444
auto passName(const QString &path, bool stripGpg) const -> QString
path as pass names it: relative to the store, without the .gpg pass appends itself.
Definition realpass.cpp:434
auto refuseUnverifiedList(const QString &file) -> bool
With signing on, refuse to have pass encrypt file when the signed list it would use is not one QtPass...
Definition realpass.cpp:106
static auto entryFingerprint(const QString &path) -> QByteArray
A SHA-256 of the regular file path (opened without following a link or blocking on a FIFO).
Definition realpass.cpp:243
void GitInit() override
Initialize Git repository in password store.
Definition realpass.cpp:43
void GitPull() override
Pull changes from remote.
Definition realpass.cpp:53
QQueue< LinkCommit > m_linkCommits
Definition realpass.h:47
void Move(const QString src, const QString dest, const bool force) override
Move password file or directory.
Definition realpass.cpp:426
void finished(int id, int exitCode, const QString &out, const QString &err) override
Finish a process; a linked-folder removal commit (GIT_COMMIT, which RealPass uses for nothing else) i...
Definition realpass.cpp:334
void executePass(PROCESS id, const QStringList &args, QString input=QString(), bool readStdout=true, bool readStderr=true)
Execute pass command with arguments.
Definition realpass.cpp:511
void GitPush() override
Push changes to remote.
Definition realpass.cpp:55
auto insertWritten(const QString &err) const -> bool override
Whether the failed pass insert wrote its entry before its git step failed. pass does not say,...
Definition realpass.cpp:225
void Grep(QString pattern, bool caseInsensitive) override
Search all password content by GPG-decrypting each real .gpg file, as ImitatePass does.
Definition realpass.cpp:500
auto refuseUnverifiedTree(const QString &dir, bool onlyListsWithin, const QString &except=QString()) -> bool
For a folder pass is about to re-encrypt in a move or copy: refuse when the signed list of one of its...
Definition realpass.cpp:141
auto listSigner() -> GpgIdSigner
The verifier for signed lists, gpg in the store's environment.
Definition realpass.cpp:66
QQueue< QString > m_insertQueue
The entries of the queued inserts, oldest first.
Definition realpass.h:187
NativeGrep, the content search that decrypts every entry on a worker thread instead of running pass g...
Pass, the abstract password-store backend that RealPass and ImitatePass implement,...
QString target
The entry's file.
Definition realpass.h:183
QByteArray before
Its fingerprint when the insert started.
Definition realpass.h:184