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: 21/Dec/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][30] = {
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_group",
00049                           "type_comp_netdev",
00050                           "type_comp_nettemp",
00051                           "type_comp_netobj",
00052                           "admin_type",
00053                           "name",
00054                           "def_fd_create_type",
00055                           "def_fd_ind_create_type",
00056                           "def_user_create_type",
00057                           "def_process_create_type",
00058                           "def_process_chown_type",
00059                           "def_process_execute_type",
00060                           "def_ipc_create_type",
00061                           "def_group_create_type",
00062                           "boot_role",
00063                           "type_fd_name",
00064                           "type_dev_name",
00065                           "type_ipc_name",
00066                           "type_user_name",
00067                           "type_process_name",
00068                           "type_group_name",
00069                           "type_netdev_name",
00070                           "type_nettemp_name",
00071                           "type_netobj_name",
00072                           "type_fd_need_secdel",
00073                           "type_scd_name",
00074                           "remove_role",
00075                           "def_fd_ind_create_type_remove",
00076                           "type_fd_remove",
00077                           "type_dev_remove",
00078                           "type_ipc_remove",
00079                           "type_user_remove",
00080                           "type_process_remove",
00081                           "type_group_remove",
00082                           "type_netdev_remove",
00083                           "type_nettemp_remove",
00084                           "type_netobj_remove",
00085 #ifdef __KERNEL__
00086 #endif
00087                           "none" };
00088 
00089 #ifndef __KERNEL__
00090 static char  rc_item_param_list[RI_none+1][100] = {
00091                           "\t0 = FALSE, 1 = TRUE",
00092                           "\t0 = FALSE, 1 = TRUE",
00093                           "\t0 = FALSE, 1 = TRUE",
00094                           "\t0 = FALSE, 1 = TRUE",
00095                           "\t0 = FALSE, 1 = TRUE",
00096                           "\t0 = FALSE, 1 = TRUE",
00097                           "0 = FALSE, 1 = TRUE",
00098                           "\t0 = FALSE, 1 = TRUE",
00099                           "\t0 = FALSE, 1 = TRUE",
00100                           "\t0 = FALSE, 1 = TRUE",
00101                           "0 = FALSE, 1 = TRUE",
00102                           "0 = FALSE, 1 = TRUE",
00103                           "0 = FALSE, 1 = TRUE",
00104                           "\t0 = no_admin, 1 = role_admin, 2 = system_admin\n\t\t\t(for RC administration only)",
00105                           "\t\tString, max. 15 chars",
00106                           "number, -2 = inherit from parent, -3 = no_create",
00107                           "parent_type new_type, -2 = inherit from parent,\n\t\t\t-3 = no_create",
00108                           "number, -2 = inherit from parent, -3 = no_create",
00109                           "number, -1 = inherit from process,\n\t\t\t-3 = no_create",
00110                           "number, -2 = inherit from parent (keep),\n\t\t\t-3 = no_create",
00111                           "number, -2 = inherit from parent (keep),\n\t\t\t-5 = use def_create of new role, -6 = no_chown",
00112                           "number, -1 = inherit from process (keep),\n\t\t\t-4 = no_execute",
00113                           "number, -3 = no_create",
00114                           "\t0 = FALSE, 1 = TRUE",
00115                           "\tString, max. 15 chars",
00116                           "\tString, max. 15 chars",
00117                           "\tString, max. 15 chars",
00118                           "\tString, max. 15 chars",
00119                           "String, max. 15 chars",
00120                           "\tString, max. 15 chars",
00121                           "String, max. 15 chars",
00122                           "String, max. 15 chars",
00123                           "String, max. 15 chars",
00124                           "0 = FALSE, 1 = TRUE",
00125                           "\tString, max. 15 chars (read-only)",
00126                           "\t\t(none)" };
00127 #endif
00128 
00129 static char  rc_special_right_list[RCR_NONE - RSBAC_RC_SPECIAL_RIGHT_BASE + 1][20] = {
00130                           "ADMIN",
00131                           "ASSIGN",
00132                           "ACCESS_CONTROL",
00133                           "SUPERVISOR",
00134                           "MODIFY_AUTH",
00135                           "NONE" };
00136 
00137 /*****************************************/
00138 
00139 char * get_rc_target_name(char * name,
00140                           enum rsbac_rc_target_t value)
00141   {
00142     if(!name)
00143       return(NULL);
00144     if(value > RT_NONE)
00145       strcpy(name, "ERROR!");
00146     else
00147       strcpy(name, rc_target_list[value]);
00148     return(name);
00149   };
00150 
00151 enum rsbac_rc_target_t get_rc_target_nr(const char * name)
00152   {
00153      enum  rsbac_rc_target_t i;
00154     
00155     if(!name)
00156       return(RT_NONE);
00157     for (i = 0; i < RT_NONE; i++)
00158       {
00159         if (!strcmp(name, rc_target_list[i]))
00160           {
00161             return(i);
00162           }
00163       }
00164     return(RT_NONE);
00165   };
00166 
00167 char * get_rc_admin_name(char * name,
00168                          enum rsbac_rc_admin_type_t value)
00169   {
00170     if(!name)
00171       return(NULL);
00172     if(value > RC_none)
00173       strcpy(name, "ERROR!");
00174     else
00175       strcpy(name, rc_admin_list[value]);
00176     return(name);
00177   };
00178 
00179 enum rsbac_rc_admin_type_t get_rc_admin_nr(const char * name)
00180   {
00181      enum  rsbac_rc_admin_type_t i;
00182     
00183     if(!name)
00184       return(RC_none);
00185     for (i = 0; i < RC_none; i++)
00186       {
00187         if (!strcmp(name, rc_admin_list[i]))
00188           {
00189             return(i);
00190           }
00191       }
00192     return(RC_none);
00193   };
00194 
00195 char * get_rc_scd_type_name(char * name,
00196                             enum rsbac_rc_scd_type_t value)
00197   {
00198     if(!name)
00199       return(NULL);
00200     if(value < RST_min)
00201       {
00202         return(get_scd_type_name(name, value));
00203       }
00204     value -= RST_min;
00205     if(value > RST_none)
00206       {
00207         strcpy(name, "ERROR!");
00208         return(name);
00209       }
00210     strcpy(name, rc_scd_type_list[value]);
00211     return(name);
00212   };
00213 
00214 enum rsbac_rc_scd_type_t get_rc_scd_type_nr(const char * name)
00215   {
00216      enum  rsbac_rc_scd_type_t i;
00217     
00218     if(!name)
00219       return(RC_none);
00220     for (i = 0; i < RC_none-RST_min; i++)
00221       {
00222         if (!strcmp(name, rc_scd_type_list[i]))
00223           {
00224             return(i+RST_min);
00225           }
00226       }
00227     return(get_scd_type_nr(name));
00228   };
00229 
00230 char * get_rc_item_name(char * name,
00231                         enum rsbac_rc_item_t value)
00232   {
00233     if(!name)
00234       return(NULL);
00235     if(value > RI_none)
00236       strcpy(name, "ERROR!");
00237     else
00238       strcpy(name, rc_item_list[value]);
00239     return(name);
00240   };
00241 
00242 enum rsbac_rc_item_t get_rc_item_nr(const char * name)
00243   {
00244      enum  rsbac_rc_item_t i;
00245     
00246     if(!name)
00247       return(RI_none);
00248     for (i = 0; i < RI_none; i++)
00249       {
00250         if (!strcmp(name, rc_item_list[i]))
00251           {
00252             return(i);
00253           }
00254       }
00255     return(RI_none);
00256   };
00257 
00258 #ifndef __KERNEL__
00259 char * get_rc_item_param(char * name,
00260                          enum rsbac_rc_item_t value)
00261   {
00262     if(!name)
00263       return(NULL);
00264     if(value > RI_none)
00265       strcpy(name, "ERROR!");
00266     else
00267       strcpy(name, rc_item_param_list[value]);
00268     return(name);
00269   };
00270 #endif
00271 
00272 char * get_rc_special_right_name(char * name,
00273                             enum rsbac_rc_special_rights_t value)
00274   {
00275     if(!name)
00276       return(NULL);
00277     if(value < RSBAC_RC_SPECIAL_RIGHT_BASE)
00278       {
00279         return(get_request_name(name, value));
00280       }
00281     value -= RSBAC_RC_SPECIAL_RIGHT_BASE;
00282     if(value > RCR_NONE)
00283       {
00284         strcpy(name, "ERROR!");
00285         return(name);
00286       }
00287     strcpy(name, rc_special_right_list[value]);
00288     return(name);
00289   };
00290 
00291 #ifndef __KERNEL__
00292 enum rsbac_rc_special_rights_t get_rc_special_right_nr(const char * name)
00293   {
00294      enum  rsbac_rc_special_rights_t i;
00295     
00296     if(!name)
00297       return(RCR_NONE);
00298     for (i = 0; i < (RCR_NONE - RSBAC_RC_SPECIAL_RIGHT_BASE); i++)
00299       {
00300         if (!strcmp(name, rc_special_right_list[i]))
00301           {
00302             return(i + RSBAC_RC_SPECIAL_RIGHT_BASE);
00303           }
00304       }
00305     return(get_request_nr(name));
00306   }
00307 #endif

Generated on Fri Jun 17 09:45:26 2005 for RSBAC by  doxygen 1.4.2