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 gsize key_len = strlen (key);
153 const gchar *last_slash;
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 last_slash = strrchr (key, '/');
164 /* Disallow empty group names or key names */
166 (last_slash != NULL &&
167 (*(last_slash + 1) == '\0' ||
171 if (kfsb->root_group)
173 /* if a root_group was specified, make sure the user hasn't given
174 * a path that ghosts that group name
176 if (last_slash != NULL && (last_slash - key) == kfsb->root_group_len && memcmp (key, kfsb->root_group, last_slash - key) == 0)
181 /* if no root_group was given, ensure that the user gave a path */
182 if (last_slash == NULL)
188 if (last_slash != NULL)
190 *group = g_memdup2 (key, (last_slash - key) + 1);
191 (*group)[(last_slash - key)] = '\0';
194 *group = g_strdup (kfsb->root_group);
199 if (last_slash != NULL)
200 *basename = g_memdup2 (last_slash + 1, key_len - (last_slash - key));
202 *basename = g_strdup (key);
209 path_is_valid (GKeyfileSettingsBackend *kfsb,
212 return convert_path (kfsb, path, NULL, NULL);
216 get_from_keyfile (GKeyfileSettingsBackend *kfsb,
217 const GVariantType *type,
220 GVariant *return_value = NULL;
223 if (convert_path (kfsb, key, &group, &name))
230 sysstr = g_key_file_get_value (kfsb->system_keyfile, group, name, NULL);
231 str = g_key_file_get_value (kfsb->keyfile, group, name, NULL);
233 (g_hash_table_contains (kfsb->system_locks, key) ||
237 str = g_steal_pointer (&sysstr);
242 return_value = g_variant_parse (type, str, NULL, NULL, NULL);
244 /* As a special case, support values of type %G_VARIANT_TYPE_STRING
245 * not being quoted, since users keep forgetting to do it and then
246 * getting confused. */
247 if (return_value == NULL &&
248 g_variant_type_equal (type, G_VARIANT_TYPE_STRING) &&
251 GString *s = g_string_sized_new (strlen (str) + 2);
254 g_string_append_c (s, '\"');
258 g_string_append_c (s, '\\');
259 g_string_append_c (s, *p);
262 g_string_append_c (s, '\"');
263 return_value = g_variant_parse (type, s->str, NULL, NULL, NULL);
264 g_string_free (s, TRUE);
279 set_to_keyfile (GKeyfileSettingsBackend *kfsb,
285 if (g_hash_table_contains (kfsb->system_locks, key))
288 if (convert_path (kfsb, key, &group, &name))
292 gchar *str = g_variant_print (value, FALSE);
293 g_key_file_set_value (kfsb->keyfile, group, name, str);
294 g_variant_unref (g_variant_ref_sink (value));
304 groups = g_key_file_get_groups (kfsb->keyfile, NULL);
306 for (i = 0; groups[i]; i++)
307 if (group_name_matches (groups[i], group))
308 g_key_file_remove_group (kfsb->keyfile, groups[i], NULL);
313 g_key_file_remove_key (kfsb->keyfile, group, name, NULL);
326 g_keyfile_settings_backend_read (GSettingsBackend *backend,
328 const GVariantType *expected_type,
329 gboolean default_value)
331 GKeyfileSettingsBackend *kfsb = G_KEYFILE_SETTINGS_BACKEND (backend);
336 return get_from_keyfile (kfsb, expected_type, key);
341 GKeyfileSettingsBackend *kfsb;
346 g_keyfile_settings_backend_write_one (gpointer key,
350 WriteManyData *data = user_data;
351 gboolean success G_GNUC_UNUSED /* when compiling with G_DISABLE_ASSERT */;
353 success = set_to_keyfile (data->kfsb, key, value);
360 g_keyfile_settings_backend_check_one (gpointer key,
364 WriteManyData *data = user_data;
366 return data->failed = g_hash_table_contains (data->kfsb->system_locks, key) ||
367 !path_is_valid (data->kfsb, key);
371 g_keyfile_settings_backend_write_tree (GSettingsBackend *backend,
375 WriteManyData data = { G_KEYFILE_SETTINGS_BACKEND (backend), 0 };
377 GError *error = NULL;
379 if (!data.kfsb->writable)
382 g_tree_foreach (tree, g_keyfile_settings_backend_check_one, &data);
387 g_tree_foreach (tree, g_keyfile_settings_backend_write_one, &data);
388 success = g_keyfile_settings_backend_keyfile_write (data.kfsb, &error);
391 g_warning ("Failed to write keyfile to %s: %s", g_file_peek_path (data.kfsb->file), error->message);
392 g_error_free (error);
395 g_settings_backend_changed_tree (backend, tree, origin_tag);
401 g_keyfile_settings_backend_write (GSettingsBackend *backend,
406 GKeyfileSettingsBackend *kfsb = G_KEYFILE_SETTINGS_BACKEND (backend);
408 GError *error = NULL;
413 success = set_to_keyfile (kfsb, key, value);
417 g_settings_backend_changed (backend, key, origin_tag);
418 success = g_keyfile_settings_backend_keyfile_write (kfsb, &error);
421 g_warning ("Failed to write keyfile to %s: %s", g_file_peek_path (kfsb->file), error->message);
422 g_error_free (error);
430 g_keyfile_settings_backend_reset (GSettingsBackend *backend,
434 GKeyfileSettingsBackend *kfsb = G_KEYFILE_SETTINGS_BACKEND (backend);
435 GError *error = NULL;
437 if (set_to_keyfile (kfsb, key, NULL))
439 g_keyfile_settings_backend_keyfile_write (kfsb, &error);
442 g_warning ("Failed to write keyfile to %s: %s", g_file_peek_path (kfsb->file), error->message);
443 g_error_free (error);
447 g_settings_backend_changed (backend, key, origin_tag);
451 g_keyfile_settings_backend_get_writable (GSettingsBackend *backend,
454 GKeyfileSettingsBackend *kfsb = G_KEYFILE_SETTINGS_BACKEND (backend);
456 return kfsb->writable &&
457 !g_hash_table_contains (kfsb->system_locks, name) &&
458 path_is_valid (kfsb, name);
462 g_keyfile_settings_backend_get_permission (GSettingsBackend *backend,
465 GKeyfileSettingsBackend *kfsb = G_KEYFILE_SETTINGS_BACKEND (backend);
467 return g_object_ref (kfsb->permission);
471 keyfile_to_tree (GKeyfileSettingsBackend *kfsb,
479 groups = g_key_file_get_groups (keyfile, NULL);
480 for (i = 0; groups[i]; i++)
482 gboolean is_root_group;
486 is_root_group = g_strcmp0 (kfsb->root_group, groups[i]) == 0;
488 /* reject group names that will form invalid key names */
489 if (!is_root_group &&
490 (g_str_has_prefix (groups[i], "/") ||
491 g_str_has_suffix (groups[i], "/") || strstr (groups[i], "//")))
494 keys = g_key_file_get_keys (keyfile, groups[i], NULL, NULL);
495 g_assert (keys != NULL);
497 for (j = 0; keys[j]; j++)
501 /* reject key names with slashes in them */
502 if (strchr (keys[j], '/'))
506 path = g_strdup_printf ("%s%s", kfsb->prefix, keys[j]);
508 path = g_strdup_printf ("%s%s/%s", kfsb->prefix, groups[i], keys[j]);
510 value = g_key_file_get_value (keyfile, groups[i], keys[j], NULL);
512 if (dup_check && g_strcmp0 (g_tree_lookup (tree, path), value) == 0)
514 g_tree_remove (tree, path);
519 g_tree_insert (tree, path, value);
528 g_keyfile_settings_backend_keyfile_reload (GKeyfileSettingsBackend *kfsb)
537 g_file_load_contents (kfsb->file, NULL, &contents, &length, NULL, NULL);
538 compute_checksum (digest, contents, length);
540 if (memcmp (kfsb->digest, digest, sizeof digest) != 0)
542 GKeyFile *keyfiles[2];
545 tree = g_tree_new_full ((GCompareDataFunc) strcmp, NULL,
548 keyfiles[0] = kfsb->keyfile;
549 keyfiles[1] = g_key_file_new ();
552 g_key_file_load_from_data (keyfiles[1], contents, length,
553 G_KEY_FILE_KEEP_COMMENTS |
554 G_KEY_FILE_KEEP_TRANSLATIONS, NULL);
556 keyfile_to_tree (kfsb, tree, keyfiles[0], FALSE);
557 keyfile_to_tree (kfsb, tree, keyfiles[1], TRUE);
558 g_key_file_free (keyfiles[0]);
559 kfsb->keyfile = keyfiles[1];
561 if (g_tree_nnodes (tree) > 0)
562 g_settings_backend_changed_tree (&kfsb->parent_instance, tree, NULL);
566 memcpy (kfsb->digest, digest, sizeof digest);
573 g_keyfile_settings_backend_keyfile_writable (GKeyfileSettingsBackend *kfsb)
578 fileinfo = g_file_query_info (kfsb->dir, "access::*", 0, NULL, NULL);
583 g_file_info_get_attribute_boolean (fileinfo, G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE) &&
584 g_file_info_get_attribute_boolean (fileinfo, G_FILE_ATTRIBUTE_ACCESS_CAN_EXECUTE);
585 g_object_unref (fileinfo);
590 if (writable != kfsb->writable)
592 kfsb->writable = writable;
593 g_settings_backend_path_writable_changed (&kfsb->parent_instance, "/");
598 g_keyfile_settings_backend_finalize (GObject *object)
600 GKeyfileSettingsBackend *kfsb = G_KEYFILE_SETTINGS_BACKEND (object);
602 g_key_file_free (kfsb->keyfile);
603 g_object_unref (kfsb->permission);
604 g_key_file_unref (kfsb->system_keyfile);
605 g_hash_table_unref (kfsb->system_locks);
606 g_free (kfsb->defaults_dir);
608 g_file_monitor_cancel (kfsb->file_monitor);
609 g_object_unref (kfsb->file_monitor);
610 g_object_unref (kfsb->file);
612 g_file_monitor_cancel (kfsb->dir_monitor);
613 g_object_unref (kfsb->dir_monitor);
614 g_object_unref (kfsb->dir);
616 g_free (kfsb->root_group);
617 g_free (kfsb->prefix);
619 G_OBJECT_CLASS (g_keyfile_settings_backend_parent_class)
624 g_keyfile_settings_backend_init (GKeyfileSettingsBackend *kfsb)
629 file_changed (GFileMonitor *monitor,
632 GFileMonitorEvent event_type,
635 GKeyfileSettingsBackend *kfsb = user_data;
637 /* Ignore file deletions, let the GKeyFile content remain in tact. */
638 if (event_type != G_FILE_MONITOR_EVENT_DELETED)
639 g_keyfile_settings_backend_keyfile_reload (kfsb);
643 dir_changed (GFileMonitor *monitor,
646 GFileMonitorEvent event_type,
649 GKeyfileSettingsBackend *kfsb = user_data;
651 g_keyfile_settings_backend_keyfile_writable (kfsb);
655 load_system_settings (GKeyfileSettingsBackend *kfsb)
657 GError *error = NULL;
658 const char *dir = "/etc/glib-2.0/settings";
662 kfsb->system_keyfile = g_key_file_new ();
663 kfsb->system_locks = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
665 if (kfsb->defaults_dir)
666 dir = kfsb->defaults_dir;
668 path = g_build_filename (dir, "defaults", NULL);
670 /* The defaults are in the same keyfile format that we use for the settings.
671 * It can be produced from a dconf database using: dconf dump
673 if (!g_key_file_load_from_file (kfsb->system_keyfile, path, G_KEY_FILE_NONE, &error))
675 if (!g_error_matches (error, G_FILE_ERROR, G_FILE_ERROR_NOENT))
676 g_warning ("Failed to read %s: %s", path, error->message);
677 g_clear_error (&error);
680 g_debug ("Loading default settings from %s", path);
684 path = g_build_filename (dir, "locks", NULL);
686 /* The locks file is a text file containing a list paths to lock, one per line.
687 * It can be produced from a dconf database using: dconf list-locks
689 if (!g_file_get_contents (path, &contents, NULL, &error))
691 if (!g_error_matches (error, G_FILE_ERROR, G_FILE_ERROR_NOENT))
692 g_warning ("Failed to read %s: %s", path, error->message);
693 g_clear_error (&error);
700 g_debug ("Loading locks from %s", path);
702 lines = g_strsplit (contents, "\n", 0);
703 for (i = 0; lines[i]; i++)
705 char *line = lines[i];
706 if (line[0] == '#' || line[0] == '\0')
712 g_debug ("Locking key %s", line);
713 g_hash_table_add (kfsb->system_locks, g_steal_pointer (&line));
724 g_keyfile_settings_backend_constructed (GObject *object)
726 GKeyfileSettingsBackend *kfsb = G_KEYFILE_SETTINGS_BACKEND (object);
729 if (kfsb->file == NULL)
731 char *filename = g_build_filename (g_get_user_config_dir (),
732 "glib-2.0", "settings", "keyfile",
734 kfsb->file = g_file_new_for_path (filename);
738 if (kfsb->prefix == NULL)
740 kfsb->prefix = g_strdup ("/");
741 kfsb->prefix_len = 1;
744 kfsb->keyfile = g_key_file_new ();
745 kfsb->permission = g_simple_permission_new (TRUE);
747 kfsb->dir = g_file_get_parent (kfsb->file);
748 path = g_file_peek_path (kfsb->dir);
749 if (g_mkdir_with_parents (path, 0700) == -1)
750 g_warning ("Failed to create %s: %s", path, g_strerror (errno));
752 kfsb->file_monitor = g_file_monitor (kfsb->file, G_FILE_MONITOR_NONE, NULL, NULL);
753 kfsb->dir_monitor = g_file_monitor (kfsb->dir, G_FILE_MONITOR_NONE, NULL, NULL);
755 compute_checksum (kfsb->digest, NULL, 0);
757 g_signal_connect (kfsb->file_monitor, "changed",
758 G_CALLBACK (file_changed), kfsb);
759 g_signal_connect (kfsb->dir_monitor, "changed",
760 G_CALLBACK (dir_changed), kfsb);
762 g_keyfile_settings_backend_keyfile_writable (kfsb);
763 g_keyfile_settings_backend_keyfile_reload (kfsb);
765 load_system_settings (kfsb);
769 g_keyfile_settings_backend_set_property (GObject *object,
774 GKeyfileSettingsBackend *kfsb = G_KEYFILE_SETTINGS_BACKEND (object);
776 switch ((GKeyfileSettingsBackendProperty)prop_id)
779 /* Construct only. */
780 g_assert (kfsb->file == NULL);
781 if (g_value_get_string (value))
782 kfsb->file = g_file_new_for_path (g_value_get_string (value));
786 /* Construct only. */
787 g_assert (kfsb->prefix == NULL);
788 kfsb->prefix = g_value_dup_string (value);
790 kfsb->prefix_len = strlen (kfsb->prefix);
793 case PROP_ROOT_GROUP:
794 /* Construct only. */
795 g_assert (kfsb->root_group == NULL);
796 kfsb->root_group = g_value_dup_string (value);
797 if (kfsb->root_group)
798 kfsb->root_group_len = strlen (kfsb->root_group);
801 case PROP_DEFAULTS_DIR:
802 /* Construct only. */
803 g_assert (kfsb->defaults_dir == NULL);
804 kfsb->defaults_dir = g_value_dup_string (value);
808 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
814 g_keyfile_settings_backend_get_property (GObject *object,
819 GKeyfileSettingsBackend *kfsb = G_KEYFILE_SETTINGS_BACKEND (object);
821 switch ((GKeyfileSettingsBackendProperty)prop_id)
824 g_value_set_string (value, g_file_peek_path (kfsb->file));
828 g_value_set_string (value, kfsb->prefix);
831 case PROP_ROOT_GROUP:
832 g_value_set_string (value, kfsb->root_group);
835 case PROP_DEFAULTS_DIR:
836 g_value_set_string (value, kfsb->defaults_dir);
840 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
846 g_keyfile_settings_backend_class_init (GKeyfileSettingsBackendClass *class)
848 GObjectClass *object_class = G_OBJECT_CLASS (class);
850 object_class->finalize = g_keyfile_settings_backend_finalize;
851 object_class->constructed = g_keyfile_settings_backend_constructed;
852 object_class->get_property = g_keyfile_settings_backend_get_property;
853 object_class->set_property = g_keyfile_settings_backend_set_property;
855 class->read = g_keyfile_settings_backend_read;
856 class->write = g_keyfile_settings_backend_write;
857 class->write_tree = g_keyfile_settings_backend_write_tree;
858 class->reset = g_keyfile_settings_backend_reset;
859 class->get_writable = g_keyfile_settings_backend_get_writable;
860 class->get_permission = g_keyfile_settings_backend_get_permission;
861 /* No need to implement subscribed/unsubscribe: the only point would be to
862 * stop monitoring the file when there's no GSettings anymore, which is no
867 * GKeyfileSettingsBackend:filename:
869 * The location where the settings are stored on disk.
871 * Defaults to `$XDG_CONFIG_HOME/glib-2.0/settings/keyfile`.
873 g_object_class_install_property (object_class,
875 g_param_spec_string ("filename",
879 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
880 G_PARAM_STATIC_STRINGS));
883 * GKeyfileSettingsBackend:root-path:
885 * All settings read to or written from the backend must fall under the
886 * path given in @root_path (which must start and end with a slash and
887 * not contain two consecutive slashes). @root_path may be "/".
891 g_object_class_install_property (object_class,
893 g_param_spec_string ("root-path",
897 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
898 G_PARAM_STATIC_STRINGS));
901 * GKeyfileSettingsBackend:root-group:
903 * If @root_group is non-%NULL then it specifies the name of the keyfile
904 * group used for keys that are written directly below the root path.
908 g_object_class_install_property (object_class,
910 g_param_spec_string ("root-group",
912 P_("The root group"),
914 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
915 G_PARAM_STATIC_STRINGS));
918 * GKeyfileSettingsBackend:default-dir:
920 * The directory where the system defaults and locks are located.
922 * Defaults to `/etc/glib-2.0/settings`.
924 g_object_class_install_property (object_class,
926 g_param_spec_string ("defaults-dir",
930 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
931 G_PARAM_STATIC_STRINGS));
935 * g_keyfile_settings_backend_new:
936 * @filename: the filename of the keyfile
937 * @root_path: the path under which all settings keys appear
938 * @root_group: (nullable): the group name corresponding to
939 * @root_path, or %NULL
941 * Creates a keyfile-backed #GSettingsBackend.
943 * The filename of the keyfile to use is given by @filename.
945 * All settings read to or written from the backend must fall under the
946 * path given in @root_path (which must start and end with a slash and
947 * not contain two consecutive slashes). @root_path may be "/".
949 * If @root_group is non-%NULL then it specifies the name of the keyfile
950 * group used for keys that are written directly below @root_path. For
951 * example, if @root_path is "/apps/example/" and @root_group is
952 * "toplevel", then settings the key "/apps/example/enabled" to a value
953 * of %TRUE will cause the following to appear in the keyfile:
960 * If @root_group is %NULL then it is not permitted to store keys
961 * directly below the @root_path.
963 * For keys not stored directly below @root_path (ie: in a sub-path),
964 * the name of the subpath (with the final slash stripped) is used as
965 * the name of the keyfile group. To continue the example, if
966 * "/apps/example/profiles/default/font-size" were set to
967 * 12 then the following would appear in the keyfile:
974 * The backend will refuse writes (and return writability as being
975 * %FALSE) for keys outside of @root_path and, in the event that
976 * @root_group is %NULL, also for keys directly under @root_path.
977 * Writes will also be refused if the backend detects that it has the
978 * inability to rewrite the keyfile (ie: the containing directory is not
981 * There is no checking done for your key namespace clashing with the
982 * syntax of the key file format. For example, if you have '[' or ']'
983 * characters in your path names or '=' in your key names you may be in
986 * The backend reads default values from a keyfile called `defaults` in
987 * the directory specified by the #GKeyfileSettingsBackend:defaults-dir property,
988 * and a list of locked keys from a text file with the name `locks` in
991 * Returns: (transfer full): a keyfile-backed #GSettingsBackend
994 g_keyfile_settings_backend_new (const gchar *filename,
995 const gchar *root_path,
996 const gchar *root_group)
998 g_return_val_if_fail (filename != NULL, NULL);
999 g_return_val_if_fail (root_path != NULL, NULL);
1000 g_return_val_if_fail (g_str_has_prefix (root_path, "/"), NULL);
1001 g_return_val_if_fail (g_str_has_suffix (root_path, "/"), NULL);
1002 g_return_val_if_fail (strstr (root_path, "//") == NULL, NULL);
1004 return G_SETTINGS_BACKEND (g_object_new (G_TYPE_KEYFILE_SETTINGS_BACKEND,
1005 "filename", filename,
1006 "root-path", root_path,
1007 "root-group", root_group,