/daten/src/linux-2.4.27-rsbac-v1.2.3/rsbac/help/rc_getname.c

Go to the documentation of this file.
00001 /************************************* */ 00002 /* Rule Set Based Access Control */ 00003 /* Author and (c) 1999-2004: Amon Ott */ 00004 /* Getname functions for RC module */ 00005 /* Last modified: 07/Jun/2004 */ 00006 /************************************* */ 00007 00008 #include <rsbac/getname.h> 00009 #include <rsbac/rc_getname.h> 00010 #include <rsbac/helpers.h> 00011 #include <rsbac/error.h> 00012 00013 #ifdef __KERNEL__ 00014 #include <linux/string.h> 00015 #else 00016 #include <string.h> 00017 #endif 00018 00019 #ifndef NULL 00020 #define NULL ((void *) 0) 00021 #endif 00022 00023 static char rc_target_list[RT_NONE+1][13] = { 00024 "ROLE", 00025 "TYPE", 00026 "NONE" }; 00027 00028 static char rc_admin_list[RC_none+1][13] = { 00029 "no_admin", 00030 "role_admin", 00031 "system_admin", 00032 "none" }; 00033 00034 static char rc_scd_type_list[RST_none - RST_min + 1][20] = { 00035 "auth_administration", 00036 "none" }; 00037 00038 static char rc_item_list[RI_none+1][25] = { 00039 "role_comp", 00040 "admin_roles", 00041 "assign_roles", 00042 "type_comp_fd", 00043 "type_comp_dev", 00044 "type_comp_user", 00045 "type_comp_process", 00046 "type_comp_ipc", 00047 "type_comp_scd", 00048 "type_comp_netdev", 00049 "type_comp_nettemp", 00050 "type_comp_netobj", 00051 "admin_type", 00052 "name", 00053 "def_fd_create_type", 00054 "def_user_create_type", 00055 "def_process_create_type", 00056 "def_process_chown_type", 00057 "def_process_execute_type", 00058 "def_ipc_create_type", 00059 "boot_role", 00060 "type_fd_name", 00061 "type_dev_name", 00062 "type_ipc_name", 00063 "type_user_name", 00064 "type_process_name", 00065 "type_netdev_name", 00066 "type_nettemp_name", 00067 "type_netobj_name", 00068 "type_fd_need_secdel", 00069 "type_scd_name", 00070 "remove_role", 00071 "type_fd_remove", 00072 "type_dev_remove", 00073 "type_ipc_remove", 00074 "type_user_remove", 00075 "type_process_remove", 00076 "type_netdev_remove", 00077 "type_nettemp_remove", 00078 "type_netobj_remove", 00079 #ifdef __KERNEL__ 00080 #endif 00081 "none" }; 00082 00083 #ifndef __KERNEL__ 00084 static char rc_item_param_list[RI_none+1][92] = { 00085 "\t0 = FALSE, 1 = TRUE", 00086 "\t0 = FALSE, 1 = TRUE", 00087 "\t0 = FALSE, 1 = TRUE", 00088 "\t0 = FALSE, 1 = TRUE", 00089 "\t0 = FALSE, 1 = TRUE", 00090 "\t0 = FALSE, 1 = TRUE", 00091 "0 = FALSE, 1 = TRUE", 00092 "\t0 = FALSE, 1 = TRUE", 00093 "\t0 = FALSE, 1 = TRUE", 00094 "0 = FALSE, 1 = TRUE", 00095 "0 = FALSE, 1 = TRUE", 00096 "0 = FALSE, 1 = TRUE", 00097 "\t0 = no_admin, 1 = role_admin, 2 = system_admin\n\t\t\t(for RC administration only)", 00098 "\t\tString, max. 15 chars", 00099 "0-63, 64 = inherit from process, 65 = inherit from\n\t\t\tparent, 66 = no_create", 00100 "0-63, 64 = inherit from process, 66 = no_create", 00101 "0-63, 65 = inherit from parent (keep),\n\t\t\t66 = no_create", 00102 "0-63, 65 = inherit from parent (keep),\n\t\t\t68 = use def_create of new role, 69 = no_chown", 00103 "0-63, 64 = inherit from process (keep),\n\t\t\t67 = no_execute", 00104 "0-63, 64 = inherit from process, 66 = no_create", 00105 "\t0 = FALSE, 1 = TRUE", 00106 "\tString, max. 15 chars", 00107 "\tString, max. 15 chars", 00108 "\tString, max. 15 chars", 00109 "\tString, max. 15 chars", 00110 "String, max. 15 chars", 00111 "String, max. 15 chars", 00112 "String, max. 15 chars", 00113 "String, max. 15 chars", 00114 "\tString, max. 15 chars (read-only)", 00115 "\t\t(none)" }; 00116 #endif 00117 00118 static char rc_special_right_list[RCR_NONE - RSBAC_RC_SPECIAL_RIGHT_BASE + 1][20] = { 00119 "ADMIN", 00120 "ASSIGN", 00121 "ACCESS_CONTROL", 00122 "SUPERVISOR", 00123 "MODIFY_AUTH", 00124 "NONE" }; 00125 00126 /*****************************************/ 00127 00128 char * get_rc_target_name(char * name, 00129 enum rsbac_rc_target_t value) 00130 { 00131 if(!name) 00132 return(NULL); 00133 if(value > RT_NONE) 00134 strcpy(name, "ERROR!"); 00135 else 00136 strcpy(name, rc_target_list[value]); 00137 return(name); 00138 }; 00139 00140 enum rsbac_rc_target_t get_rc_target_nr(const char * name) 00141 { 00142 enum rsbac_rc_target_t i; 00143 00144 if(!name) 00145 return(RT_NONE); 00146 for (i = 0; i < RT_NONE; i++) 00147 { 00148 if (!strcmp(name, rc_target_list[i])) 00149 { 00150 return(i); 00151 } 00152 } 00153 return(RT_NONE); 00154 }; 00155 00156 char * get_rc_admin_name(char * name, 00157 enum rsbac_rc_admin_type_t value) 00158 { 00159 if(!name) 00160 return(NULL); 00161 if(value > RC_none) 00162 strcpy(name, "ERROR!"); 00163 else 00164 strcpy(name, rc_admin_list[value]); 00165 return(name); 00166 }; 00167 00168 enum rsbac_rc_admin_type_t get_rc_admin_nr(const char * name) 00169 { 00170 enum rsbac_rc_admin_type_t i; 00171 00172 if(!name) 00173 return(RC_none); 00174 for (i = 0; i < RC_none; i++) 00175 { 00176 if (!strcmp(name, rc_admin_list[i])) 00177 { 00178 return(i); 00179 } 00180 } 00181 return(RC_none); 00182 }; 00183 00184 char * get_rc_scd_type_name(char * name, 00185 enum rsbac_rc_scd_type_t value) 00186 { 00187 if(!name) 00188 return(NULL); 00189 if(value < RST_min) 00190 { 00191 return(get_scd_type_name(name, value)); 00192 } 00193 value -= RST_min; 00194 if(value > RST_none) 00195 { 00196 strcpy(name, "ERROR!"); 00197 return(name); 00198 } 00199 strcpy(name, rc_scd_type_list[value]); 00200 return(name); 00201 }; 00202 00203 enum rsbac_rc_scd_type_t get_rc_scd_type_nr(const char * name) 00204 { 00205 enum rsbac_rc_scd_type_t i; 00206 00207 if(!name) 00208 return(RC_none); 00209 for (i = 0; i < RC_none-RST_min; i++) 00210 { 00211 if (!strcmp(name, rc_scd_type_list[i])) 00212 { 00213 return(i+RST_min); 00214 } 00215 } 00216 return(get_scd_type_nr(name)); 00217 }; 00218 00219 char * get_rc_item_name(char * name, 00220 enum rsbac_rc_item_t value) 00221 { 00222 if(!name) 00223 return(NULL); 00224 if(value > RI_none) 00225 strcpy(name, "ERROR!"); 00226 else 00227 strcpy(name, rc_item_list[value]); 00228 return(name); 00229 }; 00230 00231 enum rsbac_rc_item_t get_rc_item_nr(const char * name) 00232 { 00233 enum rsbac_rc_item_t i; 00234 00235 if(!name) 00236 return(RI_none); 00237 for (i = 0; i < RI_none; i++) 00238 { 00239 if (!strcmp(name, rc_item_list[i])) 00240 { 00241 return(i); 00242 } 00243 } 00244 return(RI_none); 00245 }; 00246 00247 #ifndef __KERNEL__ 00248 char * get_rc_item_param(char * name, 00249 enum rsbac_rc_item_t value) 00250 { 00251 if(!name) 00252 return(NULL); 00253 if(value > RI_none) 00254 strcpy(name, "ERROR!"); 00255 else 00256 strcpy(name, rc_item_param_list[value]); 00257 return(name); 00258 }; 00259 #endif 00260 00261 char * get_rc_special_right_name(char * name, 00262 enum rsbac_rc_special_rights_t value) 00263 { 00264 if(!name) 00265 return(NULL); 00266 if(value < RSBAC_RC_SPECIAL_RIGHT_BASE) 00267 { 00268 return(get_request_name(name, value)); 00269 } 00270 value -= RSBAC_RC_SPECIAL_RIGHT_BASE; 00271 if(value > RCR_NONE) 00272 { 00273 strcpy(name, "ERROR!"); 00274 return(name); 00275 } 00276 strcpy(name, rc_special_right_list[value]); 00277 return(name); 00278 }; 00279 00280 #ifndef __KERNEL__ 00281 enum rsbac_rc_special_rights_t get_rc_special_right_nr(const char * name) 00282 { 00283 enum rsbac_rc_special_rights_t i; 00284 00285 if(!name) 00286 return(RCR_NONE); 00287 for (i = 0; i < (RCR_NONE - RSBAC_RC_SPECIAL_RIGHT_BASE); i++) 00288 { 00289 if (!strcmp(name, rc_special_right_list[i])) 00290 { 00291 return(i + RSBAC_RC_SPECIAL_RIGHT_BASE); 00292 } 00293 } 00294 return(get_request_nr(name)); 00295 }; 00296 #endif

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