diff options
author | Alban Crequy <alban.crequy@collabora.co.uk> | 2012-03-21 19:05:42 +0000 |
---|---|---|
committer | Alban Crequy <alban.crequy@collabora.co.uk> | 2012-03-22 11:51:23 +0000 |
commit | f1cfc138efc2af0763a51ae665ea50096f613512 (patch) | |
tree | 770c074ab61b7fa8dd9dafcf14e1dd9747bd69f0 /bus/policy.c | |
parent | d0591d318f8c93f159ea4b193b79888567a6439c (diff) | |
download | dbus-f1cfc138efc2af0763a51ae665ea50096f613512.tar.gz |
test: enforce own_prefix policy rules
After parsing [allow|deny] rules with own_prefix, check they are enforced
correctly.
https://bugs.freedesktop.org/show_bug.cgi?id=46886
Diffstat (limited to 'bus/policy.c')
-rw-r--r-- | bus/policy.c | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/bus/policy.c b/bus/policy.c index e8203733..379cea95 100644 --- a/bus/policy.c +++ b/bus/policy.c @@ -1240,24 +1240,26 @@ bus_client_policy_check_can_receive (BusClientPolicy *policy, return allowed; } -dbus_bool_t -bus_client_policy_check_can_own (BusClientPolicy *policy, - const DBusString *service_name) + + +static dbus_bool_t +bus_rules_check_can_own (DBusList *rules, + const DBusString *service_name) { DBusList *link; dbus_bool_t allowed; - /* policy->rules is in the order the rules appeared + /* rules is in the order the rules appeared * in the config file, i.e. last rule that applies wins */ allowed = FALSE; - link = _dbus_list_get_first_link (&policy->rules); + link = _dbus_list_get_first_link (&rules); while (link != NULL) { BusPolicyRule *rule = link->data; - link = _dbus_list_get_next_link (&policy->rules, link); + link = _dbus_list_get_next_link (&rules, link); /* Rule is skipped if it specifies a different service name from * the desired one. @@ -1292,3 +1294,20 @@ bus_client_policy_check_can_own (BusClientPolicy *policy, return allowed; } + +dbus_bool_t +bus_client_policy_check_can_own (BusClientPolicy *policy, + const DBusString *service_name) +{ + return bus_rules_check_can_own (policy->rules, service_name); +} + +#ifdef DBUS_BUILD_TESTS +dbus_bool_t +bus_policy_check_can_own (BusPolicy *policy, + const DBusString *service_name) +{ + return bus_rules_check_can_own (policy->default_rules, service_name); +} +#endif /* DBUS_BUILD_TESTS */ + |