diff --git a/src/browser/NativeMessagingBase.cpp b/src/browser/NativeMessagingBase.cpp index a6b8d97c..33592ce3 100644 --- a/src/browser/NativeMessagingBase.cpp +++ b/src/browser/NativeMessagingBase.cpp @@ -19,6 +19,8 @@ #include "NativeMessagingBase.h" #include +#include "config-keepassx.h" + #if defined(Q_OS_UNIX) && !defined(Q_OS_LINUX) #include #include @@ -138,7 +140,7 @@ QString NativeMessagingBase::getLocalServerPath() const { const QString serverPath = "/kpxc_server"; #if defined(KEEPASSXC_DIST_SNAP) - return QProcessEnvironment::systemEnvironment().value("SNAP_COMMON") + serverPath; + return QProcessEnvironment::systemEnvironment().value("SNAP_USER_COMMON") + serverPath; #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); diff --git a/src/gui/entry/EntryAttachmentsWidget.cpp b/src/gui/entry/EntryAttachmentsWidget.cpp index 810b4bde..9610cc05 100644 --- a/src/gui/entry/EntryAttachmentsWidget.cpp +++ b/src/gui/entry/EntryAttachmentsWidget.cpp @@ -7,9 +7,11 @@ #include #include #include +#include #include #include "EntryAttachmentsModel.h" +#include "config-keepassx.h" #include "core/Config.h" #include "core/EntryAttachments.h" #include "core/Tools.h" @@ -324,7 +326,12 @@ bool EntryAttachmentsWidget::openAttachment(const QModelIndex& index, QString& e const QByteArray attachmentData = m_entryAttachments->value(filename); // tmp file will be removed once the database (or the application) has been closed +#ifdef KEEPASSXC_DIST_SNAP + const QString tmpFileTemplate = + QString("%1/XXXXXX.%2").arg(QProcessEnvironment::systemEnvironment().value("SNAP_USER_DATA"), filename); +#else const QString tmpFileTemplate = QDir::temp().absoluteFilePath(QString("XXXXXX.").append(filename)); +#endif QScopedPointer tmpFile(new QTemporaryFile(tmpFileTemplate, this));