1 /* -*- mode: C; c-file-style: "gnu" -*- */
2 /* policy.h Bus security policy
4 * Copyright (C) 2003 Red Hat, Inc.
6 * Licensed under the Academic Free License version 1.2
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 #include <dbus/dbus.h>
28 #include <dbus/dbus-string.h>
29 #include <dbus/dbus-sysdeps.h>
35 BUS_POLICY_RULE_RECEIVE,
41 /** determines whether the rule affects a connection, or some global item */
42 #define BUS_POLICY_RULE_IS_PER_CLIENT(rule) (!((rule)->type == BUS_POLICY_RULE_USER || \
43 (rule)->type == BUS_POLICY_RULE_GROUP))
49 BusPolicyRuleType type;
51 unsigned int allow : 1; /**< #TRUE if this allows, #FALSE if it denies */
57 /* message type can be DBUS_MESSAGE_TYPE_INVALID meaning "any" */
59 /* any of these can be NULL meaning "any" */
69 /* message type can be DBUS_MESSAGE_TYPE_INVALID meaning "any" */
71 /* any of these can be NULL meaning "any" */
77 unsigned int eavesdrop : 1;
82 /* can be NULL meaning "any" */
88 /* can be DBUS_UID_UNSET meaning "any" */
94 /* can be DBUS_GID_UNSET meaning "any" */
101 BusPolicyRule* bus_policy_rule_new (BusPolicyRuleType type,
103 void bus_policy_rule_ref (BusPolicyRule *rule);
104 void bus_policy_rule_unref (BusPolicyRule *rule);
106 BusPolicy* bus_policy_new (void);
107 void bus_policy_ref (BusPolicy *policy);
108 void bus_policy_unref (BusPolicy *policy);
109 BusClientPolicy* bus_policy_create_client_policy (BusPolicy *policy,
110 DBusConnection *connection,
112 dbus_bool_t bus_policy_allow_user (BusPolicy *policy,
113 DBusUserDatabase *user_database,
115 dbus_bool_t bus_policy_append_default_rule (BusPolicy *policy,
116 BusPolicyRule *rule);
117 dbus_bool_t bus_policy_append_mandatory_rule (BusPolicy *policy,
118 BusPolicyRule *rule);
119 dbus_bool_t bus_policy_append_user_rule (BusPolicy *policy,
121 BusPolicyRule *rule);
122 dbus_bool_t bus_policy_append_group_rule (BusPolicy *policy,
124 BusPolicyRule *rule);
125 dbus_bool_t bus_policy_merge (BusPolicy *policy,
126 BusPolicy *to_absorb);
128 BusClientPolicy* bus_client_policy_new (void);
129 void bus_client_policy_ref (BusClientPolicy *policy);
130 void bus_client_policy_unref (BusClientPolicy *policy);
131 dbus_bool_t bus_client_policy_check_can_send (BusClientPolicy *policy,
132 BusRegistry *registry,
133 DBusConnection *receiver,
134 DBusMessage *message);
135 dbus_bool_t bus_client_policy_check_can_receive (BusClientPolicy *policy,
136 BusRegistry *registry,
137 DBusConnection *sender,
138 DBusConnection *addressed_recipient,
139 DBusConnection *proposed_recipient,
140 DBusMessage *message);
141 dbus_bool_t bus_client_policy_check_can_own (BusClientPolicy *policy,
142 DBusConnection *connection,
143 const DBusString *service_name);
144 dbus_bool_t bus_client_policy_append_rule (BusClientPolicy *policy,
145 BusPolicyRule *rule);
146 void bus_client_policy_optimize (BusClientPolicy *policy);
149 #endif /* BUS_POLICY_H */