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, 2005 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.5"
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 /* file types */
00061 #define DAZUKO_NONE             0
00062 #define DAZUKO_REGULAR          1
00063 #define DAZUKO_DIRECTORY        2
00064 #define DAZUKO_LINK             3
00065 
00066 
00067 /*********************************************************
00068  * structures that MUST be implemented by platform-layer *
00069  *********************************************************/
00070 
00071 /*
00072 struct xp_file;
00073 struct xp_mutex;
00074 struct xp_atomic;
00075 struct xp_file_struct;
00076 struct xp_queue;
00077 struct xp_rwlock;
00078 struct xp_daemon_id;
00079 */
00080 
00081 
00082 /******************************************
00083  * structures available to platform-layer *
00084  ******************************************/
00085 
00086 struct event_properties
00087 {
00088         int     thrown;
00089 
00090         int     flags;
00091         char    set_flags;
00092         int     mode;
00093         char    set_mode;
00094         int     uid;
00095         char    set_uid;
00096         int     pid;
00097         char    set_pid;
00098 };
00099 
00100 struct file_properties
00101 {
00102         unsigned long   size;
00103         char            set_size;
00104         int             uid;
00105         char            set_uid;
00106         int             gid;
00107         char            set_gid;
00108         int             mode;
00109         char            set_mode;
00110         int             device_type;
00111         char            set_device_type;
00112         int             type;
00113         char            set_type;
00114 };
00115 
00116 struct dazuko_file_listnode
00117 {
00118         char                            *filename;
00119         int                             filename_length;
00120         struct dazuko_file_listnode     *next;
00121 };
00122 
00123 struct dazuko_file_struct
00124 {
00125         /* A structure designed for simple and
00126          * intelligent memory management when
00127          * doing filename lookups in the kernel. */
00128 
00129         int                             should_scan;            /* already know we need to scan? */
00130         char                            *filename;              /* filename to report (pointer in alias list) */
00131         int                             filename_length;        /* length of filename reported */
00132         struct dazuko_file_listnode     *aliases;               /* list of file names (alias names) */
00133         struct file_properties          file_p;                 /* properties of file */
00134         struct xp_file_struct           *extra_data;            /* extra platform-dependant data */
00135 };
00136 
00137 
00138 /********************************************************
00139  * functions that MUST be implemented by platform-layer *
00140  ********************************************************/
00141 
00142 /* mutex */
00143 int xp_init_mutex(struct xp_mutex *mutex);
00144 int xp_down(struct xp_mutex *mutex);
00145 int xp_up(struct xp_mutex *mutex);
00146 int xp_destroy_mutex(struct xp_mutex *mutex);
00147 
00148 /* read-write lock */
00149 int xp_init_rwlock(struct xp_rwlock *rwlock);
00150 int xp_write_lock(struct xp_rwlock *rwlock);
00151 int xp_write_unlock(struct xp_rwlock *rwlock);
00152 int xp_read_lock(struct xp_rwlock *rlock);
00153 int xp_read_unlock(struct xp_rwlock *rlock);
00154 int xp_destroy_rwlock(struct xp_rwlock *rwlock);
00155 
00156 /* wait-notify queue */
00157 int xp_init_queue(struct xp_queue *queue);
00158 int xp_wait_until_condition(struct xp_queue *queue, int (*cfunction)(void *), void *cparam, int allow_interrupt);
00159 int xp_notify(struct xp_queue *queue);
00160 int xp_destroy_queue(struct xp_queue *queue);
00161 
00162 /* memory */
00163 void* xp_malloc(size_t size);
00164 int xp_free(void *ptr);
00165 int xp_copyin(const void *user_src, void *kernel_dest, size_t size);
00166 int xp_copyout(const void *kernel_src, void *user_dest, size_t size);
00167 int xp_verify_user_writable(const void *user_ptr, size_t size);
00168 int xp_verify_user_readable(const void *user_ptr, size_t size);
00169 
00170 /* path attribute */
00171 int xp_is_absolute_path(const char *path);
00172 
00173 /* atomic */
00174 int xp_atomic_set(struct xp_atomic *atomic, int value);
00175 int xp_atomic_inc(struct xp_atomic *atomic);
00176 int xp_atomic_dec(struct xp_atomic *atomic);
00177 int xp_atomic_read(struct xp_atomic *atomic);
00178 
00179 /* file descriptor */
00180 int xp_copy_file(struct xp_file *dest, struct xp_file *src);
00181 int xp_compare_file(struct xp_file *file1, struct xp_file *file2);
00182 
00183 /* system hook */
00184 int xp_sys_hook(void);
00185 int xp_sys_unhook(void);
00186 
00187 /* file structure */
00188 int xp_fill_file_struct(struct dazuko_file_struct *dfs);
00189 
00190 /* daemon id */
00191 int xp_id_compare(struct xp_daemon_id *id1, struct xp_daemon_id *id2);
00192 int xp_id_free(struct xp_daemon_id *id);
00193 struct xp_daemon_id* xp_id_copy(struct xp_daemon_id *id);
00194 
00195 /* output */
00196 int xp_print(const char *fmt, ...);
00197 
00198 /* debug */
00199 #ifdef DEBUG
00200 #define DPRINT(fmt) xp_print fmt
00201 #else
00202 #define DPRINT(fmt)
00203 #endif
00204 
00205 
00206 /*****************************************
00207  * functions available to platform-layer *
00208  *****************************************/
00209 
00210 int dazuko_vsnprintf(char *str, size_t size, const char *format, va_list ap);
00211 int dazuko_snprintf(char *str, size_t size, const char *format, ...);
00212 int dazuko_is_our_daemon(struct xp_daemon_id *xp_id);
00213 int dazuko_get_value(const char *key, const char *string, char **value);
00214 int dazuko_unregister_daemon(struct xp_daemon_id *xp_id);
00215 int dazuko_handle_user_request(struct dazuko_request *user_request, struct xp_daemon_id *xp_id);
00216 int dazuko_handle_user_request_compat12(void *ptr, int cmd, struct xp_daemon_id *xp_id);
00217 int dazuko_get_filename_length(char *filename);
00218 void dazuko_bzero(void *p, int len);
00219 int dazuko_sys_check(unsigned long event, int daemon_is_allowed, struct xp_daemon_id *xp_id);
00220 int dazuko_sys_pre(unsigned long event, struct dazuko_file_struct *kfs, struct xp_file *file, struct event_properties *event_p);
00221 int dazuko_sys_post(unsigned long event, struct dazuko_file_struct *kfs, struct xp_file *file, struct event_properties *event_p);
00222 int dazuko_init(void);
00223 int dazuko_exit(void);
00224 
00225 #endif

Generated on Fri Jun 17 09:45:19 2005 for RSBAC by  doxygen 1.4.2