/linux-2.6.21.1-rsbac-1.3.4/rsbac/help/rc_getname.c

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

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