File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11/*
2- * Copyright (C) 2020 KeePassXC Team <team@keepassxc.org>
2+ * Copyright (C) 2026 KeePassXC Team <team@keepassxc.org>
33 *
44 * This program is free software: you can redistribute it and/or modify
55 * it under the terms of the GNU General Public License as published by
2424#if defined(KEEPASSXC_DIST_SNAP)
2525#include < QProcessEnvironment>
2626#endif
27+ #if defined(Q_OS_MACOS)
28+ #include " gui/osutils/macutils/MacUtils.h"
29+ #endif
2730
2831namespace BrowserShared
2932{
@@ -53,7 +56,11 @@ namespace BrowserShared
5356#elif defined(Q_OS_WIN)
5457 // Windows uses named pipes
5558 return serverName + " _" + qgetenv (" USERNAME" );
56- #else // Q_OS_MACOS and others
59+ #elif defined(Q_OS_MACOS)
60+ // In macOS QStandardPaths::TempLocation can be overridden with $TMPDIR. Use the location provided by the OS.
61+ // Otherwise the socket will be created to incorrect path, and connection with the browser extension breaks.
62+ return macUtils ()->getTemporaryDirectory () + serverName;
63+ #else
5764 return QStandardPaths::writableLocation (QStandardPaths::TempLocation) + serverName;
5865#endif
5966 }
Original file line number Diff line number Diff line change 11/*
2- * Copyright (C) 2023 KeePassXC Team <team@keepassxc.org>
2+ * Copyright (C) 2026 KeePassXC Team <team@keepassxc.org>
33 * Copyright (C) 2016 Lennart Glauer <mail@lennart-glauer.de>
44 *
55 * This program is free software: you can redistribute it and/or modify
@@ -48,6 +48,7 @@ class AppKit : public QObject
4848 void toggleForegroundApp (bool foreground);
4949 void setWindowSecurity (QWindow* window, bool state);
5050 void configureWindowAndHelpMenus (QMainWindow* mainWindow, QMenu* helpMenu);
51+ NSString* getTemporaryDirectory ();
5152
5253signals:
5354 void userSwitched ();
Original file line number Diff line number Diff line change 11/*
2+ * Copyright (C) 2026 KeePassXC Team <team@keepassxc.org>
23 * Copyright (C) 2016 Lennart Glauer <mail@lennart-glauer.de>
3- * Copyright (C) 2017 KeePassXC Team <team@keepassxc.org>
44 *
55 * This program is free software: you can redistribute it and/or modify
66 * it under the terms of the GNU General Public License as published by
4343- (void ) toggleForegroundApp : (bool ) foreground ;
4444- (void ) setWindowSecurity : (NSWindow *) window state : (bool ) state ;
4545- (void ) configureWindowAndHelpMenus : (QMainWindow*) mainWindow helpMenu : (QMenu*) helpMenu ;
46+ - (NSString *) getTemporaryDirectory ;
4647
4748@end
Original file line number Diff line number Diff line change 11/*
2- * Copyright (C) 2024 KeePassXC Team <team@keepassxc.org>
2+ * Copyright (C) 2026 KeePassXC Team <team@keepassxc.org>
33 * Copyright (C) 2016 Lennart Glauer <mail@lennart-glauer.de>
44 *
55 * This program is free software: you can redistribute it and/or modify
@@ -253,6 +253,11 @@ - (void) configureWindowAndHelpMenus:(QMainWindow*) mainWindow helpMenu:(QMenu*)
253253 NSApp .helpMenu = helpMenu->toNSMenu ();
254254}
255255
256+ - (NSString *) getTemporaryDirectory
257+ {
258+ return NSTemporaryDirectory ();
259+ }
260+
256261@end
257262
258263
@@ -314,6 +319,10 @@ - (void) configureWindowAndHelpMenus:(QMainWindow*) mainWindow helpMenu:(QMenu*)
314319 return [static_cast<id >(self ) isStatusBarDark ];
315320}
316321
322+ NSString * AppKit::getTemporaryDirectory ()
323+ {
324+ return [static_cast<id >(self ) getTemporaryDirectory ];
325+ }
317326
318327bool AppKit::enableAccessibility ()
319328{
Original file line number Diff line number Diff line change 11/*
2- * Copyright (C) 2023 KeePassXC Team <team@keepassxc.org>
2+ * Copyright (C) 2026 KeePassXC Team <team@keepassxc.org>
33 * Copyright (C) 2012 Felix Geyer <debfx@fobos.de>
44 *
55 * This program is free software: you can redistribute it and/or modify
2020#include < QApplication>
2121#include < QDir>
2222#include < QFile>
23+ #include < QMenu>
2324#include < QSettings>
2425#include < QStandardPaths>
2526#include < QTimer>
2627#include < QWindow>
27- #include < QMenu>
2828
2929#include < ApplicationServices/ApplicationServices.h>
3030
@@ -103,6 +103,12 @@ bool MacUtils::enableScreenRecording()
103103 return m_appkit->enableScreenRecording ();
104104}
105105
106+ QString MacUtils::getTemporaryDirectory ()
107+ {
108+ const auto temporaryDirectory = m_appkit->getTemporaryDirectory ();
109+ return QString::fromNSString (temporaryDirectory);
110+ }
111+
106112bool MacUtils::isDarkMode () const
107113{
108114 return m_appkit->isDarkMode ();
Original file line number Diff line number Diff line change 11/*
2- * Copyright (C) 2025 KeePassXC Team <team@keepassxc.org>
2+ * Copyright (C) 2026 KeePassXC Team <team@keepassxc.org>
33 * Copyright (C) 2012 Felix Geyer <debfx@fobos.de>
44 *
55 * This program is free software: you can redistribute it and/or modify
@@ -51,6 +51,7 @@ class MacUtils : public OSUtilsBase
5151 bool isHidden ();
5252 bool enableAccessibility ();
5353 bool enableScreenRecording ();
54+ QString getTemporaryDirectory ();
5455 void toggleForegroundApp (bool foreground);
5556
5657 void registerNativeEventFilter () override ;
You can’t perform that action at this time.
0 commit comments