Upstream Flathub patches (#7728)
This commit is contained in:
@@ -158,6 +158,18 @@ void BrowserSettingsWidget::loadSettings()
|
||||
m_ui->browserGlobalWarningWidget->setCloseButtonVisible(false);
|
||||
m_ui->browserGlobalWarningWidget->setAutoHideTimeout(-1);
|
||||
#endif
|
||||
#ifdef KEEPASSXC_DIST_FLATPAK
|
||||
// Guarantees proxy path works with different flatpak installations
|
||||
m_ui->updateBinaryPath->setChecked(true);
|
||||
m_ui->updateBinaryPath->setEnabled(false);
|
||||
// The sandbox makes custom proxy locations very unintuitive
|
||||
m_ui->useCustomProxy->setChecked(false);
|
||||
m_ui->useCustomProxy->setEnabled(false);
|
||||
m_ui->useCustomProxy->setVisible(false);
|
||||
m_ui->customProxyLocation->setVisible(false);
|
||||
// Won't work with xdg portals and executables that must be browser accessible
|
||||
m_ui->customProxyLocationBrowseButton->setVisible(false);
|
||||
#endif
|
||||
|
||||
const auto customBrowserSet = settings->customBrowserSupport();
|
||||
m_ui->customBrowserSupport->setChecked(customBrowserSet);
|
||||
|
||||
@@ -31,6 +31,9 @@ namespace BrowserShared
|
||||
const auto serverName = QStringLiteral("/org.keepassxc.KeePassXC.BrowserServer");
|
||||
#if defined(KEEPASSXC_DIST_SNAP)
|
||||
return QProcessEnvironment::systemEnvironment().value("SNAP_USER_COMMON") + serverName;
|
||||
#elif defined(KEEPASSXC_DIST_FLATPAK)
|
||||
return QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation) + "/app/" + "org.keepassxc.KeePassXC"
|
||||
+ serverName;
|
||||
#elif defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
|
||||
// Use XDG_RUNTIME_DIR instead of /tmp if it's available
|
||||
QString path = QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation);
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include <QJsonObject>
|
||||
#include <QMessageBox>
|
||||
#include <QProcessEnvironment>
|
||||
#include <QRegularExpression>
|
||||
#include <QSettings>
|
||||
#include <QStandardPaths>
|
||||
|
||||
@@ -214,12 +215,20 @@ QString NativeMessageInstaller::getNativeMessagePath(SupportedBrowsers browser)
|
||||
basePath = QStandardPaths::writableLocation(QStandardPaths::DataLocation);
|
||||
}
|
||||
return QStringLiteral("%1/%2_%3.json").arg(basePath, HOST_NAME, getBrowserName(browser));
|
||||
#elif defined(KEEPASSXC_DIST_FLATPAK)
|
||||
// Flatpak sandboxes do not have access to the XDG_DATA_HOME and XDG_CONFIG_HOME variables
|
||||
// defined in the host, so we must hardcode them here.
|
||||
if (browser == SupportedBrowsers::TOR_BROWSER) {
|
||||
basePath = QDir::homePath() + "/.local/share";
|
||||
} else if (browser == SupportedBrowsers::FIREFOX) {
|
||||
basePath = QDir::homePath();
|
||||
} else {
|
||||
basePath = QDir::homePath() + "/.config";
|
||||
}
|
||||
#elif defined(Q_OS_LINUX)
|
||||
if (browser == SupportedBrowsers::TOR_BROWSER) {
|
||||
// Tor Browser launcher stores its config in ~/.local/share/...
|
||||
basePath = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation);
|
||||
} else if (browser == SupportedBrowsers::FIREFOX) {
|
||||
// Firefox stores its config in ~/
|
||||
basePath = QDir::homePath();
|
||||
} else {
|
||||
basePath = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation);
|
||||
@@ -234,6 +243,34 @@ QString NativeMessageInstaller::getNativeMessagePath(SupportedBrowsers browser)
|
||||
return QStringLiteral("%1%2/%3.json").arg(basePath, getTargetPath(browser), HOST_NAME);
|
||||
}
|
||||
|
||||
#ifdef KEEPASSXC_DIST_FLATPAK
|
||||
/** Constructs a host accessible proxy path for use with flatpak
|
||||
*
|
||||
* @return path Path to host accessible wrapper script (org.keepassxc.KeePassXC)
|
||||
*/
|
||||
QString constructFlatpakPath()
|
||||
{
|
||||
// Find and extract the host flatpak data directory (in /var)
|
||||
QString path;
|
||||
QSettings settings("/.flatpak-info", QSettings::IniFormat);
|
||||
settings.beginGroup("Instance");
|
||||
QString appPath = settings.value("app-path").toString();
|
||||
|
||||
QRegularExpression re("^((?:/[\\.\\w-]*)+)+/app");
|
||||
QRegularExpressionMatch match = re.match(appPath);
|
||||
if (match.hasMatch()) {
|
||||
// Construct a proxy path that should work with all flatpak installations
|
||||
path = match.captured(1) + "/exports/bin/" + "org.keepassxc.KeePassXC";
|
||||
} else {
|
||||
// Fallback to the most common and default flatpak installation path
|
||||
path = "/var/lib/flatpak/exports/bin/org.keepassxc.KeePassXC";
|
||||
}
|
||||
settings.endGroup();
|
||||
|
||||
return path;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Gets the path to keepassxc-proxy binary
|
||||
*
|
||||
@@ -247,8 +284,10 @@ QString NativeMessageInstaller::getProxyPath() const
|
||||
}
|
||||
|
||||
QString path;
|
||||
#ifdef KEEPASSXC_DIST_APPIMAGE
|
||||
#if defined(KEEPASSXC_DIST_APPIMAGE)
|
||||
path = QProcessEnvironment::systemEnvironment().value("APPIMAGE");
|
||||
#elif defined(KEEPASSXC_DIST_FLATPAK)
|
||||
path = constructFlatpakPath();
|
||||
#else
|
||||
path = QCoreApplication::applicationDirPath() + QStringLiteral("/keepassxc-proxy");
|
||||
#ifdef Q_OS_WIN
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#cmakedefine KEEPASSXC_DIST_TYPE "@KEEPASSXC_DIST_TYPE@"
|
||||
#cmakedefine KEEPASSXC_DIST_SNAP
|
||||
#cmakedefine KEEPASSXC_DIST_APPIMAGE
|
||||
#cmakedefine KEEPASSXC_DIST_FLATPAK
|
||||
|
||||
#cmakedefine HAVE_PR_SET_DUMPABLE 1
|
||||
#cmakedefine HAVE_RLIMIT_CORE 1
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
#include "EntryAttachments.h"
|
||||
|
||||
#include "config-keepassx.h"
|
||||
#include "core/Global.h"
|
||||
#include "crypto/Random.h"
|
||||
|
||||
@@ -218,9 +219,13 @@ bool EntryAttachments::openAttachment(const QString& key, QString* errorMessage)
|
||||
const QByteArray attachmentData = value(key);
|
||||
auto ext = key.contains(".") ? "." + key.split(".").last() : "";
|
||||
|
||||
#ifdef KEEPASSXC_DIST_SNAP
|
||||
#if defined(KEEPASSXC_DIST_SNAP)
|
||||
const QString tmpFileTemplate =
|
||||
QString("%1/XXXXXXXXXXXX%2").arg(QProcessEnvironment::systemEnvironment().value("SNAP_USER_DATA"), ext);
|
||||
#elif defined(KEEPASSXC_DIST_FLATPAK)
|
||||
const QString tmpFileTemplate =
|
||||
QString("%1/app/%2/XXXXXX.%3")
|
||||
.arg(QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation), "org.keepassxc.KeePassXC", ext);
|
||||
#else
|
||||
const QString tmpFileTemplate = QDir::temp().absoluteFilePath(QString("XXXXXXXXXXXX").append(ext));
|
||||
#endif
|
||||
|
||||
@@ -52,9 +52,18 @@ Icons::Icons()
|
||||
{
|
||||
}
|
||||
|
||||
QString Icons::applicationIconName()
|
||||
{
|
||||
#ifdef KEEPASSXC_DIST_FLATPAK
|
||||
return QString("org.keepassxc.KeePassXC");
|
||||
#else
|
||||
return QString("keepassxc");
|
||||
#endif
|
||||
}
|
||||
|
||||
QIcon Icons::applicationIcon()
|
||||
{
|
||||
return icon("keepassxc", false);
|
||||
return icon(applicationIconName(), false);
|
||||
}
|
||||
|
||||
QString Icons::trayIconAppearance() const
|
||||
@@ -81,7 +90,7 @@ QIcon Icons::trayIcon(QString style)
|
||||
|
||||
auto iconApperance = trayIconAppearance();
|
||||
if (!iconApperance.startsWith("monochrome")) {
|
||||
return icon(QString("keepassxc%1").arg(style), false);
|
||||
return icon(QString("%1%2").arg(applicationIconName(), style), false);
|
||||
}
|
||||
|
||||
QIcon i;
|
||||
@@ -92,7 +101,7 @@ QIcon Icons::trayIcon(QString style)
|
||||
i = icon(QString("keepassxc-monochrome-dark%1").arg(style), false);
|
||||
}
|
||||
#else
|
||||
i = icon(QString("keepassxc-%1%2").arg(iconApperance, style), false);
|
||||
i = icon(QString("%1-%2%3").arg(applicationIconName(), iconApperance, style), false);
|
||||
#endif
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)
|
||||
// Set as mask to allow the operating system to recolour the tray icon. This may look weird
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
class Icons
|
||||
{
|
||||
public:
|
||||
QString applicationIconName();
|
||||
QIcon applicationIcon();
|
||||
QIcon trayIcon(QString style = "unlocked");
|
||||
QIcon trayIconLocked();
|
||||
|
||||
Reference in New Issue
Block a user