QtPass 1.6.0
Multi-platform GUI for pass, the standard unix password manager.
Loading...
Searching...
No Matches
imitatepass.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2016 Anne Jan Brouwer
2// SPDX-License-Identifier: GPL-3.0-or-later
3#ifndef SRC_IMITATEPASS_H_
4#define SRC_IMITATEPASS_H_
5
6#include "pass.h"
7#include "simpletransaction.h"
8
23class ImitatePass : public Pass, private simpleTransaction {
24 Q_OBJECT
25
26 friend class tst_util;
27
28protected:
34 auto verifyGpgIdFile(const QString &file) -> bool;
40 auto removeDir(const QString &dirName) -> bool;
46 auto checkSigningKeys(const QStringList &signingKeys) -> bool;
52 void writeGpgIdFile(const QString &gpgIdFile, const QList<UserInfo> &users);
59 auto signGpgIdFile(const QString &gpgIdFile, const QStringList &signingKeys)
60 -> bool;
68 void gitAddGpgId(const QString &gpgIdFile, const QString &gpgIdSigFile,
69 bool addFile, bool addSigFile);
77 auto verifyGpgIdForDir(const QString &file, QStringList &gpgIdFilesVerified,
78 QStringList &gpgId) -> bool;
83 auto createBackupCommit() -> bool;
89 auto getKeysFromFile(const QString &fileName) -> QStringList;
96 auto reencryptSingleFile(const QString &fileName,
97 const QStringList &recipients) -> bool;
105 auto resolveMoveDestination(const QString &src, const QString &dest,
106 bool force) -> QString;
107
108public:
115 void executeMoveGit(const QString &src, const QString &destFile, bool force);
116
122 void gitCommit(const QString &file, const QString &msg);
123
132 void executeGit(PROCESS id, const QStringList &args,
133 QString input = QString(), bool readStdout = true,
134 bool readStderr = true);
143 void executeGpg(PROCESS id, const QStringList &args,
144 QString input = QString(), bool readStdout = true,
145 bool readStderr = true);
146
152 simpleTransaction *m_transaction;
153 PROCESS m_result;
154
155 public:
162 : m_transaction(trans), m_result(result) {
163 m_transaction->transactionStart();
164 }
165
168 ~transactionHelper() { m_transaction->transactionEnd(m_result); }
169 };
170
171protected:
175 void finished(int id, int exitCode, const QString &out,
176 const QString &err) override;
177
181 void executeWrapper(PROCESS id, const QString &app, const QStringList &args,
182 QString input, bool readStdout = true,
183 bool readStderr = true) override;
184
185public:
193 ~ImitatePass() override = default;
194
195 // Git operations
199 void GitInit() override;
203 void GitPull() override;
207 void GitPull_b() override;
211 void GitPush() override;
212
213 // Password operations
217 void Show(QString file) override;
221 void OtpGenerate(QString file) override;
225 void Insert(QString file, QString newValue, bool overwrite = false) override;
229 void Remove(QString file, bool isDir = false) override;
233 void Init(QString path, const QList<UserInfo> &users) override;
234
239 void reencryptPath(const QString &dir);
240
241signals:
250
251 // Pass interface
252public:
256 void Move(const QString src, const QString dest,
257 const bool force = false) override;
261 void Copy(const QString src, const QString dest,
262 const bool force = false) override;
263};
264
265#endif // SRC_IMITATEPASS_H_
~transactionHelper()
End transaction on destruction.
transactionHelper(simpleTransaction *trans, PROCESS result)
Start transaction.
auto createBackupCommit() -> bool
Create git backup commit before re-encryption.
friend class tst_util
Definition imitatepass.h:26
void OtpGenerate(QString file) override
Generate OTP.
void GitInit() override
Initialize Git repository.
void executeGpg(PROCESS id, const QStringList &args, QString input=QString(), bool readStdout=true, bool readStderr=true)
Execute GPG command.
void GitPull_b() override
Pull with rebase.
auto checkSigningKeys(const QStringList &signingKeys) -> bool
Check if signing keys are valid.
ImitatePass()
Construct ImitatePass instance.
auto reencryptSingleFile(const QString &fileName, const QStringList &recipients) -> bool
Re-encrypt single file with new recipients.
auto verifyGpgIdFile(const QString &file) -> bool
Verify .gpg-id file exists and is valid.
void executeGit(PROCESS id, const QStringList &args, QString input=QString(), bool readStdout=true, bool readStderr=true)
Execute git command.
void Init(QString path, const QList< UserInfo > &users) override
Initialize store.
auto verifyGpgIdForDir(const QString &file, QStringList &gpgIdFilesVerified, QStringList &gpgId) -> bool
Verify .gpg-id file for a directory.
void Insert(QString file, QString newValue, bool overwrite=false) override
Insert new password.
auto removeDir(const QString &dirName) -> bool
Remove directory recursively.
void executeMoveGit(const QString &src, const QString &destFile, bool force)
Execute git move operation.
void Move(const QString src, const QString dest, const bool force=false) override
Move password file.
void Copy(const QString src, const QString dest, const bool force=false) override
Copy password file.
void endReencryptPath()
Emitted after finishing re-encryption.
void finished(int id, int exitCode, const QString &out, const QString &err) override
Handle process completion.
void executeWrapper(PROCESS id, const QString &app, const QStringList &args, QString input, bool readStdout=true, bool readStderr=true) override
Execute command wrapper.
auto signGpgIdFile(const QString &gpgIdFile, const QStringList &signingKeys) -> bool
Sign .gpg-id file with signing keys.
void Remove(QString file, bool isDir=false) override
Remove password.
void GitPull() override
Pull from remote.
~ImitatePass() override=default
Destructor.
void Show(QString file) override
Show decrypted password.
auto resolveMoveDestination(const QString &src, const QString &dest, bool force) -> QString
Resolve destination for move operation.
void GitPush() override
Push to remote.
void writeGpgIdFile(const QString &gpgIdFile, const QList< UserInfo > &users)
Write recipients to .gpg-id file.
void gitAddGpgId(const QString &gpgIdFile, const QString &gpgIdSigFile, bool addFile, bool addSigFile)
Add .gpg-id to git staging.
void startReencryptPath()
Emitted before starting re-encryption.
auto getKeysFromFile(const QString &fileName) -> QStringList
Read recipients from file.
void reencryptPath(const QString &dir)
Re-encrypt entire directory.
void gitCommit(const QString &file, const QString &msg)
Commit changes to git.
Enums::PROCESS PROCESS
Definition pass.h:44
Pass()
Construct a Pass instance.
Definition pass.cpp:34
PROCESS
Identifies different subprocess operations used in QtPass.
Definition enums.h:26