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

Go to the documentation of this file.
00001 /******************************** */ 00002 /* Rule Set Based Access Control */ 00003 /* Author and (c) 1999-2001: */ 00004 /* Amon Ott <ao@rsbac.org> */ 00005 /* PM getname functions */ 00006 /* Last modified: 10/Oct/2001 */ 00007 /******************************** */ 00008 00009 #include <rsbac/pm_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 static char pm_list[PL_none][6] = { 00020 "task", 00021 "class", 00022 "na", 00023 "cs", 00024 "tp", 00025 "pp", 00026 "tkt" }; 00027 00028 static char pm_all_list[PA_none][11] = { 00029 "task", 00030 "class", 00031 "na", 00032 "cs", 00033 "tp", 00034 "pp", 00035 "tkt", 00036 "task_set", 00037 "tp_set", 00038 "ru_set", 00039 "pp_set", 00040 "in_pp_set", 00041 "out_pp_set" }; 00042 00043 static char pm_role[PR_none+1][24] = { 00044 "user", 00045 "security_officer", 00046 "data_protection_officer", 00047 "tp_manager", 00048 "system_admin", 00049 "none" }; 00050 00051 static char pm_process_type[PP_TP+1][5] = { 00052 "none", 00053 "tp" }; 00054 00055 static char pm_object_type[PO_dir+1][18] = { 00056 "none", 00057 "tp", 00058 "personal_data", 00059 "non_personal_data", 00060 "ipc", 00061 "dir" }; 00062 00063 #ifdef __KERNEL__ 00064 static char pm_set[PS_NONE+1][5] = { 00065 "TASK", 00066 "TP", 00067 "RU", 00068 "PP", 00069 "NONE" }; 00070 00071 static char pm_target[PMT_NONE+1][6] = { 00072 "TASK", 00073 "CLASS", 00074 "NA", 00075 "CS", 00076 "TP", 00077 "PP", 00078 "TKT", 00079 "NONE" }; 00080 00081 static char pm_data[PD_none+1][15] = { 00082 "purpose", 00083 "tp_set", 00084 "ru_set", 00085 "pp_set", 00086 "task", 00087 "class", 00088 "tp", 00089 "accesses", 00090 "file", 00091 "issuer", 00092 "function_type", 00093 "function_param", 00094 "valid_until", 00095 "def_class", 00096 "none" }; 00097 #endif 00098 00099 static char pm_function_type[PF_none+1][24] = { 00100 "add_na", 00101 "delete_na", 00102 "add_task", 00103 "delete_task", 00104 "add_object_class", 00105 "delete_object_class", 00106 "add_authorized_tp", 00107 "delete_authorized_tp", 00108 "add_consent", 00109 "delete_consent", 00110 "add_purpose", 00111 "delete_purpose", 00112 "add_responsible_user", 00113 "delete_responsible_user", 00114 "delete_user_aci", 00115 "set_role", 00116 "set_object_class", 00117 "switch_pm", 00118 "switch_auth", 00119 "set_device_object_type", 00120 "set_auth_may_setuid", 00121 "set_auth_may_set_cap", 00122 /* issued by user also */ 00123 "add_authorized_task", 00124 "delete_authorized_task", 00125 /* called by tp_manager */ 00126 "create_tp", 00127 "delete_tp", 00128 "set_tp", 00129 "create_ticket", 00130 "none"}; 00131 00132 #ifndef __KERNEL__ 00133 static char pm_function_param[PF_none+1][123] = { 00134 "\t\tticket task class tp accesses (class can be IPC, DEV or NIL)", 00135 "\tticket task class tp accesses (class can be IPC, DEV or NIL)", 00136 "\tticket id purpose", 00137 "\tticket id", 00138 "ticket id purpose1 purpose2 ...", 00139 "ticket id", 00140 "ticket task tp", 00141 "ticket task tp", 00142 "\tticket filename purpose", 00143 "\tticket filename purpose", 00144 "\tticket id default-class\n (class created, if necessary, and purpose added to pp-list of class)", 00145 "\tticket id", 00146 "ticket user task", 00147 "ticket user task", 00148 "ticket id", 00149 "\tticket user role\n (roles: user|security_officer|data_protection_officer|tp_manager|system_admin)", 00150 "ticket filename object_class\n (also sets object_type personal_data (cl!=0) or non_personal_data (cl=0)", 00151 "\tticket value (0 or 1)", 00152 "\tticket value (0 or 1)", 00153 "ticket devicename object_type [object_class]\n (types: none, tp, personal_data, non_personal_data)\n (default class is DEV)", 00154 "ticket filename value(0 or 1)", 00155 "ticket filename value(0 or 1)", 00156 /* issued by user also */ 00157 "ticket user task", 00158 "ticket user task", 00159 /* called by tp_manager */ 00160 "\tid", 00161 "\tid", 00162 "\t\tfilename id", 00163 /* create_ticket */ 00164 "(call with create_ticket for params)", 00165 "INVALID"}; 00166 #endif 00167 00168 static char pm_tkt_function_type[PTF_none+1][25] = { 00169 "add_na", 00170 "delete_na", 00171 "add_task", 00172 "delete_task", 00173 "add_object_class", 00174 "delete_object_class", 00175 "add_authorized_tp", 00176 "delete_authorized_tp", 00177 "add_consent", 00178 "delete_consent", 00179 "add_purpose", 00180 "delete_purpose", 00181 "add_responsible_user", 00182 "delete_responsible_user", 00183 "delete_user_aci", 00184 "set_role", 00185 "set_object_class", 00186 "switch_pm", 00187 "switch_auth", 00188 "set_device_object_type", 00189 "set_auth_may_setuid", 00190 "set_auth_may_set_cap", 00191 /* issued by user also */ 00192 "add_authorized_task", 00193 "delete_authorized_task", 00194 "none"}; 00195 00196 #ifndef __KERNEL__ 00197 static char pm_tkt_function_param[PTF_none+1][116] = { 00198 "\t\ttask class tp accesses (class can be IPC, DEV or NIL)", 00199 "\ttask class tp accesses (class can be IPC, DEV or NIL)", 00200 "\tid purpose", 00201 "\tid", 00202 "id purpose1 purpose2 ...", 00203 "id", 00204 "task tp", 00205 "task tp", 00206 "\tfilename purpose", 00207 "\tfilename purpose", 00208 "\tid default-class (class must not be NIL, IPC or DEV)", 00209 "\tid", 00210 "user task", 00211 "user task", 00212 "user", 00213 "\tuser role\n (roles: user|security_officer|data_protection_officer|tp_manager|system_admin)", 00214 "filename object_class\n (sets object_type personal_data (cl!=0) or non_personal_data (cl=0)", 00215 "\tvalue (0 or 1)", 00216 "\tvalue (0 or 1)", 00217 "devicename object_type [object_class]\n (types: none, tp, personal_data, non_personal_data)\n (default class is DEV)", 00218 "filename value(0 or 1)", 00219 "filename value(0 or 1)", 00220 /* issued by user also */ 00221 "user task", 00222 "user task", 00223 "INVALID"}; 00224 #endif 00225 00226 /*****************************************/ 00227 00228 char * get_pm_list_name(char * name, 00229 enum rsbac_pm_list_t value) 00230 { 00231 if(!name) 00232 return(NULL); 00233 if(value > PL_none) 00234 strcpy(name, "ERROR!"); 00235 else 00236 strcpy(name, pm_list[value]); 00237 return(name); 00238 }; 00239 00240 enum rsbac_pm_list_t get_pm_list_nr(const char * name) 00241 { 00242 enum rsbac_pm_list_t i; 00243 00244 if(!name) 00245 return(PL_none); 00246 for (i = 0; i < PL_none; i++) 00247 { 00248 if (!strcmp(name,pm_list[i])) 00249 { 00250 return(i); 00251 } 00252 } 00253 return(PL_none); 00254 }; 00255 00256 char * get_pm_all_list_name(char * name, 00257 enum rsbac_pm_all_list_t value) 00258 { 00259 if(!name) 00260 return(NULL); 00261 if(value > PA_none) 00262 strcpy(name, "ERROR!"); 00263 else 00264 strcpy(name, pm_all_list[value]); 00265 return(name); 00266 }; 00267 00268 enum rsbac_pm_list_t get_pm_all_list_nr(const char * name) 00269 { 00270 enum rsbac_pm_all_list_t i; 00271 00272 if(!name) 00273 return(PA_none); 00274 for (i = 0; i < PA_none; i++) 00275 { 00276 if (!strcmp(name,pm_all_list[i])) 00277 { 00278 return(i); 00279 } 00280 } 00281 return(PA_none); 00282 }; 00283 00284 /****/ 00285 00286 char * get_pm_role_name(char * name, 00287 enum rsbac_pm_role_t value) 00288 { 00289 if(!name) 00290 return(NULL); 00291 if(value > PR_none) 00292 strcpy(name, "ERROR!"); 00293 else 00294 strcpy(name, pm_role[value]); 00295 return(name); 00296 }; 00297 00298 enum rsbac_pm_role_t get_pm_role_nr(const char * name) 00299 { 00300 enum rsbac_pm_role_t i; 00301 00302 if(!name) 00303 return(PR_none); 00304 for (i = 0; i < PR_none; i++) 00305 { 00306 if (!strcmp(name,pm_role[i])) 00307 { 00308 return(i); 00309 } 00310 } 00311 return(PR_none); 00312 }; 00313 00314 /****/ 00315 00316 char * get_pm_process_type_name(char * name, 00317 enum rsbac_pm_process_type_t value) 00318 { 00319 if(!name) 00320 return(NULL); 00321 if(value > PP_TP) 00322 strcpy(name, "ERROR!"); 00323 else 00324 strcpy(name, pm_process_type[value]); 00325 return(name); 00326 }; 00327 00328 enum rsbac_pm_process_type_t get_pm_process_type_nr(const char * name) 00329 { 00330 enum rsbac_pm_process_type_t i; 00331 00332 if(!name) 00333 return(PP_none); 00334 for (i = 0; i < PP_TP; i++) 00335 { 00336 if (!strcmp(name,pm_process_type[i])) 00337 { 00338 return(i); 00339 } 00340 } 00341 return(PP_none); 00342 }; 00343 00344 00345 /****/ 00346 00347 char * get_pm_object_type_name(char * name, 00348 enum rsbac_pm_object_type_t value) 00349 { 00350 if(!name) 00351 return(NULL); 00352 if(value > PO_dir) 00353 strcpy(name, "ERROR!"); 00354 else 00355 strcpy(name, pm_object_type[value]); 00356 return(name); 00357 }; 00358 00359 enum rsbac_pm_object_type_t get_pm_object_type_nr(const char * name) 00360 { 00361 enum rsbac_pm_object_type_t i; 00362 00363 if(!name) 00364 return(PO_none); 00365 for (i = 0; i < PO_dir; i++) 00366 { 00367 if (!strcmp(name,pm_object_type[i])) 00368 { 00369 return(i); 00370 } 00371 } 00372 return(PO_none); 00373 }; 00374 00375 /****/ 00376 00377 #ifdef __KERNEL__ 00378 char * get_pm_set_name(char * name, 00379 enum rsbac_pm_set_t value) 00380 { 00381 if(!name) 00382 return(NULL); 00383 if(value > PS_NONE) 00384 strcpy(name, "ERROR!"); 00385 else 00386 strcpy(name, pm_set[value]); 00387 return(name); 00388 }; 00389 00390 enum rsbac_pm_set_t get_pm_set_nr(const char * name) 00391 { 00392 enum rsbac_pm_set_t i; 00393 00394 if(!name) 00395 return(PS_NONE); 00396 for (i = 0; i < PS_NONE; i++) 00397 { 00398 if (!strcmp(name,pm_set[i])) 00399 { 00400 return(i); 00401 } 00402 } 00403 return(PS_NONE); 00404 }; 00405 00406 /****/ 00407 00408 char * get_pm_target_name(char * name, 00409 enum rsbac_pm_target_t value) 00410 { 00411 if(!name) 00412 return(NULL); 00413 if(value > PMT_NONE) 00414 strcpy(name, "ERROR!"); 00415 else 00416 strcpy(name, pm_target[value]); 00417 return(name); 00418 }; 00419 00420 enum rsbac_pm_target_t get_pm_target_nr(const char * name) 00421 { 00422 enum rsbac_pm_target_t i; 00423 00424 if(!name) 00425 return(PMT_NONE); 00426 for (i = 0; i < PMT_NONE; i++) 00427 { 00428 if (!strcmp(name,pm_target[i])) 00429 { 00430 return(i); 00431 } 00432 } 00433 return(PMT_NONE); 00434 }; 00435 00436 /****/ 00437 00438 char * get_pm_data_name(char * name, 00439 enum rsbac_pm_data_t value) 00440 { 00441 if(!name) 00442 return(NULL); 00443 if(value > PD_none) 00444 strcpy(name, "ERROR!"); 00445 else 00446 strcpy(name, pm_data[value]); 00447 return(name); 00448 }; 00449 00450 enum rsbac_pm_data_t get_pm_data_nr(const char * name) 00451 { 00452 enum rsbac_pm_data_t i; 00453 00454 if(!name) 00455 return(PD_none); 00456 for (i = 0; i < PD_none; i++) 00457 { 00458 if (!strcmp(name,pm_data[i])) 00459 { 00460 return(i); 00461 } 00462 } 00463 return(PD_none); 00464 }; 00465 #endif /* def __KERNEL__ */ 00466 00467 /****/ 00468 00469 char * get_pm_function_type_name(char * name, 00470 enum rsbac_pm_function_type_t value) 00471 { 00472 if(!name) 00473 return(NULL); 00474 if(value > PF_none) 00475 strcpy(name, "ERROR!"); 00476 else 00477 strcpy(name, pm_function_type[value]); 00478 return(name); 00479 }; 00480 00481 enum rsbac_pm_function_type_t get_pm_function_type_nr(const char * name) 00482 { 00483 enum rsbac_pm_function_type_t i; 00484 00485 if(!name) 00486 return(PF_none); 00487 for (i = 0; i < PF_none; i++) 00488 { 00489 if (!strcmp(name,pm_function_type[i])) 00490 { 00491 return(i); 00492 } 00493 } 00494 return(PF_none); 00495 }; 00496 00497 #ifndef __KERNEL__ 00498 char * get_pm_function_param(char * name, 00499 enum rsbac_pm_function_type_t value) 00500 { 00501 if(!name) 00502 return(NULL); 00503 if(value > PF_none) 00504 strcpy(name, "ERROR!"); 00505 else 00506 strcpy(name, pm_function_param[value]); 00507 return(name); 00508 }; 00509 #endif 00510 00511 /****/ 00512 00513 char * get_pm_tkt_function_type_name(char * name, 00514 enum rsbac_pm_tkt_function_type_t value) 00515 { 00516 if(!name) 00517 return(NULL); 00518 if(value > PTF_none) 00519 strcpy(name, "ERROR!"); 00520 else 00521 strcpy(name, pm_tkt_function_type[value]); 00522 return(name); 00523 }; 00524 00525 enum rsbac_pm_tkt_function_type_t 00526 get_pm_tkt_function_type_nr(const char * name) 00527 { 00528 enum rsbac_pm_tkt_function_type_t i; 00529 00530 if(!name) 00531 return(PTF_none); 00532 for (i = 0; i < PTF_none; i++) 00533 { 00534 if (!strcmp(name,pm_tkt_function_type[i])) 00535 { 00536 return(i); 00537 } 00538 } 00539 return(PTF_none); 00540 }; 00541 00542 #ifndef __KERNEL__ 00543 char * get_pm_tkt_function_param(char * name, 00544 enum rsbac_pm_tkt_function_type_t value) 00545 { 00546 if(!name) 00547 return(NULL); 00548 if(value > PTF_none) 00549 strcpy(name, "ERROR!"); 00550 else 00551 strcpy(name, pm_tkt_function_param[value]); 00552 return(name); 00553 }; 00554 #endif

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