summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Lortie <desrt@desrt.ca>2011-05-05 15:45:25 +0200
committerRyan Lortie <desrt@desrt.ca>2011-05-05 15:45:25 +0200
commit62e6a751886e1030fa0d4d062fde009c67a6a544 (patch)
tree820cdb65bcedf40e1fd15cab7a7a535e94380e69
parentda7229b0b2c3a4aec392a042fd231bea7aaecfc0 (diff)
downloaddconf-62e6a751886e1030fa0d4d062fde009c67a6a544.tar.gz
dconf update: support lockdown
-rw-r--r--bin/dconf-update.vala39
1 files changed, 39 insertions, 0 deletions
diff --git a/bin/dconf-update.vala b/bin/dconf-update.vala
index a30ce4b..0eaf728 100644
--- a/bin/dconf-update.vala
+++ b/bin/dconf-update.vala
@@ -41,6 +41,38 @@ unowned Gvdb.Item get_parent (Gvdb.HashTable table, string name) {
return parent;
}
+Gvdb.HashTable? read_locks_directory (string dirname) throws GLib.Error {
+ var dir = Dir.open (dirname);
+
+ if (dir == null) {
+ return null;
+ }
+
+ var table = new Gvdb.HashTable ();
+ unowned string? name;
+
+ while ((name = dir.read_name ()) != null) {
+ var filename = Path.build_filename (dirname, name);
+ Posix.Stat buf;
+
+ // only 'normal' files
+ if (Posix.stat (filename, out buf) < 0 || !Posix.S_ISREG (buf.st_mode)) {
+ continue;
+ }
+
+ string contents;
+ FileUtils.get_contents (filename, out contents, null);
+
+ foreach (var line in contents.split ("\n")) {
+ if (line.has_prefix ("/")) {
+ table.insert (line);
+ }
+ }
+ }
+
+ return table;
+}
+
Gvdb.HashTable read_directory (string dirname) throws GLib.Error {
var table = new Gvdb.HashTable ();
unowned string? name;
@@ -101,6 +133,13 @@ Gvdb.HashTable read_directory (string dirname) throws GLib.Error {
}
}
+ var locks = read_locks_directory (dirname + "/locks");
+
+ if (locks != null) {
+ unowned Gvdb.Item item = table.insert (".locks");
+ item.set_hash_table (locks);
+ }
+
return table;
}