Skip to content
Draft
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
16 changes: 14 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,13 @@ if(KPXC_FEATURE_NETWORK)
networking/UpdateChecker.cpp
gui/UpdateCheckDialog.cpp
gui/IconDownloader.cpp
gui/IconDownloaderDialog.cpp)
gui/IconDownloaderDialog.cpp
gui/remote/CloudSyncPage.cpp
gui/remote/dropbox/DropboxCloudSyncPage.cpp
gui/remote/nextcloud/NextcloudCloudSyncPage.cpp
gui/remote/nextcloud/NextcloudCloudSyncPage.h
gui/remote/nextcloud/NextcloudCloudSyncPage.ui
gui/remote/DatabaseSettingsWidgetCloudSync.cpp)
endif()

add_subdirectory(cli)
Expand All @@ -320,6 +326,11 @@ if(KPXC_FEATURE_FDOSECRETS)
set(fdosecrets_LIB fdosecrets)
endif()

add_subdirectory(remotesync)
# remotesync's foundation (provider abstraction + engine + command provider)
# is always built.
set(remotesync_LIB remotesync)

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)

Expand Down Expand Up @@ -352,7 +363,8 @@ target_link_libraries(keepassxc_gui
${browser_LIB}
${fdosecrets_LIB}
${keeshare_LIB}
${sshagent_LIB})
${sshagent_LIB}
${remotesync_LIB})

if(APPLE)
target_link_libraries(keepassxc_gui "-framework Foundation -framework AppKit -framework Carbon -framework Security -framework LocalAuthentication -framework ScreenCaptureKit")
Expand Down
22 changes: 22 additions & 0 deletions src/core/Database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,7 @@ void Database::releaseData()

m_data.clear();
m_metadata->clear();
m_syncPreviousKey.reset();

// Reset and delete the root group
auto oldGroup = setRootGroup(new Group());
Expand Down Expand Up @@ -959,6 +960,27 @@ bool Database::setKey(const QSharedPointer<const CompositeKey>& key,
return true;
}

void Database::setSyncPreviousKey(const QSharedPointer<const CompositeKey>& key)
{
// Don't overwrite an existing snapshot: if the user does A->B->C without
// an intervening successful sync, the remote still holds A and that's
// the key we need to keep.
if (m_syncPreviousKey) {
return;
}
m_syncPreviousKey = key;
}

QSharedPointer<const CompositeKey> Database::syncPreviousKey() const
{
return m_syncPreviousKey;
}

void Database::clearSyncPreviousKey()
{
m_syncPreviousKey.reset();
}

QString Database::keyError()
{
return m_keyError;
Expand Down
8 changes: 8 additions & 0 deletions src/core/Database.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,13 @@ class Database : public ModifiableObject
bool updateChangedTime = true,
bool updateTransformSalt = false,
bool transformKey = true);
/// Snapshot of the master key prior to a change-key, kept transiently so
/// the cloud-sync engine can unlock the remote DB (which still holds the
/// old key) and migrate it to the new key. Cleared on successful sync
/// upload, on releaseData (lock/close), and on destruction. Not persisted.
void setSyncPreviousKey(const QSharedPointer<const CompositeKey>& key);
QSharedPointer<const CompositeKey> syncPreviousKey() const;
void clearSyncPreviousKey();
QString keyError();
QByteArray challengeResponseKey() const;
bool challengeMasterSeed(const QByteArray& masterSeed);
Expand Down Expand Up @@ -253,6 +260,7 @@ public slots:
bool m_hasNonDataChange = false;
QString m_keyError;
bool m_isTemporaryDatabase = false;
QSharedPointer<const CompositeKey> m_syncPreviousKey;

QStringList m_commonUsernames;
QStringList m_tagList;
Expand Down
Loading