00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #include <rsbac/types.h>
00011 #include <rsbac/getname.h>
00012 #include <rsbac/acl_getname.h>
00013 #include <rsbac/helpers.h>
00014 #include <rsbac/error.h>
00015
00016 #ifdef __KERNEL__
00017 #include <linux/string.h>
00018 #else
00019 #include <string.h>
00020 #endif
00021
00022 static char acl_subject_type_list[ACLS_NONE+1][6] = {
00023 "USER",
00024 "ROLE",
00025 "GROUP",
00026 "NONE" };
00027
00028 static char acl_group_syscall_list[ACLGS_none+1][18] = {
00029 "add_group",
00030 "change_group",
00031 "remove_group",
00032 "get_group_entry",
00033 "list_groups",
00034 "add_member",
00035 "remove_member",
00036 "get_user_groups",
00037 "get_group_members",
00038 "none" };
00039
00040 static char acl_scd_type_list[AST_none-32+1][20] = {
00041 "auth_administration",
00042 "none" };
00043
00044 static char acl_special_right_list[ACLR_NONE-32+1][20] = {
00045 "FORWARD",
00046 "ACCESS_CONTROL",
00047 "SUPERVISOR",
00048 "NONE" };
00049
00050
00051
00052 char * get_acl_subject_type_name(char * name,
00053 enum rsbac_acl_subject_type_t value)
00054 {
00055 if(!name)
00056 return(NULL);
00057 if(value > ACLS_NONE)
00058 strcpy(name, "ERROR!");
00059 else
00060 strcpy(name, acl_subject_type_list[value]);
00061 return(name);
00062 };
00063
00064 #ifndef __KERNEL__
00065 enum rsbac_acl_subject_type_t get_acl_subject_type_nr(const char * name)
00066 {
00067 enum rsbac_acl_subject_type_t i;
00068
00069 if(!name)
00070 return(ACLS_NONE);
00071 for (i = 0; i < ACLS_NONE; i++)
00072 {
00073 if (!strcmp(name, acl_subject_type_list[i]))
00074 {
00075 return(i);
00076 }
00077 }
00078 return(ACLS_NONE);
00079 };
00080 #endif
00081
00082 char * get_acl_group_syscall_name(char * name,
00083 enum rsbac_acl_group_syscall_type_t value)
00084 {
00085 if(!name)
00086 return(NULL);
00087 if(value > ACLGS_none)
00088 strcpy(name, "ERROR!");
00089 else
00090 strcpy(name, acl_group_syscall_list[value]);
00091 return(name);
00092 };
00093
00094 #ifndef __KERNEL__
00095 enum rsbac_acl_group_syscall_type_t get_acl_group_syscall_nr(const char * name)
00096 {
00097 enum rsbac_acl_group_syscall_type_t i;
00098
00099 if(!name)
00100 return(ACLGS_none);
00101 for (i = 0; i < ACLGS_none; i++)
00102 {
00103 if (!strcmp(name, acl_group_syscall_list[i]))
00104 {
00105 return(i);
00106 }
00107 }
00108 return(ACLGS_none);
00109 };
00110 #endif
00111
00112 char * get_acl_scd_type_name(char * name,
00113 enum rsbac_acl_scd_type_t value)
00114 {
00115 if(!name)
00116 return(NULL);
00117 if(value < AST_min)
00118 {
00119 return(get_scd_type_name(name, value));
00120 }
00121 value -= AST_min;
00122 if(value > AST_none)
00123 {
00124 strcpy(name, "ERROR!");
00125 return(name);
00126 }
00127 strcpy(name, acl_scd_type_list[value]);
00128 return(name);
00129 };
00130
00131 #ifndef __KERNEL__
00132 enum rsbac_acl_scd_type_t get_acl_scd_type_nr(const char * name)
00133 {
00134 enum rsbac_acl_scd_type_t i;
00135
00136 if(!name)
00137 return(AST_none);
00138 for (i = 0; i < AST_none-32; i++)
00139 {
00140 if (!strcmp(name, acl_scd_type_list[i]))
00141 {
00142 return(i+32);
00143 }
00144 }
00145 return(get_scd_type_nr(name));
00146 };
00147 #endif
00148
00149 char * get_acl_special_right_name(char * name,
00150 enum rsbac_acl_special_rights_t value)
00151 {
00152 if(!name)
00153 return(NULL);
00154 if(value < RSBAC_ACL_SPECIAL_RIGHT_BASE)
00155 {
00156 return(get_request_name(name, value));
00157 }
00158 value -= RSBAC_ACL_SPECIAL_RIGHT_BASE;
00159 if(value > ACLR_NONE)
00160 {
00161 strcpy(name, "ERROR!");
00162 return(name);
00163 }
00164 strcpy(name, acl_special_right_list[value]);
00165 return(name);
00166 };
00167
00168 #ifndef __KERNEL__
00169 enum rsbac_acl_special_rights_t get_acl_special_right_nr(const char * name)
00170 {
00171 enum rsbac_acl_special_rights_t i;
00172
00173 if(!name)
00174 return(ACLR_NONE);
00175 for (i = 0; i < (ACLR_NONE - RSBAC_ACL_SPECIAL_RIGHT_BASE); i++)
00176 {
00177 if (!strcmp(name, acl_special_right_list[i]))
00178 {
00179 return(i + RSBAC_ACL_SPECIAL_RIGHT_BASE);
00180 }
00181 }
00182 return(get_request_nr(name));
00183 };
00184 #endif