[evolution-data-server/gnome-3-30] [Flatpak] Save passwords in libsecret with the same prefix as used by D-Bus services
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server/gnome-3-30] [Flatpak] Save passwords in libsecret with the same prefix as used by D-Bus services
- Date: Mon, 3 Dec 2018 10:55:22 +0000 (UTC)
commit 3ebbc3aeb909d0b5c4985a4a2bbcc90be7eb24e3
Author: Milan Crha <mcrha redhat com>
Date: Mon Dec 3 11:03:54 2018 +0100
[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.
CMakeLists.txt | 2 ++
config.h.in | 3 +++
src/libedataserver/e-secret-store.c | 8 +++++++-
src/modules/secret-monitor/module-secret-monitor.c | 10 ++++++++--
4 files changed, 20 insertions(+), 3 deletions(-)
---
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4a20ec6bb..a3da042de 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -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 ""))
# ******************************
diff --git a/config.h.in b/config.h.in
index b6e961aee..cba0afbd8 100644
--- a/config.h.in
+++ b/config.h.in
@@ -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@"
diff --git a/src/libedataserver/e-secret-store.c b/src/libedataserver/e-secret-store.c
index 96c8dbf24..e15148227 100644
--- a/src/libedataserver/e-secret-store.c
+++ b/src/libedataserver/e-secret-store.c
@@ -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
diff --git a/src/modules/secret-monitor/module-secret-monitor.c
b/src/modules/secret-monitor/module-secret-monitor.c
index 7987962ab..287a6290a 100644
--- a/src/modules/secret-monitor/module-secret-monitor.c
+++ b/src/modules/secret-monitor/module-secret-monitor.c
@@ -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. */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]