/linux-2.6.21.1-rsbac-1.3.4/include/rsbac/helpers.h

Go to the documentation of this file.
00001 /************************************* */
00002 /* Rule Set Based Access Control       */
00003 /* Author and (c) 1999-2005: Amon Ott  */
00004 /* Helper functions for all parts      */
00005 /* Last modified:  21/Jun/2005         */
00006 /************************************* */
00007 
00008 #ifndef __RSBAC_HELPER_H
00009 #define __RSBAC_HELPER_H
00010 
00011 #include <linux/types.h>
00012 #include <rsbac/types.h>
00013 #ifdef __KERNEL__
00014 #include <rsbac/rkmem.h>
00015 #endif
00016 
00017 char * inttostr(char[], int);
00018 
00019 char * ulongtostr(char[], u_long);
00020 
00021 /* convert u_long_long to binary string representation for MAC module */
00022 char * u64tostrmac(char[], __u64);
00023 
00024 #ifndef __KERNEL__
00025 int rsbac_lib_version(void);
00026 int rsbac_u32_compare(__u32 * a, __u32 * b);
00027 int rsbac_u32_void_compare(const void *a, const void *b);
00028 
00029 int rsbac_user_compare(const void * a, const void * b);
00030 int rsbac_group_compare(const void * a, const void * b);
00031 int rsbac_nettemp_id_compare(const void * a, const void * b);
00032 
00033 int rsbac_dev_compare(const void * desc1,
00034                       const void * desc2);
00035 
00036 char * get_user_name(rsbac_uid_t user, char * name);
00037 
00038 char * get_group_name(rsbac_gid_t group, char * name);
00039 
00040 int rsbac_get_uid_name(rsbac_uid_t * uid, char * name, char * sourcename);
00041 
00042 int rsbac_get_fullname(char * fullname, rsbac_uid_t uid);
00043 
00044 static inline int rsbac_get_uid(rsbac_uid_t * uid, char * sourcename)
00045   {
00046     return rsbac_get_uid_name(uid, NULL, sourcename);
00047   }
00048 
00049 int rsbac_get_gid_name(rsbac_gid_t * gid, char * name, char * sourcename);
00050 
00051 static inline int rsbac_get_gid(rsbac_gid_t * gid, char * sourcename)
00052   {
00053     return rsbac_get_gid_name(gid, NULL, sourcename);
00054   }
00055 
00056 /* covert u_long_long to binary string representation for log array */
00057 char * u64tostrlog(char[], __u64);
00058 /* and back */
00059 __u64 strtou64log(char[], __u64 *);
00060 
00061 /* convert u_long_long to binary string representation for MAC module */
00062 /* and back */
00063 __u64 strtou64mac(char[], __u64 *);
00064 
00065 /* covert u_long_long to binary string representation for RC module */
00066 char * u64tostrrc(char[], __u64);
00067 /* and back */
00068 __u64 strtou64rc(char[], __u64 *);
00069 
00070 /* covert u_long_long to binary string representation for RC module / rights */
00071 char * u64tostrrcr(char[], __u64);
00072 /* and back */
00073 __u64 strtou64rcr(char[], __u64 *);
00074 
00075 /* ACL back */
00076 __u64 strtou64acl(char[], __u64 *);
00077 
00078 char * devdesctostr(char * str, struct rsbac_dev_desc_t dev);
00079 
00080 int strtodevdesc(char * str, struct rsbac_dev_desc_t * dev_p);
00081 #endif
00082 
00083 /* covert u_long_long to binary string representation for ACL module */
00084 char * u64tostracl(char[], __u64);
00085 
00086 char * longtostr(char[], long);
00087 
00088 #ifdef __KERNEL__
00089 #include <asm/uaccess.h>
00090 
00091 int rsbac_get_owner(rsbac_uid_t * user_p);
00092 
00093 static inline int rsbac_get_user(unsigned char * kern_p, unsigned char * user_p, int size)
00094   {
00095     if(kern_p && user_p && (size > 0))
00096       {
00097         return copy_from_user(kern_p, user_p, size);
00098       }
00099     return 0;
00100   }
00101 
00102 
00103 static inline int rsbac_put_user(unsigned char * kern_p, unsigned char * user_p, int size)
00104   {
00105     if(kern_p && user_p && (size > 0))
00106       {
00107         return copy_to_user(user_p,kern_p,size);
00108       }
00109     return 0;
00110   }
00111 
00112 static inline char * rsbac_getname(const char * name)
00113   {
00114     return getname(name);
00115   }
00116 
00117 static inline void rsbac_putname(const char * name)
00118   {
00119     putname(name);
00120   }
00121 
00122 static inline int clear_user_buf(char * ubuf, int len)
00123   {
00124     return clear_user(ubuf,len);
00125   }
00126 
00127 void rsbac_get_attr_error(char * , enum rsbac_adf_request_t);
00128 
00129 void rsbac_ds_get_error(const char * function, enum rsbac_attribute_t attr);
00130 void rsbac_ds_get_error_num(const char * function, enum rsbac_attribute_t attr, int err);
00131 void rsbac_ds_set_error(const char * function, enum rsbac_attribute_t attr);
00132 void rsbac_ds_set_error_num(const char * function, enum rsbac_attribute_t attr, int err);
00133 
00134 #ifdef CONFIG_RSBAC_RC
00135 void rsbac_rc_ds_get_error(const char * function, enum rsbac_rc_item_t item);
00136 void rsbac_rc_ds_set_error(const char * function, enum rsbac_rc_item_t item);
00137 #endif
00138 
00139 #endif /* KERNEL */
00140 
00141 #endif

Generated on Wed May 16 11:53:27 2007 for RSBAC by  doxygen 1.5.1