summaryrefslogtreecommitdiff
path: root/src/bus-proxyd/bus-xml-policy.c
diff options
context:
space:
mode:
authorDavid Herrmann <dh.herrmann@gmail.com>2015-01-17 19:06:34 +0100
committerDavid Herrmann <dh.herrmann@gmail.com>2015-01-17 19:06:34 +0100
commit0d620e53360f8d1dd7fd750d26a9b273a6f4fc0b (patch)
tree7f4a9d2c739a95fd201740cc5aa509cedb8dcba6 /src/bus-proxyd/bus-xml-policy.c
parentbae8352c1dedc335b0e0b6ee2066f64b0b483e24 (diff)
bus-proxy: implement org.freedesktop.DBus.ReloadConfig()
Make sure to reload our xml policy configuration if requested via the bus.
Diffstat (limited to 'src/bus-proxyd/bus-xml-policy.c')
-rw-r--r--src/bus-proxyd/bus-xml-policy.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/bus-proxyd/bus-xml-policy.c b/src/bus-proxyd/bus-xml-policy.c
index b3daad5017..0c60b6b6eb 100644
--- a/src/bus-proxyd/bus-xml-policy.c
+++ b/src/bus-proxyd/bus-xml-policy.c
@@ -1145,6 +1145,7 @@ SharedPolicy *shared_policy_free(SharedPolicy *sp) {
policy_free(sp->policy);
pthread_rwlock_destroy(&sp->rwlock);
pthread_mutex_destroy(&sp->lock);
+ strv_free(sp->configuration);
free(sp);
return NULL;
@@ -1161,6 +1162,7 @@ static int shared_policy_reload_unlocked(SharedPolicy *sp, char **configuration)
if (r < 0)
return log_error_errno(r, "Failed to load policy: %m");
+ log_debug("Reloading configuration");
/* policy_dump(&buffer); */
pthread_rwlock_wrlock(&sp->rwlock);
@@ -1176,28 +1178,36 @@ static int shared_policy_reload_unlocked(SharedPolicy *sp, char **configuration)
return 0;
}
-int shared_policy_reload(SharedPolicy *sp, char **configuration) {
+int shared_policy_reload(SharedPolicy *sp) {
int r;
assert(sp);
pthread_mutex_lock(&sp->lock);
- r = shared_policy_reload_unlocked(sp, configuration);
+ r = shared_policy_reload_unlocked(sp, sp->configuration);
pthread_mutex_unlock(&sp->lock);
return r;
}
int shared_policy_preload(SharedPolicy *sp, char **configuration) {
- int r;
+ _cleanup_strv_free_ char **conf = NULL;
+ int r = 0;
assert(sp);
+ conf = strv_copy(configuration);
+ if (!conf)
+ return log_oom();
+
pthread_mutex_lock(&sp->lock);
- if (!sp->policy)
- r = shared_policy_reload_unlocked(sp, configuration);
- else
- r = 0;
+ if (!sp->policy) {
+ r = shared_policy_reload_unlocked(sp, conf);
+ if (r >= 0) {
+ sp->configuration = conf;
+ conf = NULL;
+ }
+ }
pthread_mutex_unlock(&sp->lock);
return r;