Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions share/macosx/keepassxc.entitlements
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
<key>com.apple.application-identifier</key>
<string>G2S7P7J672.org.keepassxc.keepassxc</string>
<key>keychain-access-groups</key>
<array>
<string>G2S7P7J672.org.keepassxc.keepassxc</string>
</array>
<key>com.apple.security.application-groups</key>
<array>
<string>G2S7P7J672.org.keepassxc.keepassxc</string>
</array>
Expand Down
8 changes: 7 additions & 1 deletion src/browser/BrowserShared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
#include <QProcessEnvironment>
#endif

#if defined(Q_OS_MACOS)
#include "BrowserSharedMac.h"
#endif

namespace BrowserShared
{
QString localServerPath()
Expand Down Expand Up @@ -53,7 +57,9 @@ namespace BrowserShared
#elif defined(Q_OS_WIN)
// Windows uses named pipes
return serverName + "_" + qgetenv("USERNAME");
#else // Q_OS_MACOS and others
#elif defined(Q_OS_MACOS)
return macOSLocalServerPath();
#else // others
return QStandardPaths::writableLocation(QStandardPaths::TempLocation) + serverName;
#endif
}
Expand Down
6 changes: 6 additions & 0 deletions src/browser/BrowserSharedMac.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include <QString>

namespace BrowserShared
{
QString macOSLocalServerPath();
}
25 changes: 25 additions & 0 deletions src/browser/BrowserSharedMac.mm
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include <Foundation/Foundation.h>
#include <QDir>
#include <QString>

namespace BrowserShared
{
QString macOSLocalServerPath()
{
NSString *appGroupIdentifier = @"G2S7P7J672.org.keepassxc.KeePassXC";

// Get the container URL for the app group identifier
NSURL *containerURL = [[NSFileManager defaultManager] containerURLForSecurityApplicationGroupIdentifier:appGroupIdentifier];

NSString *containerPath = [containerURL path];

QString homePath = QString::fromNSString(containerPath);

QDir().mkpath(homePath);

// The path will become too long therefore we must cut off serverName
QString socketPath = homePath + "/KeePassXC.BrowserServer";

return socketPath;
}
}
5 changes: 5 additions & 0 deletions src/browser/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ if(WITH_XC_BROWSER)
CustomTableWidget.cpp
NativeMessageInstaller.cpp)

if(APPLE)
list(APPEND browser_SOURCES
BrowserSharedMac.mm)
endif()

if(WITH_XC_BROWSER_PASSKEYS)
list(APPEND browser_SOURCES
BrowserCbor.cpp
Expand Down
7 changes: 7 additions & 0 deletions src/proxy/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ if(WITH_XC_BROWSER)
keepassxc-proxy.cpp
NativeMessagingProxy.cpp)

if(APPLE)
list(APPEND proxy_SOURCES
../browser/BrowserSharedMac.mm)
endif()

# Alloc must be defined in a static library to prevent clashing with clang ASAN definitions
add_library(proxy_alloc STATIC ../core/Alloc.cpp)
target_link_libraries(proxy_alloc PRIVATE Qt5::Core ${BOTAN_LIBRARIES})
Expand All @@ -39,6 +44,8 @@ if(WITH_XC_BROWSER)

set_property(GLOBAL APPEND PROPERTY
_MACDEPLOYQT_EXTRA_BINARIES "${PROXY_INSTALL_DIR}/keepassxc-proxy")

target_link_libraries(keepassxc-proxy "-framework Foundation")
endif()

if(WIN32)
Expand Down