diff options
author | David Herrmann <dh.herrmann@gmail.com> | 2015-01-17 18:07:58 +0100 |
---|---|---|
committer | David Herrmann <dh.herrmann@gmail.com> | 2015-01-17 18:27:23 +0100 |
commit | c4bc1a8434f2a34840ea6f63064fa998ecfae738 (patch) | |
tree | c10ae7cfd3864cc74fc83c997baaf45e81215b48 /src/bus-proxyd/driver.c | |
parent | b58d857136496ee463223cd90af46512e9eef152 (diff) |
bus-proxy: share policy between threads
This implements a shared policy cache with read-write locks. We no longer
parse the XML policy in each thread.
This will allow us to easily implement ReloadConfig().
Diffstat (limited to 'src/bus-proxyd/driver.c')
-rw-r--r-- | src/bus-proxyd/driver.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/bus-proxyd/driver.c b/src/bus-proxyd/driver.c index c1f7fc4a3c..3d312f65a4 100644 --- a/src/bus-proxyd/driver.c +++ b/src/bus-proxyd/driver.c @@ -80,7 +80,7 @@ static int get_creds_by_message(sd_bus *bus, sd_bus_message *m, uint64_t mask, s return get_creds_by_name(bus, name, mask, _creds, error); } -int bus_proxy_process_driver(sd_bus *a, sd_bus *b, sd_bus_message *m, Policy *policy, const struct ucred *ucred, Set *owned_names) { +int bus_proxy_process_driver(sd_bus *a, sd_bus *b, sd_bus_message *m, SharedPolicy *sp, const struct ucred *ucred, Set *owned_names) { int r; assert(a); @@ -455,8 +455,16 @@ int bus_proxy_process_driver(sd_bus *a, sd_bus *b, sd_bus_message *m, Policy *po if (r < 0) return synthetic_reply_method_errno(m, r, NULL); - if (policy && !policy_check_own(policy, ucred->uid, ucred->gid, name)) - return synthetic_reply_method_errno(m, -EPERM, NULL); + if (sp) { + Policy *policy; + bool denied; + + policy = shared_policy_acquire(sp); + denied = !policy_check_own(policy, ucred->uid, ucred->gid, name); + shared_policy_release(sp, policy); + if (denied) + return synthetic_reply_method_errno(m, -EPERM, NULL); + } if ((flags & ~(BUS_NAME_ALLOW_REPLACEMENT|BUS_NAME_REPLACE_EXISTING|BUS_NAME_DO_NOT_QUEUE)) != 0) return synthetic_reply_method_errno(m, -EINVAL, NULL); |