From 51725df97dd4ddf5c8da9a2f1350557614cdbb81 Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Mon, 18 Sep 2023 13:28:12 +0200 Subject: [PATCH] secret-backend: Allow override the backend also under Flatpak/Snap This can help applications, which rely on certain behavior, like when multiple processes are accessing the secrets and expect that secrets saved by one process can be read by another process. It also adds consistency, to be able to change the backend with the host system libsecret and sandboxed libsecret. Related to https://gitlab.gnome.org/GNOME/libsecret/-/issues/62 --- libsecret/secret-backend.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/libsecret/secret-backend.c b/libsecret/secret-backend.c index 75c42da..d185c89 100644 --- a/libsecret/secret-backend.c +++ b/libsecret/secret-backend.c @@ -152,18 +152,16 @@ backend_get_impl_type (void) g_type_ensure (secret_file_backend_get_type ()); #endif + envvar = g_getenv ("SECRET_BACKEND"); + if (envvar == NULL || *envvar == '\0') { + extension_name = "service"; #ifdef WITH_CRYPTO - if ((g_file_test ("/.flatpak-info", G_FILE_TEST_EXISTS) || g_getenv ("SNAP_NAME") != NULL) && - _secret_file_backend_check_portal_version ()) - extension_name = "file"; - else + if ((g_file_test ("/.flatpak-info", G_FILE_TEST_EXISTS) || g_getenv ("SNAP_NAME") != NULL) && + _secret_file_backend_check_portal_version ()) + extension_name = "file"; #endif - { - envvar = g_getenv ("SECRET_BACKEND"); - if (envvar == NULL || *envvar == '\0') - extension_name = "service"; - else - extension_name = envvar; + } else { + extension_name = envvar; } ep = g_io_extension_point_lookup (SECRET_BACKEND_EXTENSION_POINT_NAME);