summaryrefslogtreecommitdiff
path: root/bus
diff options
context:
space:
mode:
authorAlban Crequy <alban.crequy@collabora.co.uk>2012-03-04 14:36:56 +0000
committerAlban Crequy <alban.crequy@collabora.co.uk>2012-03-04 14:36:56 +0000
commit5670dc6cf722ea552ea4e41f5742ec447f6cddf8 (patch)
tree87f031ded2b72d3d2b8c42c8a95c1f50636f4299 /bus
parent915b71be4423648c947357fdac65446cee92450d (diff)
downloaddbus-5670dc6cf722ea552ea4e41f5742ec447f6cddf8.tar.gz
config parser: add own_prefix
https://bugs.freedesktop.org/show_bug.cgi?id=46882
Diffstat (limited to 'bus')
-rw-r--r--bus/config-parser.c57
-rw-r--r--bus/policy.h2
2 files changed, 38 insertions, 21 deletions
diff --git a/bus/config-parser.c b/bus/config-parser.c
index a8953627..b83c1b3e 100644
--- a/bus/config-parser.c
+++ b/bus/config-parser.c
@@ -1154,6 +1154,7 @@ append_rule_from_element (BusConfigParser *parser,
const char *send_requested_reply;
const char *receive_requested_reply;
const char *own;
+ const char *own_prefix;
const char *user;
const char *group;
@@ -1179,6 +1180,7 @@ append_rule_from_element (BusConfigParser *parser,
"send_requested_reply", &send_requested_reply,
"receive_requested_reply", &receive_requested_reply,
"own", &own,
+ "own_prefix", &own_prefix,
"user", &user,
"group", &group,
"log", &log,
@@ -1190,7 +1192,7 @@ append_rule_from_element (BusConfigParser *parser,
receive_interface || receive_member || receive_error || receive_sender ||
receive_type || receive_path || eavesdrop ||
send_requested_reply || receive_requested_reply ||
- own || user || group))
+ own || own_prefix || user || group))
{
dbus_set_error (error, DBUS_ERROR_FAILED,
"Element <%s> must have one or more attributes",
@@ -1218,7 +1220,7 @@ append_rule_from_element (BusConfigParser *parser,
* base send_ can combine with send_destination, send_path, send_type, send_requested_reply
* base receive_ with receive_sender, receive_path, receive_type, receive_requested_reply, eavesdrop
*
- * user, group, own must occur alone
+ * user, group, own, own_prefix must occur alone
*
* Pretty sure the below stuff is broken, FIXME think about it more.
*/
@@ -1229,7 +1231,7 @@ append_rule_from_element (BusConfigParser *parser,
receive_error ||
receive_sender ||
receive_requested_reply ||
- own ||
+ own || own_prefix ||
user ||
group)) ||
@@ -1239,7 +1241,7 @@ append_rule_from_element (BusConfigParser *parser,
receive_error ||
receive_sender ||
receive_requested_reply ||
- own ||
+ own || own_prefix ||
user ||
group)) ||
@@ -1248,7 +1250,7 @@ append_rule_from_element (BusConfigParser *parser,
receive_error ||
receive_sender ||
receive_requested_reply ||
- own ||
+ own || own_prefix ||
user ||
group)) ||
@@ -1257,7 +1259,7 @@ append_rule_from_element (BusConfigParser *parser,
receive_error ||
receive_sender ||
receive_requested_reply ||
- own ||
+ own || own_prefix ||
user ||
group)) ||
@@ -1266,7 +1268,7 @@ append_rule_from_element (BusConfigParser *parser,
receive_error ||
receive_sender ||
receive_requested_reply ||
- own ||
+ own || own_prefix ||
user ||
group)) ||
@@ -1275,7 +1277,7 @@ append_rule_from_element (BusConfigParser *parser,
receive_error ||
receive_sender ||
receive_requested_reply ||
- own ||
+ own || own_prefix ||
user ||
group)) ||
@@ -1284,33 +1286,35 @@ append_rule_from_element (BusConfigParser *parser,
receive_error ||
receive_sender ||
receive_requested_reply ||
- own ||
+ own || own_prefix ||
user ||
group)) ||
(receive_interface && (receive_error ||
- own ||
+ own || own_prefix ||
user ||
group)) ||
(receive_member && (receive_error ||
- own ||
+ own || own_prefix ||
user ||
group)) ||
- (receive_error && (own ||
+ (receive_error && (own || own_prefix ||
user ||
group)) ||
- (eavesdrop && (own ||
+ (eavesdrop && (own || own_prefix ||
user ||
group)) ||
- (receive_requested_reply && (own ||
+ (receive_requested_reply && (own || own_prefix ||
user ||
group)) ||
- (own && (user || group)) ||
+ (own && (own_prefix || user || group)) ||
+
+ (own_prefix && (own || user || group)) ||
(user && group))
{
@@ -1488,18 +1492,29 @@ append_rule_from_element (BusConfigParser *parser,
if (receive_sender && rule->d.receive.origin == NULL)
goto nomem;
}
- else if (own)
+ else if (own || own_prefix)
{
rule = bus_policy_rule_new (BUS_POLICY_RULE_OWN, allow);
if (rule == NULL)
goto nomem;
- if (IS_WILDCARD (own))
- own = NULL;
+ if (own)
+ {
+ if (IS_WILDCARD (own))
+ own = NULL;
- rule->d.own.service_name = _dbus_strdup (own);
- if (own && rule->d.own.service_name == NULL)
- goto nomem;
+ rule->d.own.prefix = 0;
+ rule->d.own.service_name = _dbus_strdup (own);
+ if (own && rule->d.own.service_name == NULL)
+ goto nomem;
+ }
+ else
+ {
+ rule->d.own.prefix = 1;
+ rule->d.own.service_name = _dbus_strdup (own_prefix);
+ if (rule->d.own.service_name == NULL)
+ goto nomem;
+ }
}
else if (user)
{
diff --git a/bus/policy.h b/bus/policy.h
index 1782dbf3..4b3ce70e 100644
--- a/bus/policy.h
+++ b/bus/policy.h
@@ -86,6 +86,8 @@ struct BusPolicyRule
{
/* can be NULL meaning "any" */
char *service_name;
+ /* if prefix is set, any name starting with service_name can be owned */
+ unsigned int prefix : 1;
} own;
struct