X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=bus%2Fpolicy.c;h=082f3853b82794bf22e80fbbce5aea1c2fe329b8;hb=3428a70ec49b9657651ad74f372912f7aa4d6b09;hp=34e8446958f42fc7520503d6e8a9620611818d0f;hpb=2214ad00c31abca64dda48c0724286b6b2c4da9c;p=platform%2Fupstream%2Fdbus.git diff --git a/bus/policy.c b/bus/policy.c index 34e8446..082f385 100644 --- a/bus/policy.c +++ b/bus/policy.c @@ -1240,25 +1240,26 @@ bus_client_policy_check_can_receive (BusClientPolicy *policy, return allowed; } -dbus_bool_t -bus_client_policy_check_can_own (BusClientPolicy *policy, - DBusConnection *connection, - 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. @@ -1267,12 +1268,25 @@ bus_client_policy_check_can_own (BusClientPolicy *policy, if (rule->type != BUS_POLICY_RULE_OWN) continue; - if (rule->d.own.service_name != NULL) + if (!rule->d.own.prefix && rule->d.own.service_name != NULL) { if (!_dbus_string_equal_c_str (service_name, rule->d.own.service_name)) continue; } + else if (rule->d.own.prefix) + { + const char *data; + char next_char; + if (!_dbus_string_starts_with_c_str (service_name, + rule->d.own.service_name)) + continue; + + data = _dbus_string_get_const_data (service_name); + next_char = data[strlen (rule->d.own.service_name)]; + if (next_char != '\0' && next_char != '.') + continue; + } /* Use this rule */ allowed = rule->allow; @@ -1280,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_ENABLE_EMBEDDED_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_ENABLE_EMBEDDED_TESTS */ +