Main Page   Modules   Data Structures   File List   Data Fields   Related Pages  

policy.h

00001 /* -*- mode: C; c-file-style: "gnu" -*- */
00002 /* policy.h  Bus security policy
00003  *
00004  * Copyright (C) 2003  Red Hat, Inc.
00005  *
00006  * Licensed under the Academic Free License version 1.2
00007  * 
00008  * This program is free software; you can redistribute it and/or modify
00009  * it under the terms of the GNU General Public License as published by
00010  * the Free Software Foundation; either version 2 of the License, or
00011  * (at your option) any later version.
00012  *
00013  * This program is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016  * GNU General Public License for more details.
00017  * 
00018  * You should have received a copy of the GNU General Public License
00019  * along with this program; if not, write to the Free Software
00020  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00021  *
00022  */
00023 
00024 #ifndef BUS_POLICY_H
00025 #define BUS_POLICY_H
00026 
00027 #include <dbus/dbus.h>
00028 #include <dbus/dbus-string.h>
00029 #include <dbus/dbus-sysdeps.h>
00030 #include "bus.h"
00031 
00032 typedef enum
00033 {
00034   BUS_POLICY_RULE_SEND,
00035   BUS_POLICY_RULE_RECEIVE,
00036   BUS_POLICY_RULE_OWN,
00037   BUS_POLICY_RULE_USER,
00038   BUS_POLICY_RULE_GROUP
00039 } BusPolicyRuleType;
00040 
00042 #define BUS_POLICY_RULE_IS_PER_CLIENT(rule) (!((rule)->type == BUS_POLICY_RULE_USER || \
00043                                                (rule)->type == BUS_POLICY_RULE_GROUP))
00044 
00045 struct BusPolicyRule
00046 {
00047   int refcount;
00048   
00049   BusPolicyRuleType type;
00050 
00051   unsigned int allow : 1; 
00053   union
00054   {
00055     struct
00056     {
00057       /* message type can be DBUS_MESSAGE_TYPE_INVALID meaning "any" */
00058       int   message_type;
00059       /* any of these can be NULL meaning "any" */
00060       char *path;
00061       char *interface;
00062       char *member;
00063       char *error;
00064       char *destination;
00065     } send;
00066 
00067     struct
00068     {
00069       /* message type can be DBUS_MESSAGE_TYPE_INVALID meaning "any" */
00070       int   message_type;
00071       /* any of these can be NULL meaning "any" */
00072       char *path;
00073       char *interface;
00074       char *member;
00075       char *error;
00076       char *origin;
00077       unsigned int eavesdrop : 1;
00078     } receive;
00079 
00080     struct
00081     {
00082       /* can be NULL meaning "any" */
00083       char *service_name;
00084     } own;
00085 
00086     struct
00087     {
00088       /* can be DBUS_UID_UNSET meaning "any" */
00089       dbus_uid_t uid;
00090     } user;
00091 
00092     struct
00093     {
00094       /* can be DBUS_GID_UNSET meaning "any" */
00095       dbus_gid_t gid;
00096     } group;
00097     
00098   } d;
00099 };
00100 
00101 BusPolicyRule* bus_policy_rule_new   (BusPolicyRuleType type,
00102                                       dbus_bool_t       allow);
00103 void           bus_policy_rule_ref   (BusPolicyRule    *rule);
00104 void           bus_policy_rule_unref (BusPolicyRule    *rule);
00105 
00106 BusPolicy*       bus_policy_new                   (void);
00107 void             bus_policy_ref                   (BusPolicy        *policy);
00108 void             bus_policy_unref                 (BusPolicy        *policy);
00109 BusClientPolicy* bus_policy_create_client_policy  (BusPolicy        *policy,
00110                                                    DBusConnection   *connection,
00111                                                    DBusError        *error);
00112 dbus_bool_t      bus_policy_allow_user            (BusPolicy        *policy,
00113                                                    DBusUserDatabase *user_database,
00114                                                    unsigned long     uid);
00115 dbus_bool_t      bus_policy_append_default_rule   (BusPolicy        *policy,
00116                                                    BusPolicyRule    *rule);
00117 dbus_bool_t      bus_policy_append_mandatory_rule (BusPolicy        *policy,
00118                                                    BusPolicyRule    *rule);
00119 dbus_bool_t      bus_policy_append_user_rule      (BusPolicy        *policy,
00120                                                    dbus_uid_t        uid,
00121                                                    BusPolicyRule    *rule);
00122 dbus_bool_t      bus_policy_append_group_rule     (BusPolicy        *policy,
00123                                                    dbus_gid_t        gid,
00124                                                    BusPolicyRule    *rule);
00125 dbus_bool_t      bus_policy_merge                 (BusPolicy        *policy,
00126                                                    BusPolicy        *to_absorb);
00127 
00128 BusClientPolicy* bus_client_policy_new               (void);
00129 void             bus_client_policy_ref               (BusClientPolicy  *policy);
00130 void             bus_client_policy_unref             (BusClientPolicy  *policy);
00131 dbus_bool_t      bus_client_policy_check_can_send    (BusClientPolicy  *policy,
00132                                                       BusRegistry      *registry,
00133                                                       DBusConnection   *receiver,
00134                                                       DBusMessage      *message);
00135 dbus_bool_t      bus_client_policy_check_can_receive (BusClientPolicy  *policy,
00136                                                       BusRegistry      *registry,
00137                                                       DBusConnection   *sender,
00138                                                       DBusConnection   *addressed_recipient,
00139                                                       DBusConnection   *proposed_recipient,
00140                                                       DBusMessage      *message);
00141 dbus_bool_t      bus_client_policy_check_can_own     (BusClientPolicy  *policy,
00142                                                       DBusConnection   *connection,
00143                                                       const DBusString *service_name);
00144 dbus_bool_t      bus_client_policy_append_rule       (BusClientPolicy  *policy,
00145                                                       BusPolicyRule    *rule);
00146 void             bus_client_policy_optimize          (BusClientPolicy  *policy);
00147 
00148 
00149 #endif /* BUS_POLICY_H */

Generated on Mon Sep 29 21:31:02 2003 for D-BUS by doxygen1.2.15