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>>;
171 static auto passUmask(
const QString &value) -> int;
196 const QStringList &searchPaths) -> QString;
213 static auto expandTilde(
const QString &path) -> QString;
228 static auto joinPath(
const QString &dir,
const QString &name) -> QString;
261 static auto endsWithGpg() ->
const QRegularExpression &;
303 static auto linkifyUrls(
const QString &text,
bool *linked =
nullptr)
319 [[nodiscard]]
static auto boundSpaceRuns(
const QString &text) -> QString;
338 [[nodiscard]]
static auto shownName(
const QString &name,
352 [[nodiscard]]
static auto plainToolTip(
const QString &text) -> QString;
404 [[nodiscard]]
static auto displayable(
const QString &text,
405 bool lineBreaks =
true) -> QString;
455 const QStringList &nameFilters,
456 QStringList *skipped =
nullptr,
457 bool hiddenFiles =
false,
458 QStringList *unlisted =
nullptr) -> QStringList;
503 static auto isUnderLink(
const QString &path,
const QString &storeRoot,
504 bool includeSelf =
true) -> bool;
516 static auto removeTree(
const QString &dir) -> bool;
534 static auto replaceFile(
const QString &from,
const QString &to,
bool replace)
572 -> std::optional<QByteArray>;
599 -> std::optional<QByteArray>;
613 -> std::optional<QByteArray>;
620 using Filler = std::function<QString(QFileDevice &)>;
648 const Filler &fill, QString *error =
nullptr)
660 bool replace, QString *error =
nullptr)
676 bool replace, QString *error =
nullptr) -> bool;
686 static auto syncToDisk(QFileDevice &file) -> bool;
697 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 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 hasLongUnbrokenRun(QStringView text) -> bool
Whether text holds more than kMaxUnbrokenRun characters in a row without white space Qt wraps at (a n...
static auto isAbsoluteFsPath(const QString &path) -> bool
Whether path is absolute to the file system: as QDir::isAbsolutePath(), except that a name starting w...
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 auto withoutOtherBlockBreaks(QString text) -> QString
text with every block break other than a line feed (isOtherBlockBreak()) shown as a space,...
static constexpr qsizetype kMaxShownName
Longest name shownName() leaves whole.
static auto hasUnreadableName(const QString &dir) -> bool
Whether dir holds an entry whose name is not valid UTF-8.
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 boundSpaceRuns(const QString &text) -> QString
text with every run of white space other than tabs and line feeds cut to kMaxSpaceRun characters,...
static auto writeFileReplacing(const QString &path, const QByteArray &bytes, bool replace, QString *error=nullptr) -> bool
Write bytes as the file path through stageFileReplacing().
static auto regularFilesUnder(const QString &dir, const QStringList &nameFilters, QStringList *skipped=nullptr, bool hiddenFiles=false, QStringList *unlisted=nullptr) -> QStringList
Regular files under dir whose name matches one of nameFilters, found by walking only real directories...
static QProcessEnvironment _env
static void requireExplicitBareRepository(QProcessEnvironment &env)
Make git in env refuse a folder that is merely laid out as a bare repository (safe....
static void setBeforePlacingForTests(std::function< void(const QString &)> hook)
For tests: called by stageFileReplacing() with the temporary's path after it is filled and before it ...
static auto isLaunchableWebUrl(const QString &value) -> bool
Check whether a value is a safe, launchable web URL.
static constexpr qsizetype kMaxUnbrokenRun
Longest run without white space hasLongUnbrokenRun() allows.
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 displayable(const QString &text, bool lineBreaks=true) -> QString
text with the characters that change how the text around them reads replaced by U+FFFD,...
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 readRegularFileUnder(const QString &root, const QString &path, qint64 maxBytes) -> std::optional< QByteArray >
readRegularFile() for a file under root, with no link followed anywhere on the way down from it.
static auto joinPath(const QString &dir, const QString &name) -> QString
name in dir, as the file system means it.
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 ...
static auto isOtherBlockBreak(QChar c) -> bool
Whether Qt's text document starts a new block at c, besides at a line feed: a carriage return,...
static auto plainToolTip(const QString &text) -> QString
text as a tooltip that shows it as written.
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 constexpr qsizetype kMaxSpaceRun
Longest run of white space boundSpaceRuns() leaves.
static auto shownName(const QString &name, qsizetype max=kMaxShownName) -> QString
A name or path from the store, as a label or list shows it: one line, at most max characters.
static auto readRegularFileInStore(const QString &store, const QString &path, qint64 maxBytes) -> std::optional< QByteArray >
readRegularFileUnder() for a file of the store at store, spelled under the store as configured or und...
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.