Commit 3ebbc3ae authored by Milan Crha's avatar Milan Crha

[Flatpak] Save passwords in libsecret with the same prefix as used by D-Bus services

As the passwords are saved in the host system, the eds-origin key cannot
use the same value as the host system, because otherwise the secret-monitor
module of evolution-source-registry would delete the password, because
the ESource is unknown to it. Similarly the other way around, the inner
(in Flatpak) source registry would delete system passwords, because those
ESource-s are unknown to it.
parent 621a741f
......@@ -178,6 +178,8 @@ if(NOT ("${DBUS_SERVICES_PREFIX}" STREQUAL ""))
set(CALENDAR_DBUS_SERVICE_NAME "${DBUS_SERVICES_PREFIX}.${CALENDAR_DBUS_SERVICE_NAME}")
set(SOURCES_DBUS_SERVICE_NAME "${DBUS_SERVICES_PREFIX}.${SOURCES_DBUS_SERVICE_NAME}")
set(USER_PROMPTER_DBUS_SERVICE_NAME "${DBUS_SERVICES_PREFIX}.${USER_PROMPTER_DBUS_SERVICE_NAME}")
else(NOT ("${DBUS_SERVICES_PREFIX}" STREQUAL ""))
unset(DBUS_SERVICES_PREFIX)
endif(NOT ("${DBUS_SERVICES_PREFIX}" STREQUAL ""))
# ******************************
......
......@@ -18,6 +18,9 @@
/* Package name for gettext */
#define GETTEXT_PACKAGE "@GETTEXT_PACKAGE@"
/* Defined to prefix used by the D-Bus services (usually when run in Flatpak) */
#cmakedefine DBUS_SERVICES_PREFIX "@DBUS_SERVICES_PREFIX@"
/* D-Bus service name for the address book factory */
#define ADDRESS_BOOK_DBUS_SERVICE_NAME "@ADDRESS_BOOK_DBUS_SERVICE_NAME@"
......
......@@ -254,6 +254,12 @@ e_win32_secret_delete_secret_sync (const gchar *uid,
#define KEYRING_ITEM_ATTRIBUTE_UID "e-source-uid"
#define KEYRING_ITEM_ATTRIBUTE_ORIGIN "eds-origin"
#ifdef DBUS_SERVICES_PREFIX
#define ORIGIN_KEY DBUS_SERVICES_PREFIX "." PACKAGE
#else
#define ORIGIN_KEY PACKAGE
#endif
static SecretSchema password_schema = {
"org.gnome.Evolution.Data.Source",
SECRET_SCHEMA_DONT_MATCH_NAME,
......@@ -316,7 +322,7 @@ e_secret_store_store_sync (const gchar *uid,
collection, label, secret,
cancellable, error,
KEYRING_ITEM_ATTRIBUTE_UID, uid,
KEYRING_ITEM_ATTRIBUTE_ORIGIN, PACKAGE,
KEYRING_ITEM_ATTRIBUTE_ORIGIN, ORIGIN_KEY,
NULL);
#endif
......
......@@ -57,6 +57,12 @@ struct _ESecretMonitorClass {
#define KEYRING_ITEM_ATTRIBUTE_ORIGIN "eds-origin"
#define KEYRING_ITEM_DISPLAY_FORMAT "Evolution Data Source '%s'"
#ifdef DBUS_SERVICES_PREFIX
#define ORIGIN_KEY DBUS_SERVICES_PREFIX "." PACKAGE
#else
#define ORIGIN_KEY PACKAGE
#endif
static SecretSchema password_schema = {
"org.gnome.Evolution.Data.Source",
SECRET_SCHEMA_DONT_MATCH_NAME,
......@@ -104,7 +110,7 @@ secret_monitor_scan_secrets_thread (gpointer user_data)
server = E_SOURCE_REGISTRY_SERVER (user_data);
attributes = g_hash_table_new (g_str_hash, g_str_equal);
g_hash_table_insert (attributes, (gpointer) KEYRING_ITEM_ATTRIBUTE_ORIGIN, (gpointer) PACKAGE);
g_hash_table_insert (attributes, (gpointer) KEYRING_ITEM_ATTRIBUTE_ORIGIN, (gpointer) ORIGIN_KEY);
/* List all items under our custom SecretSchema. */
list = secret_service_search_sync (
......@@ -187,7 +193,7 @@ secret_monitor_scan_secrets_timeout_cb (gpointer user_data)
extension = E_SECRET_MONITOR (user_data);
server = secret_monitor_get_server (extension);
g_debug ("Scanning and pruning saved passwords");
e_source_registry_debug_print ("Scanning and pruning saved passwords\n");
/* Do the real work in a thread, so we can use synchronous
* libsecret calls and keep the logic flow easy to follow. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment