diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a7b2c052b..6d720f482 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -16,7 +16,19 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) -set(keepassx_SOURCES +add_feature_info(Auto-Type WITH_XC_AUTOTYPE "Automatic password typing") +add_feature_info(Networking WITH_XC_NETWORKING "Compile KeePassXC with network access code (e.g. for downloading website icons)") +add_feature_info(KeePassXC-Browser WITH_XC_BROWSER "Browser integration with KeePassXC-Browser") +add_feature_info(Passkeys WITH_XC_BROWSER_PASSKEYS "Passkeys support for browser integration") +add_feature_info(SSHAgent WITH_XC_SSHAGENT "SSH agent integration compatible with KeeAgent") +add_feature_info(KeeShare WITH_XC_KEESHARE "Sharing integration with KeeShare") +add_feature_info(YubiKey WITH_XC_YUBIKEY "YubiKey HMAC-SHA1 challenge-response") +add_feature_info(UpdateCheck WITH_XC_UPDATECHECK "Automatic update checking") +if(UNIX AND NOT APPLE) + add_feature_info(FdoSecrets WITH_XC_FDOSECRETS "Implement freedesktop.org Secret Storage Spec server side API.") +endif() + +set(core_SOURCES core/Alloc.cpp core/AutoTypeAssociations.cpp core/Base32.cpp @@ -47,7 +59,6 @@ set(keepassx_SOURCES core/Tools.cpp core/Totp.cpp core/Translator.cpp - core/UrlTools.cpp cli/Utils.cpp cli/TextStream.cpp crypto/Crypto.cpp @@ -79,6 +90,18 @@ set(keepassx_SOURCES format/OpVaultReaderAttachments.cpp format/OpVaultReaderBandEntry.cpp format/OpVaultReaderSections.cpp + keys/CompositeKey.cpp + keys/FileKey.cpp + keys/PasswordKey.cpp + keys/ChallengeResponseKey.cpp + streams/HashedBlockStream.cpp + streams/HmacBlockStream.cpp + streams/LayeredStream.cpp + streams/qtiocompressor.cpp + streams/StoreDataStream.cpp + streams/SymmetricCipherStream.cpp) + +set(gui_SOURCES gui/styles/styles.qrc gui/styles/StateColorPalette.cpp gui/styles/base/phantomcolor.cpp @@ -124,6 +147,7 @@ set(keepassx_SOURCES gui/TotpExportSettingsDialog.cpp gui/DatabaseOpenDialog.cpp gui/URLEdit.cpp + gui/UrlTools.cpp gui/WelcomeWidget.cpp gui/csvImport/CsvImportWidget.cpp gui/csvImport/CsvParserModel.cpp @@ -180,42 +204,37 @@ set(keepassx_SOURCES gui/wizard/NewDatabaseWizardPageMetaData.cpp gui/wizard/NewDatabaseWizardPageEncryption.cpp gui/wizard/NewDatabaseWizardPageDatabaseKey.cpp - keys/CompositeKey.cpp - keys/FileKey.cpp - keys/PasswordKey.cpp - keys/ChallengeResponseKey.cpp - streams/HashedBlockStream.cpp - streams/HmacBlockStream.cpp - streams/LayeredStream.cpp - streams/qtiocompressor.cpp - streams/StoreDataStream.cpp - streams/SymmetricCipherStream.cpp - quickunlock/QuickUnlockInterface.cpp) + quickunlock/QuickUnlockInterface.cpp + ../share/icons/icons.qrc + ../share/wizard/wizard.qrc) + if(APPLE) - set(keepassx_SOURCES - ${keepassx_SOURCES} - core/MacPasteboard.cpp + list(APPEND gui_SOURCES + gui/osutils/macutils/MacPasteboard.cpp gui/osutils/macutils/MacUtils.cpp gui/osutils/macutils/ScreenLockListenerMac.cpp gui/osutils/macutils/AppKitImpl.mm - gui/osutils/macutils/AppKit.h) + gui/osutils/macutils/AppKit.h + quickunlock/TouchID.mm) + + # TODO: Remove -Wno-error once deprecation warnings have been resolved. + set_source_files_properties(quickunlock/TouchID.mm PROPERTY COMPILE_FLAGS "-Wno-old-style-cast") endif() + if(UNIX AND NOT APPLE) - set(keepassx_SOURCES - ${keepassx_SOURCES} + list(APPEND gui_SOURCES gui/osutils/nixutils/ScreenLockListenerDBus.cpp gui/osutils/nixutils/NixUtils.cpp) if("${CMAKE_SYSTEM}" MATCHES "Linux") - set(keepassx_SOURCES - ${keepassx_SOURCES} + list(APPEND core_SOURCES quickunlock/Polkit.cpp quickunlock/PolkitDbusTypes.cpp) endif() if(WITH_XC_X11) - list(APPEND keepassx_SOURCES + list(APPEND gui_SOURCES gui/osutils/nixutils/X11Funcs.cpp) endif() - qt5_add_dbus_adaptor(keepassx_SOURCES + qt5_add_dbus_adaptor(gui_SOURCES gui/org.keepassxc.KeePassXC.MainWindow.xml gui/MainWindow.h MainWindow) @@ -225,7 +244,7 @@ if(UNIX AND NOT APPLE) PROPERTIES INCLUDE "quickunlock/PolkitDbusTypes.h" ) - qt5_add_dbus_interface(keepassx_SOURCES + qt5_add_dbus_interface(core_SOURCES quickunlock/dbus/org.freedesktop.PolicyKit1.Authority.xml polkit_dbus ) @@ -235,50 +254,33 @@ if(UNIX AND NOT APPLE) message(FATAL_ERROR "Could not find libkeyutils") endif() endif() + if(WIN32) - set(keepassx_SOURCES - ${keepassx_SOURCES} + list(APPEND gui_SOURCES gui/osutils/winutils/ScreenLockListenerWin.cpp - gui/osutils/winutils/WinUtils.cpp) + gui/osutils/winutils/WinUtils.cpp + ../share/windows/icon.rc) if (MSVC) - list(APPEND keepassx_SOURCES quickunlock/WindowsHello.cpp) + list(APPEND gui_SOURCES quickunlock/WindowsHello.cpp) endif() endif() if(WITH_XC_YUBIKEY) - set(keepassx_SOURCES ${keepassx_SOURCES} gui/osutils/DeviceListener.cpp) + list(APPEND gui_SOURCES gui/osutils/DeviceListener.cpp) if(APPLE) - set(keepassx_SOURCES ${keepassx_SOURCES} gui/osutils/macutils/DeviceListenerMac.cpp) + list(APPEND gui_SOURCES gui/osutils/macutils/DeviceListenerMac.cpp) elseif(UNIX) - set(keepassx_SOURCES ${keepassx_SOURCES} gui/osutils/nixutils/DeviceListenerLibUsb.cpp) + list(APPEND gui_SOURCES gui/osutils/nixutils/DeviceListenerLibUsb.cpp) elseif(WIN32) - set(keepassx_SOURCES ${keepassx_SOURCES} gui/osutils/winutils/DeviceListenerWin.cpp) + list(APPEND gui_SOURCES gui/osutils/winutils/DeviceListenerWin.cpp) endif() endif() -set(keepassx_SOURCES ${keepassx_SOURCES} - ../share/icons/icons.qrc - ../share/wizard/wizard.qrc) - -set(keepassx_SOURCES_MAINEXE main.cpp) - -add_feature_info(Auto-Type WITH_XC_AUTOTYPE "Automatic password typing") -add_feature_info(Networking WITH_XC_NETWORKING "Compile KeePassXC with network access code (e.g. for downloading website icons)") -add_feature_info(KeePassXC-Browser WITH_XC_BROWSER "Browser integration with KeePassXC-Browser") -add_feature_info(Passkeys WITH_XC_BROWSER_PASSKEYS "Passkeys support for browser integration") -add_feature_info(SSHAgent WITH_XC_SSHAGENT "SSH agent integration compatible with KeeAgent") -add_feature_info(KeeShare WITH_XC_KEESHARE "Sharing integration with KeeShare") -add_feature_info(YubiKey WITH_XC_YUBIKEY "YubiKey HMAC-SHA1 challenge-response") -add_feature_info(UpdateCheck WITH_XC_UPDATECHECK "Automatic update checking") -if(UNIX AND NOT APPLE) - add_feature_info(FdoSecrets WITH_XC_FDOSECRETS "Implement freedesktop.org Secret Storage Spec server side API.") -endif() - add_subdirectory(browser) add_subdirectory(proxy) if(WITH_XC_BROWSER) - set(keepassxcbrowser_LIB keepassxcbrowser) - set(keepassx_SOURCES ${keepassx_SOURCES} + set(browser_LIB browser) + list(APPEND gui_SOURCES gui/dbsettings/DatabaseSettingsWidgetBrowser.cpp gui/entry/EntryURLModel.cpp gui/reports/ReportsWidgetBrowserStatistics.cpp @@ -286,7 +288,7 @@ if(WITH_XC_BROWSER) endif() if(WITH_XC_BROWSER_PASSKEYS) - set(keepassx_SOURCES ${keepassx_SOURCES} + list(APPEND gui_SOURCES gui/reports/ReportsWidgetPasskeys.cpp gui/reports/ReportsPagePasskeys.cpp gui/passkeys/PasskeyExporter.cpp @@ -318,7 +320,6 @@ endif() add_subdirectory(thirdparty) set(autotype_SOURCES - core/Tools.cpp autotype/AutoType.cpp autotype/AutoTypeAction.cpp autotype/AutoTypeMatchModel.cpp @@ -327,57 +328,42 @@ set(autotype_SOURCES autotype/PickcharsDialog.cpp autotype/WindowSelectComboBox.cpp) -if(WIN32) - set(keepassx_SOURCES_MAINEXE ${keepassx_SOURCES_MAINEXE} ${CMAKE_SOURCE_DIR}/share/windows/icon.rc) -endif() +add_library(autotype STATIC ${autotype_SOURCES}) +target_link_libraries(autotype Qt5::Core Qt5::Widgets) if(WITH_XC_YUBIKEY) - list(APPEND keepassx_SOURCES + list(APPEND core_SOURCES keys/drivers/YubiKey.h keys/drivers/YubiKey.cpp keys/drivers/YubiKeyInterface.cpp keys/drivers/YubiKeyInterfaceUSB.cpp keys/drivers/YubiKeyInterfacePCSC.cpp) else() - list(APPEND keepassx_SOURCES + list(APPEND core_SOURCES keys/drivers/YubiKey.h keys/drivers/YubiKeyStub.cpp) endif() if(WITH_XC_NETWORKING) - list(APPEND keepassx_SOURCES - core/HibpDownloader.cpp - core/NetworkManager.cpp + list(APPEND gui_SOURCES + networking/HibpDownloader.cpp + networking/NetworkManager.cpp + networking/UpdateChecker.cpp gui/UpdateCheckDialog.cpp gui/IconDownloader.cpp - gui/IconDownloaderDialog.cpp - updatecheck/UpdateChecker.cpp) -endif() - -if(APPLE) - list(APPEND keepassx_SOURCES quickunlock/TouchID.mm) - # TODO: Remove -Wno-error once deprecation warnings have been resolved. - set_source_files_properties(quickunlock/TouchID.mm PROPERTY COMPILE_FLAGS "-Wno-old-style-cast") + gui/IconDownloaderDialog.cpp) endif() configure_file(config-keepassx.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-keepassx.h) configure_file(git-info.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/git-info.h) -add_library(autotype STATIC ${autotype_SOURCES}) -target_link_libraries(autotype Qt5::Core Qt5::Widgets) - -add_library(keepassx_core STATIC ${keepassx_SOURCES}) - -set_target_properties(keepassx_core PROPERTIES COMPILE_DEFINITIONS KEEPASSX_BUILDING_CORE) -target_link_libraries(keepassx_core - autotype - ${keepassxcbrowser_LIB} +# Core Library Definition +add_library(keepassxc_core STATIC ${core_SOURCES}) +set_target_properties(keepassxc_core PROPERTIES COMPILE_DEFINITIONS KEEPASSX_BUILDING_CORE) +target_link_libraries(keepassxc_core ${qrcode_LIB} - ${fdosecrets_LIB} Qt5::Core Qt5::Concurrent - Qt5::Network - Qt5::Widgets ${BOTAN_LIBRARIES} ${PCSC_LIBRARIES} ${ZXCVBN_LIBRARIES} @@ -385,39 +371,45 @@ target_link_libraries(keepassx_core ${MINIZIP_LIBRARIES} ${ARGON2_LIBRARIES} ${KEYUTILS_LIBRARIES} - ${thirdparty_LIBRARIES} - ) + ${thirdparty_LIBRARIES}) -if(WITH_XC_SSHAGENT) - target_link_libraries(keepassx_core sshagent) -endif() -if(WITH_XC_KEESHARE) - target_link_libraries(keepassx_core keeshare) -endif() +# GUI Library Definition +add_library(keepassxc_gui STATIC ${gui_SOURCES}) +set_target_properties(keepassxc_gui PROPERTIES COMPILE_DEFINITIONS KEEPASSX_BUILDING_CORE) +target_link_libraries(keepassxc_gui + keepassxc_core + Qt5::Network + Qt5::Widgets + autotype + ${browser_LIB} + ${fdosecrets_LIB} + ${keeshare_LIB} + ${sshagent_LIB}) if(APPLE) - target_link_libraries(keepassx_core "-framework Foundation -framework AppKit -framework Carbon -framework Security -framework LocalAuthentication") + target_link_libraries(keepassxc_gui "-framework Foundation -framework AppKit -framework Carbon -framework Security -framework LocalAuthentication") if(Qt5MacExtras_FOUND) - target_link_libraries(keepassx_core Qt5::MacExtras) + target_link_libraries(keepassxc_gui Qt5::MacExtras) endif() endif() if(HAIKU) - target_link_libraries(keepassx_core network) + target_link_libraries(keepassxc_gui network) endif() if(UNIX AND NOT APPLE) - target_link_libraries(keepassx_core Qt5::DBus ${LIBUSB_LIBRARIES}) + target_link_libraries(keepassxc_core Qt5::DBus ${LIBUSB_LIBRARIES}) if(WITH_XC_X11) - target_link_libraries(keepassx_core Qt5::X11Extras X11) + target_link_libraries(keepassxc_gui Qt5::X11Extras X11) endif() include_directories(${Qt5Gui_PRIVATE_INCLUDE_DIRS}) endif() if(WIN32) - target_link_libraries(keepassx_core Wtsapi32.lib Ws2_32.lib) + target_link_libraries(keepassxc_gui Wtsapi32.lib Ws2_32.lib) if (MSVC) - target_link_libraries(keepassx_core WindowsApp.lib) + target_link_libraries(keepassxc_gui WindowsApp.lib) endif() endif() +# Main Executable Defintion if(WIN32) include(GenerateProductVersion) generate_product_version( @@ -430,11 +422,11 @@ if(WIN32) ) endif() -add_executable(${PROGNAME} WIN32 ${keepassx_SOURCES_MAINEXE} ${WIN32_ProductVersionFiles}) -target_link_libraries(${PROGNAME} keepassx_core) - +add_executable(${PROGNAME} WIN32 main.cpp ${WIN32_ProductVersionFiles}) +target_link_libraries(${PROGNAME} keepassxc_gui) set_target_properties(${PROGNAME} PROPERTIES ENABLE_EXPORTS ON) +# macOS App Bundle if(APPLE AND WITH_APP_BUNDLE) install(FILES ${CMAKE_SOURCE_DIR}/share/macosx/embedded.provisionprofile DESTINATION ${BUNDLE_INSTALL_DIR}) configure_file(${CMAKE_SOURCE_DIR}/share/macosx/Info.plist.cmake ${CMAKE_CURRENT_BINARY_DIR}/Info.plist) @@ -463,6 +455,7 @@ install(TARGETS ${PROGNAME} BUNDLE DESTINATION . COMPONENT Runtime RUNTIME DESTINATION ${BIN_INSTALL_DIR} COMPONENT Runtime) +# Windows Installer Definition if(WIN32) if(${CMAKE_SIZEOF_VOID_P} EQUAL "8") set(OUTPUT_FILE_POSTFIX "Win64") diff --git a/src/autotype/test/CMakeLists.txt b/src/autotype/test/CMakeLists.txt index 453e36af5..e27f2b1d9 100644 --- a/src/autotype/test/CMakeLists.txt +++ b/src/autotype/test/CMakeLists.txt @@ -1,4 +1,4 @@ set(autotype_test_SOURCES AutoTypeTest.cpp) add_library(keepassxc-autotype-test MODULE ${autotype_test_SOURCES}) -target_link_libraries(keepassxc-autotype-test keepassx_core ${autotype_LIB} Qt5::Core Qt5::Widgets) +target_link_libraries(keepassxc-autotype-test keepassxc_gui ${autotype_LIB} Qt5::Core Qt5::Widgets) diff --git a/src/autotype/windows/CMakeLists.txt b/src/autotype/windows/CMakeLists.txt index 33bd54c58..5b9cbecff 100644 --- a/src/autotype/windows/CMakeLists.txt +++ b/src/autotype/windows/CMakeLists.txt @@ -1,7 +1,7 @@ set(autotype_win_SOURCES AutoTypeWindows.cpp) add_library(keepassxc-autotype-windows MODULE ${autotype_win_SOURCES}) -target_link_libraries(keepassxc-autotype-windows keepassx_core ${autotype_LIB} Qt5::Core Qt5::Widgets) +target_link_libraries(keepassxc-autotype-windows keepassxc_gui ${autotype_LIB} Qt5::Core Qt5::Widgets) install(TARGETS keepassxc-autotype-windows BUNDLE DESTINATION . COMPONENT Runtime LIBRARY DESTINATION ${PLUGIN_INSTALL_DIR} COMPONENT Runtime) diff --git a/src/autotype/xcb/CMakeLists.txt b/src/autotype/xcb/CMakeLists.txt index 0704de639..f14017f63 100644 --- a/src/autotype/xcb/CMakeLists.txt +++ b/src/autotype/xcb/CMakeLists.txt @@ -3,7 +3,7 @@ include_directories(SYSTEM ${X11_X11_INCLUDE_PATH}) set(autotype_XCB_SOURCES AutoTypeXCB.cpp) add_library(keepassxc-autotype-xcb MODULE ${autotype_XCB_SOURCES}) -target_link_libraries(keepassxc-autotype-xcb keepassx_core Qt5::Core Qt5::Widgets Qt5::X11Extras ${X11_X11_LIB} ${X11_Xi_LIB} ${X11_XTest_LIB}) +target_link_libraries(keepassxc-autotype-xcb keepassxc_gui Qt5::Core Qt5::Widgets Qt5::X11Extras ${X11_X11_LIB} ${X11_Xi_LIB} ${X11_XTest_LIB}) install(TARGETS keepassxc-autotype-xcb BUNDLE DESTINATION . COMPONENT Runtime LIBRARY DESTINATION ${PLUGIN_INSTALL_DIR} COMPONENT Runtime) diff --git a/src/browser/BrowserService.cpp b/src/browser/BrowserService.cpp index cbdf2e201..67e4b9c10 100644 --- a/src/browser/BrowserService.cpp +++ b/src/browser/BrowserService.cpp @@ -25,9 +25,9 @@ #include "BrowserMessageBuilder.h" #include "BrowserSettings.h" #include "core/Tools.h" -#include "core/UrlTools.h" #include "gui/MainWindow.h" #include "gui/MessageBox.h" +#include "gui/UrlTools.h" #include "gui/osutils/OSUtils.h" #ifdef WITH_XC_BROWSER_PASSKEYS #include "BrowserPasskeys.h" diff --git a/src/browser/CMakeLists.txt b/src/browser/CMakeLists.txt index 54c089d7f..7942be430 100644 --- a/src/browser/CMakeLists.txt +++ b/src/browser/CMakeLists.txt @@ -16,7 +16,7 @@ if(WITH_XC_BROWSER) include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) - set(keepassxcbrowser_SOURCES + set(browser_SOURCES BrowserAccessControlDialog.cpp BrowserAction.cpp BrowserEntryConfig.cpp @@ -32,7 +32,7 @@ if(WITH_XC_BROWSER) NativeMessageInstaller.cpp) if(WITH_XC_BROWSER_PASSKEYS) - list(APPEND keepassxcbrowser_SOURCES + list(APPEND browser_SOURCES BrowserCbor.cpp BrowserPasskeys.cpp BrowserPasskeysClient.cpp @@ -40,6 +40,6 @@ if(WITH_XC_BROWSER) PasskeyUtils.cpp) endif() - add_library(keepassxcbrowser STATIC ${keepassxcbrowser_SOURCES}) - target_link_libraries(keepassxcbrowser Qt5::Core Qt5::Concurrent Qt5::Widgets Qt5::Network ${BOTAN_LIBRARIES}) + add_library(browser STATIC ${browser_SOURCES}) + target_link_libraries(browser Qt5::Core Qt5::Concurrent Qt5::Widgets Qt5::Network ${BOTAN_LIBRARIES}) endif() diff --git a/src/browser/PasskeyUtils.cpp b/src/browser/PasskeyUtils.cpp index fac9af09b..6ac448932 100644 --- a/src/browser/PasskeyUtils.cpp +++ b/src/browser/PasskeyUtils.cpp @@ -19,7 +19,7 @@ #include "BrowserMessageBuilder.h" #include "BrowserPasskeys.h" #include "core/Tools.h" -#include "core/UrlTools.h" +#include "gui/UrlTools.h" #include #include diff --git a/src/cli/CMakeLists.txt b/src/cli/CMakeLists.txt index 5d2bb6ba1..ecd5da284 100644 --- a/src/cli/CMakeLists.txt +++ b/src/cli/CMakeLists.txt @@ -58,7 +58,7 @@ add_executable(keepassxc-cli keepassxc-cli.cpp) target_link_libraries(keepassxc-cli ${GPGERROR_LIBRARIES} cli - keepassx_core) + keepassxc_core) install(TARGETS keepassxc-cli BUNDLE DESTINATION . COMPONENT Runtime diff --git a/src/core/Entry.cpp b/src/core/Entry.cpp index b05650c6e..674ec342e 100644 --- a/src/core/Entry.cpp +++ b/src/core/Entry.cpp @@ -802,10 +802,21 @@ void Entry::addHistoryItem(Entry* entry) { Q_ASSERT(!entry->parent()); + entry->setHistoryOwner(this); m_history.append(entry); emitModified(); } +void Entry::setHistoryOwner(Entry* entry) +{ + m_historyOwner = entry; +} + +Entry* Entry::historyOwner() const +{ + return m_historyOwner; +} + void Entry::removeHistoryItems(const QList& historyEntries) { if (historyEntries.isEmpty()) { diff --git a/src/core/Entry.h b/src/core/Entry.h index 91ca9af06..e434d8417 100644 --- a/src/core/Entry.h +++ b/src/core/Entry.h @@ -168,6 +168,8 @@ public: QList historyItems(); const QList& historyItems() const; void addHistoryItem(Entry* entry); + void setHistoryOwner(Entry* entry); + Entry* historyOwner() const; void removeHistoryItems(const QList& historyEntries); void truncateHistory(); @@ -294,6 +296,7 @@ private: QPointer m_autoTypeAssociations; QPointer m_customData; QList m_history; // Items sorted from oldest to newest + QPointer m_historyOwner; QScopedPointer m_tmpHistoryItem; bool m_modifiedSinceBegin; diff --git a/src/core/Group.cpp b/src/core/Group.cpp index bc934d35d..b7182740f 100644 --- a/src/core/Group.cpp +++ b/src/core/Group.cpp @@ -247,6 +247,20 @@ bool Group::isEmpty() const return !hasChildren() && m_entries.isEmpty(); } +// TODO: Refactor this when KeeShare is refactored +bool Group::isShared() const +{ + auto group = this; + do { + if (group->customData()->contains("KeeShare/Reference")) { + return true; + } + group = group->m_parent; + } while (group); + + return false; +} + CustomData* Group::customData() { return m_customData; diff --git a/src/core/Group.h b/src/core/Group.h index 510ecdc37..95489bc59 100644 --- a/src/core/Group.h +++ b/src/core/Group.h @@ -98,6 +98,7 @@ public: bool isExpired() const; bool isRecycled() const; bool isEmpty() const; + bool isShared() const; CustomData* customData(); const CustomData* customData() const; Group::TriState resolveCustomDataTriState(const QString& key, bool checkParent = true) const; diff --git a/src/format/Kdbx4Writer.cpp b/src/format/Kdbx4Writer.cpp index d8f412b05..1c728ac81 100644 --- a/src/format/Kdbx4Writer.cpp +++ b/src/format/Kdbx4Writer.cpp @@ -23,10 +23,6 @@ #include "crypto/CryptoHash.h" #include "crypto/Random.h" #include "format/KeePass2RandomStream.h" -#ifdef WITH_XC_KEESHARE -#include "keeshare/KeeShare.h" -#include "keeshare/KeeShareSettings.h" -#endif #include "streams/HmacBlockStream.h" #include "streams/SymmetricCipherStream.h" #include "streams/qtiocompressor.h" @@ -232,8 +228,12 @@ KdbxXmlWriter::BinaryIdxMap Kdbx4Writer::writeAttachments(QIODevice* device, Dat #ifdef WITH_XC_KEESHARE // Namespace KeeShare attachments so they don't get deduplicated together with attachments // from other databases. Prevents potential filesize side channels. - if (auto shared = KeeShare::resolveSharedGroup(entry->group())) { - hash.addData(KeeShare::referenceOf(shared).uuid.toByteArray()); + auto group = entry->group(); + if (!group && entry->historyOwner()) { + group = entry->historyOwner()->group(); + } + if (group && group->isShared()) { + hash.addData(group->uuid().toByteArray()); } else { hash.addData(db->uuid().toByteArray()); } diff --git a/src/format/KdbxXmlWriter.cpp b/src/format/KdbxXmlWriter.cpp index 53a7bfae9..142f4b7e3 100644 --- a/src/format/KdbxXmlWriter.cpp +++ b/src/format/KdbxXmlWriter.cpp @@ -24,8 +24,6 @@ #include "core/Endian.h" #include "crypto/CryptoHash.h" #include "format/KeePass2RandomStream.h" -#include "keeshare/KeeShare.h" -#include "keeshare/KeeShareSettings.h" #include "streams/qtiocompressor.h" /** @@ -114,8 +112,12 @@ void KdbxXmlWriter::fillBinaryIdxMap() #ifdef WITH_XC_KEESHARE // Namespace KeeShare attachments so they don't get deduplicated together with attachments // from other databases. Prevents potential filesize side channels. - if (auto shared = KeeShare::resolveSharedGroup(entry->group())) { - hash.addData(KeeShare::referenceOf(shared).uuid.toByteArray()); + auto group = entry->group(); + if (!group && entry->historyOwner()) { + group = entry->historyOwner()->group(); + } + if (group && group->isShared()) { + hash.addData(group->uuid().toByteArray()); } else { hash.addData(m_db->uuid().toByteArray()); } diff --git a/src/gui/Clipboard.h b/src/gui/Clipboard.h index 4dc2f3127..147b65aff 100644 --- a/src/gui/Clipboard.h +++ b/src/gui/Clipboard.h @@ -22,7 +22,7 @@ #include #include #ifdef Q_OS_MACOS -#include "core/MacPasteboard.h" +#include "gui/osutils/macutils/MacPasteboard.h" #include #endif diff --git a/src/gui/IconDownloader.cpp b/src/gui/IconDownloader.cpp index 1adb26922..6f3891772 100644 --- a/src/gui/IconDownloader.cpp +++ b/src/gui/IconDownloader.cpp @@ -17,8 +17,8 @@ #include "IconDownloader.h" #include "core/Config.h" -#include "core/NetworkManager.h" -#include "core/UrlTools.h" +#include "gui/UrlTools.h" +#include "networking/NetworkManager.h" #include #include diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index 57ea6f4fb..e80a9e7ad 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -50,7 +50,7 @@ #ifdef WITH_XC_UPDATECHECK #include "gui/UpdateCheckDialog.h" -#include "updatecheck/UpdateChecker.h" +#include "networking/UpdateChecker.h" #endif #ifdef WITH_XC_SSHAGENT diff --git a/src/gui/URLEdit.cpp b/src/gui/URLEdit.cpp index f5fbbb24b..fed277f00 100644 --- a/src/gui/URLEdit.cpp +++ b/src/gui/URLEdit.cpp @@ -18,9 +18,8 @@ #include "URLEdit.h" -#include "core/Tools.h" -#include "core/UrlTools.h" #include "gui/Icons.h" +#include "gui/UrlTools.h" #include "gui/styles/StateColorPalette.h" URLEdit::URLEdit(QWidget* parent) diff --git a/src/gui/UpdateCheckDialog.cpp b/src/gui/UpdateCheckDialog.cpp index da3169901..6d7015f73 100644 --- a/src/gui/UpdateCheckDialog.cpp +++ b/src/gui/UpdateCheckDialog.cpp @@ -22,7 +22,7 @@ #include "config-keepassx.h" #include "gui/Icons.h" -#include "updatecheck/UpdateChecker.h" +#include "networking/UpdateChecker.h" UpdateCheckDialog::UpdateCheckDialog(QWidget* parent) : QDialog(parent) diff --git a/src/core/UrlTools.cpp b/src/gui/UrlTools.cpp similarity index 100% rename from src/core/UrlTools.cpp rename to src/gui/UrlTools.cpp diff --git a/src/core/UrlTools.h b/src/gui/UrlTools.h similarity index 96% rename from src/core/UrlTools.h rename to src/gui/UrlTools.h index 9a229e39f..3f91696b4 100644 --- a/src/core/UrlTools.h +++ b/src/gui/UrlTools.h @@ -19,10 +19,12 @@ #define KEEPASSXC_URLTOOLS_H #include "config-keepassx.h" -#include #include #include #include +#if defined(WITH_XC_NETWORKING) || defined(WITH_XC_BROWSER) +#include +#endif class UrlTools : public QObject { diff --git a/src/gui/entry/EntryURLModel.cpp b/src/gui/entry/EntryURLModel.cpp index 046fbee61..b43343026 100644 --- a/src/gui/entry/EntryURLModel.cpp +++ b/src/gui/entry/EntryURLModel.cpp @@ -20,8 +20,8 @@ #include "browser/BrowserService.h" #include "core/EntryAttributes.h" -#include "core/UrlTools.h" #include "gui/Icons.h" +#include "gui/UrlTools.h" #include "gui/styles/StateColorPalette.h" EntryURLModel::EntryURLModel(QObject* parent) diff --git a/src/core/MacPasteboard.cpp b/src/gui/osutils/macutils/MacPasteboard.cpp similarity index 100% rename from src/core/MacPasteboard.cpp rename to src/gui/osutils/macutils/MacPasteboard.cpp diff --git a/src/core/MacPasteboard.h b/src/gui/osutils/macutils/MacPasteboard.h similarity index 100% rename from src/core/MacPasteboard.h rename to src/gui/osutils/macutils/MacPasteboard.h diff --git a/src/gui/reports/ReportsWidgetHibp.h b/src/gui/reports/ReportsWidgetHibp.h index 5410417b2..29a2c4ff1 100644 --- a/src/gui/reports/ReportsWidgetHibp.h +++ b/src/gui/reports/ReportsWidgetHibp.h @@ -24,7 +24,7 @@ #include #ifdef WITH_XC_NETWORKING -#include "core/HibpDownloader.h" +#include "networking/HibpDownloader.h" #endif class Database; diff --git a/src/core/HibpDownloader.cpp b/src/networking/HibpDownloader.cpp similarity index 99% rename from src/core/HibpDownloader.cpp rename to src/networking/HibpDownloader.cpp index 9ff181093..8b09ce2c4 100644 --- a/src/core/HibpDownloader.cpp +++ b/src/networking/HibpDownloader.cpp @@ -16,7 +16,7 @@ */ #include "HibpDownloader.h" -#include "core/NetworkManager.h" +#include "NetworkManager.h" #include #include diff --git a/src/core/HibpDownloader.h b/src/networking/HibpDownloader.h similarity index 100% rename from src/core/HibpDownloader.h rename to src/networking/HibpDownloader.h diff --git a/src/core/NetworkManager.cpp b/src/networking/NetworkManager.cpp similarity index 100% rename from src/core/NetworkManager.cpp rename to src/networking/NetworkManager.cpp diff --git a/src/core/NetworkManager.h b/src/networking/NetworkManager.h similarity index 100% rename from src/core/NetworkManager.h rename to src/networking/NetworkManager.h diff --git a/src/updatecheck/UpdateChecker.cpp b/src/networking/UpdateChecker.cpp similarity index 99% rename from src/updatecheck/UpdateChecker.cpp rename to src/networking/UpdateChecker.cpp index ff2240628..ea3d435df 100644 --- a/src/updatecheck/UpdateChecker.cpp +++ b/src/networking/UpdateChecker.cpp @@ -17,10 +17,10 @@ #include "UpdateChecker.h" +#include "NetworkManager.h" #include "config-keepassx.h" #include "core/Clock.h" #include "core/Config.h" -#include "core/NetworkManager.h" #include #include diff --git a/src/updatecheck/UpdateChecker.h b/src/networking/UpdateChecker.h similarity index 100% rename from src/updatecheck/UpdateChecker.h rename to src/networking/UpdateChecker.h diff --git a/src/thirdparty/ykcore/CMakeLists.txt b/src/thirdparty/ykcore/CMakeLists.txt index 103349f22..ecf3ab2b2 100644 --- a/src/thirdparty/ykcore/CMakeLists.txt +++ b/src/thirdparty/ykcore/CMakeLists.txt @@ -40,5 +40,5 @@ elseif(UNIX AND NOT APPLE) target_compile_definitions(ykcore PRIVATE _GNU_SOURCE) elseif(APPLE) target_sources(ykcore PRIVATE ykcore_osx.c) - target_link_libraries(ykcore PUBLIC "-framework IOKit") + target_link_libraries(ykcore PUBLIC "-framework IOKit -framework Foundation") endif() diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 8fee4e8c2..8ed6868df 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -90,7 +90,7 @@ macro(add_unit_test) endif() endmacro(add_unit_test) -set(TEST_LIBRARIES keepassx_core Qt5::Test) +set(TEST_LIBRARIES keepassxc_gui Qt5::Test) set(testsupport_SOURCES modeltest.cpp @@ -143,7 +143,7 @@ add_unit_test(NAME testkeepass1reader SOURCES TestKeePass1Reader.cpp LIBS ${TEST_LIBRARIES}) add_unit_test(NAME testimports SOURCES TestImports.cpp - LIBS ${TEST_LIBRARIES}) + LIBS ${TEST_LIBRARIES}) if(WITH_XC_NETWORKING) add_unit_test(NAME testupdatecheck SOURCES TestUpdateCheck.cpp @@ -163,7 +163,7 @@ if(WITH_XC_SSHAGENT) LIBS sshagent ${TEST_LIBRARIES}) if(NOT WIN32) add_unit_test(NAME testsshagent SOURCES TestSSHAgent.cpp - LIBS ${TEST_LIBRARIES}) + LIBS sshagent ${TEST_LIBRARIES}) endif() endif() @@ -195,7 +195,7 @@ add_unit_test(NAME testcsvparser SOURCES TestCsvParser.cpp LIBS ${TEST_LIBRARIES}) add_unit_test(NAME testrandomgenerator SOURCES TestRandomGenerator.cpp - LIBS testsupport ${TEST_LIBRARIES}) + LIBS testsupport ${TEST_LIBRARIES}) add_unit_test(NAME testentrysearcher SOURCES TestEntrySearcher.cpp LIBS ${TEST_LIBRARIES}) @@ -225,22 +225,16 @@ add_unit_test(NAME testconfig SOURCES TestConfig.cpp if(WITH_XC_FDOSECRETS) add_unit_test(NAME testfdosecrets SOURCES TestFdoSecrets.cpp - LIBS testsupport ${TEST_LIBRARIES}) + LIBS testsupport fdosecrets ${TEST_LIBRARIES}) endif() if(WITH_XC_BROWSER) add_unit_test(NAME testbrowser SOURCES TestBrowser.cpp - LIBS ${TEST_LIBRARIES}) + LIBS browser ${TEST_LIBRARIES}) if(WITH_XC_BROWSER_PASSKEYS) - # Prevent duplicate linking with macOS - if(APPLE) - add_unit_test(NAME testpasskeys SOURCES TestPasskeys.cpp - LIBS ${TEST_LIBRARIES}) - else() - add_unit_test(NAME testpasskeys SOURCES TestPasskeys.cpp - LIBS keepassxcbrowser ${TEST_LIBRARIES}) - endif() + add_unit_test(NAME testpasskeys SOURCES TestPasskeys.cpp + LIBS browser ${TEST_LIBRARIES}) endif() endif() diff --git a/tests/TestKdbx4.cpp b/tests/TestKdbx4.cpp index cf103c319..3233d570a 100644 --- a/tests/TestKdbx4.cpp +++ b/tests/TestKdbx4.cpp @@ -24,10 +24,6 @@ #include "format/KeePass2.h" #include "format/KeePass2Reader.h" #include "format/KeePass2Writer.h" -#ifdef WITH_XC_KEESHARE -#include "keeshare/KeeShare.h" -#include "keeshare/KeeShareSettings.h" -#endif #include "keys/FileKey.h" #include "keys/PasswordKey.h" #include "mock/MockChallengeResponseKey.h" @@ -441,13 +437,8 @@ void TestKdbx4Format::testAttachmentIndexStability() group2->setUuid(QUuid::createUuid()); QVERIFY(!group2->uuid().isNull()); group2->setParent(group1); -#ifdef WITH_XC_KEESHARE - KeeShareSettings::Reference ref; - ref.type = KeeShareSettings::SynchronizeWith; - ref.path = "123"; - KeeShare::setReferenceTo(group2, ref); - QVERIFY(KeeShare::isShared(group2)); -#endif + group2->customData()->set("KeeShare/Reference", "value doesn't matter"); + QVERIFY(group2->isShared()); auto attachment1 = QByteArray("qwerty"); auto attachment2 = QByteArray("asdf"); @@ -510,9 +501,9 @@ void TestKdbx4Format::testAttachmentIndexStability() QCOMPARE(a2->value("a"), attachment1); QCOMPARE(a2->value("b"), attachment2); -#ifdef WITH_XC_KEESHARE - QVERIFY(KeeShare::isShared(db2->rootGroup()->findEntryByUuid(uuid3)->group())); -#endif + auto sharedGroup = db2->rootGroup()->findEntryByUuid(uuid3)->group(); + QVERIFY(sharedGroup->isShared()); + auto a3 = db2->rootGroup()->findEntryByUuid(uuid3)->attachments(); QCOMPARE(a3->keys().size(), 4); QCOMPARE(a3->values().size(), 3); diff --git a/tests/TestUpdateCheck.cpp b/tests/TestUpdateCheck.cpp index df2643fad..f89757ea6 100644 --- a/tests/TestUpdateCheck.cpp +++ b/tests/TestUpdateCheck.cpp @@ -17,7 +17,7 @@ #include "TestUpdateCheck.h" #include "crypto/Crypto.h" -#include "updatecheck/UpdateChecker.h" +#include "networking/UpdateChecker.h" #include diff --git a/tests/TestUrlTools.h b/tests/TestUrlTools.h index 74e91c174..dea7ca395 100644 --- a/tests/TestUrlTools.h +++ b/tests/TestUrlTools.h @@ -18,7 +18,7 @@ #ifndef KEEPASSXC_TESTURLTOOLS_H #define KEEPASSXC_TESTURLTOOLS_H -#include "core/UrlTools.h" +#include "gui/UrlTools.h" #include #include