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       /* either can be NULL meaning "any" */
00058       char *message_name;
00059       char *destination;
00060     } send;
00061 
00062     struct
00063     {
00064       /* either can be NULL meaning "any" */
00065       char *message_name;
00066       char *origin;
00067     } receive;
00068 
00069     struct
00070     {
00071       /* can be NULL meaning "any" */
00072       char *service_name;
00073     } own;
00074 
00075     struct
00076     {
00077       /* can be DBUS_UID_UNSET meaning "any" */
00078       dbus_uid_t uid;
00079     } user;
00080 
00081     struct
00082     {
00083       /* can be DBUS_GID_UNSET meaning "any" */
00084       dbus_gid_t gid;
00085     } group;
00086     
00087   } d;
00088 };
00089 
00090 BusPolicyRule* bus_policy_rule_new   (BusPolicyRuleType type,
00091                                       dbus_bool_t       allow);
00092 void           bus_policy_rule_ref   (BusPolicyRule    *rule);
00093 void           bus_policy_rule_unref (BusPolicyRule    *rule);
00094 
00095 BusPolicy*       bus_policy_new                   (void);
00096 void             bus_policy_ref                   (BusPolicy        *policy);
00097 void             bus_policy_unref                 (BusPolicy        *policy);
00098 BusClientPolicy* bus_policy_create_client_policy  (BusPolicy        *policy,
00099                                                    DBusConnection   *connection,
00100                                                    DBusError        *error);
00101 dbus_bool_t      bus_policy_allow_user            (BusPolicy        *policy,
00102                                                    DBusUserDatabase *user_database,
00103                                                    unsigned long     uid);
00104 dbus_bool_t      bus_policy_append_default_rule   (BusPolicy        *policy,
00105                                                    BusPolicyRule    *rule);
00106 dbus_bool_t      bus_policy_append_mandatory_rule (BusPolicy        *policy,
00107                                                    BusPolicyRule    *rule);
00108 dbus_bool_t      bus_policy_append_user_rule      (BusPolicy        *policy,
00109                                                    dbus_uid_t        uid,
00110                                                    BusPolicyRule    *rule);
00111 dbus_bool_t      bus_policy_append_group_rule     (BusPolicy        *policy,
00112                                                    dbus_gid_t        gid,
00113                                                    BusPolicyRule    *rule);
00114 dbus_bool_t      bus_policy_merge                 (BusPolicy        *policy,
00115                                                    BusPolicy        *to_absorb);
00116 
00117 BusClientPolicy* bus_client_policy_new               (void);
00118 void             bus_client_policy_ref               (BusClientPolicy  *policy);
00119 void             bus_client_policy_unref             (BusClientPolicy  *policy);
00120 dbus_bool_t      bus_client_policy_check_can_send    (BusClientPolicy  *policy,
00121                                                       BusRegistry      *registry,
00122                                                       DBusConnection   *receiver,
00123                                                       DBusMessage      *message);
00124 dbus_bool_t      bus_client_policy_check_can_receive (BusClientPolicy  *policy,
00125                                                       BusRegistry      *registry,
00126                                                       DBusConnection   *sender,
00127                                                       DBusMessage      *message);
00128 dbus_bool_t      bus_client_policy_check_can_own     (BusClientPolicy  *policy,
00129                                                       DBusConnection   *connection,
00130                                                       const DBusString *service_name);
00131 dbus_bool_t      bus_client_policy_append_rule       (BusClientPolicy  *policy,
00132                                                       BusPolicyRule    *rule);
00133 void             bus_client_policy_optimize          (BusClientPolicy  *policy);
00134 
00135 
00136 #endif /* BUS_POLICY_H */

Generated on Wed Oct 22 14:05:06 2003 for D-BUS by doxygen1.3-rc3