12#include <QCoreApplication>
19#include <QRegularExpression>
20#include <QRegularExpressionMatchIterator>
22#include <QStandardPaths>
23#include <QTemporaryFile>
56 _env = QProcessEnvironment::systemEnvironment();
58 QString path =
_env.value(
"PATH");
59 if (!path.contains(
"/usr/local/MacGPG2/bin") &&
60 QDir(
"/usr/local/MacGPG2/bin").exists())
61 path +=
":/usr/local/MacGPG2/bin";
62 if (!path.contains(
"/usr/local/bin"))
63 path +=
":/usr/local/bin";
64 _env.insert(
"PATH", path);
67 QString path =
_env.value(
"PATH");
68 if (!path.contains(
"C:\\Program Files\\WinGPG\\x86") &&
69 QDir(
"C:\\Program Files\\WinGPG\\x86").exists())
70 path +=
";C:\\Program Files\\WinGPG\\x86";
71 if (!path.contains(
"C:\\Program Files\\GnuPG\\bin") &&
72 QDir(
"C:\\Program Files\\GnuPG\\bin").exists())
73 path +=
";C:\\Program Files\\GnuPG\\bin";
74 _env.insert(
"PATH", path);
76 qCDebug(lcQtPass) <<
_env.value(
"PATH");
84 if (
_env.contains(
"PASSWORD_STORE_DIR")) {
88 path = QDir(QDir::homePath()).filePath(
"password-store");
90 path = QDir(QDir::homePath()).filePath(
".password-store");
97 if (path == QLatin1String(
"~")) {
98 return QDir::homePath();
100 if (path.startsWith(QLatin1String(
"~/"))) {
101 return QDir::homePath() + path.mid(1);
107 return QDir::isAbsolutePath(path) && !path.startsWith(QLatin1Char(
':'));
111 if (name.startsWith(QLatin1Char(
':'))) {
112 return dir.endsWith(QLatin1Char(
'/')) ? dir + name
113 : dir + QLatin1Char(
'/') + name;
115 return QDir(dir).filePath(name);
119 QString normalizedPath = path;
120 if (!normalizedPath.endsWith(
'/')) {
121 normalizedPath +=
'/';
123 return normalizedPath;
130 for (
const char *variable :
131 {
"GIT_DIR",
"GIT_WORK_TREE",
"GIT_NAMESPACE",
"GIT_INDEX_FILE",
132 "GIT_INDEX_VERSION",
"GIT_OBJECT_DIRECTORY",
"GIT_COMMON_DIR",
135 "GIT_GLOB_PATHSPECS",
"GIT_NOGLOB_PATHSPECS",
"GIT_ICASE_PATHSPECS"}) {
139 passUmask(qEnvironmentVariable(
"PASSWORD_STORE_UMASK")));
147 static const QRegularExpression octal(
148 QRegularExpression::anchoredPattern(QStringLiteral(
"[0-7]{1,4}")));
149 if (!octal.match(value).hasMatch()) {
152 return value.toInt(
nullptr, 8);
156 if (store.isEmpty()) {
159 QString path = QFileInfo(store).canonicalFilePath();
160 if (path.isEmpty()) {
161 path = QDir::cleanPath(QDir(store).absolutePath());
163 return QFileInfo(path).absolutePath();
178auto openFollowedRegularFile(
const QString &path, QFile &file) ->
bool {
179 const int fd = ::open(QFile::encodeName(path).constData(),
180 O_RDONLY | O_NONBLOCK | O_CLOEXEC);
185 if (::fstat(fd, &info) != 0 || !S_ISREG(info.st_mode) ||
186 !file.open(fd, QIODevice::ReadOnly, QFileDevice::AutoCloseHandle)) {
199auto gitWalkStart(
const QString &store) -> QString {
209 store.startsWith(u
'/') ? store : QDir::currentPath() + u
'/' + store;
210 while (path.size() > 1 && path.endsWith(u
'/')) {
214 while (!QFileInfo::exists(path)) {
215 const qsizetype slash = path.lastIndexOf(u
'/');
219 const QString name = path.mid(slash + 1);
220 rest = rest.isEmpty() ? name : name + u
'/' + rest;
221 path = slash == 0 ? QStringLiteral(
"/") : path.left(slash);
223 const QString real = QFileInfo(path).canonicalFilePath();
224 const QString start = real.isEmpty() ? QDir::cleanPath(path) : real;
225 return rest.isEmpty() ? start : QDir::cleanPath(start + u
'/' + rest);
235auto passCeilingFor(
const QString &store,
const QString &start) -> QString {
242 bool afterEmpty =
false;
243 const QStringList pieces =
244 (store + QStringLiteral(
"/..")).split(QLatin1Char(
':'));
245 for (
const QString &piece : pieces) {
246 if (piece.isEmpty()) {
250 if (!piece.startsWith(u
'/')) {
253 const QString entry =
254 afterEmpty ? piece : QFileInfo(piece).canonicalFilePath();
257 const QString under = entry == u
'/' ? entry : entry + u
'/';
258 if (!entry.isEmpty() && start.startsWith(under) &&
259 entry.size() > ceiling.size()) {
273auto isGitDirectory(
const QString &candidate) ->
bool {
274 const QDir dir(candidate);
275 if (!QFileInfo(dir.filePath(QStringLiteral(
"objects"))).isDir() ||
276 !QFileInfo(dir.filePath(QStringLiteral(
"refs"))).isDir()) {
285 const QString headPath = dir.filePath(QStringLiteral(
"HEAD"));
286 if (
const QFileInfo headInfo(headPath); headInfo.isSymLink()) {
288 return headInfo.readSymLink().startsWith(QLatin1String(
"refs/"));
291 if (!openFollowedRegularFile(headPath, head)) {
294 static const QRegularExpression valid(
295 QStringLiteral(
"^(?:ref: refs/|[0-9a-f]{40}\\s*$|[0-9a-f]{64}\\s*$)"));
296 return valid.match(QString::fromUtf8(head.read(256))).hasMatch();
314auto repositoryAt(
const QString &dir) -> Found {
315 const QString dotGit = QDir(dir).filePath(QStringLiteral(
".git"));
316 const QFileInfo info(dotGit);
318 return isGitDirectory(dotGit) ? Found::Repository : Found::Nothing;
320 if (!info.exists()) {
321 return Found::Nothing;
326 if (!openFollowedRegularFile(dotGit, file)) {
327 return Found::Refused;
329 const QString line = QString::fromUtf8(file.readLine(4096)).trimmed();
330 if (!line.startsWith(QLatin1String(
"gitdir: "))) {
331 return Found::Refused;
333 const QString target = line.mid(8);
334 return isGitDirectory(target.startsWith(u
'/') ? target
335 : QDir(dir).filePath(target))
347 if (!store.contains(QLatin1Char(
':'))) {
350 const QString start = gitWalkStart(store);
351 if (start.isEmpty()) {
354 const QString ceiling = passCeilingFor(store, start);
358 for (QString dir = start;;) {
359 switch (repositoryAt(dir)) {
360 case Found::Repository:
361 return dir == start ? QString() : std::move(dir);
369 if (isGitDirectory(dir)) {
372 const QString up = QFileInfo(dir).absolutePath();
373 if (up == dir || up == ceiling) {
383std::optional<uint> s_gitOwnerForTests;
387 s_gitOwnerForTests = user;
405auto safeDirectoryEntries(
const QString &git) -> std::optional<QString> {
412 QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
413 env.remove(QStringLiteral(
"GIT_DIR"));
414 env.remove(QStringLiteral(
"GIT_WORK_TREE"));
415 env.remove(QStringLiteral(
"GIT_COMMON_DIR"));
419 env.remove(QStringLiteral(
"GIT_CONFIG"));
421 process.setProcessEnvironment(env);
422 process.setWorkingDirectory(QStringLiteral(
"/"));
425 constexpr int kQueryTimeoutMs = 5000;
428 process, git.isEmpty() ? QStringLiteral(
"git") : git,
429 {QStringLiteral(
"config"), QStringLiteral(
"--show-scope"),
430 QStringLiteral(
"--type=path"), QStringLiteral(
"--get-all"),
431 QStringLiteral(
"safe.directory")},
432 QString(), &out,
nullptr,
nullptr, kQueryTimeoutMs) != 0) {
445auto safeDirectoryNames(
const QString &value,
const QString &root) ->
bool {
446 if (!QDir::isAbsolutePath(value)) {
449 if (value.endsWith(QLatin1String(
"/*"))) {
450 const QString base = value.chopped(2);
451 QString prefix = QFileInfo(base.isEmpty() ? QStringLiteral(
"/") : base)
452 .canonicalFilePath();
453 if (prefix.isEmpty()) {
456 if (!prefix.endsWith(QLatin1Char(
'/'))) {
457 prefix += QLatin1Char(
'/');
459 return root.startsWith(prefix);
461 const QString named = QFileInfo(value).canonicalFilePath();
462 return !named.isEmpty() && named == root;
481auto isSafeDirectory(
const QString &root,
const QString &git) ->
bool {
482 const std::optional<QString> out = safeDirectoryEntries(git);
487 const QStringList lines = out->split(QLatin1Char(
'\n'));
488 for (
const QString &line : lines) {
489 const qsizetype tab = line.indexOf(QLatin1Char(
'\t'));
493 const QString scope = line.left(tab);
494 if (scope != QLatin1String(
"system") && scope != QLatin1String(
"global") &&
495 scope != QLatin1String(
"command")) {
498 const QString value = line.mid(tab + 1);
499 if (value.isEmpty()) {
502 safe = safe || value == QLatin1String(
"*") ||
503 safeDirectoryNames(value, root);
512 const QString key = QStringLiteral(
"safe.bareRepository");
513 const QString value = QStringLiteral(
"explicit");
514 const QString countText = env.value(QStringLiteral(
"GIT_CONFIG_COUNT"));
515 bool ok = countText.isEmpty();
516 int count = countText.isEmpty() ? 0 : countText.toInt(&ok);
517 if (!ok || count < 0) {
524 for (
int i = 0; i < count; ++i) {
525 if (env.value(QStringLiteral(
"GIT_CONFIG_KEY_%1").arg(i))
526 .compare(key, Qt::CaseInsensitive) == 0) {
527 last = env.value(QStringLiteral(
"GIT_CONFIG_VALUE_%1").arg(i));
535 const QString parameters = env.value(QStringLiteral(
"GIT_CONFIG_PARAMETERS"));
536 const QString explicitEntry =
537 QStringLiteral(
"'safe.bareRepository=explicit'");
538 if (parameters.contains(QLatin1String(
"barerepository"),
539 Qt::CaseInsensitive) &&
540 parameters != explicitEntry &&
541 !parameters.endsWith(QLatin1Char(
' ') + explicitEntry)) {
542 env.insert(QStringLiteral(
"GIT_CONFIG_PARAMETERS"),
543 parameters + QLatin1Char(
' ') + explicitEntry);
545 if (last.compare(value, Qt::CaseInsensitive) == 0) {
548 env.insert(QStringLiteral(
"GIT_CONFIG_KEY_%1").arg(count), key);
549 env.insert(QStringLiteral(
"GIT_CONFIG_VALUE_%1").arg(count), value);
550 env.insert(QStringLiteral(
"GIT_CONFIG_COUNT"), QString::number(count + 1));
554 std::optional<uint> asUser)
555 -> QList<std::pair<QString, QString>> {
557 if (ceiling.isEmpty()) {
560 QList<std::pair<QString, QString>> vars{
561 {QStringLiteral(
"GIT_CEILING_DIRECTORIES"), ceiling}};
563 const QChar separator = QLatin1Char(
';');
565 const QChar separator = QLatin1Char(
':');
569 if (ceiling.contains(separator)) {
570 QString root = QFileInfo(store).canonicalFilePath();
571 if (root.isEmpty()) {
572 root = QDir::cleanPath(QDir(store).absolutePath());
574 QString gitDir = QDir(root).filePath(QStringLiteral(
".git"));
580 const uint me = asUser.value_or(
581 s_gitOwnerForTests.value_or(
static_cast<uint
>(::geteuid())));
582 const auto ownedOrMissing = [me](
const QString &path) {
583 const QFileInfo info(path);
584 return !info.exists() || info.ownerId() == me;
586 bool owned = ownedOrMissing(root) && ownedOrMissing(gitDir);
587 if (owned && QFileInfo(gitDir).isFile()) {
588 QFile gitFile(gitDir);
589 if (gitFile.open(QIODevice::ReadOnly)) {
591 QString::fromUtf8(gitFile.readLine(4096)).trimmed();
592 if (line.startsWith(QLatin1String(
"gitdir:"))) {
593 const QString target = line.mid(7).trimmed();
594 owned = ownedOrMissing(QDir(root).absoluteFilePath(target));
599 if (!owned && !isSafeDirectory(root, git)) {
600 gitDir = QStringLiteral(
"/dev/null/.git");
609 vars.append({QStringLiteral(
"GIT_DIR"), gitDir});
610 vars.append({QStringLiteral(
"GIT_WORK_TREE"), root});
616 const QString clean = QDir::cleanPath(QDir(path).absolutePath());
617 if (QFileInfo(clean).isDir()) {
620 const QString parent = QFileInfo(clean).absolutePath();
628 QFile::Permissions permissions;
629 const std::array<QFile::Permission, 9> bits = {
630 QFile::ReadOwner, QFile::WriteOwner, QFile::ExeOwner,
631 QFile::ReadGroup, QFile::WriteGroup, QFile::ExeGroup,
632 QFile::ReadOther, QFile::WriteOther, QFile::ExeOther};
633 for (
int i = 0; i < 9; ++i) {
634 if ((umask & (0400 >> i)) == 0) {
635 permissions |= bits[i];
641 const bool made = QDir().mkdir(clean, permissions) &&
642 QFile::setPermissions(clean, permissions);
646 const bool made = QDir().mkdir(clean);
648 return made || QFileInfo(clean).isDir();
652 if (binary.isEmpty()) {
658 const QStringList dirs =
659 _env.value(QStringLiteral(
"PATH"))
660 .split(QDir::listSeparator(), Qt::SkipEmptyParts);
662 if (QDir::fromNativeSeparators(binary).contains(u
'/')) {
666 if (QDir::isAbsolutePath(binary)) {
667 ret = QStandardPaths::findExecutable(binary);
668 }
else if (!dirs.isEmpty()) {
669 ret = QStandardPaths::findExecutable(binary, dirs);
679 static QHash<QString, QString> wslBinaryCache;
680 const bool hasWhitespace =
681 std::any_of(binary.cbegin(), binary.cend(),
682 [](
const QChar ch) { return ch.isSpace(); });
683 if (!hasWhitespace) {
684 auto cached = wslBinaryCache.constFind(binary);
685 if (cached != wslBinaryCache.constEnd()) {
686 ret = cached.value();
688 QString wslCommand = QStringLiteral(
"wsl ") + binary;
690 <<
"Util::findBinaryInPath(): falling back to WSL for binary"
693 QString cachedResult;
696 !out.isEmpty() && err.isEmpty()) {
698 <<
"Util::findBinaryInPath(): using WSL binary" << wslCommand;
699 cachedResult = wslCommand;
701 wslBinaryCache.insert(binary, cachedResult);
715 const QStringList &searchPaths) -> QString {
716 if (binary.isEmpty() || QDir::fromNativeSeparators(binary).contains(u
'/')) {
720 dirs.reserve(searchPaths.size());
721 for (
const QString &dir : searchPaths) {
722 if (!dir.isEmpty()) {
726 if (dirs.isEmpty()) {
730 return QStandardPaths::findExecutable(binary, dirs);
734 const QString configFilePath = QDir(s.passStore).filePath(
".gpg-id");
735 if (!QFile(configFilePath).exists()) {
739 const QString executable = s.usePass ? s.passExecutable : s.gpgExecutable;
744 static const bool wslAvailable = [&wsl]() {
748 {QStringLiteral(
"--version")}, &out,
750 !out.isEmpty() && err.isEmpty();
756 return QFile(executable).exists();
760 static const QRegularExpression expr{R
"(\.gpg$)"};
768 static const QRegularExpression regex{
769 R
"(((?:https?|ftp|ssh|sftp|ftps|webdav|webdavs)://[^"\s<>\)\]\[]+))"};
779auto endsUrlPart(QChar c) ->
bool {
780 return c == QLatin1Char(
'/') || c == QLatin1Char(
'?') ||
781 c == QLatin1Char(
'#');
789auto isAsciiLetter(QChar c) ->
bool {
790 return (c >= QLatin1Char(
'a') && c <= QLatin1Char(
'z')) ||
791 (c >= QLatin1Char(
'A') && c <= QLatin1Char(
'Z'));
800auto afterScheme(
const QString &url) -> qsizetype {
801 qsizetype colon = -1;
802 for (qsizetype i = 0; i < url.size() && !endsUrlPart(url.at(i)); ++i) {
803 if (url.at(i) == QLatin1Char(
':')) {
808 bool scheme = colon > 0 && isAsciiLetter(url.at(0));
809 for (qsizetype i = 1; scheme && i < colon; ++i) {
810 const QChar c = url.at(i);
812 isAsciiLetter(c) || (c >= QLatin1Char(
'0') && c <= QLatin1Char(
'9')) ||
813 c == QLatin1Char(
'+') || c == QLatin1Char(
'-') || c == QLatin1Char(
'.');
815 return scheme ? colon + 1 : 0;
830auto authorityLength(
const QString &url) -> qsizetype {
831 const qsizetype hier = afterScheme(url);
832 if (url.mid(hier, 2) != QLatin1String(
"//")) {
835 qsizetype end = hier + 2;
836 while (end < url.size() && !endsUrlPart(url.at(end))) {
839 return end - (hier + 2);
844 const QString trimmed = value.trimmed();
845 if (trimmed.isEmpty()) {
850 for (
const QChar &c : trimmed) {
851 if (c == QLatin1Char(
'\r') || c == QLatin1Char(
'\n') ||
852 c == QChar(QChar::Null)) {
861 constexpr qsizetype kMaxAuthority = 259;
862 if (authorityLength(trimmed) > kMaxAuthority) {
865 const QUrl url(trimmed, QUrl::StrictMode);
866 if (!url.isValid()) {
869 const QString scheme = url.scheme().toLower();
870 if (scheme != QLatin1String(
"http") && scheme != QLatin1String(
"https")) {
873 if (url.host().isEmpty()) {
877 if (!url.userName().isEmpty() || !url.password().isEmpty()) {
891auto isDeceptiveChar(
char16_t u) ->
bool {
892 return (u < 0x20 && u != u
'\t') || (u >= 0x7f && u <= 0x9f) || u == 0x2028 ||
893 u == 0x2029 || (u >= 0x202a && u <= 0x202e) ||
894 (u >= 0x2066 && u <= 0x2069);
899 QString shown = text;
900 for (qsizetype i = 0; i < shown.size(); ++i) {
901 const char16_t u = shown.at(i).unicode();
905 lineBreaks && (u == u
'\n' || (u == u
'\r' && i + 1 < shown.size() &&
906 shown.at(i + 1) == u
'\n'));
907 if (!lineEnd && isDeceptiveChar(u)) {
908 shown[i] = QChar(QChar::ReplacementCharacter);
915 if (linked !=
nullptr) {
919 html.reserve(text.size());
920 qsizetype lastIndex = 0;
921 QRegularExpressionMatchIterator it =
protocolRegex().globalMatch(text);
922 while (it.hasNext()) {
923 const QRegularExpressionMatch match = it.next();
924 const QString url = match.captured(0);
929 const bool plain = std::all_of(url.cbegin(), url.cend(), [](QChar c) {
930 return c.unicode() > 0x20 && c.unicode() < 0x7f;
937 const qsizetype start = match.capturedStart(0);
938 html += text.mid(lastIndex, start - lastIndex).toHtmlEscaped();
939 const QString escapedUrl = url.toHtmlEscaped();
940 html += QStringLiteral(
"<a href=\"%1\">%1</a>").arg(escapedUrl);
941 lastIndex = match.capturedEnd(0);
942 if (linked !=
nullptr) {
946 html += text.mid(lastIndex).toHtmlEscaped();
951 if (linked !=
nullptr ? *linked : html.contains(QLatin1String(
"<a href="))) {
952 for (QChar &c : html) {
953 const char16_t u = c.unicode();
954 if ((u >= 0x202A && u <= 0x202E) || (u >= 0x2066 && u <= 0x2069)) {
955 c = QChar(QChar::ReplacementCharacter);
963 const char16_t u = c.unicode();
964 return u == u
'\r' || u == 0x2029 || u == 0xFDD0 || u == 0xFDD1;
968 for (QChar &c : text) {
970 c = QLatin1Char(
' ');
978 for (
const QChar c : text) {
981 const char16_t u = c.unicode();
983 c.isSpace() && u != 0x00A0 && u != 0x2007 && u != 0x202F;
984 run = breaks ? 0 : run + 1;
995 return QStringLiteral(
"<p style=\"white-space: pre-wrap;\">") +
997 QStringLiteral(
"</p>");
1002 line.replace(QLatin1Char(
'\t'), QLatin1Char(
' '));
1003 if (line.size() <= max) {
1008 qsizetype keep = std::max<qsizetype>(max, 0);
1009 if (keep > 0 && line.at(keep - 1).isHighSurrogate()) {
1012 return line.left(keep);
1014 qsizetype head = max / 3;
1015 if (line.at(head - 1).isHighSurrogate()) {
1018 qsizetype tail = max - max / 3 - 1;
1019 if (line.at(line.size() - tail).isLowSurrogate()) {
1022 return line.left(head) + QChar(0x2026) + line.right(tail);
1034 for (qsizetype i = 0; i < text.size(); ++i) {
1035 const QChar ch = text.at(i);
1036 if (!ch.isSpace() || ch == QLatin1Char(
'\t') || ch == QLatin1Char(
'\n')) {
1044 bounded += QStringView(text).sliced(from, i - from);
1051 bounded += QStringView(text).sliced(from);
1056 static const QRegularExpression regex{
"[\r\n]"};
1064 return !keyId.isEmpty() && !keyId.startsWith(
'-');
1076auto canList(
const QString &dir) ->
bool {
1079 QNtfsPermissionCheckGuard aclCheck;
1080 return QFileInfo(dir).isReadable();
1082 const QFileInfo info(dir);
1083 return info.isReadable() && info.isExecutable() &&
1095template <
typename Visit>
1096void walkStore(
const QString &dir, Visit visit,
1097 QStringList *unlisted =
nullptr) {
1100 QStringList pending{QDir(QDir::cleanPath(dir)).absolutePath()};
1101 while (!pending.isEmpty()) {
1102 const QDir current(pending.takeLast());
1103 if (unlisted !=
nullptr && current.exists() && !canList(current.path())) {
1104 qCWarning(lcQtPass) <<
"Cannot list" << current.path();
1105 *unlisted << current.path();
1111 const QFileInfoList entries =
1112 current.entryInfoList(QDir::Dirs | QDir::Files | QDir::Hidden |
1113 QDir::System | QDir::NoDotAndDotDot,
1115 QStringList subdirs;
1116 for (
const QFileInfo &entry : entries) {
1118 subdirs << entry.filePath();
1122 for (
auto it = subdirs.crbegin(); it != subdirs.crend(); ++it) {
1129auto isLink(
const QFileInfo &entry) ->
bool {
1130 return entry.isSymLink() || entry.isJunction();
1138auto isHiddenEntry(
const QFileInfo &entry) ->
bool {
1139 return entry.isHidden() || entry.fileName().startsWith(QLatin1Char(
'.'));
1144auto isStoreDirectory(
const QFileInfo &entry) ->
bool {
1145 return !isLink(entry) && entry.isDir() && !isHiddenEntry(entry);
1150 QStringList *skipped,
bool hiddenFiles,
1151 QStringList *unlisted) -> QStringList {
1155 [&](
const QFileInfo &entry) {
1156 if (isStoreDirectory(entry)) {
1159 const bool named = QDir::match(nameFilters, entry.fileName());
1160 if (isLink(entry) || (!entry.isDir() && !entry.isFile())) {
1164 if (skipped !=
nullptr && (entry.isDir() || named)) {
1165 qCWarning(lcQtPass) <<
"Skipping" << entry.filePath()
1166 <<
": not a regular file or directory";
1167 *skipped << entry.filePath();
1171 if (entry.isFile() && named && (hiddenFiles || !isHiddenEntry(entry))) {
1172 files << entry.filePath();
1182 walkStore(dir, [&](
const QFileInfo &entry) {
1183 if (!isStoreDirectory(entry)) {
1186 dirs << entry.filePath();
1199 DIR *listing = ::opendir(QFile::encodeName(dir).constData());
1200 if (listing ==
nullptr) {
1203 const auto close = qScopeGuard([listing] { ::closedir(listing); });
1204 while (
const dirent *entry = ::readdir(listing)) {
1205 if (!QByteArrayView(entry->d_name).isValidUtf8()) {
1214 return isLink(QFileInfo(QDir::cleanPath(path)));
1218 bool includeSelf) ->
bool {
1222 constexpr auto cs = Qt::CaseInsensitive;
1224 constexpr auto cs = Qt::CaseSensitive;
1226 const QString root = QDir::cleanPath(storeRoot);
1228 const QString prefix =
1229 root.endsWith(QLatin1Char(
'/')) ? root : root + QLatin1Char(
'/');
1230 const auto isRoot = [&](
const QString &p) {
1231 return p.compare(root, cs) == 0;
1233 QString current = QDir::cleanPath(path);
1234 if (!current.startsWith(prefix, cs)) {
1236 return includeSelf && !isRoot(current) &&
isLinkedFolder(current);
1239 current = QFileInfo(current).path();
1241 for (; !isRoot(current) && current.startsWith(prefix, cs);
1242 current = QFileInfo(current).path()) {
1255auto hasNoHardLinks(
int error) ->
bool {
1256 return error == EPERM || error == ENOTSUP || error == EOPNOTSUPP ||
1262auto renameExclusive(
const QByteArray &source,
const QByteArray &target)
1263 -> std::optional<bool> {
1264#if defined(__GLIBC__) && \
1265 (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 28))
1266 if (::renameat2(AT_FDCWD, source.constData(), AT_FDCWD, target.constData(),
1267 RENAME_NOREPLACE) == 0) {
1270 if (errno == EINVAL || errno == ENOSYS || hasNoHardLinks(errno)) {
1271 return std::nullopt;
1274#elif defined(Q_OS_MACOS)
1275 if (::renamex_np(source.constData(), target.constData(), RENAME_EXCL) == 0) {
1278 if (errno == EINVAL || errno == ENOTSUP) {
1279 return std::nullopt;
1285 return std::nullopt;
1298auto placeWithoutReplacing(
const QByteArray &source,
const QByteArray &target)
1303 if (::linkat(AT_FDCWD, source.constData(), AT_FDCWD, target.constData(), 0) ==
1305 if (::unlink(source.constData()) == 0) {
1311 const int err = errno;
1312 ::unlink(target.constData());
1316 if (!hasNoHardLinks(errno)) {
1319 if (
const std::optional<bool> renamed = renameExclusive(source, target)) {
1323 if (::lstat(target.constData(), &st) == 0 || errno != ENOENT) {
1327 return ::rename(source.constData(), target.constData()) == 0;
1336 const std::wstring source =
1337 QDir::toNativeSeparators(QFileInfo(from).absoluteFilePath())
1339 const std::wstring target =
1340 QDir::toNativeSeparators(QFileInfo(to).absoluteFilePath()).toStdWString();
1342 return MoveFileExW(source.c_str(), target.c_str(),
1343 (replace ? MOVEFILE_REPLACE_EXISTING : 0) |
1344 MOVEFILE_WRITE_THROUGH) != 0;
1346 const QByteArray source = QFile::encodeName(from);
1347 const QByteArray target = QFile::encodeName(to);
1349 if (::rename(source.constData(), target.constData()) != 0) {
1353 if (!placeWithoutReplacing(source, target)) {
1360 const int dir = ::open(QFile::encodeName(QFileInfo(to).path()).constData(),
1361 O_RDONLY | O_DIRECTORY | O_CLOEXEC);
1366 }
while (rc != 0 && errno == EINTR);
1381auto diskFileAttributes(HANDLE handle) -> std::optional<DWORD> {
1382 BY_HANDLE_FILE_INFORMATION info{};
1383 if (!GetFileInformationByHandle(handle, &info) ||
1384 (info.dwFileAttributes &
1385 (FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_DEVICE)) != 0 ||
1386 GetFileType(handle) != FILE_TYPE_DISK) {
1387 return std::nullopt;
1389 return info.dwFileAttributes;
1405auto openThroughReparsePoint(HANDLE handle,
const std::wstring &native)
1407 FILE_ATTRIBUTE_TAG_INFO tag{};
1408 if (!GetFileInformationByHandleEx(handle, FileAttributeTagInfo, &tag,
1410 IsReparseTagNameSurrogate(tag.ReparseTag)) {
1411 return INVALID_HANDLE_VALUE;
1414 CreateFileW(native.c_str(), GENERIC_READ,
1415 FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
1416 nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,
nullptr);
1417 if (through == INVALID_HANDLE_VALUE) {
1418 return INVALID_HANDLE_VALUE;
1422 FILE_ID_INFO firstId{};
1423 FILE_ID_INFO throughId{};
1425 GetFileInformationByHandleEx(handle, FileIdInfo, &firstId,
1427 GetFileInformationByHandleEx(through, FileIdInfo, &throughId,
1428 sizeof(throughId)) &&
1429 firstId.VolumeSerialNumber == throughId.VolumeSerialNumber &&
1430 std::memcmp(&firstId.FileId, &throughId.FileId,
sizeof(firstId.FileId)) ==
1432 diskFileAttributes(through).has_value();
1434 CloseHandle(through);
1435 return INVALID_HANDLE_VALUE;
1446auto openRegularFileNative(
const QString &path, QFile &file) ->
bool {
1450 const std::wstring native =
1451 QDir::toNativeSeparators(QFileInfo(path).absoluteFilePath())
1453 HANDLE handle = CreateFileW(
1454 native.c_str(), GENERIC_READ,
1455 FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
nullptr,
1456 OPEN_EXISTING, FILE_FLAG_OPEN_REPARSE_POINT,
nullptr);
1457 if (handle == INVALID_HANDLE_VALUE) {
1460 const std::optional<DWORD> attributes = diskFileAttributes(handle);
1462 CloseHandle(handle);
1465 if ((*attributes & FILE_ATTRIBUTE_REPARSE_POINT) != 0) {
1466 const HANDLE through = openThroughReparsePoint(handle, native);
1467 CloseHandle(handle);
1468 if (through == INVALID_HANDLE_VALUE) {
1473 const int fd = _open_osfhandle(
reinterpret_cast<intptr_t
>(handle),
1474 _O_RDONLY | _O_BINARY);
1476 CloseHandle(handle);
1479 if (!file.open(fd, QIODevice::ReadOnly, QFileDevice::AutoCloseHandle)) {
1493auto adoptRegularFd(
int fd, QFile &file) ->
bool {
1495 if (::fstat(fd, &st) != 0 || !S_ISREG(st.st_mode)) {
1506 if (!file.open(fd, QIODevice::ReadOnly, QFileDevice::AutoCloseHandle)) {
1519auto openRegularFileNative(
const QString &path, QFile &file) ->
bool {
1522 const int fd = ::open(QFile::encodeName(path).constData(),
1523 O_RDONLY | O_NOFOLLOW | O_NONBLOCK | O_CLOEXEC);
1524 return fd >= 0 && adoptRegularFd(fd, file);
1530 return openRegularFileNative(path, file);
1540auto readOpenFile(QFile &file, qint64 maxBytes) -> std::optional<QByteArray> {
1544 if (file.size() > maxBytes) {
1545 return std::nullopt;
1547 QByteArray bytes = file.read(maxBytes + 1);
1548 if (bytes.size() > maxBytes || file.error() != QFileDevice::NoError) {
1549 return std::nullopt;
1556 -> std::optional<QByteArray> {
1559 return std::nullopt;
1561 return readOpenFile(file, maxBytes);
1566 -> std::optional<QByteArray> {
1567 const auto under = [&path](
const QString &root) {
1568 const QString relative = QDir(root).relativeFilePath(QDir::cleanPath(path));
1570 relative != QStringLiteral(
"..") &&
1571 !relative.startsWith(QStringLiteral(
"../"));
1573 const QString root = QDir::cleanPath(store);
1577 const QString canonical = QFileInfo(root).canonicalFilePath();
1578 if (under(canonical)) {
1581 return std::nullopt;
1599auto holdFolder(
const QString &folder,
bool isRoot) -> HANDLE {
1600 const std::wstring native = QDir::toNativeSeparators(folder).toStdWString();
1604 HANDLE handle = CreateFileW(
1605 native.c_str(), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,
nullptr,
1607 FILE_FLAG_BACKUP_SEMANTICS | (isRoot ? 0 : FILE_FLAG_OPEN_REPARSE_POINT),
1609 if (handle == INVALID_HANDLE_VALUE) {
1610 return INVALID_HANDLE_VALUE;
1612 FILE_ATTRIBUTE_TAG_INFO info{};
1613 if (!GetFileInformationByHandleEx(handle, FileAttributeTagInfo, &info,
1615 (info.FileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0) {
1616 CloseHandle(handle);
1617 return INVALID_HANDLE_VALUE;
1619 const bool link = (info.FileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) != 0 &&
1620 IsReparseTagNameSurrogate(info.ReparseTag);
1621 if (!isRoot && link) {
1622 CloseHandle(handle);
1623 return INVALID_HANDLE_VALUE;
1636auto readUnderNative(
const QString &cleanRoot,
const QStringList &parts,
1637 const QString &path, qint64 maxBytes)
1638 -> std::optional<QByteArray> {
1644 std::vector<HANDLE> held;
1645 const auto release = qScopeGuard([&held] {
1646 for (HANDLE handle : held) {
1647 CloseHandle(handle);
1650 QString folder = cleanRoot;
1651 for (qsizetype i = 0; i < parts.size(); ++i) {
1652 const bool isRoot = i == 0;
1654 folder += QLatin1Char(
'/') + parts.at(i - 1);
1656 const HANDLE handle = holdFolder(folder, isRoot);
1657 if (handle == INVALID_HANDLE_VALUE) {
1658 return std::nullopt;
1660 held.push_back(handle);
1675auto readUnderNative(
const QString &cleanRoot,
const QStringList &parts,
1676 const QString &path, qint64 maxBytes)
1677 -> std::optional<QByteArray> {
1681 int dir = ::open(QFile::encodeName(cleanRoot).constData(),
1682 O_RDONLY | O_DIRECTORY | O_CLOEXEC);
1684 return std::nullopt;
1686 for (qsizetype i = 0; i + 1 < parts.size(); ++i) {
1687 const int next = ::openat(dir, QFile::encodeName(parts.at(i)).constData(),
1688 O_RDONLY | O_DIRECTORY | O_NOFOLLOW | O_CLOEXEC);
1691 return std::nullopt;
1696 const int fd = ::openat(dir, QFile::encodeName(parts.constLast()).constData(),
1697 O_RDONLY | O_NOFOLLOW | O_NONBLOCK | O_CLOEXEC);
1700 if (fd < 0 || !adoptRegularFd(fd, file)) {
1701 return std::nullopt;
1703 return readOpenFile(file, maxBytes);
1709 qint64 maxBytes) -> std::optional<QByteArray> {
1710 const QString cleanRoot = QDir::cleanPath(root);
1711 const QString relative =
1712 QDir(cleanRoot).relativeFilePath(QDir::cleanPath(path));
1713 const QStringList parts = relative.split(QLatin1Char(
'/'));
1715 parts.contains(QStringLiteral(
"..")) ||
1716 parts.contains(QStringLiteral(
".")) || parts.contains(QString())) {
1717 return std::nullopt;
1719 return readUnderNative(cleanRoot, parts, path, maxBytes);
1723 if (!file.flush()) {
1727 const HANDLE handle =
reinterpret_cast<HANDLE
>(_get_osfhandle(file.handle()));
1728 return handle != INVALID_HANDLE_VALUE && FlushFileBuffers(handle) != 0;
1730 return ::fsync(file.handle()) == 0;
1740struct FileIdentity {
1746auto operator==(
const FileIdentity &a,
const FileIdentity &b) ->
bool {
1747 return a.known && b.known && a.volume == b.volume && a.index == b.index;
1751auto identityOf(
const QFileDevice &file) -> FileIdentity {
1753 const HANDLE handle =
reinterpret_cast<HANDLE
>(_get_osfhandle(file.handle()));
1754 BY_HANDLE_FILE_INFORMATION info;
1755 if (handle == INVALID_HANDLE_VALUE ||
1756 GetFileInformationByHandle(handle, &info) == 0) {
1763 if (GetVolumeInformationByHandleW(handle,
nullptr, 0,
nullptr,
nullptr,
1764 &flags,
nullptr, 0) == 0 ||
1765 (flags & FILE_SUPPORTS_HARD_LINKS) == 0) {
1768 return {info.dwVolumeSerialNumber,
1769 (
static_cast<quint64
>(info.nFileIndexHigh) << 32) |
1774 if (::fstat(file.handle(), &st) != 0) {
1777 return {
static_cast<quint64
>(st.st_dev),
static_cast<quint64
>(st.st_ino),
1783auto fail(QString *error,
const QString &text) ->
bool {
1784 if (error !=
nullptr) {
1793 FileIdentity identity;
1796 std::shared_ptr<void> pin;
1805auto stageNextTo(
const QString &path,
const Util::Filler &fill, QString *why)
1806 -> std::optional<Staged> {
1809 QTemporaryFile file(QFileInfo(path).path() +
1810 QStringLiteral(
"/.qtpass-XXXXXX.tmp"));
1811 file.setAutoRemove(
false);
1813 *why = QCoreApplication::translate(
1814 "Util",
"Cannot create a temporary file next to %1: %2")
1815 .arg(path, file.errorString());
1816 return std::nullopt;
1818 staged.path = file.fileName();
1822 file.setPermissions(QFile::ReadOwner | QFile::WriteOwner);
1825 *why = QCoreApplication::translate(
"Util",
"Cannot write %1: %2")
1826 .arg(path, file.errorString());
1828 staged.identity = identityOf(file);
1834 if (
const int fd = ::dup(file.handle()); fd >= 0) {
1836 std::shared_ptr<void>(
nullptr, [fd](
void *) { ::close(fd); });
1840 if (!why->isEmpty()) {
1841 QFile::remove(staged.path);
1842 return std::nullopt;
1848auto placementError(
const QString &path,
bool replace) -> QString {
1850 return QCoreApplication::translate(
"Util",
"Failed to replace %1.")
1853 const QFileInfo taken(path);
1854 return taken.exists() || taken.isSymLink()
1855 ? QCoreApplication::translate(
"Util",
"%1 already exists.")
1857 : QCoreApplication::translate(
"Util",
"Failed to write %1.")
1868auto isTheFileWritten(
const QString &path,
const FileIdentity &written)
1874 const FileIdentity there = identityOf(placed);
1875 if (!written.known || !there.known) {
1876 qCWarning(lcQtPass) <<
"Cannot tell whether" << path
1877 <<
"is the file that was written here";
1880 return there == written;
1886 const Filler &fill, QString *error) ->
bool {
1888 const std::optional<Staged> staged = stageNextTo(path, fill, &why);
1890 return fail(error, why);
1896 QFile::remove(staged->path);
1897 return fail(error, placementError(path, replace));
1901 if (!isTheFileWritten(path, staged->identity)) {
1904 QCoreApplication::translate(
1905 "Util",
"%1 was swapped for another file while it was written.")
1912 bool replace, QString *error) ->
bool {
1915 [&path, &bytes](QFileDevice &staged) -> QString {
1916 if (staged.write(bytes) != bytes.size()) {
1917 return QCoreApplication::translate(
"Util",
"Cannot write %1: %2")
1918 .arg(path, staged.errorString());
1926 bool replace, QString *error) ->
bool {
1930 *error = QCoreApplication::translate(
"Util",
"Cannot read %1.").arg(src);
1935 [&src, &dst, &in](QFileDevice &staged) -> QString {
1936 std::array<char, std::size_t{64} * 1024> buf;
1938 const qint64 n = in.read(buf.data(), buf.size());
1940 return QCoreApplication::translate(
"Util",
"Cannot read %1: %2")
1941 .arg(src, in.errorString());
1946 if (staged.write(buf.data(), n) != n) {
1947 return QCoreApplication::translate(
"Util",
"Cannot write %1: %2")
1948 .arg(dst, staged.errorString());
1961auto removeEntry(
const QFileInfo &entry) ->
bool {
1962 const QString path = entry.filePath();
1963 if (isLink(entry)) {
1964 if (QFile::remove(path) || QDir().rmdir(path)) {
1967 qCWarning(lcQtPass) <<
"Could not remove link" << path;
1970 if (QFile::remove(path)) {
1973 const QFile::Permissions perms = QFile::permissions(path);
1974 if (!perms.testFlag(QFile::WriteUser) &&
1975 QFile::setPermissions(path, perms | QFile::WriteUser) &&
1976 QFile::remove(path)) {
1979 qCWarning(lcQtPass) <<
"Could not remove" << path;
1988 const QString path = QDir::cleanPath(dir);
1989 const QFileInfo top(path);
1992 return QFile::remove(path) || QDir().rmdir(path);
1998 const QFileInfoList entries =
1999 QDir(path).entryInfoList(QDir::Dirs | QDir::Files | QDir::Hidden |
2000 QDir::System | QDir::NoDotAndDotDot,
2002 for (
const QFileInfo &entry : entries) {
2003 const bool removed = entry.isDir() && !isLink(entry)
2005 : removeEntry(entry);
2008 return ok && QDir().rmdir(path);
AppSettings, the value object holding every flat QtPass setting.
static auto childUmask() -> int
The umask setChildUmask() set.
static auto executeBlocking(const QString &app, const QStringList &args, const QString &input=QString(), QString *process_out=nullptr, QString *process_err=nullptr) -> int
Run a command synchronously and return its exit code.
static void setChildUmask(int mask)
The umask every child QtPass starts gets, as pass sets its own.
static auto parseWslCommand(const QString &app) -> std::optional< WslCommand >
Parse a configured executable as a WSL command.
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 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 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.
Executor, the FIFO queue every gpg, git and pass child process of QtPass goes through,...
bool operator==(const NamedValue &a, const NamedValue &b)
Two fields are equal when name and value match; originalLine is formatting, not content,...
The "qtpass" logging category.
Plain value-object holding all flat QtPass configuration.
std::function< void(const QString &)> s_beforePlacingForTests
setBeforePlacingForTests(): called between staging and the rename.
Util: static helpers for the process environment, binary discovery, store paths, URL safety and the l...