QtPass 1.6.0
Multi-platform GUI for pass, the standard unix password manager.
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:

Signals

void error (QProcess::ProcessError)
 Emitted when a process error occurs.
void startingExecuteWrapper ()
 Emitted before executing a command.
void statusMsg (const QString &, int)
 Emit status message.
void critical (const QString &, const QString &)
 Emit critical error.
void processErrorExit (int exitCode, const QString &err)
 Emitted on process error exit.
void finishedAny (const QString &, const QString &)
 Emitted when any operation finishes.
void finishedGitInit (const QString &, const QString &)
 Emitted when Git init finishes.
void finishedGitPull (const QString &, const QString &)
 Emitted when Git pull finishes.
void finishedGitPush (const QString &, const QString &)
 Emitted when Git push finishes.
void finishedShow (const QString &)
 Emitted when show finishes.
void finishedOtpGenerate (const QString &)
 Emitted when OTP generation finishes.
void finishedInsert (const QString &, const QString &)
 Emitted when insert finishes.
void finishedRemove (const QString &, const QString &)
 Emitted when remove finishes.
void finishedInit (const QString &, const QString &)
 Emitted when init finishes.
void finishedMove (const QString &, const QString &)
 Emitted when move finishes.
void finishedCopy (const QString &, const QString &)
 Emitted when copy finishes.
void finishedGenerate (const QString &, const QString &)
 Emitted when generate finishes.
void finishedGenerateGPGKeys (const QString &, const QString &)
 Emitted when GPG key generation finishes.

Public Member Functions

 Pass ()
 Construct a Pass instance.
void init ()
 Initialize the Pass instance.
 ~Pass () override=default
virtual void GitInit ()=0
 Initialize Git repository in password store.
virtual void GitPull ()=0
 Pull changes from remote Git repository.
virtual void GitPull_b ()=0
 Pull with rebase from remote.
virtual void GitPush ()=0
 Push changes to remote Git repository.
virtual void Show (QString file)=0
 Show decrypted password file.
virtual void OtpGenerate (QString file)=0
 Generate OTP for password file.
virtual void Insert (QString file, QString value, bool force)=0
 Insert or update password.
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=false)=0
 Move password file or directory.
virtual void Copy (const QString srcDir, const QString dest, const bool force=false)=0
 Copy password file or directory.
virtual void Init (QString path, const QList< UserInfo > &users)=0
 Initialize new password store.
virtual auto generatePassword (unsigned int length, const QString &charset) -> QString
 Generate random password.
void GenerateGPGKeys (QString batch)
 Generate GPG keys using batch script.
auto listKeys (QStringList keystrings, bool secret=false) -> QList< UserInfo >
 List GPG keys matching patterns.
auto listKeys (const QString &keystring="", bool secret=false) -> QList< UserInfo >
 List GPG keys.
void updateEnv ()
 Update environment for subprocesses.

Static Public Member Functions

static bool gpgSupportsEd25519 ()
 Check if GPG supports Ed25519 encryption.
static QString getDefaultKeyTemplate ()
 Get default key template for new GPG keys.
static auto resolveGpgconfCommand (const QString &gpgPath) -> ResolvedGpgconfCommand
 Resolve the gpgconf command to kill agents.
static auto getGpgIdPath (const QString &for_file) -> QString
 Get .gpg-id file path for a password file.
static auto getRecipientList (const QString &for_file) -> QStringList
 Get list of recipients for a password file.
static auto getRecipientString (const QString &for_file, const QString &separator=" ", int *count=nullptr) -> QStringList
 Get recipients as string.

Protected Types

using PROCESS = Enums::PROCESS

Protected Slots

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

Protected Member Functions

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.
virtual void executeWrapper (PROCESS id, const QString &app, const QStringList &args, QString input, bool readStdout=true, bool readStderr=true)
 Execute wrapper with input.

Protected Attributes

Executor exec

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.

Examples
/home/annejan/Projects/QtPass/src/qtpasssettings.cpp.

Definition at line 35 of file pass.h.

Member Typedef Documentation

◆ PROCESS

Constructor & Destructor Documentation

◆ Pass()

Pass::Pass ( )

Construct a Pass instance.

Pass::Pass wrapper for using either pass or the pass imitation.

Examples
/home/annejan/Projects/QtPass/src/pass.cpp.

Definition at line 34 of file pass.cpp.

Here is the call graph for this function:

◆ ~Pass()

Pass::~Pass ( )
overridedefault

Member Function Documentation

◆ boundedRandom()

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

Generate random number in range.

Generates a random number bounded by the given value.

Parameters
boundUpper bound (exclusive).
Returns
Random number.
Parameters
boundUpper bound (exclusive)
Returns
Random number in range [0, bound)
Examples
/home/annejan/Projects/QtPass/src/pass.cpp.

Definition at line 591 of file pass.cpp.

Here is the caller graph for this function:

◆ Copy()

virtual void Pass::Copy ( const QString srcDir,
const QString dest,
const bool force = false )
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 & ,
const QString &  )
signal

Emit critical error.

Parameters
titleError title.
messageError message.
Examples
/home/annejan/Projects/QtPass/src/imitatepass.cpp.
Here is the caller graph for this function:

◆ error

void Pass::error ( QProcess::ProcessError )
signal

Emitted when a process error occurs.

◆ 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.

Executes a wrapper command.

Parameters
idProcess identifier.
appExecutable path.
argsCommand arguments.
readStdoutCapture stdout.
readStderrCapture stderr.
idProcess ID
appApplication to execute
argsArguments
readStdoutWhether to read stdout
readStderrWhether to read stderr
Examples
/home/annejan/Projects/QtPass/src/imitatepass.cpp, and /home/annejan/Projects/QtPass/src/pass.cpp.

Definition at line 57 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 = true,
bool readStderr = true )
protectedvirtual

Execute wrapper with input.

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

Reimplemented in ImitatePass.

Definition at line 63 of file pass.cpp.

Here is the call graph for this function:

◆ finished

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

Handle process completion.

Pass::processFinished reemits specific signal based on what process has finished.

Parameters
idProcess identifier.
exitCodeProcess exit code.
outStandard output.
errStandard error.
idid of Pass process that was scheduled and finished
exitCodereturn code of a process
outoutput generated by process(if capturing was requested, empty otherwise)
errerror output generated by process(if capturing was requested, or error occurred)

Reimplemented in ImitatePass.

Examples
/home/annejan/Projects/QtPass/src/imitatepass.cpp, and /home/annejan/Projects/QtPass/src/pass.cpp.

Definition at line 429 of file pass.cpp.

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

◆ finishedAny

void Pass::finishedAny ( const QString & ,
const QString &  )
signal

Emitted when any operation finishes.

◆ finishedCopy

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

Emitted when copy finishes.

Examples
/home/annejan/Projects/QtPass/src/pass.cpp.
Here is the caller graph for this function:

◆ finishedGenerate

void Pass::finishedGenerate ( const QString & ,
const QString &  )
signal

Emitted when generate finishes.

◆ finishedGenerateGPGKeys

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

Emitted when GPG key generation finishes.

Examples
/home/annejan/Projects/QtPass/src/pass.cpp.
Here is the caller graph for this function:

◆ finishedGitInit

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

Emitted when Git init finishes.

Examples
/home/annejan/Projects/QtPass/src/pass.cpp.
Here is the caller graph for this function:

◆ finishedGitPull

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

Emitted when Git pull finishes.

Examples
/home/annejan/Projects/QtPass/src/pass.cpp.
Here is the caller graph for this function:

◆ finishedGitPush

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

Emitted when Git push finishes.

Examples
/home/annejan/Projects/QtPass/src/pass.cpp.
Here is the caller graph for this function:

◆ finishedInit

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

Emitted when init finishes.

Examples
/home/annejan/Projects/QtPass/src/pass.cpp.
Here is the caller graph for this function:

◆ finishedInsert

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

Emitted when insert finishes.

Examples
/home/annejan/Projects/QtPass/src/pass.cpp.
Here is the caller graph for this function:

◆ finishedMove

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

Emitted when move finishes.

Examples
/home/annejan/Projects/QtPass/src/pass.cpp.
Here is the caller graph for this function:

◆ finishedOtpGenerate

void Pass::finishedOtpGenerate ( const QString & )
signal

Emitted when OTP generation finishes.

Examples
/home/annejan/Projects/QtPass/src/pass.cpp.
Here is the caller graph for this function:

◆ finishedRemove

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

Emitted when remove finishes.

Examples
/home/annejan/Projects/QtPass/src/pass.cpp.
Here is the caller graph for this function:

◆ finishedShow

void Pass::finishedShow ( const QString & )
signal

Emitted when show finishes.

Examples
/home/annejan/Projects/QtPass/src/mainwindow.cpp, and /home/annejan/Projects/QtPass/src/pass.cpp.
Here is the caller graph for this function:

◆ GenerateGPGKeys()

void Pass::GenerateGPGKeys ( QString batch)

Generate GPG keys using batch script.

Pass::GenerateGPGKeys internal gpg keypair generator . .

Parameters
batchGPG batch script content.
batchGnuPG style configuration string
Examples
/home/annejan/Projects/QtPass/src/pass.cpp.

Definition at line 369 of file pass.cpp.

Here is the call graph for this function:

◆ generatePassword()

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

Generate random password.

Pass::Generate use either pwgen or internal password generator.

Parameters
lengthPassword length.
charsetCharacter set to use.
Returns
Generated password.
Parameters
lengthof the desired password
charsetto use for generation
Returns
the password
Examples
/home/annejan/Projects/QtPass/src/pass.cpp.

Definition at line 100 of file pass.cpp.

Here is the call graph for this function:

◆ generateRandomPassword()

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

Generate random password from charset.

Generates a random password from the given charset.

Parameters
charsetCharacter set.
lengthPassword length.
Returns
Generated password.
Parameters
charsetCharacters to use in the password
lengthDesired password length
Returns
Generated password string
Examples
/home/annejan/Projects/QtPass/src/pass.cpp.

Definition at line 617 of file pass.cpp.

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

◆ getDefaultKeyTemplate()

QString Pass::getDefaultKeyTemplate ( )
static

Get default key template for new GPG keys.

Pass::getDefaultKeyTemplate return default key generation template Uses ed25519 if supported, otherwise falls back to RSA.

Returns
Default template string.
GPG batch template string
Examples
/home/annejan/Projects/QtPass/src/pass.cpp.

Definition at line 178 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) -> QString
static

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

Pass::getGpgIdPath return gpgid file path for some file (folder).

Parameters
for_filePath to password file.
Returns
Path to .gpg-id file.
Parameters
for_filewhich file (folder) would you like the gpgid file path for.
Returns
path to the gpgid file.
Examples
/home/annejan/Projects/QtPass/src/imitatepass.cpp, and /home/annejan/Projects/QtPass/src/pass.cpp.

Definition at line 520 of file pass.cpp.

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

◆ getRecipientList()

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

Get list of recipients for a password file.

Pass::getRecipientList return list of gpg-id's to encrypt for.

Parameters
for_filePath to password file.
Returns
List of recipient key IDs.
Parameters
for_filewhich file (folder) would you like recipients for
Returns
recipients gpg-id contents
Examples
/home/annejan/Projects/QtPass/src/imitatepass.cpp, and /home/annejan/Projects/QtPass/src/pass.cpp.

Definition at line 550 of file pass.cpp.

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

◆ getRecipientString()

auto Pass::getRecipientString ( const QString & for_file,
const QString & separator = " ",
int * count = nullptr ) -> QStringList
static

Get recipients as string.

Pass::getRecipientString formatted string for use with GPG.

Parameters
for_filePath to password file.
separatorSeparator between recipients.
countPointer to store recipient count.
Returns
List of recipient key IDs.
Parameters
for_filewhich file (folder) would you like recipients for
separatorformating separator eg: " -r "
count
Returns
recipient string
Examples
/home/annejan/Projects/QtPass/src/pass.cpp.

Definition at line 573 of file pass.cpp.

Here is the call 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 ( )
pure virtual

Pull with rebase from remote.

Implemented in ImitatePass, and RealPass.

◆ GitPush()

virtual void Pass::GitPush ( )
pure virtual

Push changes to remote Git repository.

Implemented in ImitatePass, and RealPass.

◆ gpgSupportsEd25519()

bool Pass::gpgSupportsEd25519 ( )
static

Check if GPG supports Ed25519 encryption.

Pass::gpgSupportsEd25519 check if GPG supports ed25519 (ECC) GPG 2.1+ supports ed25519 which is much faster for key generation.

Returns
true if Ed25519 is supported.
true if ed25519 is supported
Examples
/home/annejan/Projects/QtPass/src/pass.cpp.

Definition at line 157 of file pass.cpp.

Here is the call graph for this function:
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.

◆ init()

void Pass::init ( )

Initialize the Pass instance.

Initializes the pass wrapper environment.

Examples
/home/annejan/Projects/QtPass/src/pass.cpp.

Definition at line 76 of file pass.cpp.

Here is the call 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.

◆ listKeys() [1/2]

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

List GPG keys.

Pass::listKeys list users.

Parameters
keystringSearch pattern.
secretInclude secret keys.
Returns
List of matching keys.
Parameters
keystring
secretlist private keys
Returns
QList<UserInfo> users

Definition at line 415 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.

Pass::listKeys list users.

Parameters
keystringsList of search patterns.
secretInclude secret keys.
Returns
List of matching keys.
Parameters
keystrings
secretlist private keys
Returns
QList<UserInfo> users
Examples
/home/annejan/Projects/QtPass/src/pass.cpp.

Definition at line 392 of file pass.cpp.

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

◆ Move()

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

Move password file or directory.

Parameters
srcDirSource path.
destDestination path.
forceOverwrite existing.

Implemented in ImitatePass, and RealPass.

◆ OtpGenerate()

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

Generate OTP for password file.

Parameters
filePath to password file.

Implemented in ImitatePass, and RealPass.

◆ processErrorExit

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

Emitted on process error exit.

Examples
/home/annejan/Projects/QtPass/src/pass.cpp.
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.

◆ 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.
Examples
/home/annejan/Projects/QtPass/src/pass.cpp.

Definition at line 322 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.

◆ startingExecuteWrapper

void Pass::startingExecuteWrapper ( )
signal

Emitted before executing a command.

Examples
/home/annejan/Projects/QtPass/src/pass.cpp.
Here is the caller graph for this function:

◆ statusMsg

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

Emit status message.

Parameters
Messagetext.
Timeoutin ms.
Examples
/home/annejan/Projects/QtPass/src/imitatepass.cpp.
Here is the caller graph for this function:

◆ updateEnv()

void Pass::updateEnv ( )

Update environment for subprocesses.

Pass::updateEnv update the execution environment (used when switching profiles).

Examples
/home/annejan/Projects/QtPass/src/pass.cpp.

Definition at line 482 of file pass.cpp.

Here is the call graph for this function:

Member Data Documentation

◆ exec


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