2 * Copyright © 2010 Codethink Limited
3 * Copyright © 2010 Novell, Inc.
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
18 * Authors: Vincent Untz <vuntz@gnome.org>
19 * Ryan Lortie <desrt@desrt.ca>
31 #include "gfileinfo.h"
32 #include "gfileenumerator.h"
33 #include "gfilemonitor.h"
34 #include "gsimplepermission.h"
35 #include "gsettingsbackendinternal.h"
36 #include "giomodule-priv.h"
37 #include "gportalsupport.h"
40 #define G_TYPE_KEYFILE_SETTINGS_BACKEND (g_keyfile_settings_backend_get_type ())
41 #define G_KEYFILE_SETTINGS_BACKEND(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), \
42 G_TYPE_KEYFILE_SETTINGS_BACKEND, \
43 GKeyfileSettingsBackend))
44 #define G_IS_KEYFILE_SETTINGS_BACKEND(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), \
45 G_TYPE_KEYFILE_SETTINGS_BACKEND))
48 typedef GSettingsBackendClass GKeyfileSettingsBackendClass;
55 } GKeyfileSettingsBackendProperty;
59 GSettingsBackend parent_instance;
62 GPermission *permission;
65 GKeyFile *system_keyfile;
66 GHashTable *system_locks; /* Used as a set, owning the strings it contains */
74 GFileMonitor *file_monitor;
77 GFileMonitor *dir_monitor;
78 } GKeyfileSettingsBackend;
81 #define EXTENSION_PRIORITY 10
83 #define EXTENSION_PRIORITY (glib_should_use_portal () && !glib_has_dconf_access_in_sandbox () ? 110 : 10)
86 G_DEFINE_TYPE_WITH_CODE (GKeyfileSettingsBackend,
87 g_keyfile_settings_backend,
88 G_TYPE_SETTINGS_BACKEND,
89 _g_io_modules_ensure_extension_points_registered ();
90 g_io_extension_point_implement (G_SETTINGS_BACKEND_EXTENSION_POINT_NAME,
91 g_define_type_id, "keyfile", EXTENSION_PRIORITY))
94 compute_checksum (guint8 *digest,
95 gconstpointer contents,
101 checksum = g_checksum_new (G_CHECKSUM_SHA256);
102 g_checksum_update (checksum, contents, length);
103 g_checksum_get_digest (checksum, digest, &len);
104 g_checksum_free (checksum);
105 g_assert (len == 32);
109 g_keyfile_settings_backend_keyfile_write (GKeyfileSettingsBackend *kfsb,
116 contents = g_key_file_to_data (kfsb->keyfile, &length, NULL);
117 success = g_file_replace_contents (kfsb->file, contents, length, NULL, FALSE,
118 G_FILE_CREATE_REPLACE_DESTINATION |
119 G_FILE_CREATE_PRIVATE,
122 compute_checksum (kfsb->digest, contents, length);
129 group_name_matches (const gchar *group_name,
132 /* sort of like g_str_has_prefix() except that it must be an exact
133 * match or the prefix followed by '/'.
135 * for example 'a' is a prefix of 'a' and 'a/b' but not 'ab'.
139 for (i = 0; prefix[i]; i++)
140 if (prefix[i] != group_name[i])
143 return group_name[i] == '\0' || group_name[i] == '/';
147 convert_path (GKeyfileSettingsBackend *kfsb,
152 gint key_len = strlen (key);
155 if (key_len < kfsb->prefix_len ||
156 memcmp (key, kfsb->prefix, kfsb->prefix_len) != 0)
159 key_len -= kfsb->prefix_len;
160 key += kfsb->prefix_len;
162 for (i = key_len; i >= 0; i--)
166 if (kfsb->root_group)
168 /* if a root_group was specified, make sure the user hasn't given
169 * a path that ghosts that group name
171 if (i == kfsb->root_group_len && memcmp (key, kfsb->root_group, i) == 0)
176 /* if no root_group was given, ensure that the user gave a path */
185 *group = g_memdup (key, i + 1);
189 *group = g_strdup (kfsb->root_group);
193 *basename = g_memdup (key + i + 1, key_len - i);
199 path_is_valid (GKeyfileSettingsBackend *kfsb,
202 return convert_path (kfsb, path, NULL, NULL);
206 get_from_keyfile (GKeyfileSettingsBackend *kfsb,
207 const GVariantType *type,
210 GVariant *return_value = NULL;
213 if (convert_path (kfsb, key, &group, &name))
220 sysstr = g_key_file_get_value (kfsb->system_keyfile, group, name, NULL);
221 str = g_key_file_get_value (kfsb->keyfile, group, name, NULL);
223 (g_hash_table_contains (kfsb->system_locks, key) ||
227 str = g_steal_pointer (&sysstr);
232 return_value = g_variant_parse (type, str, NULL, NULL, NULL);
234 /* As a special case, support values of type %G_VARIANT_TYPE_STRING
235 * not being quoted, since users keep forgetting to do it and then
236 * getting confused. */
237 if (return_value == NULL &&
238 g_variant_type_equal (type, G_VARIANT_TYPE_STRING) &&
241 GString *s = g_string_sized_new (strlen (str) + 2);
244 g_string_append_c (s, '\"');
248 g_string_append_c (s, '\\');
249 g_string_append_c (s, *p);
252 g_string_append_c (s, '\"');
253 return_value = g_variant_parse (type, s->str, NULL, NULL, NULL);
254 g_string_free (s, TRUE);
269 set_to_keyfile (GKeyfileSettingsBackend *kfsb,
275 if (g_hash_table_contains (kfsb->system_locks, key))
278 if (convert_path (kfsb, key, &group, &name))
282 gchar *str = g_variant_print (value, FALSE);
283 g_key_file_set_value (kfsb->keyfile, group, name, str);
284 g_variant_unref (g_variant_ref_sink (value));
294 groups = g_key_file_get_groups (kfsb->keyfile, NULL);
296 for (i = 0; groups[i]; i++)
297 if (group_name_matches (groups[i], group))
298 g_key_file_remove_group (kfsb->keyfile, groups[i], NULL);
303 g_key_file_remove_key (kfsb->keyfile, group, name, NULL);
316 g_keyfile_settings_backend_read (GSettingsBackend *backend,
318 const GVariantType *expected_type,
319 gboolean default_value)
321 GKeyfileSettingsBackend *kfsb = G_KEYFILE_SETTINGS_BACKEND (backend);
326 return get_from_keyfile (kfsb, expected_type, key);
331 GKeyfileSettingsBackend *kfsb;
336 g_keyfile_settings_backend_write_one (gpointer key,
340 WriteManyData *data = user_data;
341 gboolean success G_GNUC_UNUSED /* when compiling with G_DISABLE_ASSERT */;
343 success = set_to_keyfile (data->kfsb, key, value);
350 g_keyfile_settings_backend_check_one (gpointer key,
354 WriteManyData *data = user_data;
356 return data->failed = g_hash_table_contains (data->kfsb->system_locks, key) ||
357 !path_is_valid (data->kfsb, key);
361 g_keyfile_settings_backend_write_tree (GSettingsBackend *backend,
365 WriteManyData data = { G_KEYFILE_SETTINGS_BACKEND (backend) };
367 GError *error = NULL;
369 if (!data.kfsb->writable)
372 g_tree_foreach (tree, g_keyfile_settings_backend_check_one, &data);
377 g_tree_foreach (tree, g_keyfile_settings_backend_write_one, &data);
378 success = g_keyfile_settings_backend_keyfile_write (data.kfsb, &error);
381 g_warning ("Failed to write keyfile to %s: %s", g_file_peek_path (data.kfsb->file), error->message);
382 g_error_free (error);
385 g_settings_backend_changed_tree (backend, tree, origin_tag);
391 g_keyfile_settings_backend_write (GSettingsBackend *backend,
396 GKeyfileSettingsBackend *kfsb = G_KEYFILE_SETTINGS_BACKEND (backend);
398 GError *error = NULL;
403 success = set_to_keyfile (kfsb, key, value);
407 g_settings_backend_changed (backend, key, origin_tag);
408 success = g_keyfile_settings_backend_keyfile_write (kfsb, &error);
411 g_warning ("Failed to write keyfile to %s: %s", g_file_peek_path (kfsb->file), error->message);
412 g_error_free (error);
420 g_keyfile_settings_backend_reset (GSettingsBackend *backend,
424 GKeyfileSettingsBackend *kfsb = G_KEYFILE_SETTINGS_BACKEND (backend);
425 GError *error = NULL;
427 if (set_to_keyfile (kfsb, key, NULL))
429 g_keyfile_settings_backend_keyfile_write (kfsb, &error);
432 g_warning ("Failed to write keyfile to %s: %s", g_file_peek_path (kfsb->file), error->message);
433 g_error_free (error);
437 g_settings_backend_changed (backend, key, origin_tag);
441 g_keyfile_settings_backend_get_writable (GSettingsBackend *backend,
444 GKeyfileSettingsBackend *kfsb = G_KEYFILE_SETTINGS_BACKEND (backend);
446 return kfsb->writable &&
447 !g_hash_table_contains (kfsb->system_locks, name) &&
448 path_is_valid (kfsb, name);
452 g_keyfile_settings_backend_get_permission (GSettingsBackend *backend,
455 GKeyfileSettingsBackend *kfsb = G_KEYFILE_SETTINGS_BACKEND (backend);
457 return g_object_ref (kfsb->permission);
461 keyfile_to_tree (GKeyfileSettingsBackend *kfsb,
469 groups = g_key_file_get_groups (keyfile, NULL);
470 for (i = 0; groups[i]; i++)
472 gboolean is_root_group;
476 is_root_group = g_strcmp0 (kfsb->root_group, groups[i]) == 0;
478 /* reject group names that will form invalid key names */
479 if (!is_root_group &&
480 (g_str_has_prefix (groups[i], "/") ||
481 g_str_has_suffix (groups[i], "/") || strstr (groups[i], "//")))
484 keys = g_key_file_get_keys (keyfile, groups[i], NULL, NULL);
485 g_assert (keys != NULL);
487 for (j = 0; keys[j]; j++)
491 /* reject key names with slashes in them */
492 if (strchr (keys[j], '/'))
496 path = g_strdup_printf ("%s%s", kfsb->prefix, keys[j]);
498 path = g_strdup_printf ("%s%s/%s", kfsb->prefix, groups[i], keys[j]);
500 value = g_key_file_get_value (keyfile, groups[i], keys[j], NULL);
502 if (dup_check && g_strcmp0 (g_tree_lookup (tree, path), value) == 0)
504 g_tree_remove (tree, path);
509 g_tree_insert (tree, path, value);
518 g_keyfile_settings_backend_keyfile_reload (GKeyfileSettingsBackend *kfsb)
527 g_file_load_contents (kfsb->file, NULL, &contents, &length, NULL, NULL);
528 compute_checksum (digest, contents, length);
530 if (memcmp (kfsb->digest, digest, sizeof digest) != 0)
532 GKeyFile *keyfiles[2];
535 tree = g_tree_new_full ((GCompareDataFunc) strcmp, NULL,
538 keyfiles[0] = kfsb->keyfile;
539 keyfiles[1] = g_key_file_new ();
542 g_key_file_load_from_data (keyfiles[1], contents, length,
543 G_KEY_FILE_KEEP_COMMENTS |
544 G_KEY_FILE_KEEP_TRANSLATIONS, NULL);
546 keyfile_to_tree (kfsb, tree, keyfiles[0], FALSE);
547 keyfile_to_tree (kfsb, tree, keyfiles[1], TRUE);
548 g_key_file_free (keyfiles[0]);
549 kfsb->keyfile = keyfiles[1];
551 if (g_tree_nnodes (tree) > 0)
552 g_settings_backend_changed_tree (&kfsb->parent_instance, tree, NULL);
556 memcpy (kfsb->digest, digest, sizeof digest);
563 g_keyfile_settings_backend_keyfile_writable (GKeyfileSettingsBackend *kfsb)
568 fileinfo = g_file_query_info (kfsb->dir, "access::*", 0, NULL, NULL);
573 g_file_info_get_attribute_boolean (fileinfo, G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE) &&
574 g_file_info_get_attribute_boolean (fileinfo, G_FILE_ATTRIBUTE_ACCESS_CAN_EXECUTE);
575 g_object_unref (fileinfo);
580 if (writable != kfsb->writable)
582 kfsb->writable = writable;
583 g_settings_backend_path_writable_changed (&kfsb->parent_instance, "/");
588 g_keyfile_settings_backend_finalize (GObject *object)
590 GKeyfileSettingsBackend *kfsb = G_KEYFILE_SETTINGS_BACKEND (object);
592 g_key_file_free (kfsb->keyfile);
593 g_object_unref (kfsb->permission);
594 g_key_file_unref (kfsb->system_keyfile);
595 g_hash_table_unref (kfsb->system_locks);
596 g_free (kfsb->defaults_dir);
598 g_file_monitor_cancel (kfsb->file_monitor);
599 g_object_unref (kfsb->file_monitor);
600 g_object_unref (kfsb->file);
602 g_file_monitor_cancel (kfsb->dir_monitor);
603 g_object_unref (kfsb->dir_monitor);
604 g_object_unref (kfsb->dir);
606 g_free (kfsb->root_group);
607 g_free (kfsb->prefix);
609 G_OBJECT_CLASS (g_keyfile_settings_backend_parent_class)
614 g_keyfile_settings_backend_init (GKeyfileSettingsBackend *kfsb)
619 file_changed (GFileMonitor *monitor,
622 GFileMonitorEvent event_type,
625 GKeyfileSettingsBackend *kfsb = user_data;
627 /* Ignore file deletions, let the GKeyFile content remain in tact. */
628 if (event_type != G_FILE_MONITOR_EVENT_DELETED)
629 g_keyfile_settings_backend_keyfile_reload (kfsb);
633 dir_changed (GFileMonitor *monitor,
636 GFileMonitorEvent event_type,
639 GKeyfileSettingsBackend *kfsb = user_data;
641 g_keyfile_settings_backend_keyfile_writable (kfsb);
645 load_system_settings (GKeyfileSettingsBackend *kfsb)
647 GError *error = NULL;
648 const char *dir = "/etc/glib-2.0/settings";
652 kfsb->system_keyfile = g_key_file_new ();
653 kfsb->system_locks = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
655 if (kfsb->defaults_dir)
656 dir = kfsb->defaults_dir;
658 path = g_build_filename (dir, "defaults", NULL);
660 /* The defaults are in the same keyfile format that we use for the settings.
661 * It can be produced from a dconf database using: dconf dump
663 if (!g_key_file_load_from_file (kfsb->system_keyfile, path, G_KEY_FILE_NONE, &error))
665 if (!g_error_matches (error, G_FILE_ERROR, G_FILE_ERROR_NOENT))
666 g_warning ("Failed to read %s: %s", path, error->message);
667 g_clear_error (&error);
670 g_debug ("Loading default settings from %s", path);
674 path = g_build_filename (dir, "locks", NULL);
676 /* The locks file is a text file containing a list paths to lock, one per line.
677 * It can be produced from a dconf database using: dconf list-locks
679 if (!g_file_get_contents (path, &contents, NULL, &error))
681 if (!g_error_matches (error, G_FILE_ERROR, G_FILE_ERROR_NOENT))
682 g_warning ("Failed to read %s: %s", path, error->message);
683 g_clear_error (&error);
690 g_debug ("Loading locks from %s", path);
692 lines = g_strsplit (contents, "\n", 0);
693 for (i = 0; lines[i]; i++)
695 char *line = lines[i];
696 if (line[0] == '#' || line[0] == '\0')
702 g_debug ("Locking key %s", line);
703 g_hash_table_add (kfsb->system_locks, g_steal_pointer (&line));
714 g_keyfile_settings_backend_constructed (GObject *object)
716 GKeyfileSettingsBackend *kfsb = G_KEYFILE_SETTINGS_BACKEND (object);
719 if (kfsb->file == NULL)
721 char *filename = g_build_filename (g_get_user_config_dir (),
722 "glib-2.0", "settings", "keyfile",
724 kfsb->file = g_file_new_for_path (filename);
728 if (kfsb->prefix == NULL)
730 kfsb->prefix = g_strdup ("/");
731 kfsb->prefix_len = 1;
734 kfsb->keyfile = g_key_file_new ();
735 kfsb->permission = g_simple_permission_new (TRUE);
737 kfsb->dir = g_file_get_parent (kfsb->file);
738 path = g_file_peek_path (kfsb->dir);
739 if (g_mkdir_with_parents (path, 0700) == -1)
740 g_warning ("Failed to create %s: %s", path, g_strerror (errno));
742 kfsb->file_monitor = g_file_monitor (kfsb->file, G_FILE_MONITOR_NONE, NULL, NULL);
743 kfsb->dir_monitor = g_file_monitor (kfsb->dir, G_FILE_MONITOR_NONE, NULL, NULL);
745 compute_checksum (kfsb->digest, NULL, 0);
747 g_signal_connect (kfsb->file_monitor, "changed",
748 G_CALLBACK (file_changed), kfsb);
749 g_signal_connect (kfsb->dir_monitor, "changed",
750 G_CALLBACK (dir_changed), kfsb);
752 g_keyfile_settings_backend_keyfile_writable (kfsb);
753 g_keyfile_settings_backend_keyfile_reload (kfsb);
755 load_system_settings (kfsb);
759 g_keyfile_settings_backend_set_property (GObject *object,
764 GKeyfileSettingsBackend *kfsb = G_KEYFILE_SETTINGS_BACKEND (object);
766 switch ((GKeyfileSettingsBackendProperty)prop_id)
769 /* Construct only. */
770 g_assert (kfsb->file == NULL);
771 if (g_value_get_string (value))
772 kfsb->file = g_file_new_for_path (g_value_get_string (value));
776 /* Construct only. */
777 g_assert (kfsb->prefix == NULL);
778 kfsb->prefix = g_value_dup_string (value);
780 kfsb->prefix_len = strlen (kfsb->prefix);
783 case PROP_ROOT_GROUP:
784 /* Construct only. */
785 g_assert (kfsb->root_group == NULL);
786 kfsb->root_group = g_value_dup_string (value);
787 if (kfsb->root_group)
788 kfsb->root_group_len = strlen (kfsb->root_group);
791 case PROP_DEFAULTS_DIR:
792 /* Construct only. */
793 g_assert (kfsb->defaults_dir == NULL);
794 kfsb->defaults_dir = g_value_dup_string (value);
798 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
804 g_keyfile_settings_backend_get_property (GObject *object,
809 GKeyfileSettingsBackend *kfsb = G_KEYFILE_SETTINGS_BACKEND (object);
811 switch ((GKeyfileSettingsBackendProperty)prop_id)
814 g_value_set_string (value, g_file_peek_path (kfsb->file));
818 g_value_set_string (value, kfsb->prefix);
821 case PROP_ROOT_GROUP:
822 g_value_set_string (value, kfsb->root_group);
825 case PROP_DEFAULTS_DIR:
826 g_value_set_string (value, kfsb->defaults_dir);
830 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
836 g_keyfile_settings_backend_class_init (GKeyfileSettingsBackendClass *class)
838 GObjectClass *object_class = G_OBJECT_CLASS (class);
840 object_class->finalize = g_keyfile_settings_backend_finalize;
841 object_class->constructed = g_keyfile_settings_backend_constructed;
842 object_class->get_property = g_keyfile_settings_backend_get_property;
843 object_class->set_property = g_keyfile_settings_backend_set_property;
845 class->read = g_keyfile_settings_backend_read;
846 class->write = g_keyfile_settings_backend_write;
847 class->write_tree = g_keyfile_settings_backend_write_tree;
848 class->reset = g_keyfile_settings_backend_reset;
849 class->get_writable = g_keyfile_settings_backend_get_writable;
850 class->get_permission = g_keyfile_settings_backend_get_permission;
851 /* No need to implement subscribed/unsubscribe: the only point would be to
852 * stop monitoring the file when there's no GSettings anymore, which is no
857 * GKeyfileSettingsBackend:filename:
859 * The location where the settings are stored on disk.
861 * Defaults to `$XDG_CONFIG_HOME/glib-2.0/settings/keyfile`.
863 g_object_class_install_property (object_class,
865 g_param_spec_string ("filename",
869 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
870 G_PARAM_STATIC_STRINGS));
873 * GKeyfileSettingsBackend:root-path:
875 * All settings read to or written from the backend must fall under the
876 * path given in @root_path (which must start and end with a slash and
877 * not contain two consecutive slashes). @root_path may be "/".
881 g_object_class_install_property (object_class,
883 g_param_spec_string ("root-path",
887 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
888 G_PARAM_STATIC_STRINGS));
891 * GKeyfileSettingsBackend:root-group:
893 * If @root_group is non-%NULL then it specifies the name of the keyfile
894 * group used for keys that are written directly below the root path.
898 g_object_class_install_property (object_class,
900 g_param_spec_string ("root-group",
902 P_("The root group"),
904 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
905 G_PARAM_STATIC_STRINGS));
908 * GKeyfileSettingsBackend:default-dir:
910 * The directory where the system defaults and locks are located.
912 * Defaults to `/etc/glib-2.0/settings`.
914 g_object_class_install_property (object_class,
916 g_param_spec_string ("defaults-dir",
920 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
921 G_PARAM_STATIC_STRINGS));
925 * g_keyfile_settings_backend_new:
926 * @filename: the filename of the keyfile
927 * @root_path: the path under which all settings keys appear
928 * @root_group: (nullable): the group name corresponding to
929 * @root_path, or %NULL
931 * Creates a keyfile-backed #GSettingsBackend.
933 * The filename of the keyfile to use is given by @filename.
935 * All settings read to or written from the backend must fall under the
936 * path given in @root_path (which must start and end with a slash and
937 * not contain two consecutive slashes). @root_path may be "/".
939 * If @root_group is non-%NULL then it specifies the name of the keyfile
940 * group used for keys that are written directly below @root_path. For
941 * example, if @root_path is "/apps/example/" and @root_group is
942 * "toplevel", then settings the key "/apps/example/enabled" to a value
943 * of %TRUE will cause the following to appear in the keyfile:
950 * If @root_group is %NULL then it is not permitted to store keys
951 * directly below the @root_path.
953 * For keys not stored directly below @root_path (ie: in a sub-path),
954 * the name of the subpath (with the final slash stripped) is used as
955 * the name of the keyfile group. To continue the example, if
956 * "/apps/example/profiles/default/font-size" were set to
957 * 12 then the following would appear in the keyfile:
964 * The backend will refuse writes (and return writability as being
965 * %FALSE) for keys outside of @root_path and, in the event that
966 * @root_group is %NULL, also for keys directly under @root_path.
967 * Writes will also be refused if the backend detects that it has the
968 * inability to rewrite the keyfile (ie: the containing directory is not
971 * There is no checking done for your key namespace clashing with the
972 * syntax of the key file format. For example, if you have '[' or ']'
973 * characters in your path names or '=' in your key names you may be in
976 * The backend reads default values from a keyfile called `defaults` in
977 * the directory specified by the #GKeyfileSettingsBackend:defaults-dir property,
978 * and a list of locked keys from a text file with the name `locks` in
981 * Returns: (transfer full): a keyfile-backed #GSettingsBackend
984 g_keyfile_settings_backend_new (const gchar *filename,
985 const gchar *root_path,
986 const gchar *root_group)
988 g_return_val_if_fail (filename != NULL, NULL);
989 g_return_val_if_fail (root_path != NULL, NULL);
990 g_return_val_if_fail (g_str_has_prefix (root_path, "/"), NULL);
991 g_return_val_if_fail (g_str_has_suffix (root_path, "/"), NULL);
992 g_return_val_if_fail (strstr (root_path, "//") == NULL, NULL);
994 return G_SETTINGS_BACKEND (g_object_new (G_TYPE_KEYFILE_SETTINGS_BACKEND,
995 "filename", filename,
996 "root-path", root_path,
997 "root-group", root_group,