summaryrefslogtreecommitdiff
path: root/Userland/Services/ConfigServer/ConnectionFromClient.cpp
diff options
context:
space:
mode:
authorthankyouverycool <66646555+thankyouverycool@users.noreply.github.com>2022-09-23 09:45:05 -0400
committerAli Mohammad Pur <Ali.mpfard@gmail.com>2022-10-01 13:39:10 +0330
commitc34f2e75e974dcb0933470753795aba50e50e662 (patch)
tree21bdfa581046dc05b8ce16b0695da88242c16b54 /Userland/Services/ConfigServer/ConnectionFromClient.cpp
parent6f394d9ee29e8e81107dee91744b63a4d1216cc1 (diff)
downloadserenity-c34f2e75e974dcb0933470753795aba50e50e662.zip
LibCore+LibConfig+ConfigServer: Add Config::{add,remove}_group()
Plumbs synchronous calls for adding and removing group entries to config files. This is useful for services like SystemServer which default to group names for executable paths, and for removing all keys at once.
Diffstat (limited to 'Userland/Services/ConfigServer/ConnectionFromClient.cpp')
-rw-r--r--Userland/Services/ConfigServer/ConnectionFromClient.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/Userland/Services/ConfigServer/ConnectionFromClient.cpp b/Userland/Services/ConfigServer/ConnectionFromClient.cpp
index 22bf2370cf..264cd7ead1 100644
--- a/Userland/Services/ConfigServer/ConnectionFromClient.cpp
+++ b/Userland/Services/ConfigServer/ConnectionFromClient.cpp
@@ -267,4 +267,40 @@ void ConnectionFromClient::remove_key_entry(String const& domain, String const&
});
}
+void ConnectionFromClient::remove_group_entry(String const& domain, String const& group)
+{
+ if (!validate_access(domain, group, {}))
+ return;
+
+ auto& config = ensure_domain_config(domain);
+ if (!config.has_group(group))
+ return;
+
+ config.remove_group(group);
+ m_dirty_domains.set(domain);
+ start_or_restart_sync_timer();
+
+ for_each_monitoring_connection(domain, this, [&domain, &group](ConnectionFromClient& connection) {
+ connection.async_notify_removed_group(domain, group);
+ });
+}
+
+void ConnectionFromClient::add_group_entry(String const& domain, String const& group)
+{
+ if (!validate_access(domain, group, {}))
+ return;
+
+ auto& config = ensure_domain_config(domain);
+ if (config.has_group(group))
+ return;
+
+ config.add_group(group);
+ m_dirty_domains.set(domain);
+ start_or_restart_sync_timer();
+
+ for_each_monitoring_connection(domain, this, [&domain, &group](ConnectionFromClient& connection) {
+ connection.async_notify_added_group(domain, group);
+ });
+}
+
}