13#include <QProcessEnvironment>
14#include <QRegularExpression>
66 static auto gitCeiling(
const QString &store) -> QString;
113 std::optional<uint> asUser = std::nullopt)
114 -> QList<std::pair<QString, QString>>;
143 static auto passUmask(
const QString &value) -> int;
168 const QStringList &searchPaths) -> QString;
185 static auto expandTilde(
const QString &path) -> QString;
210 static auto endsWithGpg() ->
const QRegularExpression &;
250 static auto linkifyUrls(
const QString &text,
bool *linked =
nullptr)
297 const QStringList &nameFilters,
298 QStringList *skipped =
nullptr,
299 bool hiddenFiles =
false) -> QStringList;
333 static auto isUnderLink(
const QString &path,
const QString &storeRoot,
334 bool includeSelf =
true) -> bool;
346 static auto removeTree(
const QString &dir) -> bool;
364 static auto replaceFile(
const QString &from,
const QString &to,
bool replace)
398 -> std::optional<QByteArray>;
405 using Filler = std::function<QString(QFileDevice &)>;
430 const Filler &fill, QString *error =
nullptr)
442 bool replace, QString *error =
nullptr)
458 bool replace, QString *error =
nullptr) -> bool;
468 static auto syncToDisk(QFileDevice &file) -> bool;
479 static QProcessEnvironment
_env;
AppSettings, the value object holding every flat QtPass setting.
Static helpers that have no better home: setting up the process and the Git environment the way pass ...
static auto regularFilesUnder(const QString &dir, const QStringList &nameFilters, QStringList *skipped=nullptr, bool hiddenFiles=false) -> QStringList
Regular files under dir whose name matches one of nameFilters, found by walking only real directories...
static auto passUmask(const QString &value) -> int
The umask pass would use for value of PASSWORD_STORE_UMASK.
static auto protocolRegex() -> const QRegularExpression &
Returns a regex to match URL protocols.
static auto repositoryPassClimbsTo(const QString &store) -> QString
The repository above store that pass itself would commit to, if any.
static auto removeTree(const QString &dir) -> bool
Remove dir and everything in it, the way rm -rf does: a symbolic link or NTFS junction,...
static auto endsWithGpg() -> const QRegularExpression &
Returns a regex to match .gpg file extensions.
static auto isUnderLink(const QString &path, const QString &storeRoot, bool includeSelf=true) -> bool
Whether the way from storeRoot down to path passes through a symbolic link or NTFS junction: path its...
static void setGitOwnerForTests(std::optional< uint > user)
For tests: the user gitStoreVariables() compares owners with when no asUser is given,...
static auto findPasswordStore() -> QString
Locate the password store directory.
static auto configIsValid(const AppSettings &s) -> bool
Verify that the required configuration is complete.
static auto writeFileReplacing(const QString &path, const QByteArray &bytes, bool replace, QString *error=nullptr) -> bool
Write bytes as the file path through stageFileReplacing().
static QProcessEnvironment _env
static auto isLaunchableWebUrl(const QString &value) -> bool
Check whether a value is a safe, launchable web URL.
static constexpr qint64 kMaxGpgIdBytes
Most bytes of a .gpg-id QtPass reads.
static auto readRegularFile(const QString &path, qint64 maxBytes) -> std::optional< QByteArray >
Read path whole, as the regular file it is (openRegularFile()), when it holds at most maxBytes.
static auto gitStoreVariables(const QString &store, const QString &git={}, std::optional< uint > asUser=std::nullopt) -> QList< std::pair< QString, QString > >
The variables that keep git in store's own repository, never one above it: GIT_CEILING_DIRECTORIES (g...
static auto syncToDisk(QFileDevice &file) -> bool
Flush file's bytes to the device (fsync, FlushFileBuffers) before it is renamed into place,...
static auto mkpathForStore(const QString &path) -> bool
Create path and any missing parents as pass would.
static auto expandTilde(const QString &path) -> QString
Expand a leading current-user tilde in a path.
static auto isLinkedFolder(const QString &path) -> bool
Whether path names a symbolic link or NTFS junction, with or without a trailing separator (which woul...
static auto replaceFile(const QString &from, const QString &to, bool replace) -> bool
Give the file at from the name to, atomically and without following anything: the operating system's ...
static void applyPassProcessDefaults()
Set up the process the way pass sets up its own, before anything runs git or gpg or writes into the s...
static auto isValidKeyId(const QString &keyId) -> bool
Check whether a .gpg-id token may be passed to gpg as a key selector. Accepts any non-empty token tha...
static auto copyFileReplacing(const QString &src, const QString &dst, bool replace, QString *error=nullptr) -> bool
Copy the regular file src to the name dst through stageFileReplacing(): src is read through a handle ...
std::function< QString(QFileDevice &)> Filler
Fills the temporary of stageFileReplacing() through its open handle; returns why it could not (transl...
static auto newLinesRegex() -> const QRegularExpression &
Returns a regex to match newline characters.
static auto openRegularFile(const QString &path, QFile &file) -> bool
Open path for reading as the regular file it is, not as what a link under that name points to: the ob...
static auto normalizeFolderPath(const QString &path) -> QString
Ensure a folder path always ends with '/'.
static auto linkifyUrls(const QString &text, bool *linked=nullptr) -> QString
Turn plain text into HTML with clickable links for safe web URLs.
static auto stageFileReplacing(const QString &path, bool replace, const Filler &fill, QString *error=nullptr) -> bool
The staged write every file QtPass puts into a store goes through: a temporary created next to path (...
static void initialiseEnvironment()
Fill _env once: the process environment with the usual GPG install directories appended to PATH (MacG...
static auto directoriesUnder(const QString &dir) -> QStringList
Every real, visible directory under dir, walked by the same rules as regularFilesUnder(): links,...
static bool _envInitialised
Whether initialiseEnvironment() has run.
static auto findBinaryInPath(const QString &binary) -> QString
Locate an executable by searching the process PATH and (on Windows) falling back to WSL.
static auto gitCeiling(const QString &store) -> QString
GIT_CEILING_DIRECTORIES for a store, as pass sets it.
Plain value-object holding all flat QtPass configuration.
constexpr int MS_PER_SECOND
Milliseconds in a second, for timers set from a setting in seconds.