-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpolicy.c
69 lines (55 loc) · 2.62 KB
/
policy.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include "policy.h"
#include <stdbool.h>
#define POLICY_T_BATCH \
"bt" \
"a(btbs)" \
"a(btssssuutt)" \
"a(btssssuutt)"
#define POLICY_T \
"a(u(" POLICY_T_BATCH "))" \
"a(buu(" POLICY_T_BATCH "))" \
"a(ss)" \
"b"
#define POLICY_PRIORITY_DEFAULT (UINT64_C(1))
/*
* At the moment, we just allow everything
* The syntax of the policy is not stable yet: refer to
* dbus-broker/src/launch/policy.c and dbus-broker/src/bus/policy.c
*/
void policy_export_connect(sd_bus_message *m) {
sd_bus_message_append(m, "bt", true, POLICY_PRIORITY_DEFAULT);
}
void policy_export_own(sd_bus_message *m) {
sd_bus_message_open_container(m, 'a', "(btbs)");
sd_bus_message_append(m, "(btbs)", true, POLICY_PRIORITY_DEFAULT, true, "");
sd_bus_message_close_container(m);
}
void policy_export_xmit(sd_bus_message *m) {
sd_bus_message_open_container(m, 'a', "(btssssuutt)");
sd_bus_message_append(m, "(btssssuutt)", true, POLICY_PRIORITY_DEFAULT, "", "", "", "", 0, 0, 0, (uint64_t)-1);
sd_bus_message_close_container(m);
}
int policy(sd_bus_message *m) {
int r;
r = sd_bus_message_open_container(m, 'v', "(" POLICY_T ")");
r = sd_bus_message_open_container(m, 'r', POLICY_T);
r = sd_bus_message_open_container(m, 'a', "(u(" POLICY_T_BATCH "))");
r = sd_bus_message_open_container(m, 'r', "u(" POLICY_T_BATCH ")");
r = sd_bus_message_append(m, "u", (uint32_t)-1);
r = sd_bus_message_open_container(m, 'r', POLICY_T_BATCH);
policy_export_connect(m);
policy_export_own(m);
policy_export_xmit(m);
policy_export_xmit(m);
r = sd_bus_message_close_container(m);
r = sd_bus_message_close_container(m);
r = sd_bus_message_close_container(m);
r = sd_bus_message_open_container(m, 'a', "(buu(" POLICY_T_BATCH "))");
r = sd_bus_message_close_container(m);
r = sd_bus_message_open_container(m, 'a', "(ss)");
r = sd_bus_message_close_container(m);
r = sd_bus_message_append(m, "b", false);
r = sd_bus_message_close_container(m);
r = sd_bus_message_close_container(m);
return r;
}