summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2022-09-29 21:36:46 +0200
committerMilan Crha <mcrha@redhat.com>2022-09-29 22:20:11 +0200
commit684897d4516b086aa0b4b27fa0298d2ea5f7fbcb (patch)
tree1432cd2897697a497c499ee201e344f27d051fb6
parent0318020bae437cb8f6ec8dbcf68ed5e0a5ea95d0 (diff)
downloadgnome-online-accounts-224-ability-to-restrict-which-services-of-a-particular-account-type-are-available.tar.gz
goaprovider: Prefer goa.conf over GSettings for enabled providers224-ability-to-restrict-which-services-of-a-particular-account-type-are-available
This prefers [providers] enable=owncloud,kerberos in goa.conf in the system config directory over GSettings' value, if present, to limit which providers can be enabled. When the goa.conf doesn't exist, or the group/key does not exist, then the value from the GSettings is used instead. Related to https://gitlab.gnome.org/GNOME/gnome-online-accounts/-/issues/224
-rw-r--r--data/org.gnome.online-accounts.gschema.xml2
-rw-r--r--src/goabackend/goaprovider.c30
2 files changed, 27 insertions, 5 deletions
diff --git a/data/org.gnome.online-accounts.gschema.xml b/data/org.gnome.online-accounts.gschema.xml
index 46b79b2..4419d61 100644
--- a/data/org.gnome.online-accounts.gschema.xml
+++ b/data/org.gnome.online-accounts.gschema.xml
@@ -6,6 +6,8 @@
<summary>List of providers that are allowed to be loaded</summary>
<description>
A list of strings representing the providers that are allowed to be loaded (default: 'all'). This is only evaluated on startup.
+
+ Deprecated: use goa.conf in the system config directory instead, with a key [providers] enable=all instead. The key is comma-separated list of the provider names.
</description>
</key>
</schema>
diff --git a/src/goabackend/goaprovider.c b/src/goabackend/goaprovider.c
index 89e01f1..939040a 100644
--- a/src/goabackend/goaprovider.c
+++ b/src/goabackend/goaprovider.c
@@ -1116,14 +1116,35 @@ goa_provider_ensure_builtins_loaded (void)
if (g_once_init_enter (&once_init_value))
{
- GSettings *settings;
- gchar **whitelisted_providers;
+ GKeyFile *goa_conf;
+ gchar **whitelisted_providers = NULL;
guint i;
guint j;
gboolean all = FALSE;
- settings = g_settings_new (GOA_SETTINGS_SCHEMA);
- whitelisted_providers = g_settings_get_strv (settings, GOA_SETTINGS_WHITELISTED_PROVIDERS);
+ goa_conf = goa_util_open_goa_conf ();
+ if (goa_conf)
+ {
+ whitelisted_providers = g_key_file_get_string_list (goa_conf, "providers", "enable", NULL, NULL);
+ /* Let the empty array be like 'all' */
+ if (whitelisted_providers && !*whitelisted_providers)
+ {
+ g_strfreev (whitelisted_providers);
+ whitelisted_providers = g_new0 (gchar *, 2);
+ whitelisted_providers[0] = g_strdup ("all");
+ whitelisted_providers[1] = NULL;
+ }
+ g_clear_pointer (&goa_conf, g_key_file_free);
+ }
+
+ if (!whitelisted_providers)
+ {
+ GSettings *settings;
+
+ settings = g_settings_new (GOA_SETTINGS_SCHEMA);
+ whitelisted_providers = g_settings_get_strv (settings, GOA_SETTINGS_WHITELISTED_PROVIDERS);
+ g_object_unref (settings);
+ }
/* Enable everything if there is 'all'. */
for (i = 0; whitelisted_providers[i] != NULL; i++)
@@ -1162,7 +1183,6 @@ goa_provider_ensure_builtins_loaded (void)
cleanup:
g_strfreev (whitelisted_providers);
- g_object_unref (settings);
g_once_init_leave (&once_init_value, 1);
}
}