dazuko_core.h File Reference

#include "dazuko_transport.h"
#include "dazuko_events.h"

Go to the source code of this file.

Defines

#define DAZUKO_DIFFERENT   0
#define DAZUKO_SUSPICIOUS   1
#define DAZUKO_CHILD   2
#define DAZUKO_SAME   3
#define DAZUKO_NONE   0
#define DAZUKO_REGULAR   1
#define DAZUKO_DIRECTORY   2
#define DAZUKO_LINK   3
#define DPRINT(fmt)

Functions

void xp_init_mutex (struct xp_mutex *mutex)
void xp_down (struct xp_mutex *mutex)
void xp_up (struct xp_mutex *mutex)
void xp_destroy_mutex (struct xp_mutex *mutex)
void xp_init_rwlock (struct xp_rwlock *rwlock)
void xp_write_lock (struct xp_rwlock *rwlock)
void xp_write_unlock (struct xp_rwlock *rwlock)
void xp_read_lock (struct xp_rwlock *rlock)
void xp_read_unlock (struct xp_rwlock *rlock)
void xp_destroy_rwlock (struct xp_rwlock *rwlock)
int xp_init_queue (struct xp_queue *queue)
int xp_wait_until_condition (struct xp_queue *queue, int(*cfunction)(void *), void *cparam, int allow_interrupt)
int xp_notify (struct xp_queue *queue)
int xp_destroy_queue (struct xp_queue *queue)
void * xp_malloc (size_t size)
int xp_free (void *ptr)
int xp_copyin (const void *user_src, void *kernel_dest, size_t size)
int xp_copyout (const void *kernel_src, void *user_dest, size_t size)
int xp_verify_user_writable (const void *user_ptr, size_t size)
int xp_verify_user_readable (const void *user_ptr, size_t size)
int xp_is_absolute_path (const char *path)
int xp_atomic_set (struct xp_atomic *atomic, int value)
int xp_atomic_inc (struct xp_atomic *atomic)
int xp_atomic_dec (struct xp_atomic *atomic)
int xp_atomic_read (struct xp_atomic *atomic)
int xp_sys_hook (void)
int xp_sys_unhook (void)
int xp_fill_file_struct (struct dazuko_file_struct *dfs)
int xp_id_compare (struct xp_daemon_id *id1, struct xp_daemon_id *id2, int check_related)
int xp_id_free (struct xp_daemon_id *id)
xp_daemon_idxp_id_copy (struct xp_daemon_id *id)
int xp_set_event_properties (struct event_properties *event_p, struct xp_daemon_id *xp_id)
int xp_init_cache (unsigned long ttl)
int xp_print (const char *fmt,...)
int dazuko_vsnprintf (char *str, size_t size, const char *format, va_list ap)
int dazuko_snprintf (char *str, size_t size, const char *format,...)
int dazuko_is_our_daemon (struct xp_daemon_id *xp_id, struct slot_list **slotlist)
int dazuko_get_value (const char *key, const char *string, char **value)
int dazuko_unregister_daemon (struct xp_daemon_id *xp_id)
int dazuko_handle_user_request (const char *request_buffer, struct xp_daemon_id *xp_id)
int dazuko_handle_user_request_compat1 (void *ptr, int cmd, struct xp_daemon_id *xp_id)
int dazuko_get_filename_length (const char *filename)
void dazuko_bzero (void *p, int len)
int dazuko_check_access (unsigned long event, int daemon_is_allowed, struct xp_daemon_id *xp_id, struct slot_list **cached_lookup)
int dazuko_process_access (unsigned long event, struct dazuko_file_struct *kfs, struct event_properties *event_p, struct slot_list *cached_lookup)
int dazuko_init (void)
int dazuko_exit (void)


Define Documentation

#define DAZUKO_CHILD   2
 

Definition at line 44 of file dazuko_core.h.

Referenced by dazuko_is_our_daemon(), and xp_id_compare().

#define DAZUKO_DIFFERENT   0
 

Definition at line 42 of file dazuko_core.h.

Referenced by xp_id_compare().

#define DAZUKO_DIRECTORY   2
 

Definition at line 50 of file dazuko_core.h.

Referenced by xp_fill_file_struct().

#define DAZUKO_LINK   3
 

Definition at line 51 of file dazuko_core.h.

Referenced by xp_fill_file_struct().

#define DAZUKO_NONE   0
 

Definition at line 48 of file dazuko_core.h.

#define DAZUKO_REGULAR   1
 

Definition at line 49 of file dazuko_core.h.

Referenced by xp_fill_file_struct().

#define DAZUKO_SAME   3
 

Definition at line 45 of file dazuko_core.h.

Referenced by _dazuko_find_slot(), dazuko_add_trusted_daemon(), dazuko_is_our_daemon(), dazuko_unregister_trusted_daemon(), and xp_id_compare().

#define DAZUKO_SUSPICIOUS   1
 

Definition at line 43 of file dazuko_core.h.

Referenced by dazuko_is_our_daemon(), and xp_id_compare().

#define DPRINT fmt   ) 
 

Definition at line 187 of file dazuko_core.h.

Referenced by _dazuko_unregister_daemon(), dazuko_get_an_access(), dazuko_handle_request_return_an_access(), dazuko_handle_user_request_compat1(), dazuko_insert_path_fs(), dazuko_is_our_daemon(), dazuko_register_daemon(), dazuko_remove_all_hash(), dazuko_remove_all_paths(), dazuko_return_access(), dazuko_run_daemon_on_slotlist(), linux_dazuko_device_open(), linux_dazuko_device_read(), and linux_dazuko_device_release().


Function Documentation

void dazuko_bzero void *  p,
int  len
[inline]
 

Definition at line 306 of file dazuko_core.c.

00307 {
00308         /* "zero out" len bytes starting with p */
00309 
00310         char    *ptr = (char *)p;
00311 
00312         while (len--)
00313                 *ptr++ = 0;
00314 }

int dazuko_check_access unsigned long  event,
int  daemon_is_allowed,
struct xp_daemon_id xp_id,
struct slot_list **  cached_lookup
 

Definition at line 3327 of file dazuko_core.c.

References access_mask_cache, AMC_UNSET, call_xp_atomic_read(), call_xp_down(), call_xp_up(), dazuko_event2index(), dazuko_is_our_daemon(), NULL, and NUM_EVENTS.

Referenced by dazuko_sys_generic(), and linux_dazuko_sys_generic().

03328 {       
03329         int                     i;
03330         struct slot_list        *sl = NULL;
03331 
03332         /* do we have any daemons? */
03333         if (call_xp_atomic_read(&active) <= 0)
03334                 return -1;
03335 
03336         /* is a group interested in this event type? */
03337 
03338         i = dazuko_event2index(event);
03339         if (i < 0 || i >= NUM_EVENTS)
03340                 return -1;
03341 
03342 /* DOWN */
03343         call_xp_down(&mutex_amc);
03344 
03345         i = access_mask_cache[i][0];
03346 
03347         call_xp_up(&mutex_amc);
03348 /* UP */
03349 
03350         if (i == AMC_UNSET)
03351                 return -1;
03352 
03353         if (dazuko_is_our_daemon(xp_id, &sl))
03354         {
03355                 /* should daemons be allowed this event without a scan? */
03356                 if (daemon_is_allowed)
03357                 {
03358                         /* this is one of our daemons, so we will report as
03359                          * as if this event was not in the mask */
03360 
03361                         return -1;
03362                 }
03363                 else
03364                 {
03365                         /* this is one of our daemons, but the
03366                          * other groups must be informed */
03367 
03368                         /* if there are no other groups, allow this event */
03369                         if (call_xp_atomic_read(&groupcount) == 1)
03370                                 return -1;
03371 
03372                         if (cached_lookup != NULL)
03373                         {
03374                                 /* this slot list (ours) will be skipped */
03375                                 *cached_lookup = sl;
03376                         }
03377                 }
03378         }
03379 
03380         /* if we made it this far, then the
03381          * access should be processed */
03382 
03383         return 0;
03384 }

int dazuko_exit void   )  [inline]
 

Definition at line 3458 of file dazuko_core.c.

03459 {
03460         int     error;
03461         int     i;
03462         int     j;
03463 
03464         i = call_xp_atomic_read(&active);
03465 
03466         if (i != 0)
03467         {
03468                 call_xp_print("dazuko: warning: trying to remove Dazuko with %d process%s still registered\n", i, i==1 ? "" : "es");
03469                 return -1;
03470         }
03471 
03472         error = call_xp_sys_unhook();
03473 
03474         if (error == 0)
03475         {
03476                 call_xp_destroy_mutex(&mutex_unique_count);
03477                 call_xp_destroy_mutex(&mutex_amc);
03478 
03479                 for (i=0 ; i<NUM_SLOT_LISTS ; i++)
03480                 {
03481                         if (slot_lists[i].slot_list != NULL)
03482                         {
03483                                 dazuko_remove_all_paths(slot_lists[i].slot_list);
03484 
03485                                 if (call_xp_atomic_read(&(slot_lists[i].slot_list->use_count)) != 0)
03486                                         call_xp_print("dazuko: slot_list count was not 0 (possible bug)\n");
03487 
03488                                 for (j=0 ; j<NUM_SLOTS ; j++)
03489                                 {
03490                                         call_xp_destroy_mutex(&(slot_lists[i].slot_list->slots[j].mutex));
03491                                         call_xp_destroy_queue(&(slot_lists[i].slot_list->slots[j].wait_daemon_waiting_until_this_slot_not_READY));
03492                                         call_xp_destroy_queue(&(slot_lists[i].slot_list->slots[j].wait_kernel_waiting_until_this_slot_not_WAITING_and_not_WORKING));
03493                                         call_xp_destroy_queue(&(slot_lists[i].slot_list->slots[j].wait_daemon_waiting_until_this_slot_not_DONE));
03494                                 }
03495 
03496                                 call_xp_destroy_rwlock(&(slot_lists[i].slot_list->lock_lists));
03497 
03498 #ifdef TRUSTED_APPLICATION_SUPPORT
03499                                 dazuko_remove_all_trusted(slot_lists[i].slot_list);
03500                                 call_xp_destroy_rwlock(&(slot_lists[i].slot_list->lock_trusted_list));
03501 #endif
03502 
03503                                 call_xp_destroy_queue(&(slot_lists[i].slot_list->wait_kernel_waiting_for_any_READY_slot_or_zero_use_count));
03504 
03505                                 if (slot_lists[i].slot_list->reg_name != NULL)
03506                                         call_xp_free(slot_lists[i].slot_list->reg_name);
03507                                 slot_lists[i].slot_list->reg_name = NULL;
03508 
03509                                 call_xp_free(slot_lists[i].slot_list);
03510                                 slot_lists[i].slot_list = NULL;
03511                         }
03512 
03513                         call_xp_destroy_mutex(&(slot_lists[i].mutex));
03514                 }
03515 
03516                 call_xp_print("dazuko: unloaded, version=%s\n", VERSION_STRING);
03517         }
03518 
03519         return error;
03520 }

int dazuko_get_filename_length const char *  filename  )  [inline]
 

Definition at line 1990 of file dazuko_core.c.

01991 {
01992         int len;
01993 
01994         for (len=0 ; filename[len] ; len++);
01995 
01996         return len;
01997 }

int dazuko_get_value const char *  key,
const char *  string,
char **  value
 

Definition at line 1310 of file dazuko_core.c.

01311 {
01312         const char      *p1;
01313         const char      *p2;
01314         int             size;
01315 
01316         if (value == NULL)
01317                 return -1;
01318 
01319         *value = NULL;
01320 
01321         if (key == NULL || string == NULL)
01322                 return -1;
01323 
01324         p1 = dazuko_strstr(string, key);
01325         if (p1 == NULL)
01326                 return -1;
01327 
01328         p1 += dazuko_strlen(key);
01329 
01330         for (p2=p1 ; *p2 && *p2!='\n' ; p2++)
01331                 continue;
01332 
01333         size = (p2 - p1) + 1;
01334         *value = call_xp_malloc(size);
01335         if (*value == NULL)
01336                 return -1;
01337 
01338         memcpy(*value, p1, size - 1);
01339         (*value)[size - 1] = 0;
01340 
01341         return 0;
01342 }

int dazuko_handle_user_request const char *  request_buffer,
struct xp_daemon_id xp_id
 

Definition at line 2711 of file dazuko_core.c.

References dazuko_request::buffer, dazuko_request::buffer_size, call_xp_copyin(), call_xp_copyout(), call_xp_free(), call_xp_malloc(), dazuko_bzero(), dazuko_get_value(), dazuko_handle_request(), dazuko_reqstream_chunksize(), dazuko_reqstream_ll2hl(), dazuko_reqstream_updll(), dazuko_strtoul(), NULL, dazuko_request::reply_buffer, dazuko_request::reply_buffer_size, dazuko_request::reply_buffer_size_used, dazuko_request::type, XP_ERROR_FAULT, XP_ERROR_PERMISSION, and xp_free().

02712 {
02713         int                     error = 0;
02714         struct dazuko_request   *user_request = NULL;
02715         unsigned char           *ll_request = NULL;
02716         unsigned char           *ll_stream = NULL;
02717         struct dazuko_request   *request = NULL;
02718         struct dazuko_request   *temp_request = NULL;
02719         char                    *value;
02720         unsigned char           tempslen[4];
02721         int                     streamlen = 0;
02722 
02723         /*
02724          * some notes on the variables: we allocate a "request" struct which
02725          * has a kernel space address and references data which is _completely_
02726          * valid from within the kernel, in addition we allocate a
02727          * "temp_request" struct which has a kernel space address and its data
02728          * mirrors the userland struct "user_request", the "ll_stream" byte
02729          * array has a kernel space address and holds a copy of the user space
02730          * request stream
02731          */
02732 
02733         if (request_buffer == NULL || xp_id == NULL)
02734                 return XP_ERROR_FAULT;
02735 
02736         if (dazuko_get_value("\nra=", request_buffer, &value) == 0)
02737         {
02738                 ll_request = (unsigned char *)dazuko_strtoul(value);
02739                 xp_free(value);
02740         }
02741         else if (dazuko_get_value("\nRA=", request_buffer, &value) == 0)
02742         {
02743                 user_request = (struct dazuko_request *)dazuko_strtoul(value);
02744                 xp_free(value);
02745         }
02746 
02747         /*
02748          * at least one kind of request presentation needs to be given (having
02749          * multiple kinds does not hurt -- we pick the most portable one and
02750          * process it)
02751          */
02752         if (ll_request == NULL && user_request == NULL)
02753                 return XP_ERROR_FAULT;
02754 
02755         /* allocate temp kernel request */
02756         temp_request = (struct dazuko_request *)call_xp_malloc(sizeof(struct dazuko_request));
02757         if (temp_request == NULL)
02758                 return XP_ERROR_FAULT;
02759 
02760         /* allocate kernel request */
02761         request = (struct dazuko_request *)call_xp_malloc(sizeof(struct dazuko_request));
02762         if (request == NULL)
02763         {
02764                 error = XP_ERROR_FAULT;
02765                 goto dazuko_handle_user_request_out;
02766         }
02767 
02768         /* request bytes are zero'd out because the "out" will check
02769          * these values */
02770         dazuko_bzero(request, sizeof(struct dazuko_request));
02771 
02772         if (ll_request != NULL)
02773         {
02774                 /*
02775                  * this is the "new style ra= (streamed) request" -- we have a
02776                  * description which is high level language independent: fill in *OUR*
02777                  * C language struct with the data we read in in a portable way
02778                  */
02779 
02780                 /* copy in the length bytes (4 bytes) */
02781                 if (call_xp_copyin(ll_request, tempslen, 4) != 0)
02782                 {
02783                         error = XP_ERROR_FAULT;
02784                         goto dazuko_handle_user_request_out;
02785                 }
02786 
02787                 if (dazuko_reqstream_chunksize(tempslen, &streamlen) != 0)
02788                 {
02789                         error = XP_ERROR_FAULT;
02790                         goto dazuko_handle_user_request_out;
02791                 }
02792 
02793                 /* allocate a buffer and copyin the stream */
02794                 ll_stream = (unsigned char *)call_xp_malloc(streamlen);
02795                 if (ll_stream == NULL)
02796                 {
02797                         error = XP_ERROR_FAULT;
02798                         goto dazuko_handle_user_request_out;
02799                 }
02800 
02801                 if (call_xp_copyin(ll_request, ll_stream, streamlen) != 0)
02802                 {
02803                         error = XP_ERROR_FAULT;
02804                         goto dazuko_handle_user_request_out;
02805                 }
02806 
02807                 /* convert the stream to into a (our) struct */
02808                 if (dazuko_reqstream_ll2hl(ll_stream, temp_request, 0) != 0)
02809                 {
02810                         error = XP_ERROR_FAULT;
02811                         goto dazuko_handle_user_request_out;
02812                 }
02813 
02814                 /* do NOT release the stream buffer here */
02815         }
02816         else if (user_request != NULL)
02817         {
02818                 /*
02819                  * this is the "old style (high level language struct) request" -- we
02820                  * HAVE TO ASSUME that the memory layout of the application and the
02821                  * kernel module match regarding the "struct dazuko_request" data type
02822                  * (yes, it's dangerous but we have no means to check anything here)
02823                  */
02824 
02825                 /* copy in the request */
02826                 if (call_xp_copyin(user_request, temp_request, sizeof(struct dazuko_request)) != 0)
02827                 {
02828                         error = XP_ERROR_FAULT;
02829                         goto dazuko_handle_user_request_out;
02830                 }
02831         }
02832 
02833         /*
02834          * at this point we have a valid request structure in "temp_request"
02835          * (still pointing to userland buffers for request and reply)
02836          */
02837 
02838         memcpy(request->type, temp_request->type, sizeof(char[2]));
02839 
02840         /* sanity check */
02841         request->buffer_size = temp_request->buffer_size;
02842         if (request->buffer_size < 0 || request->buffer_size > 8192)
02843         {
02844                 error = XP_ERROR_FAULT;
02845                 goto dazuko_handle_user_request_out;
02846         }
02847 
02848         /* sanity check */
02849         request->reply_buffer_size = temp_request->reply_buffer_size;
02850         if (request->reply_buffer_size < 0 || request->reply_buffer_size > 8192)
02851         {
02852                 error = XP_ERROR_PERMISSION;
02853                 goto dazuko_handle_user_request_out;
02854         }
02855 
02856         if (request->buffer_size > 0)
02857         {
02858                 /* allocate request command string buffer */
02859                 request->buffer = (char *)call_xp_malloc(request->buffer_size + 1);
02860                 if (request->buffer == NULL)
02861                 {
02862                         error = XP_ERROR_FAULT;
02863                         goto dazuko_handle_user_request_out;
02864                 }
02865 
02866         }
02867 
02868         if (request->reply_buffer_size > 0)
02869         {
02870                 /* allocate reply text buffer */
02871                 request->reply_buffer = (char *)call_xp_malloc(request->reply_buffer_size + 1);
02872                 if (request->reply_buffer == NULL)
02873                 {
02874                         error = XP_ERROR_FAULT;
02875                         goto dazuko_handle_user_request_out;
02876                 }
02877 
02878                 request->reply_buffer_size_used = 0;
02879         }
02880 
02881         if (request->buffer_size > 0)
02882         {
02883                 /* copy the buffer from userspace to kernelspace */
02884                 if (call_xp_copyin(temp_request->buffer, request->buffer, request->buffer_size) != 0)
02885                 {
02886                         error = XP_ERROR_FAULT;
02887                         goto dazuko_handle_user_request_out;
02888                 }
02889 
02890                 request->buffer[request->buffer_size] = 0;
02891         }
02892 
02893         /* process the request */
02894         error = dazuko_handle_request(request, xp_id);
02895 
02896         /* successfully processed and a response to be transferred back? */
02897         if (error == 0 && request->reply_buffer_size > 0)
02898         {
02899                 request->reply_buffer[request->reply_buffer_size] = 0;
02900 
02901                 temp_request->reply_buffer_size_used = request->reply_buffer_size_used;
02902 
02903                 if (ll_request != NULL)
02904                 {
02905                         /* new style (streamed) request */
02906 
02907                         /* update a few return fields */
02908                         if (dazuko_reqstream_updll(temp_request, ll_stream) != 0)
02909                         {
02910                                 error = XP_ERROR_FAULT;
02911                                 goto dazuko_handle_user_request_out;
02912                         }
02913 
02914                         /* copyout the stream back to the application */
02915                         if (call_xp_copyout(ll_stream, ll_request, streamlen) != 0)
02916                         {
02917                                 error = XP_ERROR_FAULT;
02918                                 goto dazuko_handle_user_request_out;
02919                         }
02920                 }
02921                 else if (user_request != NULL)
02922                 {
02923                         /* old style (high level language struct) request */
02924 
02925                         /* copyout the complete "struct dazuko_request" struct */
02926                         if (call_xp_copyout(temp_request, user_request, sizeof(struct dazuko_request)) != 0)
02927                         {
02928                                 error = XP_ERROR_FAULT;
02929                                 goto dazuko_handle_user_request_out;
02930                         }
02931                 }
02932 
02933                 /* transfer back the reply data itself */
02934                 if (request->reply_buffer_size_used > 0)
02935                 {
02936                         /* reply_buffer_size_used already includes the NUL byte */
02937                         if (call_xp_copyout(request->reply_buffer, temp_request->reply_buffer, request->reply_buffer_size_used) != 0)
02938                         {
02939                                 error = XP_ERROR_FAULT;
02940                                 goto dazuko_handle_user_request_out;
02941                         }
02942                 }
02943         }
02944 
02945 dazuko_handle_user_request_out:
02946 
02947         if (request != NULL)
02948         {
02949                 if (request->buffer != NULL)
02950                         call_xp_free(request->buffer);
02951 
02952                 if (request->reply_buffer != NULL)
02953                         call_xp_free(request->reply_buffer);
02954 
02955                 call_xp_free(request);
02956         }
02957 
02958         if (temp_request != NULL)
02959                 call_xp_free(temp_request);
02960 
02961         if (ll_stream != NULL)
02962                 call_xp_free(ll_stream);
02963 
02964         return error;
02965 }

int dazuko_handle_user_request_compat1 void *  ptr,
int  cmd,
struct xp_daemon_id xp_id
 

Definition at line 2967 of file dazuko_core.c.

References slot_list::access_mask, call_xp_copyin(), call_xp_copyout(), call_xp_free(), call_xp_id_copy(), call_xp_id_free(), call_xp_malloc(), call_xp_notify(), call_xp_up(), call_xp_verify_user_readable(), call_xp_verify_user_writable(), DAZUKO_BROKEN, dazuko_change_slot_state(), DAZUKO_FILENAME_MAX_LENGTH_COMPAT1, dazuko_find_slot(), dazuko_find_slot_and_slotlist(), dazuko_get_an_access(), dazuko_register_daemon(), dazuko_return_access(), dazuko_set_option(), dazuko_setup_amc_cache(), DAZUKO_WORKING, access_compat1::deny, DPRINT, slot::event, access_compat1::event, slot::event_p, access_compat1::filename, slot::filename, slot::filenamelength, event_properties::flags, handle_event_as_readonly(), IOCTL_GET_AN_ACCESS, IOCTL_RETURN_ACCESS, IOCTL_SET_OPTION, event_properties::mode, slot::mutex, NULL, access_compat1::o_flags, access_compat1::o_mode, event_properties::pid, access_compat1::pid, REGISTER, SET_ACCESS_MASK, event_properties::uid, access_compat1::uid, daemon_id::unique, XP_ERROR_FAULT, XP_ERROR_INTERRUPT, XP_ERROR_INVALID, XP_ERROR_PERMISSION, and daemon_id::xp_id.

02968 {
02969         struct access_compat1   *user_request_1;
02970         struct access_compat1   *temp_request_1;
02971         struct slot_list        *sl;
02972         int                     error = 0;
02973         struct slot             *s;
02974         char                    *k_param;
02975         struct daemon_id        did;
02976         int                     temp_length;
02977         int                     temp_int;
02978 
02979         if (ptr == NULL || xp_id == NULL)
02980                 return XP_ERROR_FAULT;
02981 
02982         did.xp_id = call_xp_id_copy(xp_id);
02983         did.unique = -1;
02984 
02985         switch (cmd)
02986         {
02987                 case IOCTL_GET_AN_ACCESS:
02988                         /* The daemon is requesting a filename of a file
02989                          * to scan. This code will wait until a filename
02990                          * is available, or until we should be killed.
02991                          * (killing is done if any errors occur as well
02992                          * as when the user kills us) */
02993 
02994                         user_request_1 = (struct access_compat1 *)ptr;
02995 
02996                         error = call_xp_verify_user_writable(user_request_1, sizeof(struct access_compat1));
02997                         if (error)
02998                         {
02999                                 error = XP_ERROR_FAULT;
03000                                 break;
03001                         }
03002 
03003 /* DOWN? */
03004                         s = dazuko_get_an_access(&did);
03005 
03006                         if (s == NULL)
03007                         {
03008                                 error = XP_ERROR_INTERRUPT;
03009                                 break;
03010                         }
03011 
03012 /* DOWN */
03013 
03014                         /* Slot IS in WORKING state. Copy all the
03015                          * necessary information to userspace structure. */
03016 
03017                         if (s->filenamelength >= DAZUKO_FILENAME_MAX_LENGTH_COMPAT1)
03018                         {
03019                                 /* filename length overflow :( */
03020 
03021                                 s->filename[DAZUKO_FILENAME_MAX_LENGTH_COMPAT1 - 1] = 0;
03022                                 temp_length = DAZUKO_FILENAME_MAX_LENGTH_COMPAT1;
03023                         }
03024                         else
03025                         {
03026                                 temp_length = s->filenamelength + 1;
03027                         }
03028 
03029                         temp_request_1 = (struct access_compat1 *)call_xp_malloc(sizeof(struct access_compat1));
03030                         if (temp_request_1 == NULL)
03031                         {
03032                                 error = XP_ERROR_FAULT;
03033                         }
03034                         else if (call_xp_copyin(user_request_1, temp_request_1, sizeof(struct access_compat1)) != 0)
03035                         {
03036                                 error = XP_ERROR_FAULT;
03037                         }
03038 
03039                         if (error == 0)
03040                         {
03041                                 temp_request_1->event = s->event;
03042                                 temp_request_1->o_flags = s->event_p.flags;
03043                                 temp_request_1->o_mode = s->event_p.mode;
03044                                 temp_request_1->uid = s->event_p.uid;
03045                                 temp_request_1->pid = s->event_p.pid;
03046                                 memcpy(temp_request_1->filename, s->filename, temp_length);
03047 
03048                                 if (call_xp_copyout(temp_request_1, user_request_1, sizeof(struct access_compat1)) != 0)
03049                                 {
03050                                         error = XP_ERROR_FAULT;
03051                                 }
03052                         }
03053 
03054                         call_xp_up(&(s->mutex));
03055 /* UP */
03056 
03057                         if (error)
03058                         {
03059                                 if (dazuko_change_slot_state(s, DAZUKO_WORKING, DAZUKO_BROKEN, 1))
03060                                 {
03061                                         /* slot->state has changed to BROKEN, notifiy appropriate queue */
03062                                         call_xp_notify(&(s->wait_kernel_waiting_until_this_slot_not_WAITING_and_not_WORKING));
03063                                 }
03064                         }
03065 
03066                         if (temp_request_1 != NULL)
03067                         {
03068                                 call_xp_free(temp_request_1);
03069                         }
03070 
03071                         break;
03072 
03073                 case IOCTL_RETURN_ACCESS:
03074                         /* The daemon has finished scanning a file
03075                          * and has the response to give. The daemon's
03076                          * slot should be in the WORKING state. */
03077 
03078                         user_request_1 = (struct access_compat1 *)ptr;
03079 
03080                         error = call_xp_verify_user_readable(user_request_1, sizeof(struct access_compat1));
03081                         if (error)
03082                         {
03083                                 error = XP_ERROR_FAULT;
03084                                 break;
03085                         }
03086 
03087                         temp_request_1 = (struct access_compat1 *)call_xp_malloc(sizeof(struct access_compat1));
03088                         if (temp_request_1 == NULL)
03089                         {
03090                                 error = XP_ERROR_FAULT;
03091                                 break;
03092                         }
03093 
03094                         if (call_xp_copyin(user_request_1, temp_request_1, sizeof(struct access_compat1)) != 0)
03095                         {
03096                                 error = XP_ERROR_FAULT;
03097                         }
03098 
03099                         temp_int = temp_request_1->deny;
03100 
03101                         call_xp_free(temp_request_1);
03102 
03103                         /* find our slot */
03104                         s = dazuko_find_slot(&did, 1, NULL);
03105 
03106                         if (s == NULL)
03107                         {
03108                                 /* It appears the kernel isn't interested
03109                                  * in us or our response. It gave our slot away! */
03110 
03111                                 DPRINT(("dazuko: daemon %d unexpectedly lost slot (by return access compat1)\n", did.unique));
03112 
03113                                 error = XP_ERROR_FAULT;
03114                         }
03115                         else if (!handle_event_as_readonly(s))
03116                         {
03117                                 error = dazuko_return_access(&did, temp_int, s);
03118                         }
03119 
03120                         break;
03121 
03122                 case IOCTL_SET_OPTION:
03123                         /* The daemon wants to set a configuration
03124                          * option in the kernel. */
03125 
03126                         error = call_xp_verify_user_readable(ptr, 2*sizeof(int));
03127                         if (error)
03128                         {
03129                                 error = XP_ERROR_FAULT;
03130                                 break;
03131                         }
03132 
03133                         /* copy option type from userspace */
03134                         if (call_xp_copyin(ptr, &temp_int, sizeof(int)) != 0)
03135                         {
03136                                 error = XP_ERROR_FAULT;
03137                                 break;
03138                         }
03139 
03140                         ptr = ((char *)ptr + sizeof(int));
03141 
03142                         /* copy path length from userspace */
03143                         if (call_xp_copyin(ptr, &temp_length, sizeof(int)) != 0)
03144                         {
03145                                 error = XP_ERROR_FAULT;
03146                                 break;
03147                         }
03148 
03149                         /* sanity check */
03150                         if (temp_length < 0 || temp_length > 4096)
03151                         {
03152                                 error = XP_ERROR_INVALID;
03153                                 break;
03154                         }
03155 
03156                         ptr = ((char *)ptr + sizeof(int));
03157 
03158                         error = call_xp_verify_user_readable(ptr, temp_length);
03159                         if (error)
03160                         {
03161                                 error = XP_ERROR_FAULT;
03162                                 break;
03163                         }
03164 
03165                         k_param = (char *)call_xp_malloc(temp_length + 1);
03166                         if (k_param == NULL)
03167                         {
03168                                 error = XP_ERROR_FAULT;
03169                                 break;
03170                         }
03171 
03172                         /* We must copy the param from userspace to kernelspace. */
03173 
03174                         if (call_xp_copyin(ptr, k_param, temp_length) != 0)
03175                         {
03176                                 call_xp_free(k_param);
03177                                 error = XP_ERROR_FAULT;
03178                                 break;
03179                         }
03180 
03181                         k_param[temp_length] = 0;
03182 
03183                         switch (temp_int)
03184                         {
03185                                 case REGISTER:
03186                                         error = dazuko_register_daemon(&did, k_param, temp_length, 1);
03187                                         break;
03188 
03189                                 case SET_ACCESS_MASK:
03190                                         /* find our slot */
03191                                         if (dazuko_find_slot_and_slotlist(&did, 1, NULL, &sl) == NULL)
03192                                         {
03193                                                 error = XP_ERROR_PERMISSION;
03194                                         }
03195                                         else if (sl == NULL)
03196                                         {
03197                                                 error = XP_ERROR_PERMISSION;
03198                                         }
03199                                         else
03200                                         {
03201                                                 sl->access_mask = k_param[0];
03202 
03203                                                 /* rebuild access_mask_cache */
03204                                                 dazuko_setup_amc_cache();
03205                                         }
03206                                         break;
03207 
03208                                 default:
03209                                         error = dazuko_set_option(&did, temp_int, k_param, temp_length);
03210                                         break;
03211                         }
03212 
03213                         call_xp_free(k_param);
03214 
03215                         break;
03216 
03217                 default:
03218                         error = XP_ERROR_INVALID;
03219 
03220                         break;
03221         }
03222 
03223         call_xp_id_free(did.xp_id);
03224 
03225         return error;
03226 }

int dazuko_init void   )  [inline]
 

Definition at line 3432 of file dazuko_core.c.

03433 {
03434         int     i;
03435         int     error;
03436 
03437         call_xp_init_mutex(&mutex_unique_count);
03438         call_xp_init_mutex(&mutex_amc);
03439 
03440         dazuko_bzero(&slot_lists, sizeof(slot_lists));
03441 
03442         memset(&access_mask_cache, AMC_UNSET, sizeof(access_mask_cache));
03443 
03444         for (i=0 ; i<NUM_SLOT_LISTS ; i++)
03445                 call_xp_init_mutex(&(slot_lists[i].mutex));
03446 
03447         call_xp_atomic_set(&active, 0);
03448         call_xp_atomic_set(&groupcount, 0);
03449 
03450         error = call_xp_sys_hook();
03451 
03452         if (error == 0)
03453                 call_xp_print("dazuko: loaded, version=%s\n", VERSION_STRING);
03454 
03455         return error;
03456 }

int dazuko_is_our_daemon struct xp_daemon_id xp_id,
struct slot_list **  slotlist
[inline]
 

Definition at line 3228 of file dazuko_core.c.

References _dazuko_find_slot(), _remove_trusted_node(), call_xp_down(), call_xp_id_compare(), call_xp_id_copy(), call_xp_id_free(), call_xp_read_lock(), call_xp_read_unlock(), call_xp_up(), DAZUKO_CHILD, DAZUKO_SAME, DAZUKO_SUSPICIOUS, DPRINT, slot_list::lock_trusted_list, trusted_container::next, NULL, slot_list::set_trusted_list, slot_list_container::slot_list, trusted_container::trust_children, slot_list::trusted_list, daemon_id::unique, trusted_container::xp_id, and daemon_id::xp_id.

03229 {
03230         /* Check if the current process is one
03231          * of the daemons. */
03232 
03233         int                             ret = 0;
03234         struct daemon_id                did;
03235         struct slot                     *s;
03236         int                             i;
03237         struct slot_list                *sl;
03238 #ifdef TRUSTED_APPLICATION_SUPPORT
03239         int                             cmp;
03240         struct trusted_container        *tc;
03241         struct trusted_container        *prev;
03242 #endif
03243 
03244         did.xp_id = call_xp_id_copy(xp_id);
03245         did.unique = -1;
03246 
03247         for (i=0 ; i<NUM_SLOT_LISTS ; i++)
03248         {
03249 /* DOWN */
03250                 call_xp_down(&(slot_lists[i].mutex));
03251 
03252                 sl = slot_lists[i].slot_list;
03253 
03254                 call_xp_up(&(slot_lists[i].mutex));
03255 /* UP */
03256 
03257                 if (sl == NULL)
03258                         continue;
03259 
03260                 s = _dazuko_find_slot(&did, 1, sl);
03261                 if (s != NULL)
03262                 {
03263                         ret = 1;
03264 
03265                         if (slotlist != NULL)
03266                                 *slotlist = sl;
03267 
03268                         break;
03269                 }
03270 
03271                 if (did.xp_id == NULL)
03272                         continue;
03273 
03274 #ifdef TRUSTED_APPLICATION_SUPPORT
03275                 /* This boolean is not protected by a lock on purpose.
03276                  * It is used as optimization when there are no trusted
03277                  * processes. If it is set, then we will use the lock. */
03278                 if (!(sl->set_trusted_list))
03279                         continue;
03280 
03281 /* LOCK */
03282                 call_xp_read_lock(&(sl->lock_trusted_list));
03283 
03284                 tc = sl->trusted_list;
03285                 prev = NULL;
03286                 while (tc != NULL)
03287                 {
03288                         cmp = call_xp_id_compare(tc->xp_id, did.xp_id, 1);
03289 
03290                         if (cmp == DAZUKO_SAME || (cmp == DAZUKO_CHILD && tc->trust_children))
03291                         {
03292                                 ret = 1;
03293 
03294                                 if (slotlist != NULL)
03295                                         *slotlist = sl;
03296 
03297                                 break;
03298                         }
03299                         else if (cmp == DAZUKO_SUSPICIOUS)
03300                         {
03301                                 DPRINT(("dazuko: detected suspicios activity, removing trusted daemon [%d]\n", did.unique));
03302 
03303                                 /* remove invalid trusted node */
03304                                 tc = _remove_trusted_node(prev, tc, sl);
03305                                 break;
03306                         }
03307                         else
03308                         {
03309                                 prev = tc;
03310                                 tc = tc->next;
03311                         }
03312                 }
03313 
03314                 call_xp_read_unlock(&(sl->lock_trusted_list));
03315 /* UNLOCK */
03316 
03317                 if (ret)
03318                         break;
03319 #endif
03320         }
03321 
03322         call_xp_id_free(did.xp_id);
03323 
03324         return ret;
03325 }

int dazuko_process_access unsigned long  event,
struct dazuko_file_struct kfs,
struct event_properties event_p,
struct slot_list cached_lookup
 

Definition at line 3386 of file dazuko_core.c.

References call_xp_print, dazuko_run_daemon(), NULL, XP_ERROR_INTERRUPT, and XP_ERROR_PERMISSION.

Referenced by dazuko_sys_generic(), and linux_dazuko_sys_generic().

03387 {
03388         /* return codes:
03389          *   >0 -> access should be blocked
03390          *   <0 -> access should be blocked (because user interrupted)
03391          *    0 -> access is allowed
03392          *    2 -> access is not taken care of (unscanned)
03393          */
03394 
03395         int             error = 0;
03396 
03397         if (kfs == NULL)
03398         {
03399                 /* kfs is required */
03400 
03401                 call_xp_print("dazuko: kfs=NULL (possible bug)\n");
03402 
03403                 return XP_ERROR_PERMISSION;
03404         }
03405 
03406         /* check and handle this event */
03407         error = dazuko_run_daemon(event, kfs, event_p, cached_lookup);
03408         
03409         if (error == 2)
03410         {
03411                 /* access will be skipped */
03412                 return 2;
03413         }
03414         else if (error > 0)
03415         {
03416                 /* access will be blocked */
03417 
03418                 return XP_ERROR_PERMISSION;
03419         }
03420         else if (error < 0)
03421         {
03422                 /* user interrupted */
03423 
03424                 return XP_ERROR_INTERRUPT;
03425         }
03426 
03427         /* access allowed */
03428 
03429         return 0;
03430 }

int dazuko_snprintf char *  str,
size_t  size,
const char *  format,
  ...
 

Definition at line 294 of file dazuko_core.c.

00295 {
00296         va_list ap;
00297         int     ret;
00298 
00299         va_start(ap, format);
00300         ret = dazuko_vsnprintf(str, size, format, ap);
00301         va_end(ap);
00302 
00303         return ret;
00304 }

int dazuko_unregister_daemon struct xp_daemon_id xp_id  ) 
 

Definition at line 834 of file dazuko_core.c.

00835 {
00836         struct daemon_id        did;
00837         int                     ret;
00838 
00839         if (xp_id == NULL)
00840                 return 0;
00841 
00842         did.unique = -1;
00843         did.xp_id = call_xp_id_copy(xp_id);
00844 
00845         ret = _dazuko_unregister_daemon(&did);
00846 
00847         call_xp_id_free(did.xp_id);
00848 
00849         return ret;
00850 }

int dazuko_vsnprintf char *  str,
size_t  size,
const char *  format,
va_list  ap
 

Definition at line 176 of file dazuko_core.c.

00177 {
00178         char            *target;
00179         const char      *end;
00180         int             overflow = 0;
00181         char            number_buffer[32]; /* 32 should be enough to hold any number, right? */
00182         const char      *s;
00183 
00184         if (str == NULL || size < 1 || format == NULL)
00185                 return -1;
00186 
00187         target = str;
00188         end = (target + size) - 1;
00189 
00190 #define DAZUKO_VSNPRINTF_PRINTSTRING \
00191         for ( ; *s ; s++) \
00192         { \
00193                 if (target == end) \
00194                 { \
00195                         overflow = 1; \
00196                         goto dazuko_vsnprintf_out; \
00197                 } \
00198                 *target = *s; \
00199                 target++; \
00200         }
00201 
00202         for ( ; *format ; format++)
00203         {
00204                 if (target == end)
00205                 {
00206                         overflow = 1;
00207                         goto dazuko_vsnprintf_out;
00208                 }
00209 
00210                 if (*format == '%')
00211                 {
00212                         format++;
00213 
00214                         switch (*format)
00215                         {
00216                                 case 's': /* %s */
00217                                         s = va_arg(ap, char *);
00218                                         if (s == NULL)
00219                                                 s = "(null)";
00220                                         DAZUKO_VSNPRINTF_PRINTSTRING
00221                                         break;
00222 
00223                                 case 'd': /* %d */
00224                                         sprintf(number_buffer, "%d", va_arg(ap, int));
00225                                         s = number_buffer;
00226                                         DAZUKO_VSNPRINTF_PRINTSTRING
00227                                         break;
00228 
00229                                 case 'p': /* %p */
00230                                         sprintf(number_buffer, "%p", va_arg(ap, void *));
00231                                         s = number_buffer;
00232                                         DAZUKO_VSNPRINTF_PRINTSTRING
00233                                         break;
00234 
00235                                 case 'c': /* %c */
00236                                         *target = va_arg(ap, int);
00237                                         target++;
00238                                         break;
00239 
00240                                 case 'l': /* %lu */
00241                                         format++;
00242                                         if (*format != 'u')
00243                                         {
00244                                                 /* print error message */
00245                                                 goto dazuko_vsnprintf_out;
00246                                         }
00247                                         sprintf(number_buffer, "%lu", va_arg(ap, unsigned long));
00248                                         s = number_buffer;
00249                                         DAZUKO_VSNPRINTF_PRINTSTRING
00250                                         break;
00251 
00252                                 case '0': /* %02x */
00253                                         format++;
00254                                         if (*format != '2')
00255                                         {
00256                                                 /* print error message */
00257                                                 goto dazuko_vsnprintf_out;
00258                                         }
00259                                         format++;
00260                                         if (*format != 'x')
00261                                         {
00262                                                 /* print error message */
00263                                                 goto dazuko_vsnprintf_out;
00264                                         }
00265                                         sprintf(number_buffer, "%02x", va_arg(ap, int));
00266                                         s = number_buffer;
00267                                         DAZUKO_VSNPRINTF_PRINTSTRING
00268                                         break;
00269 
00270                                 default:
00271                                         /* print error message */
00272                                         goto dazuko_vsnprintf_out;
00273                         }
00274                 }
00275                 else
00276                 {
00277                         *target = *format;
00278                         target++;
00279                 }
00280         }
00281 
00282 dazuko_vsnprintf_out:
00283 
00284         *target = 0;
00285 
00286         /* We are returning what we've written. If there was an
00287          * overflow, the returned value will match "size" rather
00288          * than being less than "size"
00289          */
00290 
00291         return ((target - str) + overflow);
00292 }

int xp_atomic_dec struct xp_atomic atomic  )  [inline]
 

Definition at line 302 of file daz_main.c.

00303 {
00304         #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
00305                 #ifdef MODULE
00306                         if (atomic == &active)
00307                                 MOD_DEC_USE_COUNT;
00308                 #endif
00309         #endif
00310 
00311         atomic_dec(&(atomic->atomic));
00312         return 0;
00313 }

int xp_atomic_inc struct xp_atomic atomic  )  [inline]
 

Definition at line 289 of file daz_main.c.

00290 {
00291         #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
00292                 #ifdef MODULE
00293                         if (atomic == &active)
00294                                 MOD_INC_USE_COUNT;
00295                 #endif
00296         #endif
00297 
00298         atomic_inc(&(atomic->atomic));
00299         return 0;
00300 }

int xp_atomic_read struct xp_atomic atomic  )  [inline]
 

Definition at line 315 of file daz_main.c.

00316 {
00317         return atomic_read(&(atomic->atomic));
00318 }

int xp_atomic_set struct xp_atomic atomic,
int  value
[inline]
 

Definition at line 283 of file daz_main.c.

00284 {
00285         atomic_set(&(atomic->atomic), value);
00286         return 0;
00287 }

int xp_copyin const void *  user_src,
void *  kernel_dest,
size_t  size
[inline]
 

Definition at line 252 of file daz_main.c.

00253 {
00254         return copy_from_user(kernel_dest, user_src, size);
00255 }

int xp_copyout const void *  kernel_src,
void *  user_dest,
size_t  size
[inline]
 

Definition at line 257 of file daz_main.c.

00258 {
00259         return copy_to_user(user_dest, kernel_src, size);
00260 }

void xp_destroy_mutex struct xp_mutex mutex  )  [inline]
 

Definition at line 159 of file daz_main.c.

00160 {
00161         return 0;
00162 }

int xp_destroy_queue struct xp_queue queue  )  [inline]
 

Definition at line 233 of file daz_main.c.

00234 {
00235         return 0;
00236 }

void xp_destroy_rwlock struct xp_rwlock rwlock  )  [inline]
 

Definition at line 197 of file daz_main.c.

00198 {
00199         return 0;
00200 }

void xp_down struct xp_mutex mutex  )  [inline]
 

Definition at line 147 of file daz_main.c.

00148 {
00149         down(&(mutex->mutex));
00150         return 0;
00151 }

int xp_fill_file_struct struct dazuko_file_struct dfs  )  [inline]
 

Definition at line 333 of file daz_main.c.

00334 {
00335         int     length;
00336 
00337         /* make sure we have access to everything */
00338 
00339         if (dfs == NULL)
00340                 return -1;
00341 
00342         if (dfs->extra_data == NULL)
00343                 return -1;
00344 
00345         if (dfs->extra_data->dentry == NULL)
00346                 return -1;
00347 
00348         if (dfs->extra_data->dentry->d_inode == NULL)
00349                 return -1;
00350 
00351         /* ok, we have everything we need */
00352 
00353         length = rsbac_get_full_path_length(dfs->extra_data->dentry);
00354         if (length < 1)
00355                 return -1;
00356 
00357         dfs->extra_data->full_filename = xp_malloc(length + 1);
00358         if (dfs->extra_data->full_filename == NULL)
00359                 return -1;
00360 
00361         /* the full_filename will need to be deleted later */
00362         dfs->extra_data->free_full_filename = 1;
00363 
00364         if (rsbac_get_full_path(dfs->extra_data->dentry, dfs->extra_data->full_filename, length + 1) < 1)
00365                 return -1;
00366 
00367         /* find the actual value of the length */
00368         dfs->extra_data->full_filename_length = dazuko_get_filename_length(dfs->extra_data->full_filename);
00369 
00370         /* reference copy of full path */
00371         dfs->filename = dfs->extra_data->full_filename;
00372 
00373         dfs->filename_length = dfs->extra_data->full_filename_length;
00374 
00375         dfs->file_p.size = dfs->extra_data->dentry->d_inode->i_size;
00376         dfs->file_p.set_size = 1;
00377         dfs->file_p.uid = dfs->extra_data->dentry->d_inode->i_uid;
00378         dfs->file_p.set_uid = 1;
00379         dfs->file_p.gid = dfs->extra_data->dentry->d_inode->i_gid;
00380         dfs->file_p.set_gid = 1;
00381         dfs->file_p.mode = dfs->extra_data->dentry->d_inode->i_mode;
00382         dfs->file_p.set_mode = 1;
00383 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
00384         dfs->file_p.device_type = dfs->extra_data->dentry->d_inode->i_dev;
00385 #else
00386         dfs->file_p.device_type = dfs->extra_data->dentry->d_inode->i_rdev;
00387 #endif
00388         dfs->file_p.set_device_type = 1;
00389 
00390         return 0;
00391 }

int xp_free void *  ptr  )  [inline]
 

Definition at line 246 of file daz_main.c.

00247 {
00248         kfree(ptr);
00249         return 0;
00250 }

int xp_id_compare struct xp_daemon_id id1,
struct xp_daemon_id id2,
int  check_related
[inline]
 

Definition at line 934 of file dazuko_linux.c.

00935 {
00936         if (id1 == NULL || id2 == NULL)
00937                 return DAZUKO_DIFFERENT;
00938 
00939         /* if file's are available and they match,
00940          * then we say that the id's match
00941          * ("file" is only used to unregister daemons and
00942          * here we allow other processes to do this)
00943          * Note: this is a Linux-only "hack" */
00944         if (id1->file != NULL && id1->file == id2->file)
00945                 return DAZUKO_SAME;
00946 
00947         if (id1->pid == id2->pid && id1->current_p == id2->current_p && id1->files == id2->files)
00948                 return DAZUKO_SAME;
00949 
00950         if (check_related)
00951         {
00952                 if (check_parent(id1->current_p, id2->current_p) == 0)
00953                 {
00954                         return DAZUKO_CHILD;
00955                 }
00956                 else if (id1->pid == id2->pid || id1->current_p == id2->current_p || id1->files == id2->files)
00957                 {
00958                         return DAZUKO_SUSPICIOUS;
00959                 }
00960         }
00961 
00962         return DAZUKO_DIFFERENT;
00963 }

struct xp_daemon_id* xp_id_copy struct xp_daemon_id id  )  [inline]
 

Definition at line 442 of file daz_main.c.

00443 {
00444         struct xp_daemon_id     *ptr;
00445 
00446         if (id == NULL)
00447                 return NULL;
00448 
00449         ptr = (struct xp_daemon_id *)xp_malloc(sizeof(struct xp_daemon_id));
00450 
00451         if (ptr != NULL)
00452         {
00453                 ptr->pid = id->pid;
00454                 ptr->file = id->file;
00455         }
00456 
00457         return ptr;
00458 }

int xp_id_free struct xp_daemon_id id  )  [inline]
 

Definition at line 435 of file daz_main.c.

00436 {
00437         xp_free(id);
00438 
00439         return 0;
00440 }

int xp_init_cache unsigned long  ttl  ) 
 

Definition at line 1006 of file dazuko_linux.c.

01007 {
01008         return -1;
01009 }

void xp_init_mutex struct xp_mutex mutex  )  [inline]
 

Definition at line 136 of file daz_main.c.

00137 {
00138         #ifdef init_MUTEX
00139                 init_MUTEX(&(mutex->mutex));
00140         #else
00141                 sema_init(&(mutex->mutex), 1);
00142         #endif
00143 
00144         return 0;
00145 }

int xp_init_queue struct xp_queue queue  )  [inline]
 

Definition at line 205 of file daz_main.c.

00206 {
00207         init_waitqueue_head(&(queue->queue));
00208         return 0;
00209 }

void xp_init_rwlock struct xp_rwlock rwlock  )  [inline]
 

Definition at line 167 of file daz_main.c.

00168 {
00169         rwlock_init(&(rwlock->rwlock));
00170         return 0;
00171 }

int xp_is_absolute_path const char *  path  )  [inline]
 

Definition at line 275 of file daz_main.c.

00276 {
00277         return (path[0] == '/');
00278 }

void* xp_malloc size_t  size  )  [inline]
 

Definition at line 241 of file daz_main.c.

00242 {
00243         return rsbac_kmalloc(size);
00244 }

int xp_notify struct xp_queue queue  )  [inline]
 

Definition at line 227 of file daz_main.c.

00228 {
00229         wake_up(&(queue->queue));
00230         return 0;
00231 }

int xp_print const char *  fmt,
  ...
 

Definition at line 522 of file daz_main.c.

00523 {
00524         va_list args;
00525         char *p;
00526         size_t size = 1024;
00527 
00528         p = (char *)xp_malloc(size);
00529         if (!p)
00530                 return -1;
00531 
00532         va_start(args, fmt);
00533         dazuko_vsnprintf(p, size-1, fmt, args);
00534         va_end(args);
00535 
00536         p[size-1] = 0;
00537 
00538         rsbac_printk(p);
00539 
00540         xp_free(p);
00541 
00542         return 0;
00543 }

void xp_read_lock struct xp_rwlock rlock  )  [inline]
 

Definition at line 185 of file daz_main.c.

00186 {
00187         read_lock(&(rlock->rwlock));
00188         return 0;
00189 }

void xp_read_unlock struct xp_rwlock rlock  )  [inline]
 

Definition at line 191 of file daz_main.c.

00192 {
00193         read_unlock(&(rlock->rwlock));
00194         return 0;
00195 }

int xp_set_event_properties struct event_properties event_p,
struct xp_daemon_id xp_id
 

Definition at line 995 of file dazuko_linux.c.

References xp_daemon_id::pid.

00996 {
00997         event_p->pid = xp_id->pid;
00998         event_p->set_pid = 1;
00999 
01000         return 0;
01001 }

int xp_sys_hook void   )  [inline]
 

Definition at line 463 of file daz_main.c.

00464 {
00465         /* Called insmod when inserting the module. */
00466 
00467         /* register the dazuko device */
00468 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
00469         dev_major = register_chrdev(CONFIG_RSBAC_DAZ_DEV_MAJOR, DEVICE_NAME, &fops);
00470 
00471         devfs_mk_cdev(MKDEV(dev_major, CONFIG_RSBAC_DAZ_DEV_MAJOR), S_IFCHR | S_IRUSR | S_IWUSR, DEVICE_NAME);
00472 #else
00473         #ifdef CONFIG_DEVFS_FS
00474                 dev_major = devfs_register_chrdev(CONFIG_RSBAC_DAZ_DEV_MAJOR, DEVICE_NAME, &fops);
00475                 devfs_register(NULL, DEVICE_NAME, DEVFS_FL_DEFAULT,
00476                         dev_major, 0, S_IFCHR | S_IRUSR | S_IWUSR,
00477                         &fops, NULL);
00478         #else
00479                 dev_major = register_chrdev(CONFIG_RSBAC_DAZ_DEV_MAJOR, DEVICE_NAME, &fops);
00480         #endif
00481 #endif
00482         if (dev_major < 0)
00483         {
00484                 xp_print("dazuko: unable to register device chrdev, err=%d\n", dev_major);
00485                 return dev_major;
00486         }
00487 
00488         /* initialization complete */
00489 
00490         return 0;
00491 }

int xp_sys_unhook void   )  [inline]
 

Definition at line 493 of file daz_main.c.

00494 {
00495         /* Called by rmmod when removing the module. */
00496 
00497         int     error;
00498 
00499 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
00500         error = unregister_chrdev(dev_major, DEVICE_NAME);
00501 
00502         devfs_remove(DEVICE_NAME);
00503 #else
00504         #ifdef CONFIG_DEVFS_FS
00505                 error = devfs_unregister_chrdev(dev_major, DEVICE_NAME);
00506                 devfs_unregister(devfs_find_handle(NULL, DEVICE_NAME, dev_major, 0, DEVFS_SPECIAL_CHR, 0));
00507         #else
00508                 error = unregister_chrdev(dev_major, DEVICE_NAME);
00509         #endif
00510 #endif
00511         if (error < 0)
00512         {
00513                 xp_print("dazuko: error unregistering chrdev, err=%d\n", error);
00514         }
00515 
00516         return 0;
00517 }

void xp_up struct xp_mutex mutex  )  [inline]
 

Definition at line 153 of file daz_main.c.

00154 {
00155         up(&(mutex->mutex));
00156         return 0;
00157 }

int xp_verify_user_readable const void *  user_ptr,
size_t  size
[inline]
 

Definition at line 267 of file daz_main.c.

00268 {
00269         return 0;
00270 }

int xp_verify_user_writable const void *  user_ptr,
size_t  size
[inline]
 

Definition at line 262 of file daz_main.c.

00263 {
00264         return 0;
00265 }

int xp_wait_until_condition struct xp_queue queue,
int(*)(void *)  cfunction,
void *  cparam,
int  allow_interrupt
[inline]
 

Definition at line 211 of file daz_main.c.

00212 {
00213         /* wait until cfunction(cparam) != 0 (condition is true) */
00214 
00215         if (allow_interrupt)
00216         {
00217                 return wait_event_interruptible(queue->queue, cfunction(cparam) != 0);
00218         }
00219         else
00220         {
00221                 wait_event(queue->queue, cfunction(cparam) != 0);
00222         }
00223 
00224         return 0;
00225 }

void xp_write_lock struct xp_rwlock rwlock  )  [inline]
 

Definition at line 173 of file daz_main.c.

00174 {
00175         write_lock(&(rwlock->rwlock));
00176         return 0;
00177 }

void xp_write_unlock struct xp_rwlock rwlock  )  [inline]
 

Definition at line 179 of file daz_main.c.

00180 {
00181         write_unlock(&(rwlock->rwlock));
00182         return 0;
00183 }


Generated on Sun May 21 14:31:01 2006 for RSBAC by  doxygen 1.4.2