[systemd-commits] 2 commits - src/bus-proxyd

David Herrmann dvdhrm at kemper.freedesktop.org
Sat Jan 17 10:09:49 PST 2015


 src/bus-proxyd/bus-xml-policy.c |   24 +++++++++++++++++-------
 src/bus-proxyd/bus-xml-policy.h |    3 ++-
 src/bus-proxyd/driver.c         |    8 +++++---
 3 files changed, 24 insertions(+), 11 deletions(-)

New commits:
commit 0d620e53360f8d1dd7fd750d26a9b273a6f4fc0b
Author: David Herrmann <dh.herrmann at gmail.com>
Date:   Sat Jan 17 19:06:34 2015 +0100

    bus-proxy: implement org.freedesktop.DBus.ReloadConfig()
    
    Make sure to reload our xml policy configuration if requested via the bus.

diff --git a/src/bus-proxyd/bus-xml-policy.c b/src/bus-proxyd/bus-xml-policy.c
index b3daad5..0c60b6b 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;
diff --git a/src/bus-proxyd/bus-xml-policy.h b/src/bus-proxyd/bus-xml-policy.h
index 762cb66..9716772 100644
--- a/src/bus-proxyd/bus-xml-policy.h
+++ b/src/bus-proxyd/bus-xml-policy.h
@@ -77,6 +77,7 @@ typedef struct Policy {
 } Policy;
 
 typedef struct SharedPolicy {
+        char **configuration;
         pthread_mutex_t lock;
         pthread_rwlock_t rwlock;
         Policy buffer;
@@ -122,7 +123,7 @@ PolicyItemClass policy_item_class_from_string(const char *s) _pure_;
 int shared_policy_new(SharedPolicy **out);
 SharedPolicy *shared_policy_free(SharedPolicy *sp);
 
-int shared_policy_reload(SharedPolicy *sp, char **configuration);
+int shared_policy_reload(SharedPolicy *sp);
 int shared_policy_preload(SharedPolicy *sp, char **configuration);
 Policy *shared_policy_acquire(SharedPolicy *sp);
 void shared_policy_release(SharedPolicy *sp, Policy *p);
diff --git a/src/bus-proxyd/driver.c b/src/bus-proxyd/driver.c
index 37fb87c..361b14c 100644
--- a/src/bus-proxyd/driver.c
+++ b/src/bus-proxyd/driver.c
@@ -439,9 +439,11 @@ int bus_proxy_process_driver(sd_bus *a, sd_bus *b, sd_bus_message *m, SharedPoli
                 if (!sd_bus_message_has_signature(m, ""))
                         return synthetic_reply_method_error(m, &SD_BUS_ERROR_MAKE_CONST(SD_BUS_ERROR_INVALID_ARGS, "Invalid parameters"));
 
-                r = sd_bus_error_setf(&error, SD_BUS_ERROR_NOT_SUPPORTED, "%s() is not supported", sd_bus_message_get_member(m));
+                r = shared_policy_reload(sp);
+                if (r < 0)
+                        return synthetic_reply_method_errno(m, r, NULL);
 
-                return synthetic_reply_method_errno(m, r, &error);
+                return synthetic_reply_method_return(m, NULL);
 
         } else if (sd_bus_message_is_method_call(m, "org.freedesktop.DBus", "RequestName")) {
                 const char *name;

commit bae8352c1dedc335b0e0b6ee2066f64b0b483e24
Author: David Herrmann <dh.herrmann at gmail.com>
Date:   Sat Jan 17 18:54:09 2015 +0100

    bus-proxy: fix indentation
    
    Fix whitespace indentation.

diff --git a/src/bus-proxyd/driver.c b/src/bus-proxyd/driver.c
index 3d312f6..37fb87c 100644
--- a/src/bus-proxyd/driver.c
+++ b/src/bus-proxyd/driver.c
@@ -595,7 +595,7 @@ int bus_proxy_process_driver(sd_bus *a, sd_bus *b, sd_bus_message *m, SharedPoli
                 if (r < 0)
                         return synthetic_reply_method_errno(m, r, NULL);
 
-               return synthetic_reply_method_return(m, NULL);
+                return synthetic_reply_method_return(m, NULL);
 
         } else {
                 _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;



More information about the systemd-commits mailing list