QtPass 2.0.0
Developer documentation
Loading...
Searching...
No Matches
ProfileInit Class Reference

Turn a directory into a password store without going through the Pass backend of the currently active store. More...

#include <profileinit.h>

Static Public Member Functions

static auto gpgEnvironment (const AppSettings &s) -> QProcessEnvironment
 The environment QtPass runs gpg in outside the active store's backend: the system's, with GNUPGHOME set to the configured GPG home when there is one, so lookups and signatures use the keyring that signs.
static auto needsInit (const QString &path) -> bool
 Check if a profile path needs initialization.
static auto initialise (const QString &dir, const QList< UserInfo > &users, const AppSettings &s, bool useGit, QString *note) -> bool
 Write the recipients and, if wanted, put the folder under git.
static auto initGit (const QString &dir, const AppSettings &s, QString *note) -> bool
 Put an existing store under Git: git init, stage the .gpg entries and the .gpg-id files (nothing else that may lie around in the folder) and make a first commit, with blocking processes of their own in dir.
static auto gitIdentityConfigured (const QString &dir, const AppSettings &s) -> bool
 Whether git has a name and e-mail to commit with, i.e. user.name and user.email resolve (globally or in dir).

Static Private Member Functions

static auto writeGpgId (const QString &gpgIdFile, const QList< UserInfo > &users, bool signed_, QString *note, QByteArray *written=nullptr) -> bool
 Write the enabled recipients to gpgIdFile, whole or not at all; with signed_ the list carries the generation and folder header a signed store's lists are checked against (GpgIdGeneration).
static auto signGpgId (const QString &gpgIdFile, const QByteArray &contents, const AppSettings &s, QString *note) -> bool
 Sign the list just written as gpgIdFile, over the bytes contents that were written.
static auto commitGpgId (const QString &dir, const QString &gpgIdFile, const QString &sigFile, const AppSettings &s, QString *note) -> bool
 git init in dir, stage the .gpg-id and its signature, and commit them (signed when pass.signcommits is set), with a QProcess of its own in the store's Git environment.

Detailed Description

Turn a directory into a password store without going through the Pass backend of the currently active store.

The backend is a shared singleton bound to the active store (settings snapshot, PASSWORD_STORE_DIR, one FIFO of asynchronous processes), so a new profile cannot be initialised through it without racing the active store (#1774). Everything here is synchronous and touches only dir.

Definition at line 30 of file profileinit.h.

Member Function Documentation

◆ commitGpgId()

auto ProfileInit::commitGpgId ( const QString & dir,
const QString & gpgIdFile,
const QString & sigFile,
const AppSettings & s,
QString * note ) -> bool
staticprivate

git init in dir, stage the .gpg-id and its signature, and commit them (signed when pass.signcommits is set), with a QProcess of its own in the store's Git environment.

Parameters
dirThe store, absolute.
gpgIdFileThe .gpg-id just written.
sigFileIts .sig, or empty when the store is not signed.
sSettings for the git executable and the GPG home.
noteReceives a translated error naming the failed git command.
Returns
Whether the commit was made.

Definition at line 262 of file profileinit.cpp.

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

◆ gitIdentityConfigured()

auto ProfileInit::gitIdentityConfigured ( const QString & dir,
const AppSettings & s ) -> bool
static

Whether git has a name and e-mail to commit with, i.e. user.name and user.email resolve (globally or in dir).

Parameters
dirDirectory to ask in; a repository's own config counts.
sSettings for the git executable.
Returns
true when a commit would not fail for lack of an identity.

Definition at line 340 of file profileinit.cpp.

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

◆ gpgEnvironment()

auto ProfileInit::gpgEnvironment ( const AppSettings & s) -> QProcessEnvironment
static

The environment QtPass runs gpg in outside the active store's backend: the system's, with GNUPGHOME set to the configured GPG home when there is one, so lookups and signatures use the keyring that signs.

Parameters
sThe settings naming the GPG home.
Returns
The environment for a gpg process.

Definition at line 77 of file profileinit.cpp.

Here is the caller graph for this function:

◆ initGit()

auto ProfileInit::initGit ( const QString & dir,
const AppSettings & s,
QString * note ) -> bool
static

Put an existing store under Git: git init, stage the .gpg entries and the .gpg-id files (nothing else that may lie around in the folder) and make a first commit, with blocking processes of their own in dir.

Parameters
dirThe store.
sSettings for the git executable.
noteReceives a translated error on failure.
Returns
true when the repository exists and the commit is made.

Definition at line 297 of file profileinit.cpp.

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

◆ initialise()

auto ProfileInit::initialise ( const QString & dir,
const QList< UserInfo > & users,
const AppSettings & s,
bool useGit,
QString * note ) -> bool
static

Write the recipients and, if wanted, put the folder under git.

Writes <dir>/.gpg-id with the enabled key ids, signs it when s.passSigningKey is set, and when useGit runs git init, git add and git commit inside dir with blocking processes. Existing *.gpg files are left alone: re-encrypting them needs the backend, i.e. the profile has to be the active store; note says so.

Parameters
dirDirectory to initialise; created if missing.
usersKey list; only entries with enabled == true are written.
sSettings for the gpg/git executables and the signing key.
useGitWhether to create a repository and commit the file.
noteReceives a translated message for the user (empty on a quiet success): the error, or the warning about existing entries.
Returns
true when the .gpg-id (and signature/commit if requested) is in place.

Definition at line 92 of file profileinit.cpp.

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

◆ needsInit()

auto ProfileInit::needsInit ( const QString & path) -> bool
static

Check if a profile path needs initialization.

Parameters
pathThe profile path to check.
Returns
true if the path exists but has no .gpg-id file.

Definition at line 81 of file profileinit.cpp.

Here is the caller graph for this function:

◆ signGpgId()

auto ProfileInit::signGpgId ( const QString & gpgIdFile,
const QByteArray & contents,
const AppSettings & s,
QString * note ) -> bool
staticprivate

Sign the list just written as gpgIdFile, over the bytes contents that were written.

Parameters
gpgIdFileThe .gpg-id; <gpgIdFile>.sig is written.
contentsThe bytes written as that file.
sThe settings naming gpg and the signing key.
noteReceives the reason on failure.
Returns
Whether the signature is in place.

Definition at line 225 of file profileinit.cpp.

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

◆ writeGpgId()

auto ProfileInit::writeGpgId ( const QString & gpgIdFile,
const QList< UserInfo > & users,
bool signed_,
QString * note,
QByteArray * written = nullptr ) -> bool
staticprivate

Write the enabled recipients to gpgIdFile, whole or not at all; with signed_ the list carries the generation and folder header a signed store's lists are checked against (GpgIdGeneration).

Parameters
gpgIdFileThe .gpg-id to write.
usersThe recipients; the enabled ones are written.
signed_Whether the store gets a signing key, i.e. the header.
noteReceives the reason on failure.
writtenReceives the exact bytes written, if not null.
Returns
Whether the file was written.

Definition at line 168 of file profileinit.cpp.

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

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