setools patch
Attached is a patch to our selinux tools (setools) package. It fixes two issues:
1. Fixes problem handling type aliases noted by Carsten Grohmann.
2. Updates the core library to handle policy version 15 files (as used with the new 2.6 kernel). As always, this library should remain backward compatible with older policy versions too.
This patch is for release 20030609 of setools (the source of which can be found at wwww.tresys.com/selinux among other places).
Just as a heads up we're planning to release a new version in September that will add more analysis capabilities for apol (such as information flow analysis, and more domain transition analysis), plus various minor stuff.
Regards, Frank
ChangeLog-setools +7 -0
@@ -1,6 +1,13 @@ CHANGE LOG, SE Linux TOOLS (setools) ======================================================== +August 18, 2003 SE Linux Tools, Release 20030609a + +Libapol: + Fixed alias bug. + Added support for v15 policy files. + +======================================================== June 9, 2003 SE Linux Tools, Release 20030609 Apol:
libapol/apolicy_parse.y +11 -7
@@ -126,7 +126,7 @@ static int define_port_context(int ver); static int define_netif_context(int ver); static int define_node_context(int ver); -static int define_fs_use(int behavior); +static int define_fs_use(int behavior, int ver); static int define_genfs_context(int has_type); static int define_nfs_context(void); %}
@@ -164,7 +164,7 @@ %token TARGET %token SAMEUSER %token FSCON PORTCON NETIFCON NODECON -%token FSUSEPSID FSUSETASK FSUSETRANS +%token FSUSEPSID FSUSETASK FSUSETRANS FSUSEXATTR %token GENFSCON %token U1 U2 R1 R2 T1 T2 %token NOT AND OR
@@ -524,12 +524,15 @@ | fs_uses fs_use_def ; /* added Jul 2002 */ +/* changed Jul 2003; added FSUSEXATTR */ fs_use_def : FSUSEPSID identifier ';' - {if (define_fs_use(0)) return -1;} + {if (define_fs_use(0, POL_VER_JUL2002)) return -1;} + | FSUSEXATTR identifier security_context_def ';' + {if (define_fs_use(1, POL_VER_15)) return -1;} | FSUSETASK identifier security_context_def ';' - {if (define_fs_use(1)) return -1;} + {if (define_fs_use(1, POL_VER_JUL2002)) return -1;} | FSUSETRANS identifier security_context_def ';' - {if (define_fs_use(1)) return -1;} + {if (define_fs_use(1, POL_VER_JUL2002)) return -1;} ; /* added Jul 2002 */ opt_genfs_contexts : genfs_contexts
@@ -2271,11 +2274,12 @@ } /* added Jul 2002 */ -static int define_fs_use(int behavior) +/* changed Jul 2003; added FSUSEXATTR */ +static int define_fs_use(int behavior, int ver) { int rt; - rt = set_policy_version(POL_VER_JUL2002, policy); + rt = set_policy_version(ver, policy); if(rt != 0) { if(rt == -2) { yyerror("fs_use keyword (FSUSE*) in what appears to be a pre-July 2002 policy)");
libapol/apolicy_scan.l +2 -0
@@ -100,6 +100,8 @@ FS_USE_TASK {return(FSUSETASK);} fs_use_trans | FS_USE_TRANS {return(FSUSETRANS);} +fs_use_xattr | +FS_USE_XATTR {return(FSUSEXATTR);} genfscon | GENFSCON { return(GENFSCON);} r1 |
libapol/apol_tcl.c +3 -0
@@ -894,6 +894,9 @@/* case POL_VER_12: */ /* (currently synonmous with v.11 */ Tcl_AppendResult (interp,POL_VER_STRING_11 , (char *)NULL );break ; +case POL_VER_15 : +Tcl_AppendResult (interp,POL_VER_STRING_15 , (char *)NULL ); +break ;default :Tcl_AppendResult (interp,"Unkown version" , (char *)NULL );break ;
libapol/policy-avl.c +1 -14
@@ -57,21 +57,8 @@/* Compare support function for TYPES to use with avl-utils */ int type_compare (const char *key,int idx,policy_t *policy) { -int cmpval; -name_item_t *ptr; -assert (!(key ==NULL || policy ==NULL || !is_valid_type_idx (idx, policy))); - cmpval =strcasecmp (key, policy->types[idx].name); -if (cmpval !=0 ) { -/* FIX: for now aliases are just unsorted attached linked list; -* low priority since they are rare */ -/* check aliases */ -for (ptr = policy->types[idx].aliases; ptr !=NULL ; ptr = ptr->next) { -if (strcasecmp (ptr->name, key) ==0 ) -return 0 ;/* found via alias */ - } - } -return cmpval; +return strcasecmp (key, policy->types[idx].name); }/* ATTRIB comp function*/ int attrib_compare (const char *key,int idx,policy_t *policy)
libapol/policy.c +93 -2
157 lines not on this page · raw message
libapol/policy.h +14 -2
@@ -249,6 +249,12 @@ } user_list_t; +/* type alias array +* TODO: see comments in add_alias() in policy.c */ +typedef struct alias_item { +char *name; +int type;/* assoicated type */ +}alias_item_t ;/* IDs for DYNAMIC array only (e.g., clones is not a dynamic array, but rather a linked list*/ #define POL_LIST_TYPE 0
@@ -262,7 +268,8 @@#define POL_LIST_PERMS 8#define POL_LIST_COMMON_PERMS 9#define POL_LIST_OBJ_CLASSES 10 -#define POL_NUM_LISTS 11 +#define POL_LIST_ALIAS 11 +#define POL_NUM_LISTS 12
@@ -282,10 +289,12 @@#define POL_VER_JUL2002 2/* all version after Jul 2002 until next date */ #define POL_VER_11 2/* same as POL_VER_JUL2002 */ #define POL_VER_12 2/* same as POL_VER_JUL2002; no apparent syntax changes b/w 11 and 12 */ -#define POL_VER_MAX 2 +#define POL_VER_15 3/* somewhere between v 12 and 15! */ +#define POL_VER_MAX 3#define POL_VER_STRING_PRE_11 "prior to v. 11"#define POL_VER_STRING_11 "v.11 -- v.12" +#define POL_VER_STRING_15 "v.13 -- v.15"
@@ -303,6 +312,7 @@int num_perms;/* " " */ int num_common_perms;int num_obj_classes; +int num_aliases;int rule_cnt[RULE_MAX ];/* statics on # of various rules */ int list_sz[POL_NUM_LISTS ];/* keep track of dynamic array sizes */ #ifdef USE_SORTING
@@ -316,6 +326,7 @@obj_class_t *obj_classes;/* define objects and their perms (ARRAY) */ /* Type Enforcement Rules */ type_item_t *types;/* defined types and their attribs (ARRAY)*/ +alias_item_t *aliases;/* separate index into type aliases (ARRAY) */ attrib_item_t *attribs;/* defined attribs and their types (ARRAY)*/ av_item_t *av_access;/* allow and neverallow rules; we expect lots of these (ARRAY)*/ av_item_t *av_audit;/* audit and notify rules (ARRAY)*/
@@ -375,6 +386,7 @@int init_policy (policy_t **policy_ptr);int free_policy (policy_t **policy_ptr);int get_type_idx (char *name,policy_t *policy); +int get_type_idx_by_alias_name (const char *alias,policy_t *policy);int get_attrib_idx (char *name,policy_t *policy);int get_type_or_attrib_idx (char *name,int *idx_type,policy_t *policy);int get_role_name (int idx,char **name,policy_t *policy);
libapol/util.h +1 -1
@@ -15,7 +15,7 @@#include <stdlib.h> #include "policy.h" -#define VERSION_STRING "0.7.1" +#define VERSION_STRING "0.7.1a"/* generic link list structures */ typedef struct llist_node {