/daten/src/linux-2.4.27-rsbac-v1.2.3/rsbac/adf/daz/dazuko_xp.h

Go to the documentation of this file.
00001 /* DazukoXP. Allow cross platform file access control for 3rd-party applications. 00002 Written by John Ogness <jogness@antivir.de> 00003 00004 Copyright (c) 2002, 2003, 2004 H+BEDV Datentechnik GmbH 00005 All rights reserved. 00006 00007 Redistribution and use in source and binary forms, with or without 00008 modification, are permitted provided that the following conditions 00009 are met: 00010 00011 1. Redistributions of source code must retain the above copyright notice, 00012 this list of conditions and the following disclaimer. 00013 00014 2. Redistributions in binary form must reproduce the above copyright notice, 00015 this list of conditions and the following disclaimer in the documentation 00016 and/or other materials provided with the distribution. 00017 00018 3. Neither the name of Dazuko nor the names of its contributors may be used 00019 to endorse or promote products derived from this software without specific 00020 prior written permission. 00021 00022 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00023 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00024 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00025 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 00026 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00027 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 00028 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00029 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00030 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 00031 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00032 POSSIBILITY OF SUCH DAMAGE. 00033 */ 00034 00035 #ifndef DAZUKO_XP_H 00036 #define DAZUKO_XP_H 00037 00038 #define VERSION "2.0.2" 00039 00040 #include "dazukoio_xp.h" 00041 00042 /* various requests */ 00043 #define SET_ACCESS_MASK 0 00044 #define ADD_INCLUDE_PATH 1 00045 #define ADD_EXCLUDE_PATH 2 00046 #define REGISTER 3 00047 #define REMOVE_ALL_PATHS 4 00048 #define UNREGISTER 5 00049 #define GET_AN_ACCESS 6 00050 #define RETURN_AN_ACCESS 7 00051 00052 /* slot states */ 00053 #define DAZUKO_FREE 0 /* the daemon is not ready */ 00054 #define DAZUKO_READY 1 /* a daemon waits for something to do */ 00055 #define DAZUKO_WAITING 2 /* a request is waiting to be served */ 00056 #define DAZUKO_WORKING 3 /* daemon is currently in action */ 00057 #define DAZUKO_DONE 4 /* daemon response is available */ 00058 #define DAZUKO_BROKEN 5 /* invalid state (interrupt from ready,waiting) */ 00059 00060 00061 /********************************************************* 00062 * structures that MUST be implemented by platform-layer * 00063 *********************************************************/ 00064 00065 /* 00066 struct xp_file; 00067 struct xp_mutex; 00068 struct xp_atomic; 00069 struct xp_file_struct; 00070 struct xp_queue; 00071 struct xp_rwlock; 00072 struct xp_daemon_id; 00073 */ 00074 00075 00076 /****************************************** 00077 * structures available to platform-layer * 00078 ******************************************/ 00079 00080 struct event_properties 00081 { 00082 int thrown; 00083 00084 int flags; 00085 char set_flags; 00086 int mode; 00087 char set_mode; 00088 int uid; 00089 char set_uid; 00090 int pid; 00091 char set_pid; 00092 }; 00093 00094 struct file_properties 00095 { 00096 unsigned long size; 00097 char set_size; 00098 int uid; 00099 char set_uid; 00100 int gid; 00101 char set_gid; 00102 int mode; 00103 char set_mode; 00104 int device_type; 00105 char set_device_type; 00106 }; 00107 00108 struct dazuko_file_struct 00109 { 00110 /* A structure designed for simple and 00111 * intelligent memory management when 00112 * doing filename lookups in the kernel. */ 00113 00114 int should_scan; /* already know we need to scan? */ 00115 char *filename; /* filename */ 00116 int filename_length; /* length of filename */ 00117 struct file_properties file_p; /* properties of file */ 00118 struct xp_file_struct *extra_data; /* extra platform-dependant data */ 00119 }; 00120 00121 00122 /******************************************************** 00123 * functions that MUST be implemented by platform-layer * 00124 ********************************************************/ 00125 00126 /* mutex */ 00127 int xp_init_mutex(struct xp_mutex *mutex); 00128 int xp_down(struct xp_mutex *mutex); 00129 int xp_up(struct xp_mutex *mutex); 00130 int xp_destroy_mutex(struct xp_mutex *mutex); 00131 00132 /* read-write lock */ 00133 int xp_init_rwlock(struct xp_rwlock *rwlock); 00134 int xp_write_lock(struct xp_rwlock *rwlock); 00135 int xp_write_unlock(struct xp_rwlock *rwlock); 00136 int xp_read_lock(struct xp_rwlock *rlock); 00137 int xp_read_unlock(struct xp_rwlock *rlock); 00138 int xp_destroy_rwlock(struct xp_rwlock *rwlock); 00139 00140 /* wait-notify queue */ 00141 int xp_init_queue(struct xp_queue *queue); 00142 int xp_wait_until_condition(struct xp_queue *queue, int (*cfunction)(void *), void *cparam, int allow_interrupt); 00143 int xp_notify(struct xp_queue *queue); 00144 int xp_destroy_queue(struct xp_queue *queue); 00145 00146 /* memory */ 00147 void* xp_malloc(size_t size); 00148 int xp_free(void *ptr); 00149 int xp_copyin(const void *user_src, void *kernel_dest, size_t size); 00150 int xp_copyout(const void *kernel_src, void *user_dest, size_t size); 00151 int xp_verify_user_writable(const void *user_ptr, size_t size); 00152 int xp_verify_user_readable(const void *user_ptr, size_t size); 00153 00154 /* path attribute */ 00155 int xp_is_absolute_path(const char *path); 00156 00157 /* atomic */ 00158 int xp_atomic_set(struct xp_atomic *atomic, int value); 00159 int xp_atomic_inc(struct xp_atomic *atomic); 00160 int xp_atomic_dec(struct xp_atomic *atomic); 00161 int xp_atomic_read(struct xp_atomic *atomic); 00162 00163 /* file descriptor */ 00164 int xp_copy_file(struct xp_file *dest, struct xp_file *src); 00165 int xp_compare_file(struct xp_file *file1, struct xp_file *file2); 00166 00167 /* system hook */ 00168 int xp_sys_hook(void); 00169 int xp_sys_unhook(void); 00170 00171 /* file structure */ 00172 int xp_file_struct_check(struct dazuko_file_struct *dfs); 00173 int xp_file_struct_check_cleanup(struct dazuko_file_struct *dfs); 00174 00175 /* daemon id */ 00176 int xp_id_compare(struct xp_daemon_id *id1, struct xp_daemon_id *id2); 00177 int xp_id_free(struct xp_daemon_id *id); 00178 struct xp_daemon_id* xp_id_copy(struct xp_daemon_id *id); 00179 00180 /* output */ 00181 int xp_print(const char *fmt, ...); 00182 00183 /* debug */ 00184 #ifdef DEBUG 00185 #define DPRINT(fmt) xp_print fmt 00186 #else 00187 #define DPRINT(fmt) 00188 #endif 00189 00190 00191 /***************************************** 00192 * functions available to platform-layer * 00193 *****************************************/ 00194 00195 int dazuko_vsnprintf(char *str, size_t size, const char *format, va_list ap); 00196 int dazuko_snprintf(char *str, size_t size, const char *format, ...); 00197 int dazuko_is_our_daemon(struct xp_daemon_id *xp_id); 00198 int dazuko_get_value(const char *key, const char *string, char **value); 00199 int dazuko_unregister_daemon(struct xp_daemon_id *xp_id); 00200 int dazuko_handle_user_request(struct dazuko_request *user_request, struct xp_daemon_id *xp_id); 00201 int dazuko_handle_user_request_compat12(void *ptr, int cmd, struct xp_daemon_id *xp_id); 00202 int dazuko_get_filename_length(char *filename); 00203 void dazuko_bzero(void *p, int len); 00204 int dazuko_sys_check(unsigned long event, int daemon_is_allowed, struct xp_daemon_id *xp_id); 00205 int dazuko_sys_pre(unsigned long event, struct dazuko_file_struct *kfs, struct event_properties *event_p); 00206 int dazuko_sys_post(unsigned long event, struct dazuko_file_struct *kfs, struct xp_file *file, struct event_properties *event_p); 00207 int dazuko_init(void); 00208 int dazuko_exit(void); 00209 00210 #endif

Generated on Tue Aug 31 10:05:23 2004 for RSBAC by doxygen 1.3.8